diff options
| author | Xian Wu <[email protected]> | 2023-12-27 18:41:52 +0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2023-12-27 18:41:52 +0800 |
| commit | 6360253c129afcb91d34770cb253eea8d837e66a (patch) | |
| tree | 065167006028882ff4d57208252d1e0ce9f3b4e4 /bsp/synwit/libraries/SWM341_CSL/SWM341_StdPeriph_Driver/SWM341_gpio.h | |
| parent | 7b4592c2d15bf90c1958bdbc840ea4df3d97cd96 (diff) | |
Synwit MCU 采用新的 BSP 框架,将 BSP 与 libraries 分离 (#8432)
Diffstat (limited to 'bsp/synwit/libraries/SWM341_CSL/SWM341_StdPeriph_Driver/SWM341_gpio.h')
| -rw-r--r-- | bsp/synwit/libraries/SWM341_CSL/SWM341_StdPeriph_Driver/SWM341_gpio.h | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/bsp/synwit/libraries/SWM341_CSL/SWM341_StdPeriph_Driver/SWM341_gpio.h b/bsp/synwit/libraries/SWM341_CSL/SWM341_StdPeriph_Driver/SWM341_gpio.h new file mode 100644 index 0000000000..705d4d1ca3 --- /dev/null +++ b/bsp/synwit/libraries/SWM341_CSL/SWM341_StdPeriph_Driver/SWM341_gpio.h @@ -0,0 +1,38 @@ +#ifndef __SWM341_GPIO_H__ +#define __SWM341_GPIO_H__ + + +void GPIO_Init(GPIO_TypeDef * GPIOx, uint32_t n, uint32_t dir, uint32_t pull_up, uint32_t pull_down, uint32_t open_drain); //引脚初始化,包含引脚方向、上拉、下拉、开漏 + +#define GPIO_INPUT ((0 << 0) | (0 << 1) | (0 << 2) | (0 << 3)) +#define GPIO_INPUT_PullUp ((0 << 0) | (1 << 1) | (0 << 2) | (0 << 3)) +#define GPIO_INPUT_PullDown ((0 << 0) | (0 << 1) | (1 << 2) | (0 << 3)) +#define GPIO_OUTPUT ((1 << 0) | (0 << 1) | (0 << 2) | (0 << 3)) +#define GPIO_OUTPUT_OpenDrain ((1 << 0) | (0 << 1) | (0 << 2) | (1 << 3)) +#define GPIO_OUTPUT_OpenDrain_PullUp ((1 << 0) | (1 << 1) | (0 << 2) | (1 << 3)) + +#define GPIO_INIT(GPIOx, n, mode) GPIO_Init(GPIOx, n, (mode & 1) ? 1 : 0, (mode & 2) ? 1 : 0, (mode & 4) ? 1 : 0, (mode & 8) ? 1 : 0) + + +void GPIO_SetBit(GPIO_TypeDef * GPIOx, uint32_t n); //将参数指定的引脚电平置高 +void GPIO_ClrBit(GPIO_TypeDef * GPIOx, uint32_t n); //将参数指定的引脚电平置低 +void GPIO_InvBit(GPIO_TypeDef * GPIOx, uint32_t n); //将参数指定的引脚电平反转 +uint32_t GPIO_GetBit(GPIO_TypeDef * GPIOx, uint32_t n); //读取参数指定的引脚的电平状态 +void GPIO_SetBits(GPIO_TypeDef * GPIOx, uint32_t n, uint32_t w); //将参数指定的从n开始的w位连续引脚的电平置高 +void GPIO_ClrBits(GPIO_TypeDef * GPIOx, uint32_t n, uint32_t w); //将参数指定的从n开始的w位连续引脚的电平置低 +void GPIO_InvBits(GPIO_TypeDef * GPIOx, uint32_t n, uint32_t w); //将参数指定的从n开始的w位连续引脚的电平反转 +uint32_t GPIO_GetBits(GPIO_TypeDef * GPIOx, uint32_t n, uint32_t w); //读取参数指定的从n开始的w位连续引脚的电平状态 + + +void GPIO_AtomicSetBits(GPIO_TypeDef * GPIOx, uint32_t n, uint32_t w); +void GPIO_AtomicClrBits(GPIO_TypeDef * GPIOx, uint32_t n, uint32_t w); +void GPIO_AtomicInvBits(GPIO_TypeDef * GPIOx, uint32_t n, uint32_t w); + + +// for compatibility +#define GPIO_AtomicSetBit GPIO_SetBit +#define GPIO_AtomicClrBit GPIO_ClrBit +#define GPIO_AtomicInvBit GPIO_InvBit + + +#endif //__SWM341_GPIO_H__ |
