Both_Way_Comm_SY8833/TP3310_Demo.si4project/Backup/led(4781).h

135 lines
3.8 KiB
C
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*
******************************************************************************
*
* @file led.h
* @brief led dispaly module
*
*
* @version 1.0
* @date 2023/05/12 09:59:40
* @author Alex Xu
*
* Copyright (c) 2013-2099,Tkplusemi Technology Co.,Ltd.
* All Rights Reserved
*
* History:
* Revision Date Author Desc
* 1.0.0 2023/07/12 Alex build this file
******************************************************************************
*/
#ifndef __LED_H__
#define __LED_H__
#include "define.h"
#ifdef LED_DISPLAY
#ifdef _DEBUG_LED
#define _DEBUG_LED_1
#define _DEBUG_LED_2
#endif
/******************************************************************************\
Macro definitions
\******************************************************************************/
sbit pin_LED_1 = P0^3;
// LED端口定义
#define LEDR_ON() pin_LED_1 = 1 //LED_1_ON() p03
#define LEDR_OFF() pin_LED_1 = 0 //LED_1_OFF()
#define LEDR_TOG() pin_LED_1 = !pin_LED_1 //LED_1_RUN()
#define LED_PLUS_TIME 1 //LED闪烁最小时间周期单位ms
/******************************************************************************\
Typedef definitions
\******************************************************************************/
extern idata volatile uint8_t Display_Sta; // 显示状态
//LED工作状态
enum LED_STATE
{
LED_OFF,
LED_ON,
LED_FLASH,
LED_KEEP_FLASHING,
};
//LED控制结构体
typedef struct{
uint8_t State;//LED 的工作状态
uint8_t Flash_Duty;//LED占空比即点亮时间
uint8_t Flash_Period;//LED周期
uint8_t Flash_Times;//闪烁次数
uint8_t Timer;//时间计数 1ms计数一次
}TS_LED_INFO;
// LED显示相关定义
// LED显示逻辑
// -- 红色LED用于充电指示原则上充电时闪烁充电完常亮未充电熄灭
// -- 绿色LED用于操作指示原则上耳机放入、取出、开盖、关盖时闪烁一次即可
typedef enum {
// DISPLAY_NONE,
DISPLAY_ON,
DISPLAY_OFF,
DISPLAY_FLASH,
DISPLAY_KEEP_FLASH,
// DISPLAY_MAX
} TE_DISPLAY_STA;
/******************************************************************************\
Global variables and functions
\******************************************************************************/
/*
* 函数名称 : LED_Init
* 功能描述 : LED初始化
* 参 数 : NONE
* 返回值 : NONE
*/
/******************************************************************************/
extern void LED_Init(void);
/******************************************************************************/
/*
* 函数名称 : LED_Clr
* 功能描述 : 熄灭全部LED
* 参 数 : NONE
* 返回值 : NONE
*/
/******************************************************************************/
extern void LED_Drv(void);
/******************************************************************************/
/*
* 函数名称 : LED_Set
* 功能描述 : LED工作方式设置
* 参 数 : State工作方式 / Period:闪烁周期(单位ms) / Times:闪烁次数
* 返回值 : NONE
*/
/******************************************************************************/
extern void LED_Set(uint8_t State,uint8_t Period,uint8_t Times);
/******************************************************************************/
// 外部操作接口;Fre:闪烁周期ms;n:闪烁次数
#define LED_R_ON() LED_Set(LED_ON, 0,0)
#define LED_R_OFF() LED_Set(LED_OFF, 0,0)
#define LED_R_FLASH(Fre,n) LED_Set(LED_FLASH, Fre,n)
#define LED_R_KEEP_FLASHING(Fre) LED_Set(LED_KEEP_FLASHING, Fre,0)
#define Display_Red_On() {LED_R_ON();Display_Sta=DISPLAY_ON;}
#define Display_Red_Off() {LED_R_OFF();Display_Sta=DISPLAY_OFF;}
#define Display_Red_Flash(n) {LED_R_FLASH(100,n);Display_Sta=DISPLAY_FLASH;}
#define Display_Red_KeepFlash() {LED_R_KEEP_FLASHING(100);Display_Sta=DISPLAY_KEEP_FLASH;}
//------------------------------------------------------------------------------
#endif
#endif