32 #define GPIO_Pin_0 (BIT(0))
33 #define GPIO_Pin_1 (BIT(1))
34 #define GPIO_Pin_2 (BIT(2))
35 #define GPIO_Pin_3 (BIT(3))
36 #define GPIO_Pin_4 (BIT(4))
37 #define GPIO_Pin_5 (BIT(5))
38 #define GPIO_Pin_6 (BIT(6))
39 #define GPIO_Pin_7 (BIT(7))
40 #define GPIO_Pin_8 (BIT(8))
41 #define GPIO_Pin_9 (BIT(9))
42 #define GPIO_Pin_10 (BIT(10))
43 #define GPIO_Pin_11 (BIT(11))
44 #define GPIO_Pin_12 (BIT(12))
45 #define GPIO_Pin_13 (BIT(13))
46 #define GPIO_Pin_14 (BIT(14))
47 #define GPIO_Pin_15 (BIT(15))
48 #define GPIO_Pin_All (0xFFFF)
50 #define GPIO_PIN_REG_0 PERIPHS_IO_MUX_GPIO0_U
51 #define GPIO_PIN_REG_1 PERIPHS_IO_MUX_U0TXD_U
52 #define GPIO_PIN_REG_2 PERIPHS_IO_MUX_GPIO2_U
53 #define GPIO_PIN_REG_3 PERIPHS_IO_MUX_U0RXD_U
54 #define GPIO_PIN_REG_4 PERIPHS_IO_MUX_GPIO4_U
55 #define GPIO_PIN_REG_5 PERIPHS_IO_MUX_GPIO5_U
56 #define GPIO_PIN_REG_6 PERIPHS_IO_MUX_SD_CLK_U
57 #define GPIO_PIN_REG_7 PERIPHS_IO_MUX_SD_DATA0_U
58 #define GPIO_PIN_REG_8 PERIPHS_IO_MUX_SD_DATA1_U
59 #define GPIO_PIN_REG_9 PERIPHS_IO_MUX_SD_DATA2_U
60 #define GPIO_PIN_REG_10 PERIPHS_IO_MUX_SD_DATA3_U
61 #define GPIO_PIN_REG_11 PERIPHS_IO_MUX_SD_CMD_U
62 #define GPIO_PIN_REG_12 PERIPHS_IO_MUX_MTDI_U
63 #define GPIO_PIN_REG_13 PERIPHS_IO_MUX_MTCK_U
64 #define GPIO_PIN_REG_14 PERIPHS_IO_MUX_MTMS_U
65 #define GPIO_PIN_REG_15 PERIPHS_IO_MUX_MTDO_U
67 #define GPIO_PIN_REG(i) \
68 (i==0) ? GPIO_PIN_REG_0: \
69 (i==1) ? GPIO_PIN_REG_1: \
70 (i==2) ? GPIO_PIN_REG_2: \
71 (i==3) ? GPIO_PIN_REG_3: \
72 (i==4) ? GPIO_PIN_REG_4: \
73 (i==5) ? GPIO_PIN_REG_5: \
74 (i==6) ? GPIO_PIN_REG_6: \
75 (i==7) ? GPIO_PIN_REG_7: \
76 (i==8) ? GPIO_PIN_REG_8: \
77 (i==9) ? GPIO_PIN_REG_9: \
78 (i==10)? GPIO_PIN_REG_10: \
79 (i==11)? GPIO_PIN_REG_11: \
80 (i==12)? GPIO_PIN_REG_12: \
81 (i==13)? GPIO_PIN_REG_13: \
82 (i==14)? GPIO_PIN_REG_14: \
85 #define GPIO_PIN_ADDR(i) (GPIO_PIN0_ADDRESS + i*4)
87 #define GPIO_ID_IS_PIN_REGISTER(reg_id) \
88 ((reg_id >= GPIO_ID_PIN0) && (reg_id <= GPIO_ID_PIN(GPIO_PIN_COUNT-1)))
90 #define GPIO_REGID_TO_PINIDX(reg_id) ((reg_id) - GPIO_ID_PIN0)
93 GPIO_PIN_INTR_DISABLE = 0,
94 GPIO_PIN_INTR_POSEDGE = 1,
95 GPIO_PIN_INTR_NEGEDGE = 2,
96 GPIO_PIN_INTR_ANYEDGE = 3,
97 GPIO_PIN_INTR_LOLEVEL = 4,
98 GPIO_PIN_INTR_HILEVEL = 5
102 GPIO_Mode_Input = 0x0,
105 GPIO_Mode_Sigma_Delta ,
109 GPIO_PullUp_DIS = 0x0,
110 GPIO_PullUp_EN = 0x1,
144 #define GPIO_OUTPUT_SET(gpio_no, bit_value) \
145 gpio_output_conf(bit_value<<gpio_no, ((~bit_value)&0x01)<<gpio_no, 1<<gpio_no, 0)
155 #define GPIO_OUTPUT(gpio_bits, bit_value) \
156 if(bit_value) gpio_output_conf(gpio_bits, 0, gpio_bits, 0);\
157 else gpio_output_conf(0, gpio_bits, gpio_bits, 0)
166 #define GPIO_DIS_OUTPUT(gpio_no) gpio_output_conf(0, 0, 0, 1<<gpio_no)
175 #define GPIO_AS_INPUT(gpio_bits) gpio_output_conf(0, 0, 0, gpio_bits)
184 #define GPIO_AS_OUTPUT(gpio_bits) gpio_output_conf(0, 0, gpio_bits, 0)
193 #define GPIO_INPUT_GET(gpio_no) ((gpio_input_get()>>gpio_no)&BIT0)
245 void gpio_output_conf(uint32 set_mask, uint32 clear_mask, uint32 enable_mask, uint32 disable_mask);
void gpio16_output_set(uint8 value)
Set GPIO16 output level.
uint32 gpio_input_get(void)
Sample the value of GPIO input pins and returns a bitmask.
uint16 GPIO_Pin
Definition: gpio.h:114
GPIO_Pullup_IF GPIO_Pullup
Definition: gpio.h:116
void gpio_pin_wakeup_enable(uint32 i, GPIO_INT_TYPE intr_state)
Configure GPIO wake up to light sleep,Only level way is effective.
void gpio16_output_conf(void)
Enable GPIO16 output.
uint8 gpio16_input_get(void)
Sample the value of GPIO16 input.
void gpio_pin_intr_state_set(uint32 i, GPIO_INT_TYPE intr_state)
Config interrupt types of GPIO pin.
GPIO_INT_TYPE GPIO_IntrType
Definition: gpio.h:117
GPIOMode_TypeDef GPIO_Mode
Definition: gpio.h:115
void gpio16_input_conf(void)
Enable GPIO pin intput.
void gpio_output_conf(uint32 set_mask, uint32 clear_mask, uint32 enable_mask, uint32 disable_mask)
Configure Gpio pins out or input.
void gpio_pin_wakeup_disable()
Disable GPIO wake up to light sleep.
void gpio_intr_handler_register(void *fn, void *arg)
Register an application-specific interrupt handler for GPIO pin interrupts.