BeRTOS
|
00001 00036 #ifndef GPIO_STM32_H 00037 #define GPIO_STM32_H 00038 00039 #include <io/stm32.h> 00040 00045 enum 00046 { 00047 GPIO_MODE_AIN = 0x0, 00048 GPIO_MODE_IN_FLOATING = 0x04, 00049 GPIO_MODE_IPD = 0x28, 00050 GPIO_MODE_IPU = 0x48, 00051 GPIO_MODE_OUT_OD = 0x14, 00052 GPIO_MODE_OUT_PP = 0x10, 00053 GPIO_MODE_AF_OD = 0x1C, 00054 GPIO_MODE_AF_PP = 0x18, 00055 }; 00056 /*\}*/ 00057 00062 enum 00063 { 00064 GPIO_SPEED_10MHZ = 1, 00065 GPIO_SPEED_2MHZ, 00066 GPIO_SPEED_50MHZ, 00067 }; 00068 /*\}*/ 00069 00077 INLINE void stm32_gpioPinWrite(struct stm32_gpio *base, uint16_t pins, bool val) 00078 { 00079 if (val) 00080 base->BSRR |= pins; 00081 else 00082 base->BRR |= pins; 00083 } 00084 00091 INLINE uint16_t stm32_gpioPinRead(struct stm32_gpio *base, uint16_t pins) 00092 { 00093 return (base->IDR & pins); 00094 } 00095 00104 int stm32_gpioPinConfig(struct stm32_gpio *base, uint16_t pins, uint8_t mode, uint8_t speed); 00105 00106 #endif /* GPIO_STM32_H */