gpio.c 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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. #if (CONFIG_BOARD_TYPE==SHARK_BOARD_SP700)
  9. //hall 2 detect
  10. gpio_mode_input(GPIOC, GPIO_PUPD_NONE, GPIO_PIN_13);
  11. //hall 1 detect
  12. gpio_mode_input(GPIOC, GPIO_PUPD_NONE, GPIO_PIN_15);
  13. //IR uart0 enable
  14. gpio_mode_output(GPIOC, GPIO_PUPD_NONE, GPIO_OTYPE_PP, GPIO_OSPEED_10MHZ, GPIO_PIN_14);
  15. //IR uart2 enable
  16. gpio_mode_output(GPIOF, GPIO_PUPD_NONE, GPIO_OTYPE_PP, GPIO_OSPEED_10MHZ, GPIO_PIN_0);
  17. //cs1180 power enable
  18. gpio_mode_output(GPIOB, GPIO_PUPD_NONE, GPIO_OTYPE_PP, GPIO_OSPEED_10MHZ, GPIO_PIN_12);
  19. //detect cs1180 ready
  20. gpio_mode_input(GPIOA, GPIO_PUPD_NONE, GPIO_PIN_0);
  21. //CS1180 cs
  22. gpio_mode_output(GPIOA, GPIO_PUPD_NONE, GPIO_OTYPE_PP, GPIO_OSPEED_50MHZ, GPIO_PIN_9);
  23. #elif (CONFIG_BOARD_TYPE==SHARK_BOARD_SP600)
  24. //rs485 INT ,this can be used detect rs485 in/out, then open rs485 power, and then detect GPIOF0
  25. gpio_mode_input(GPIOC, GPIO_PUPD_NONE, GPIO_PIN_13);
  26. //rs485 pwr enable
  27. gpio_mode_output(GPIOC, GPIO_PUPD_NONE, GPIO_OTYPE_PP, GPIO_OSPEED_10MHZ, GPIO_PIN_14);
  28. //rs485 in/out detect, only works when rs485 pwr on
  29. gpio_mode_input(GPIOF, GPIO_PUPD_NONE, GPIO_PIN_0);
  30. //cs1180 pwr enable
  31. gpio_mode_output(GPIOC, GPIO_PUPD_NONE, GPIO_OTYPE_PP, GPIO_OSPEED_10MHZ, GPIO_PIN_15);
  32. //detect cs1180 ready
  33. gpio_mode_input(GPIOB, GPIO_PUPD_NONE, GPIO_PIN_12);
  34. //CS1180 cs
  35. gpio_mode_output(GPIOA, GPIO_PUPD_NONE, GPIO_OTYPE_PP, GPIO_OSPEED_50MHZ, GPIO_PIN_8);
  36. //LED 0,1,2
  37. gpio_mode_output(GPIOA, GPIO_PUPD_NONE, GPIO_OTYPE_PP, GPIO_OSPEED_10MHZ, GPIO_PIN_2|GPIO_PIN_3);
  38. gpio_mode_output(GPIOF, GPIO_PUPD_NONE, GPIO_OTYPE_PP, GPIO_OSPEED_10MHZ, GPIO_PIN_6);
  39. //LED3,4
  40. gpio_mode_output(GPIOA, GPIO_PUPD_NONE, GPIO_OTYPE_PP, GPIO_OSPEED_10MHZ, GPIO_PIN_10|GPIO_PIN_9);
  41. #endif
  42. //CS1180_PWR_ENABLE(0);
  43. //power good detect
  44. gpio_mode_input(GPIOF, GPIO_PUPD_NONE, GPIO_PIN_7);
  45. //temp senser enable
  46. gpio_mode_output(GPIOF, GPIO_PUPD_NONE, GPIO_OTYPE_PP, GPIO_OSPEED_10MHZ, GPIO_PIN_1);
  47. //charger detect
  48. gpio_mode_input(GPIOB, GPIO_PUPD_NONE, GPIO_PIN_10);
  49. //aux 12v power enable
  50. gpio_mode_output(GPIOB, GPIO_PUPD_NONE, GPIO_OTYPE_PP, GPIO_OSPEED_10MHZ, GPIO_PIN_2);
  51. //aux 12v lock detect
  52. gpio_mode_input(GPIOB, GPIO_PUPD_NONE, GPIO_PIN_11);
  53. //DC-DC enable
  54. gpio_mode_output(GPIOA, GPIO_PUPD_NONE, GPIO_OTYPE_PP, GPIO_OSPEED_10MHZ, GPIO_PIN_11);
  55. //DC-DC power good indicat
  56. gpio_mode_input(GPIOF, GPIO_PUPD_NONE, GPIO_PIN_7);
  57. //ms5238 irq
  58. gpio_mode_input(GPIOA, GPIO_PUPD_NONE, GPIO_PIN_12);
  59. //ML5238 cs
  60. gpio_mode_output(GPIOA, GPIO_PUPD_NONE, GPIO_OTYPE_PP, GPIO_OSPEED_50MHZ, GPIO_PIN_15);
  61. }