| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- #ifndef _ELECT_SW_H__
- #define _ELECT_SW_H__
- #include <stdint.h>
- #include <stdbool.h>
- #include "define.h"
- #ifdef __cplusplus
- extern "C" {
- #endif
- #define ELECT_SW_INTERVAL 5
- #define ELECT_SW_CHECK_COUNT 10
- #define ELECT_SW_CHECK_FAST_COUNT 2
- #define ELECT_SW_GPIO_RCC_ENABLE RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE);
- #define ELECT_SW01_GPIO GPIOA
- #define ELECT_SW01_PIN GPIO_Pin_0
- #define ELECT_SW01_IN GPIO_ReadInputDataBit(ELECT_SW01_GPIO, ELECT_SW01_PIN)
- #define ELECT_SW02_GPIO GPIOA
- #define ELECT_SW02_PIN GPIO_Pin_1
- #define ELECT_SW02_IN GPIO_ReadInputDataBit(ELECT_SW02_GPIO, ELECT_SW02_PIN)
- #define ELECT_SW03_GPIO GPIOA
- #define ELECT_SW03_PIN GPIO_Pin_2
- #define ELECT_SW03_IN GPIO_ReadInputDataBit(ELECT_SW03_GPIO, ELECT_SW03_PIN)
- #define ELECT_SW04_GPIO GPIOA
- #define ELECT_SW04_PIN GPIO_Pin_3
- #define ELECT_SW04_IN GPIO_ReadInputDataBit(ELECT_SW04_GPIO, ELECT_SW04_PIN)
- #define ELECT_SW05_GPIO GPIOA
- #define ELECT_SW05_PIN GPIO_Pin_4
- #define ELECT_SW05_IN GPIO_ReadInputDataBit(ELECT_SW05_GPIO, ELECT_SW05_PIN)
- typedef bool (*get_level_func)(void);
- typedef enum{
- ELECTSW_STAT_NULL = 0,
- ELECTSW_STAT_OPEN = 1,
- ELECTSW_STAT_CLOSE = 2,
- }electsw_stat_e;
- typedef struct{
- uint8_t idx;
- electsw_stat_e electsw_stat;
- bool electsw_finish;
- uint8_t electsw_on_count;
- uint8_t electsw_off_count;
- get_level_func get_level;
- }electsw_work_s;
- typedef void (*electsw_upload_func)(uint8_t idx, bool stat);
- void vElectsw_init(void);
- void electsw_task_start(void);
- void vElectsw_set_upload_func(electsw_upload_func func);
- uint16_t electsw_task_process_event(uint8_t task_id, uint16_t events);
- electsw_stat_e bElectsw_get_stat(uint8_t idx);
- #endif //_SWITCH_H__
|