123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100 |
- #include "led.h"
- #include "board.h"
- uint16_t beepOnTimeOut;
- uint8_t beepFrequence = 1;
- //·äÃùÆ÷ IO³õʼ»¯
- void beep_init(void)
- {
-
- GPIO_InitTypeDef GPIO_InitStructure;
-
- GPIO_InitStructure.GPIO_Pin = BOARD_PIN_BEEP;
- GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
- GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
- GPIO_Init(BOARD_PORT_BEEP, &GPIO_InitStructure);
-
- GPIO_WriteBit(BOARD_PORT_BEEP, BOARD_PIN_BEEP, BEEP_OFF);
- }
- void beep_onDriver(void)
- {
- static uint8_t freqCount = 0;
- freqCount ++;
- if (freqCount >= beepFrequence)
- {
- freqCount = 0;
- if (beepOnTimeOut)
- {
- GPIO_WriteBit(BOARD_PORT_BEEP, BOARD_PIN_BEEP,
- (BitAction)!GPIO_ReadOutputDataBit(BOARD_PORT_BEEP, BOARD_PIN_BEEP));
- }
- }
-
- if (beepOnTimeOut)
- {
- beepOnTimeOut --;
- if (beepOnTimeOut == 0)
- {
- GPIO_WriteBit(BOARD_PORT_BEEP, BOARD_PIN_BEEP, BEEP_OFF);
- }
- }
- }
- void beep_setFreq(uint8_t freq)
- {
- beepFrequence = freq;
- }
- void beep_longBeep(void)
- {
- beepOnTimeOut = 200;
- }
- void beep_shortBeep(void)
- {
- beepOnTimeOut = 60;
- }
- //LED IO³õʼ»¯
- void LED_Init(void)
- {
-
- GPIO_InitTypeDef GPIO_InitStructure;
-
- GPIO_InitStructure.GPIO_Pin = BOARD_PIN_LED1;
- GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
- GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
- GPIO_Init(BOARD_PORT_LED1, &GPIO_InitStructure);
- GPIO_InitStructure.GPIO_Pin = BOARD_PIN_LED2;
- GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
- GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
- GPIO_Init(BOARD_PORT_LED2, &GPIO_InitStructure);
- GPIO_WriteBit(BOARD_PORT_LED1, BOARD_PIN_LED1, LED_OFF);
- GPIO_WriteBit(BOARD_PORT_LED2, BOARD_PIN_LED2, LED_OFF);
- }
- void testAllLed(void)
- {
- static uint8_t ledSta = 1;
- GPIO_WriteBit(BOARD_PORT_LED1, BOARD_PIN_LED1, LED_OFF);
- GPIO_WriteBit(BOARD_PORT_LED2, BOARD_PIN_LED2, LED_OFF);
- switch (ledSta)
- {
- case 1:
- GPIO_WriteBit(BOARD_PORT_LED1, BOARD_PIN_LED1, LED_ON);
- break;
- case 2:
- GPIO_WriteBit(BOARD_PORT_LED2, BOARD_PIN_LED2, LED_ON);
- break;
-
- default:
- break;
- }
- ledSta ++;
- if (ledSta == 3)
- {
- ledSta = 0;
- }
-
- }
|