初中生
最后登录1970-1-1
在线时间 小时
注册时间2018-8-23
|

楼主 |
发表于 2018-8-31 11:34:21
|
显示全部楼层
#ifndef _BSP_LED_H
#define _BSP_LED_H
#include "stm32f10x.h"
#define LED_2_GPIO_PIN GPIO_Pin_1
#define LED_2_GPIO_PORT GPIOB
#define LED_2_GPIO_CLK RCC_APB2Periph_GPIOB
#define LED_1_GPIO_PIN GPIO_Pin_0
#define LED_1_GPIO_PORT GPIOB
#define LED_1_GPIO_CLK RCC_APB2Periph_GPIOB
#define LED_3_GPIO_PIN GPIO_Pin_5
#define LED_3_GPIO_PORT GPIOB
#define LED_3_GPIO_CLK RCC_APB2Periph_GPIOB
#define ON 1
#define OFF 0
//\C语言续行符,要求后面不能有任何东西
#define LED_2(a) if(a) \
GPIO_ResetBits(LED_2_GPIO_PORT, LED_2_GPIO_PIN);\
else\
GPIO_SetBits(LED_2_GPIO_PORT, LED_2_GPIO_PIN);
#define LED_1(a) if(a) \
GPIO_ResetBits(LED_1_GPIO_PORT, LED_1_GPIO_PIN);\
else\
GPIO_SetBits(LED_1_GPIO_PORT, LED_1_GPIO_PIN);
#define LED_3(a) if(a) \
GPIO_ResetBits(LED_3_GPIO_PORT, LED_3_GPIO_PIN);\
else\
GPIO_SetBits(LED_3_GPIO_PORT, LED_3_GPIO_PIN);
#define LED_G(ON) ((LED_1(ON)&& LED_2(OFF)&&LED_3(OFF))
#define LED_B(ON) ((LED_1(OFF)&& LED_2(ON)&&LED_3(OFF))
#define LED_R(ON) ((LED_1(OFF)&& LED_2(OFF)&&LED_3(ON))
void LED_GPIO_Config(void);
#endif
|
|