| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- #include "gpio.h"
- /* all pins used as gpio(input/output/irq) must be defined here */
- void gpio_init(void){
- rcu_periph_clock_enable(RCU_GPIOA);
- rcu_periph_clock_enable(RCU_GPIOB);
- rcu_periph_clock_enable(RCU_GPIOC);
- rcu_periph_clock_enable(RCU_GPIOF);
- #if (CONFIG_BOARD_TYPE==SHARK_BOARD_SP700)
- //hall 2 detect
- gpio_mode_input(GPIOC, GPIO_PUPD_NONE, GPIO_PIN_13);
- //hall 1 detect
- gpio_mode_input(GPIOC, GPIO_PUPD_NONE, GPIO_PIN_15);
-
- //IR uart0 enable
- gpio_mode_output(GPIOC, GPIO_PUPD_NONE, GPIO_OTYPE_PP, GPIO_OSPEED_10MHZ, GPIO_PIN_14);
- //IR uart2 enable
- gpio_mode_output(GPIOF, GPIO_PUPD_NONE, GPIO_OTYPE_PP, GPIO_OSPEED_10MHZ, GPIO_PIN_0);
- //cs1180 power enable
- gpio_mode_output(GPIOB, GPIO_PUPD_NONE, GPIO_OTYPE_PP, GPIO_OSPEED_10MHZ, GPIO_PIN_12);
- //detect cs1180 ready
- gpio_mode_input(GPIOA, GPIO_PUPD_NONE, GPIO_PIN_0);
- //CS1180 cs
- gpio_mode_output(GPIOA, GPIO_PUPD_NONE, GPIO_OTYPE_PP, GPIO_OSPEED_50MHZ, GPIO_PIN_9);
-
- #elif (CONFIG_BOARD_TYPE==SHARK_BOARD_SP600)
- //rs485 INT ,this can be used detect rs485 in/out, then open rs485 power, and then detect GPIOF0
- gpio_mode_input(GPIOC, GPIO_PUPD_NONE, GPIO_PIN_13);
- //rs485 pwr enable
- gpio_mode_output(GPIOC, GPIO_PUPD_NONE, GPIO_OTYPE_PP, GPIO_OSPEED_10MHZ, GPIO_PIN_14);
- //rs485 in/out detect, only works when rs485 pwr on
- gpio_mode_input(GPIOF, GPIO_PUPD_NONE, GPIO_PIN_0);
- //cs1180 pwr enable
- gpio_mode_output(GPIOC, GPIO_PUPD_NONE, GPIO_OTYPE_PP, GPIO_OSPEED_10MHZ, GPIO_PIN_15);
- //detect cs1180 ready
- gpio_mode_input(GPIOB, GPIO_PUPD_NONE, GPIO_PIN_12);
- //CS1180 cs
- gpio_mode_output(GPIOA, GPIO_PUPD_NONE, GPIO_OTYPE_PP, GPIO_OSPEED_50MHZ, GPIO_PIN_8);
- //LED 0,1,2
- gpio_mode_output(GPIOA, GPIO_PUPD_NONE, GPIO_OTYPE_PP, GPIO_OSPEED_10MHZ, GPIO_PIN_2|GPIO_PIN_3);
- gpio_mode_output(GPIOF, GPIO_PUPD_NONE, GPIO_OTYPE_PP, GPIO_OSPEED_10MHZ, GPIO_PIN_6);
- //LED3,4
- gpio_mode_output(GPIOA, GPIO_PUPD_NONE, GPIO_OTYPE_PP, GPIO_OSPEED_10MHZ, GPIO_PIN_10|GPIO_PIN_9);
- #endif
- //CS1180_PWR_ENABLE(0);
- //power good detect
- gpio_mode_input(GPIOF, GPIO_PUPD_NONE, GPIO_PIN_7);
- //temp senser enable
- gpio_mode_output(GPIOF, GPIO_PUPD_NONE, GPIO_OTYPE_PP, GPIO_OSPEED_10MHZ, GPIO_PIN_1);
- //charger detect
- gpio_mode_input(GPIOB, GPIO_PUPD_NONE, GPIO_PIN_10);
- //aux 12v power enable
- gpio_mode_output(GPIOB, GPIO_PUPD_NONE, GPIO_OTYPE_PP, GPIO_OSPEED_10MHZ, GPIO_PIN_2);
- //aux 12v lock detect
- gpio_mode_input(GPIOB, GPIO_PUPD_NONE, GPIO_PIN_11);
- //DC-DC enable
- gpio_mode_output(GPIOA, GPIO_PUPD_NONE, GPIO_OTYPE_PP, GPIO_OSPEED_10MHZ, GPIO_PIN_11);
- //DC-DC power good indicat
- gpio_mode_input(GPIOF, GPIO_PUPD_NONE, GPIO_PIN_7);
- //ms5238 irq
- gpio_mode_input(GPIOA, GPIO_PUPD_NONE, GPIO_PIN_12);
- //ML5238 cs
- gpio_mode_output(GPIOA, GPIO_PUPD_NONE, GPIO_OTYPE_PP, GPIO_OSPEED_50MHZ, GPIO_PIN_15);
- }
|