44 #define GPIO_PIN_10 10 45 #define GPIO_PIN_11 11 46 #define GPIO_PIN_12 12 47 #define GPIO_PIN_13 13 48 #define GPIO_PIN_14 14 49 #define GPIO_PIN_15 15 50 #define GPIO_PIN_16 16 51 #define GPIO_PIN_17 17 52 #define GPIO_PIN_18 18 53 #define GPIO_PIN_19 19 54 #define GPIO_PIN_20 20 55 #define GPIO_PIN_21 21 56 #define GPIO_PIN_22 22 57 #define GPIO_PIN_23 23 58 #define GPIO_PIN_24 24 59 #define GPIO_PIN_25 25 60 #define GPIO_PIN_26 26 61 #define GPIO_PIN_27 27 62 #define GPIO_PIN_28 28 63 #define GPIO_PIN_29 29 64 #define GPIO_PIN_30 30 65 #define GPIO_PIN_31 31 66 #define GPIO_PIN_32 32 67 #define GPIO_PIN_33 33 68 #define GPIO_PIN_34 34 69 #define GPIO_PIN_35 35 70 #define GPIO_PIN_36 36 71 #define GPIO_PIN_37 37 72 #define GPIO_PIN_38 38 73 #define GPIO_PIN_39 39 74 #define GPIO_PIN_40 40 75 #define GPIO_PIN_41 41 76 #define GPIO_PIN_42 42 77 #define GPIO_PIN_43 43 78 #define GPIO_PIN_44 44 79 #define GPIO_PIN_45 45 85 #define GPIO_FUNC_SHIFT (0) 86 #define GPIO_FUNC_MASK (0x1f << GPIO_FUNC_SHIFT) 88 #define GPIO_FUNC_SDU (1 << GPIO_FUNC_SHIFT) 89 #define GPIO_FUNC_SPI0 (4 << GPIO_FUNC_SHIFT) 90 #define GPIO_FUNC_I2C0 (6 << GPIO_FUNC_SHIFT) 91 #define GPIO_FUNC_PWM0 (8 << GPIO_FUNC_SHIFT) 92 #define GPIO_FUNC_JTAG (14 << GPIO_FUNC_SHIFT) 94 #define GPIO_FUNC_CLK_OUT (0 << GPIO_FUNC_SHIFT) 95 #define GPIO_FUNC_I2S (3 << GPIO_FUNC_SHIFT) 96 #define GPIO_FUNC_SPI0 (4 << GPIO_FUNC_SHIFT) 97 #define GPIO_FUNC_I2C0 (6 << GPIO_FUNC_SHIFT) 98 #define GPIO_FUNC_PWM0 (8 << GPIO_FUNC_SHIFT) 99 #define GPIO_FUNC_CAM (9 << GPIO_FUNC_SHIFT) 100 #define GPIO_FUNC_JTAG (14 << GPIO_FUNC_SHIFT) 101 #define GPIO_FUNC_EMAC (19 << GPIO_FUNC_SHIFT) 102 #define GPIO_FUNC_CAM_MCLK (23 << GPIO_FUNC_SHIFT) 103 #elif defined(BL702L) 104 #define GPIO_FUNC_SPI0 (4 << GPIO_FUNC_SHIFT) 105 #define GPIO_FUNC_I2C0 (6 << GPIO_FUNC_SHIFT) 106 #define GPIO_FUNC_PWM0 (8 << GPIO_FUNC_SHIFT) 107 #define GPIO_FUNC_KEYSCAN (13 << GPIO_FUNC_SHIFT) 108 #define GPIO_FUNC_JTAG (14 << GPIO_FUNC_SHIFT) 110 #define GPIO_FUNC_SDH (0 << GPIO_FUNC_SHIFT) 111 #define GPIO_FUNC_SPI0 (1 << GPIO_FUNC_SHIFT) 112 #define GPIO_FUNC_I2S (3 << GPIO_FUNC_SHIFT) 113 #define GPIO_FUNC_PDM (4 << GPIO_FUNC_SHIFT) 114 #define GPIO_FUNC_I2C0 (5 << GPIO_FUNC_SHIFT) 115 #define GPIO_FUNC_I2C1 (6 << GPIO_FUNC_SHIFT) 116 #define GPIO_FUNC_EMAC (8 << GPIO_FUNC_SHIFT) 117 #define GPIO_FUNC_CAM (9 << GPIO_FUNC_SHIFT) 118 #define GPIO_FUNC_SDU (12 << GPIO_FUNC_SHIFT) 119 #define GPIO_FUNC_PWM0 (16 << GPIO_FUNC_SHIFT) 120 #define GPIO_FUNC_DBI_B (22 << GPIO_FUNC_SHIFT) 121 #define GPIO_FUNC_DBI_C (23 << GPIO_FUNC_SHIFT) 122 #define GPIO_FUNC_DBI_QSPI (24 << GPIO_FUNC_SHIFT) 123 #define GPIO_FUNC_AUDAC_PWM (25 << GPIO_FUNC_SHIFT) 124 #define GPIO_FUNC_JTAG (26 << GPIO_FUNC_SHIFT) 125 #define GPIO_FUNC_CLKOUT (31 << GPIO_FUNC_SHIFT) 126 #elif defined(BL606P) || defined(BL808) 127 #define GPIO_FUNC_SDH (0 << GPIO_FUNC_SHIFT) 128 #define GPIO_FUNC_SPI0 (1 << GPIO_FUNC_SHIFT) 129 #define GPIO_FUNC_I2S (3 << GPIO_FUNC_SHIFT) 130 #define GPIO_FUNC_PDM (4 << GPIO_FUNC_SHIFT) 131 #define GPIO_FUNC_I2C0 (5 << GPIO_FUNC_SHIFT) 132 #define GPIO_FUNC_I2C1 (6 << GPIO_FUNC_SHIFT) 133 #define GPIO_FUNC_EMAC (8 << GPIO_FUNC_SHIFT) 134 #define GPIO_FUNC_CAM (9 << GPIO_FUNC_SHIFT) 135 #define GPIO_FUNC_SDU (12 << GPIO_FUNC_SHIFT) 136 #define GPIO_FUNC_PWM0 (16 << GPIO_FUNC_SHIFT) 137 #define GPIO_FUNC_PWM1 (17 << GPIO_FUNC_SHIFT) 138 #define GPIO_FUNC_SPI1 (18 << GPIO_FUNC_SHIFT) 139 #define GPIO_FUNC_I2C2 (19 << GPIO_FUNC_SHIFT) 140 #define GPIO_FUNC_I2C3 (20 << GPIO_FUNC_SHIFT) 141 #define GPIO_FUNC_DBI_B (22 << GPIO_FUNC_SHIFT) 142 #define GPIO_FUNC_DBI_C (23 << GPIO_FUNC_SHIFT) 143 #define GPIO_FUNC_JTAG_LP (25 << GPIO_FUNC_SHIFT) 144 #define GPIO_FUNC_JTAG_M0 (26 << GPIO_FUNC_SHIFT) 145 #define GPIO_FUNC_JTAG_D0 (27 << GPIO_FUNC_SHIFT) 146 #define GPIO_FUNC_CLKOUT (31 << GPIO_FUNC_SHIFT) 148 #define GPIO_FUNC_SDH (0 << GPIO_FUNC_SHIFT) 149 #define GPIO_FUNC_SPI0 (1 << GPIO_FUNC_SHIFT) 150 #define GPIO_FUNC_I2S (3 << GPIO_FUNC_SHIFT) 151 #define GPIO_FUNC_PDM (4 << GPIO_FUNC_SHIFT) 152 #define GPIO_FUNC_I2C0 (5 << GPIO_FUNC_SHIFT) 153 #define GPIO_FUNC_I2C1 (6 << GPIO_FUNC_SHIFT) 154 #define GPIO_FUNC_UART (7 << GPIO_FUNC_SHIFT) 155 #define GPIO_FUNC_EMAC (8 << GPIO_FUNC_SHIFT) 156 #define GPIO_FUNC_CAM (9 << GPIO_FUNC_SHIFT) 157 #define GPIO_FUNC_SDU (12 << GPIO_FUNC_SHIFT) 158 #define GPIO_FUNC_PWM0 (16 << GPIO_FUNC_SHIFT) 159 #define GPIO_FUNC_DBI_B (22 << GPIO_FUNC_SHIFT) 160 #define GPIO_FUNC_DBI_C (23 << GPIO_FUNC_SHIFT) 161 #define GPIO_FUNC_CLKOUT (31 << GPIO_FUNC_SHIFT) 164 #define GPIO_MODE_SHIFT (5) 165 #define GPIO_MODE_MASK (3 << GPIO_MODE_SHIFT) 166 #define GPIO_INPUT (0 << GPIO_MODE_SHIFT) 167 #define GPIO_OUTPUT (1 << GPIO_MODE_SHIFT) 168 #define GPIO_ANALOG (2 << GPIO_MODE_SHIFT) 169 #define GPIO_ALTERNATE (3 << GPIO_MODE_SHIFT) 171 #define GPIO_PUPD_SHIFT (7) 172 #define GPIO_PUPD_MASK (3 << GPIO_PUPD_SHIFT) 173 #define GPIO_FLOAT (0 << GPIO_PUPD_SHIFT) 174 #define GPIO_PULLUP (1 << GPIO_PUPD_SHIFT) 175 #define GPIO_PULLDOWN (2 << GPIO_PUPD_SHIFT) 177 #define GPIO_SMT_SHIFT (9) 178 #define GPIO_SMT_MASK (1 << GPIO_SMT_SHIFT) 179 #define GPIO_SMT_DIS (0 << GPIO_SMT_SHIFT) 180 #define GPIO_SMT_EN (1 << GPIO_SMT_SHIFT) 182 #define GPIO_DRV_SHIFT (10) 183 #define GPIO_DRV_MASK (3 << GPIO_DRV_SHIFT) 184 #define GPIO_DRV_0 (0 << GPIO_DRV_SHIFT) 185 #define GPIO_DRV_1 (1 << GPIO_DRV_SHIFT) 186 #define GPIO_DRV_2 (2 << GPIO_DRV_SHIFT) 187 #define GPIO_DRV_3 (3 << GPIO_DRV_SHIFT) 192 #define GPIO_INT_TRIG_MODE_SYNC_FALLING_EDGE 0 193 #define GPIO_INT_TRIG_MODE_SYNC_RISING_EDGE 1 194 #define GPIO_INT_TRIG_MODE_SYNC_LOW_LEVEL 2 195 #define GPIO_INT_TRIG_MODE_SYNC_HIGH_LEVEL 3 196 #if defined(BL602) || defined(BL702) 197 #define GPIO_INT_TRIG_MODE_ASYNC_FALLING_EDGE 4 198 #define GPIO_INT_TRIG_MODE_ASYNC_RISING_EDGE 5 199 #define GPIO_INT_TRIG_MODE_ASYNC_LOW_LEVEL 6 200 #define GPIO_INT_TRIG_MODE_ASYNC_HIGH_LEVEL 7 202 #define GPIO_INT_TRIG_MODE_SYNC_FALLING_RISING_EDGE 4 203 #define GPIO_INT_TRIG_MODE_ASYNC_FALLING_EDGE 8 204 #define GPIO_INT_TRIG_MODE_ASYNC_RISING_EDGE 9 205 #define GPIO_INT_TRIG_MODE_ASYNC_LOW_LEVEL 10 206 #define GPIO_INT_TRIG_MODE_ASYNC_HIGH_LEVEL 11 215 #define GPIO_UART_FUNC_UART0_RTS 0 216 #define GPIO_UART_FUNC_UART0_CTS 1 217 #define GPIO_UART_FUNC_UART0_TX 2 218 #define GPIO_UART_FUNC_UART0_RX 3 219 #define GPIO_UART_FUNC_UART1_RTS 4 220 #define GPIO_UART_FUNC_UART1_CTS 5 221 #define GPIO_UART_FUNC_UART1_TX 6 222 #define GPIO_UART_FUNC_UART1_RX 7 223 #if defined(BL808) || defined(BL606P) 224 #define GPIO_UART_FUNC_UART2_RTS 8 225 #define GPIO_UART_FUNC_UART2_CTS 9 226 #define GPIO_UART_FUNC_UART2_TX 10 227 #define GPIO_UART_FUNC_UART2_RX 11 236 #define GPIO_CMD_GET_GPIO_FUN (0x01) void bflb_gpio_deinit(struct bflb_device_s *dev, uint8_t pin)
Deinitialize gpio pin with input float.
int bflb_gpio_feature_control(struct bflb_device_s *dev, int cmd, size_t arg)
Control gpio feature.
void bflb_gpio_int_mask(struct bflb_device_s *dev, uint8_t pin, bool mask)
Enable or disable gpio pin interrupt.
void bflb_gpio_int_init(struct bflb_device_s *dev, uint8_t pin, uint8_t trig_mode)
Config gpio pin interrupt.
void bflb_gpio_int_clear(struct bflb_device_s *dev, uint8_t pin)
Clear gpio pin interrupt status.
uint32_t bflb_gpio_pin0_31_read(struct bflb_device_s *dev)
Read level from gpio pin 0~31.
void bflb_gpio_pin0_31_write(struct bflb_device_s *dev, uint32_t val)
Write gpio pin 0~31.
void bflb_gpio_init(struct bflb_device_s *dev, uint8_t pin, uint32_t cfgset)
Initialize gpio pin.
void bflb_gpio_pin32_63_write(struct bflb_device_s *dev, uint32_t val)
Write gpio pin 32~63.
bool bflb_gpio_read(struct bflb_device_s *dev, uint8_t pin)
Read level from gpio pin.
void bflb_gpio_reset(struct bflb_device_s *dev, uint8_t pin)
Write gpio pin with low level.
uint32_t bflb_gpio_pin32_63_read(struct bflb_device_s *dev)
Read level from gpio pin 32~63.
bool bflb_gpio_get_intstatus(struct bflb_device_s *dev, uint8_t pin)
Get gpio pin interrupt status.
void bflb_gpio_set(struct bflb_device_s *dev, uint8_t pin)
Write gpio pin with high level.
void bflb_gpio_uart_init(struct bflb_device_s *dev, uint8_t pin, uint8_t uart_func)
Config gpio pin with uart function.