/* Includes ------------------------------------------------------------------*/
#include "stm8s_gpio.h"
#include "LED_power.h"
/* Private typedef -----------------------------------------------------------*/
typedef struct
{
uint32_t LED_Power_Date_bit;
uint8_t Show_bit;
uint8_t Show_Over;
uint8_t Temp;
}LED_Power_Handle_type;
/* Private define ------------------------------------------------------------*/
#define High GPIO_MODE_OUT_PP_HIGH_SLOW
#define Low GPIO_MODE_OUT_OD_HIZ_FAST
#define HIZ GPIO_MODE_OUT_OD_HIZ_SLOW
/* Private macro -------------------------------------------------------------*/
/* Private variables ---------------------------------------------------------*/
uint8_t LED_Hold_1ms_Flag;
LED_Power_Handle_type LED_Power_Handle = {0x0000,1,0,0};
extern uint16_t TIM1Count;
/* Private function prototypes -----------------------------------------------*/
/* Private functions ---------------------------------------------------------*/
void LED_Power_DeInit()
{
GPIO_DeInit(GPIOA);
GPIO_DeInit(GPIOB);
GPIO_DeInit(GPIOC);
GPIO_DeInit(GPIOD);
}
/**
* @brief set LED
*
* @param GPIOx
* @param GPIO_Pin
*/
void LED_Set_HIZ(GPIO_TypeDef* GPIOx, GPIO_Pin_TypeDef GPIO_Pin)
{
GPIOx->ODR|=(uint8_t)GPIO_Pin;
GPIOx->CR1&=(uint8_t)(~(GPIO_Pin));
}
void LED_Set_Low(GPIO_TypeDef* GPIOx, GPIO_Pin_TypeDef GPIO_Pin)
{
GPIOx->ODR&=(uint8_t)(~(GPIO_Pin));
GPIOx->CR1|=(uint8_t)GPIO_Pin;
}
void LED_Set_High(GPIO_TypeDef* GPIOx, GPIO_Pin_TypeDef GPIO_Pin)
{
GPIOx->ODR|=(uint8_t)GPIO_Pin;
GPIOx->CR1|=(uint8_t)GPIO_Pin;
}
/**
* @brief Init LED of power
*
*/
void LED_Power_Init()
{
GPIO_Init(LED1,GPIO_MODE_OUT_OD_HIZ_FAST);// LED1
GPIO_Init(LED2,GPIO_MODE_OUT_OD_HIZ_FAST);// LED2
GPIO_Init(LED3,GPIO_MODE_OUT_OD_HIZ_FAST);// LED3
GPIO_Init(LED4,GPIO_MODE_OUT_OD_HIZ_FAST);// LED4
GPIO_Init(LED5,GPIO_MODE_OUT_OD_HIZ_FAST);// LED5
}
void LED_Power_Data_Change(int CurrentLevel)
{
switch (CurrentLevel)
{
case 0:
LED_Power_Handle.LED_Power_Date_bit = 0x00000000;
break;
case 1:
LED_Power_Handle.LED_Power_Date_bit = 0x00000001;
break;
case 2:
LED_Power_Handle.LED_Power_Date_bit = 0x00000003;
break;
case 3:
LED_Power_Handle.LED_Power_Date_bit = 0x00000007;
break;
case 4:
LED_Power_Handle.LED_Power_Date_bit = 0x0000000F;
break;
case 5:
LED_Power_Handle.LED_Power_Date_bit = 0x0000001F;
break;
case 6:
LED_Power_Handle.LED_Power_Date_bit = 0x0000003F;
break;
case 7:
LED_Power_Handle.LED_Power_Date_bit = 0x0000007F;
break;
case 8:
LED_Power_Handle.LED_Power_Date_bit = 0x000000FF;
break;
case 9:
LED_Power_Handle.LED_Power_Date_bit = 0x000001FF;
break;
case 10:
LED_Power_Handle.LED_Power_Date_bit = 0x000003FF;
break;
case 11:
LED_Power_Handle.LED_Power_Date_bit = 0x000007FF;
break;
case 12:
LED_Power_Handle.LED_Power_Date_bit = 0x00000FFF;
break;
case 13:
LED_Power_Handle.LED_Power_Date_bit = 0x00001FFF;
break;
case 14:
LED_Power_Handle.LED_Power_Date_bit = 0x00003FFF;
break;
case 15:
LED_Power_Handle.LED_Power_Date_bit = 0x00007FFF;
break;
case 16:
LED_Power_Handle.LED_Power_Date_bit = 0x0000FFFF;
break;
case 17:
LED_Power_Handle.LED_Power_Date_bit = 0x0001FFFF;
break;
case 18:
LED_Power_Handle.LED_Power_Date_bit = 0x0003FFFF;
break;
case 19:
LED_Power_Handle.LED_Power_Date_bit = 0x0007FFFF;
break;
case 20:
LED_Power_Handle.LED_Power_Date_bit = 0x000FFFFF;
break;
case 21:
LED_Power_Handle.LED_Power_Date_bit = 0x000FFFFF;
break;
case 22:
LED_Power_Handle.LED_Power_Date_bit = 0x000FFFFF;
break;
default:
LED_Power_Handle.LED_Power_Date_bit = 0x00000000;
break;
}
}
void LED_Power_ON_bit()
{
switch (LED_Power_Handle.Show_bit)
{
case 1:
if((LED_Power_Handle.LED_Power_Date_bit&0x00000001)!=0x00000000)
{
LED1_ON();
}
LED_Power_Handle.Show_bit = 2;
break;
case 2:
if((LED_Power_Handle.LED_Power_Date_bit&0x00000002)!=0x00000000)
{
LED2_ON();
}
LED_Power_Handle.Show_bit = 3;
break;
case 3:
if((LED_Power_Handle.LED_Power_Date_bit&0x00000004)!=0x00000000)
{
LED3_ON();
}
LED_Power_Handle.Show_bit = 4;
break;
case 4:
if((LED_Power_Handle.LED_Power_Date_bit&0x00000008)!=0x00000000)
{
LED4_ON();
}
LED_Power_Handle.Show_bit = 5;
break;
case 5:
if((LED_Power_Handle.LED_Power_Date_bit&0x00000010)!=0x00000000)
{
LED5_ON();
}
LED_Power_Handle.Show_bit = 6;
break;
case 6:
if((LED_Power_Handle.LED_Power_Date_bit&0x00000020)!=0x00000000)
{
LED6_ON();
}
LED_Power_Handle.Show_bit = 7;
break;
case 7:
if((LED_Power_Handle.LED_Power_Date_bit&0x00000040)!=0x00000000)
{
LED7_ON();
}
LED_Power_Handle.Show_bit = 8;
break;
case 8:
if((LED_Power_Handle.LED_Power_Date_bit&0x00000080)!=0x00000000)
{
LED8_ON();
}
LED_Power_Handle.Show_bit = 9;
break;
case 9:
if((LED_Power_Handle.LED_Power_Date_bit&0x00000100)!=0x00000000)
{
LED9_ON();
}
LED_Power_Handle.Show_bit = 10;
break;
case 10:
if((LED_Power_Handle.LED_Power_Date_bit&0x00000200)!=0x00000000)
{
LED10_ON();
}
LED_Power_Handle.Show_bit = 11;
break;
case 11:
if((LED_Power_Handle.LED_Power_Date_bit&0x00000400)!=0x00000000)
{
LED11_ON();
}
LED_Power_Handle.Show_bit = 12;
break;
case 12:
if((LED_Power_Handle.LED_Power_Date_bit&0x00000800)!=0x00000000)
{
LED12_ON();
}
LED_Power_Handle.Show_bit = 13;
break;
case 13:
if((LED_Power_Handle.LED_Power_Date_bit&0x00001000)!=0x00000000)
{
LED13_ON();
}
LED_Power_Handle.Show_bit = 14;
break;
case 14:
if((LED_Power_Handle.LED_Power_Date_bit&0x00002000)!=0x00000000)
{
LED14_ON();
}
LED_Power_Handle.Show_bit = 15;
break;
case 15:
if((LED_Power_Handle.LED_Power_Date_bit&0x00004000)!=0x00000000)
{
LED15_ON();
}
LED_Power_Handle.Show_bit = 16;
break;
case 16:
if((LED_Power_Handle.LED_Power_Date_bit&0x00008000)!=0x00000000)
{
LED16_ON();
}
LED_Power_Handle.Show_bit = 17;
break;
case 17:
if((LED_Power_Handle.LED_Power_Date_bit&0x00010000)!=0x00000000)
{
LED17_ON();
}
LED_Power_Handle.Show_bit = 18;
break;
case 18:
if((LED_Power_Handle.LED_Power_Date_bit&0x00020000)!=0x00000000)
{
LED18_ON();
}
LED_Power_Handle.Show_bit = 19;
break;
case 19:
if((LED_Power_Handle.LED_Power_Date_bit&0x00040000)!=0x00000000)
{
LED19_ON();
}
LED_Power_Handle.Show_bit = 20;
break;
case 20:
if((LED_Power_Handle.LED_Power_Date_bit&0x00080000)!=0x00

error10086
- 粉丝: 1
最新资源
- 基于计算机技术下科技管理模式的现代化应用初探.docx
- 新零售环境下人工智能对消费及购物体验的影响研究.docx
- XX商业广场项目管理营销推广业务策略.doc
- 9.jidao-chap6-递归算法设计(1)16679.ppt
- 面向对象程序设计试题样例.doc
- 大数据技术发展的社会代价之表现、根源及其消弭.docx
- 基于单片机的转速测量的研究与方案设计书.doc
- 计算机技术在环境保护中的应用分析.docx
- 数据库实习报告范例:图书管理系统.doc
- 疫情防控下高职院校线上混合式教学存在的问题和对策-以互联网金融为例.docx
- 基于无线传输网络的智能小区系统集成研究与实现.docx
- MAXPLUS软件的使用.doc
- 师范类非计算机专业《VB程序设计》教学存在的问题及解决对策.docx
- 构建软件工程专业一体化、多层次、开放式实践平台.docx
- 软件公司项目部经理职位说明.doc
- 云计算在短信业务中的应用研究.docx
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈



评论0