| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 |
- #ifndef _DIP_SW_H__
- #define _DIP_SW_H__
- #include <stdint.h>
- #include <stdbool.h>
- #include "define.h"
- #ifdef __cplusplus
- extern "C" {
- #endif
- #define DIP_SW_INTERVAL 5
- #define DIP_SW_CHECK_COUNT 10
- #define DIP_SW_CHECK_FAST_COUNT 2
- #define DIP_SW_GPIO_RCC_ENABLE RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA | RCC_APB2Periph_GPIOB | RCC_APB2Periph_GPIOC | RCC_APB2Periph_AFIO, ENABLE);
- #define DIP_SW01_GPIO GPIOA
- #define DIP_SW01_PIN GPIO_Pin_10
- #define DIP_SW01_IN GPIO_ReadInputDataBit(DIP_SW01_GPIO, DIP_SW01_PIN)
- #define DIP_SW02_GPIO GPIOA
- #define DIP_SW02_PIN GPIO_Pin_9
- #define DIP_SW02_IN GPIO_ReadInputDataBit(DIP_SW02_GPIO, DIP_SW02_PIN)
- #define DIP_SW03_GPIO GPIOA
- #define DIP_SW03_PIN GPIO_Pin_8
- #define DIP_SW03_IN GPIO_ReadInputDataBit(DIP_SW03_GPIO, DIP_SW03_PIN)
- #define DIP_SW04_GPIO GPIOC
- #define DIP_SW04_PIN GPIO_Pin_9
- #define DIP_SW04_IN GPIO_ReadInputDataBit(DIP_SW04_GPIO, DIP_SW04_PIN)
- #define DIP_SW05_GPIO GPIOC
- #define DIP_SW05_PIN GPIO_Pin_8
- #define DIP_SW05_IN GPIO_ReadInputDataBit(DIP_SW05_GPIO, DIP_SW05_PIN)
- #define DIP_SW06_GPIO GPIOC
- #define DIP_SW06_PIN GPIO_Pin_7
- #define DIP_SW06_IN GPIO_ReadInputDataBit(DIP_SW06_GPIO, DIP_SW06_PIN)
- #define DIP_SW07_GPIO GPIOC
- #define DIP_SW07_PIN GPIO_Pin_6
- #define DIP_SW07_IN GPIO_ReadInputDataBit(DIP_SW07_GPIO, DIP_SW07_PIN)
- typedef struct{
- uint8_t dipsw01_level:1;
- uint8_t dipsw02_level:1;
- uint8_t dipsw03_level:1;
- uint8_t dipsw04_level:1;
- uint8_t dipsw05_level:1;
- uint8_t dipsw06_level:1;
- uint8_t dipsw07_level:1;
- uint8_t dipsw08_level:1;
- }dipsw_addr_s;
- typedef union{
- dipsw_addr_s dipsw_addr;
- uint8_t addr;
- }dipsw_addr_u;
- typedef bool (*get_level_func)(void);
- typedef struct{
- uint8_t idx;
- uint8_t dipsw_stat;
- bool dipsw_finish;
- uint8_t dipsw_on_count;
- uint8_t dipsw_off_count;
- get_level_func get_level;
- }dipsw_work_s;
- typedef void (*dipsw_upload_func)(uint8_t addr);
- void vDipsw_init(void);
- void dipsw_task_start(void);
- void vDipsw_set_upload_func(dipsw_upload_func func);
- uint16_t dipsw_task_process_event(uint8_t task_id, uint16_t events);
- #endif //_SWITCH_H__
|