gpio.h 1.1 KB

12345678910111213141516171819202122232425262728293031
  1. #ifndef _GPIO_H__
  2. #define _GPIO_H__
  3. #include "gd32f1x0.h"
  4. #include "gd32f1x0_libopt.h"
  5. /*switch for temperature sensers */
  6. #define TEMP_OPEN(x) gpio_bit_write(GPIOF,GPIO_PIN_1,(bit_status)(x))
  7. /*switch for small current aux */
  8. #define AUX_VOL_OPEN(x) gpio_bit_write(GPIOB,GPIO_PIN_2,(bit_status)(x))
  9. /*switch for larger current DCDC */
  10. #define DCDC_VOL_OPEN(x) gpio_bit_write(GPIOA,GPIO_PIN_11,(bit_status)(x))
  11. /*switch for IR uart0 */
  12. #define UART0_IR_EN(x) gpio_bit_write(GPIOC,GPIO_PIN_14,(bit_status)(x))
  13. /*switch for IR uart1 */
  14. #define UART1_IR_EN(x) gpio_bit_write(GPIOF,GPIO_PIN_0,(bit_status)(x))
  15. /*detect for charger in/out */
  16. #define IS_CHARGER_IN() !gpio_input_bit_get(GPIOB,GPIO_PIN_10)
  17. static __inline__ void gpio_mode_input(uint32_t gpio_periph, uint32_t pull_up_down, uint32_t pin){
  18. gpio_mode_set(gpio_periph, GPIO_MODE_INPUT, pull_up_down, pin);
  19. }
  20. static __inline__ void gpio_mode_output(uint32_t gpio_periph, uint32_t pull_up_down, uint8_t otype, uint32_t speed, uint32_t pin){
  21. gpio_mode_set(gpio_periph, GPIO_MODE_OUTPUT, pull_up_down, pin);
  22. gpio_output_options_set(gpio_periph, otype, speed, pin);
  23. }
  24. #endif /* _GPIO_H__ */