gpio.c 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. #include "gpio.h"
  2. /* all pins used as gpio(input/output/irq) must be defined here */
  3. void gpio_init(void){
  4. rcu_periph_clock_enable(RCU_GPIOA);
  5. rcu_periph_clock_enable(RCU_GPIOB);
  6. rcu_periph_clock_enable(RCU_GPIOC);
  7. rcu_periph_clock_enable(RCU_GPIOF);
  8. //hall 2 detect
  9. gpio_mode_input(GPIOC, GPIO_PUPD_NONE, GPIO_PIN_13);
  10. //hall 1 detect
  11. gpio_mode_input(GPIOC, GPIO_PUPD_NONE, GPIO_PIN_15);
  12. //IR uart0 enable
  13. gpio_mode_output(GPIOC, GPIO_PUPD_NONE, GPIO_OTYPE_PP, GPIO_OSPEED_10MHZ, GPIO_PIN_14);
  14. //IR uart2 enable
  15. gpio_mode_output(GPIOF, GPIO_PUPD_NONE, GPIO_OTYPE_PP, GPIO_OSPEED_10MHZ, GPIO_PIN_0);
  16. //power good detect
  17. gpio_mode_input(GPIOF, GPIO_PUPD_NONE, GPIO_PIN_7);
  18. //temp senser enable
  19. gpio_mode_output(GPIOF, GPIO_PUPD_NONE, GPIO_OTYPE_PP, GPIO_OSPEED_10MHZ, GPIO_PIN_1);
  20. //charger detect
  21. gpio_mode_input(GPIOB, GPIO_PUPD_NONE, GPIO_PIN_10);
  22. //aux 12v power enable
  23. gpio_mode_output(GPIOB, GPIO_PUPD_NONE, GPIO_OTYPE_PP, GPIO_OSPEED_10MHZ, GPIO_PIN_2);
  24. //aux 12v lock detect
  25. gpio_mode_input(GPIOB, GPIO_PUPD_NONE, GPIO_PIN_11);
  26. #if 0
  27. //LED 0,1,2
  28. gpio_mode_output(GPIOB, GPIO_PUPD_NONE, GPIO_OTYPE_PP, GPIO_OSPEED_10MHZ, GPIO_PIN_12);
  29. gpio_mode_output(GPIOB, GPIO_PUPD_NONE, GPIO_OTYPE_PP, GPIO_OSPEED_10MHZ, GPIO_PIN_13);
  30. gpio_mode_output(GPIOB, GPIO_PUPD_NONE, GPIO_OTYPE_PP, GPIO_OSPEED_10MHZ, GPIO_PIN_14);
  31. //LED3,4
  32. gpio_mode_output(GPIOA, GPIO_PUPD_NONE, GPIO_OTYPE_PP, GPIO_OSPEED_10MHZ, GPIO_PIN_8);
  33. gpio_mode_output(GPIOA, GPIO_PUPD_NONE, GPIO_OTYPE_PP, GPIO_OSPEED_10MHZ, GPIO_PIN_9);
  34. #endif
  35. //cs1180 power enable
  36. gpio_mode_output(GPIOB, GPIO_PUPD_NONE, GPIO_OTYPE_PP, GPIO_OSPEED_10MHZ, GPIO_PIN_12);
  37. //12v DC-DC enable
  38. gpio_mode_output(GPIOA, GPIO_PUPD_NONE, GPIO_OTYPE_PP, GPIO_OSPEED_10MHZ, GPIO_PIN_11);
  39. //ms5238 irq
  40. gpio_mode_input(GPIOA, GPIO_PUPD_NONE, GPIO_PIN_12);
  41. //detect cs1180 ready
  42. gpio_mode_input(GPIOA, GPIO_PUPD_NONE, GPIO_PIN_0);
  43. }