131 lines
3.0 KiB
C
131 lines
3.0 KiB
C
|
#ifndef __LED_H
|
|||
|
#define __LED_H
|
|||
|
|
|||
|
#include "stm32h7xx.h"
|
|||
|
|
|||
|
//<2F><><EFBFBD>Ŷ<EFBFBD><C5B6><EFBFBD>
|
|||
|
/*******************************************************/
|
|||
|
//R <20><>ɫ<EFBFBD><C9AB>
|
|||
|
#define LED1_PIN GPIO_PIN_0
|
|||
|
#define LED1_GPIO_PORT GPIOB
|
|||
|
#define LED1_GPIO_CLK_ENABLE() __GPIOB_CLK_ENABLE()
|
|||
|
|
|||
|
//G <20><>ɫ<EFBFBD><C9AB>
|
|||
|
#define LED2_PIN GPIO_PIN_1
|
|||
|
#define LED2_GPIO_PORT GPIOB
|
|||
|
#define LED2_GPIO_CLK_ENABLE() __GPIOB_CLK_ENABLE()
|
|||
|
|
|||
|
//B <20><>ɫ<EFBFBD><C9AB>
|
|||
|
#define LED3_PIN GPIO_PIN_3
|
|||
|
#define LED3_GPIO_PORT GPIOA
|
|||
|
#define LED3_GPIO_CLK_ENABLE() __GPIOA_CLK_ENABLE()
|
|||
|
|
|||
|
//Сָʾ<D6B8><CABE>
|
|||
|
//#define LED4_PIN GPIO_PIN_3
|
|||
|
//#define LED4_GPIO_PORT GPIOA
|
|||
|
//#define LED4_GPIO_CLK_ENABLE() __GPIOA_CLK_ENABLE()
|
|||
|
/************************************************************/
|
|||
|
|
|||
|
|
|||
|
/** <20><><EFBFBD><EFBFBD>LED<45><44><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ĺ꣬
|
|||
|
* LED<EFBFBD>͵<EFBFBD>ƽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ON=0<EFBFBD><EFBFBD>OFF=1
|
|||
|
* <EFBFBD><EFBFBD>LED<EFBFBD>ߵ<EFBFBD>ƽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ѻ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ó<EFBFBD>ON=1 <EFBFBD><EFBFBD>OFF=0 <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
*/
|
|||
|
#define ON GPIO_PIN_RESET
|
|||
|
#define OFF GPIO_PIN_SET
|
|||
|
|
|||
|
/* <20><><EFBFBD>κ꣬<CEBA><EAA3AC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>ʹ<EFBFBD><CAB9> */
|
|||
|
#define LED1(a) HAL_GPIO_WritePin(LED1_GPIO_PORT,LED1_PIN,a)
|
|||
|
|
|||
|
|
|||
|
#define LED2(a) HAL_GPIO_WritePin(LED2_GPIO_PORT,LED2_PIN,a)
|
|||
|
|
|||
|
|
|||
|
#define LED3(a) HAL_GPIO_WritePin(LED2_GPIO_PORT,LED3_PIN,a)
|
|||
|
|
|||
|
|
|||
|
#define LED4(a) HAL_GPIO_WritePin(LED4_GPIO_PORT,LED4_PIN,a)
|
|||
|
|
|||
|
|
|||
|
/* ֱ<>Ӳ<EFBFBD><D3B2><EFBFBD><EFBFBD>Ĵ<EFBFBD><C4B4><EFBFBD><EFBFBD>ķ<EFBFBD><C4B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>IO */
|
|||
|
#define digitalHi(p,i) {p->BSRRL=i;} //<2F><><EFBFBD><EFBFBD>Ϊ<EFBFBD>ߵ<EFBFBD>ƽ
|
|||
|
#define digitalLo(p,i) {p->BSRRH=i;} //<2F><><EFBFBD><EFBFBD><EFBFBD>͵<EFBFBD>ƽ
|
|||
|
#define digitalToggle(p,i) {p->ODR ^=i;} //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ת״̬
|
|||
|
|
|||
|
|
|||
|
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>IO<49>ĺ<EFBFBD> */
|
|||
|
#define LED1_TOGGLE digitalToggle(LED1_GPIO_PORT,LED1_PIN)
|
|||
|
#define LED1_OFF digitalHi(LED1_GPIO_PORT,LED1_PIN)
|
|||
|
#define LED1_ON digitalLo(LED1_GPIO_PORT,LED1_PIN)
|
|||
|
|
|||
|
#define LED2_TOGGLE digitalToggle(LED2_GPIO_PORT,LED2_PIN)
|
|||
|
#define LED2_OFF digitalHi(LED2_GPIO_PORT,LED2_PIN)
|
|||
|
#define LED2_ON digitalLo(LED2_GPIO_PORT,LED2_PIN)
|
|||
|
|
|||
|
#define LED3_TOGGLE digitalToggle(LED3_GPIO_PORT,LED3_PIN)
|
|||
|
#define LED3_OFF digitalHi(LED3_GPIO_PORT,LED3_PIN)
|
|||
|
#define LED3_ON digitalLo(LED3_GPIO_PORT,LED3_PIN)
|
|||
|
|
|||
|
#define LED4_TOGGLE digitalToggle(LED4_GPIO_PORT,LED4_PIN)
|
|||
|
#define LED4_OFF digitalHi(LED4_GPIO_PORT,LED4_PIN)
|
|||
|
#define LED4_ON digitalLo(LED4_GPIO_PORT,LED4_PIN)
|
|||
|
|
|||
|
|
|||
|
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɫ<EFBFBD><C9AB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><DFBC>÷<EFBFBD>ʹ<EFBFBD><CAB9>PWM<57>ɻ<EFBFBD><C9BB><EFBFBD>ȫ<EFBFBD><C8AB><EFBFBD><EFBFBD>ɫ,<2C><>Ч<EFBFBD><D0A7><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
|||
|
|
|||
|
//<2F><>
|
|||
|
#define LED_RED \
|
|||
|
LED1_ON;\
|
|||
|
LED2_OFF\
|
|||
|
LED3_OFF
|
|||
|
|
|||
|
//<2F><>
|
|||
|
#define LED_GREEN \
|
|||
|
LED1_OFF;\
|
|||
|
LED2_ON\
|
|||
|
LED3_OFF
|
|||
|
|
|||
|
//<2F><>
|
|||
|
#define LED_BLUE \
|
|||
|
LED1_OFF;\
|
|||
|
LED2_OFF\
|
|||
|
LED3_ON
|
|||
|
|
|||
|
|
|||
|
//<2F><>(<28><>+<2B><>)
|
|||
|
#define LED_YELLOW \
|
|||
|
LED1_ON;\
|
|||
|
LED2_ON\
|
|||
|
LED3_OFF
|
|||
|
//<2F><>(<28><>+<2B><>)
|
|||
|
#define LED_PURPLE \
|
|||
|
LED1_ON;\
|
|||
|
LED2_OFF\
|
|||
|
LED3_ON
|
|||
|
|
|||
|
//<2F><>(<28><>+<2B><>)
|
|||
|
#define LED_CYAN \
|
|||
|
LED1_OFF;\
|
|||
|
LED2_ON\
|
|||
|
LED3_ON
|
|||
|
|
|||
|
//<2F><>(<28><>+<2B><>+<2B><>)
|
|||
|
#define LED_WHITE \
|
|||
|
LED1_ON;\
|
|||
|
LED2_ON\
|
|||
|
LED3_ON
|
|||
|
|
|||
|
//<2F><>(ȫ<><C8AB><EFBFBD>ر<EFBFBD>)
|
|||
|
#define LED_RGBOFF \
|
|||
|
LED1_OFF;\
|
|||
|
LED2_OFF\
|
|||
|
LED3_OFF
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
void LED_GPIO_Config(void);
|
|||
|
|
|||
|
#endif /* __LED_H */
|