Trident IoT SDK
Loading...
Searching...
No Matches
T32CM11_gpio.h
Go to the documentation of this file.
1
24
25#ifndef T32CM11_GPIO_H_
26#define T32CM11_GPIO_H_
27
28#include "tr_hal_platform.h"
29
30
36
37
41#define TR_HAL_MAX_PIN_NUMBER (32)
42
43
54#define CHIP_MEMORY_MAP_GPIO_BASE (0x40000000UL)
55#define CHIP_MEMORY_MAP_SYS_CTRL_BASE (0x40800000UL)
56
57
61typedef struct
62{
63 // read current pin input state and interrupt status
64 // (note these 2 registers have different meanings for read and
65 // write. See below for their alternate use)
66 __IO uint32_t state; // 0x00
67 __IO uint32_t interrupt_status; // 0x04
68
69 // these two registers set a pin for output or input. Note that
70 // all pins start as inputs on chip bootup.
71 // to set a pin for output: set a 1 in that bit in output_enable.
72 // to set a pin for input: set a 1 in that bit in input_enable.
73 // note that reading output_enable and input_enable will give the same value.
74 // A value of 1 means that pin is set for input
75 // A value of 0 means that pin is set for output
76 __IO uint32_t output_enable; // 0x08
77 __IO uint32_t input_enable; // 0x0C
78
79 // settings for configuring interrupts on GPIO pins
80 // enable / disable registers are a pair
81 // read the enable register to get the current setting
82 __IO uint32_t enable_interrupt; // 0x10
83 __IO uint32_t disable_interrupt; // 0x14
84 // edge/level are a pair, default is level
85 __IO uint32_t enable_edge_trigger_interrupt; // 0x18
86 __IO uint32_t enable_level_trigger_interrupt; // 0x1C
87 // high/low are a pair, default is low
90 // enable_edge/disable_edge are a pait, default is disable
91 __IO uint32_t enable_any_edge_trigger_interrupt; // 0x28
93
94 // this register is how to clear edge triggered interrupts
95 // level sensitive interrupts stay until the pin state is cleared
96 __IO uint32_t clear_interrupt; // 0x30
97
98 // the next 3 fields are test fields - we don't expect them to be used
99 __IO uint32_t enable_loopback_mode; // 0x34
100 __IO uint32_t enable_inhibit_input_mode; // 0x38
101 __IO uint32_t disable_inhibit_input_mode; // 0x3C
102
103 // debounce settings
104 // set 1 in enable_debounce for that pin bit to enable debounce
105 // set 1 in disable_debounce for that pin bit to disable debounce
106 // note that reading enable_debounce and disable_debounce give the same value
107 // on read a 1 means enabled and 0 means disabled
108 __IO uint32_t enable_debounce; // 0x40
109 __IO uint32_t disable_debounce; // 0x44
110 __IO uint32_t debounce_time; // 0x48
111
113
114
115// *****************************************************************
116// *** some registers are multi-purpose:
117
118// at register address 0x00, a read means get pin state, a write is set_output_high
119#define set_output_high state
120
121// at register address 0x04, a read is get interrupt status, a write is set_output_low
122#define set_output_low interrupt_status
123
124
125// *****************************************************************
126// this orients the GPIO_REGISTERS struct with the correct addresses
127// so referencing a field will now read/write the correct GPIO register
128// chip address
129#define GPIO_CHIP_REGISTERS ((GPIO_REGISTERS_T *) CHIP_MEMORY_MAP_GPIO_BASE)
130
166
167
176
177
186
187
200
201
219
220
239
240
254
255
265
266
270
271// there is only one event that can come back from a GPIO callback currently
272// reserve 0 for none in case we need it later
278
279// GPIO/button interrupt callback function type
280// to create a function in the app that can be used as a callback:
281// void app_gpio_button_callback(tr_hal_gpio_pin_t pin, tr_hal_gpio_event_t event)
282// where pin = the pin triggered
283// and event = what happened (TR_HAL_GPIO_EVENT_xxx)
284// this is set using the tr_hal_gpio_set_interrupt_callback API
286
287
318typedef struct
319{
320 // direction - INPUT or OUTPUT
322
323 // output level
325
326 // open drain
328
329 // output drive strength
331
332 // interrupt trigger (edge high, edge low, etc)
333 // (note: int priority is not set here since it is set for ALL GPIOs)
335
336 // event callback
338
339 // pull up / pull down
341
342 // debounce
343 // (note: debounce time is not set here since it is set for ALL GPIOs)
345
346 // set wake mode for this GPIO
348
350
351
357#define DEFAULT_GPIO_OUTPUT_CONFIG \
358 { \
359 .direction = TR_HAL_GPIO_DIRECTION_OUTPUT, \
360 .output_level = TR_HAL_GPIO_LEVEL_HIGH, \
361 .enable_open_drain = false, \
362 .drive_strength = TR_HAL_DRIVE_STRENGTH_DEFAULT, \
363 .interrupt_trigger = TR_HAL_GPIO_TRIGGER_NONE, \
364 .event_handler_fx = NULL, \
365 .pull_mode = TR_HAL_PULLOPT_PULL_NONE, \
366 .enable_debounce = false, \
367 .wake_mode = TR_HAL_WAKE_MODE_NONE, \
368 }
369
370#define DEFAULT_GPIO_INPUT_CONFIG \
371 { \
372 .direction = TR_HAL_GPIO_DIRECTION_INPUT, \
373 .interrupt_trigger = TR_HAL_GPIO_TRIGGER_EITHER_EDGE, \
374 .event_handler_fx = NULL, \
375 .pull_mode = TR_HAL_PULLOPT_PULL_NONE, \
376 .enable_debounce = true, \
377 .wake_mode = TR_HAL_WAKE_MODE_NONE, \
378 .output_level = TR_HAL_GPIO_LEVEL_HIGH, \
379 .enable_open_drain = false, \
380 .drive_strength = TR_HAL_DRIVE_STRENGTH_DEFAULT \
381 }
382
383
387
388
389#endif // T32CM11_GPIO_H_
This file contains the CHIP SPECIFIC types and defines for the T32CM11.
tr_hal_drive_strength_t
values for setting the GPIO drive strength in the Trident HAL APIs NOTE: these CANNOT be changed....
Definition T32CM11_gpio.h:246
tr_hal_wake_mode_t
values for setting the GPIO wake mode
Definition T32CM11_gpio.h:260
tr_hal_pullopt_t
values for setting the pull option in the Trident HAL GPIO APIs NOTE: these CANNOT be changed....
Definition T32CM11_gpio.h:208
tr_hal_direction_t
values for setting the direction in the Trident HAL GPIO APIs
Definition T32CM11_gpio.h:172
tr_hal_pin_mode_t
these are the pin MODEs to be passed to tr_hal_gpio_set_mode note that these are defined by the chip ...
Definition T32CM11_gpio.h:137
tr_hal_gpio_event_t
GPIO interrupt callback functions.
Definition T32CM11_gpio.h:274
tr_hal_debounce_time_t
values for setting the debounce time register each individual GPIO can be set to enable or disable de...
Definition T32CM11_gpio.h:228
tr_hal_trigger_t
values for setting the interrupt trigger in the Trident HAL GPIO APIs
Definition T32CM11_gpio.h:192
void(* tr_hal_gpio_event_callback_t)(tr_hal_gpio_pin_t pin, tr_hal_gpio_event_t event)
Definition T32CM11_gpio.h:285
tr_hal_level_t
values for setting the level in the Trident HAL GPIO APIs
Definition T32CM11_gpio.h:182
@ TR_HAL_DRIVE_STRENGTH_20_MA
Definition T32CM11_gpio.h:250
@ TR_HAL_DRIVE_STRENGTH_DEFAULT
Definition T32CM11_gpio.h:252
@ TR_HAL_DRIVE_STRENGTH_4_MA
Definition T32CM11_gpio.h:247
@ TR_HAL_DRIVE_STRENGTH_14_MA
Definition T32CM11_gpio.h:249
@ TR_HAL_DRIVE_STRENGTH_MAX
Definition T32CM11_gpio.h:251
@ TR_HAL_DRIVE_STRENGTH_10_MA
Definition T32CM11_gpio.h:248
@ TR_HAL_WAKE_MODE_INPUT_LOW
Definition T32CM11_gpio.h:262
@ TR_HAL_WAKE_MODE_INPUT_HIGH
Definition T32CM11_gpio.h:263
@ TR_HAL_WAKE_MODE_NONE
Definition T32CM11_gpio.h:261
@ TR_HAL_PULLOPT_PULL_DOWN_1M
Definition T32CM11_gpio.h:212
@ TR_HAL_PULLOPT_PULL_UP_100K
Definition T32CM11_gpio.h:215
@ TR_HAL_PULLOPT_PULL_NONE
Definition T32CM11_gpio.h:209
@ TR_HAL_PULLOPT_PULL_UP_10K
Definition T32CM11_gpio.h:214
@ TR_HAL_PULLOPT_MAX_VALUE
Definition T32CM11_gpio.h:217
@ TR_HAL_PULLOPT_PULL_ALSO_NONE
Definition T32CM11_gpio.h:213
@ TR_HAL_PULLOPT_PULL_DOWN_10K
Definition T32CM11_gpio.h:210
@ TR_HAL_PULLOPT_PULL_UP_1M
Definition T32CM11_gpio.h:216
@ TR_HAL_PULLOPT_PULL_DOWN_100K
Definition T32CM11_gpio.h:211
@ TR_HAL_GPIO_DIRECTION_INPUT
Definition T32CM11_gpio.h:174
@ TR_HAL_GPIO_DIRECTION_OUTPUT
Definition T32CM11_gpio.h:173
@ TR_HAL_GPIO_MODE_PWM1
Definition T32CM11_gpio.h:146
@ TR_HAL_GPIO_MODE_QSPI0
Definition T32CM11_gpio.h:139
@ TR_HAL_GPIO_MODE_PWM0
Definition T32CM11_gpio.h:145
@ TR_HAL_GPIO_MODE_I2C
Definition T32CM11_gpio.h:140
@ TR_HAL_GPIO_MODE_PWM3
Definition T32CM11_gpio.h:148
@ TR_HAL_GPIO_MODE_I2S
Definition T32CM11_gpio.h:143
@ TR_HAL_GPIO_MODE_PWM_SPECIAL
Definition T32CM11_gpio.h:153
@ TR_HAL_GPIO_MODE_SPI0_CS2
Definition T32CM11_gpio.h:161
@ TR_HAL_GPIO_MODE_SPI0_CS1
Definition T32CM11_gpio.h:160
@ TR_HAL_GPIO_MODE_MAX
Definition T32CM11_gpio.h:164
@ TR_HAL_GPIO_MODE_SPI0
Definition T32CM11_gpio.h:156
@ TR_HAL_GPIO_MODE_UART
Definition T32CM11_gpio.h:141
@ TR_HAL_GPIO_MODE_PWM2
Definition T32CM11_gpio.h:147
@ TR_HAL_GPIO_MODE_SPI0_CS3
Definition T32CM11_gpio.h:162
@ TR_HAL_GPIO_MODE_PWM
Definition T32CM11_gpio.h:144
@ TR_HAL_GPIO_MODE_PWM4
Definition T32CM11_gpio.h:149
@ TR_HAL_GPIO_MODE_GPIO
Definition T32CM11_gpio.h:138
@ TR_HAL_GPIO_MODE_SPI1
Definition T32CM11_gpio.h:157
@ TR_HAL_GPIO_EVENT_INPUT_TRIGGERED
Definition T32CM11_gpio.h:276
@ TR_HAL_GPIO_EVENT_NONE
Definition T32CM11_gpio.h:275
@ TR_HAL_DEBOUNCE_TIME_512_CLOCKS
Definition T32CM11_gpio.h:233
@ TR_HAL_DEBOUNCE_TIME_MAX_VALUE
Definition T32CM11_gpio.h:237
@ TR_HAL_DEBOUNCE_TIME_2048_CLOCKS
Definition T32CM11_gpio.h:235
@ TR_HAL_DEBOUNCE_TIME_32_CLOCKS
Definition T32CM11_gpio.h:229
@ TR_HAL_DEBOUNCE_TIME_128_CLOCKS
Definition T32CM11_gpio.h:231
@ TR_HAL_DEBOUNCE_TIME_1024_CLOCKS
Definition T32CM11_gpio.h:234
@ TR_HAL_DEBOUNCE_TIME_4096_CLOCKS
Definition T32CM11_gpio.h:236
@ TR_HAL_DEBOUNCE_TIME_64_CLOCKS
Definition T32CM11_gpio.h:230
@ TR_HAL_DEBOUNCE_TIME_256_CLOCKS
Definition T32CM11_gpio.h:232
@ TR_HAL_GPIO_TRIGGER_LEVEL_LOW
Definition T32CM11_gpio.h:197
@ TR_HAL_GPIO_TRIGGER_EITHER_EDGE
Definition T32CM11_gpio.h:196
@ TR_HAL_GPIO_TRIGGER_LEVEL_HIGH
Definition T32CM11_gpio.h:198
@ TR_HAL_GPIO_TRIGGER_NONE
Definition T32CM11_gpio.h:193
@ TR_HAL_GPIO_TRIGGER_RISING_EDGE
Definition T32CM11_gpio.h:194
@ TR_HAL_GPIO_TRIGGER_FALLING_EDGE
Definition T32CM11_gpio.h:195
@ TR_HAL_GPIO_LEVEL_HIGH
Definition T32CM11_gpio.h:184
@ TR_HAL_GPIO_LEVEL_LOW
Definition T32CM11_gpio.h:183
tr_hal_drive_strength_t
values for setting the GPIO drive strength in the Trident HAL APIs NOTE: these CANNOT be changed....
Definition T32CZ20_gpio.h:399
tr_hal_wake_mode_t
values for setting the GPIO wake mode
Definition T32CZ20_gpio.h:413
tr_hal_pullopt_t
values for setting the pull option in the Trident HAL GPIO APIs NOTE: these CANNOT be changed....
Definition T32CZ20_gpio.h:360
tr_hal_direction_t
values for setting the direction in the Trident HAL GPIO APIs
Definition T32CZ20_gpio.h:324
tr_hal_trigger_t
values for setting the interrupt trigger in the Trident HAL GPIO APIs
Definition T32CZ20_gpio.h:344
void(* tr_hal_gpio_event_callback_t)(tr_hal_gpio_pin_t pin, tr_hal_gpio_event_t event)
Definition T32CZ20_gpio.h:438
tr_hal_level_t
values for setting the level in the Trident HAL GPIO APIs
Definition T32CZ20_gpio.h:334
Definition T32CM11_gpio.h:62
__IO uint32_t enable_level_trigger_interrupt
Definition T32CM11_gpio.h:86
__IO uint32_t enable_loopback_mode
Definition T32CM11_gpio.h:99
__IO uint32_t state
Definition T32CM11_gpio.h:66
__IO uint32_t enable_edge_trigger_interrupt
Definition T32CM11_gpio.h:85
__IO uint32_t disable_inhibit_input_mode
Definition T32CM11_gpio.h:101
__IO uint32_t input_enable
Definition T32CM11_gpio.h:77
__IO uint32_t clear_interrupt
Definition T32CM11_gpio.h:96
__IO uint32_t output_enable
Definition T32CM11_gpio.h:76
__IO uint32_t enable_interrupt
Definition T32CM11_gpio.h:82
__IO uint32_t enable_any_edge_trigger_interrupt
Definition T32CM11_gpio.h:91
__IO uint32_t disable_interrupt
Definition T32CM11_gpio.h:83
__IO uint32_t enable_debounce
Definition T32CM11_gpio.h:108
__IO uint32_t disable_debounce
Definition T32CM11_gpio.h:109
__IO uint32_t enable_inhibit_input_mode
Definition T32CM11_gpio.h:100
__IO uint32_t enable_active_high_trigger_interrupt
Definition T32CM11_gpio.h:88
__IO uint32_t debounce_time
Definition T32CM11_gpio.h:110
__IO uint32_t disable_any_edge_trigger_interrupt
Definition T32CM11_gpio.h:92
__IO uint32_t interrupt_status
Definition T32CM11_gpio.h:67
__IO uint32_t enable_active_low_trigger_interrupt
Definition T32CM11_gpio.h:89
pin type
Definition tr_hal_platform.h:23
Definition T32CM11_gpio.h:319
tr_hal_gpio_event_callback_t event_handler_fx
Definition T32CM11_gpio.h:337
tr_hal_wake_mode_t wake_mode
Definition T32CM11_gpio.h:347
tr_hal_level_t output_level
Definition T32CM11_gpio.h:324
tr_hal_trigger_t interrupt_trigger
Definition T32CM11_gpio.h:334
tr_hal_drive_strength_t drive_strength
Definition T32CM11_gpio.h:330
tr_hal_direction_t direction
Definition T32CM11_gpio.h:321
bool enable_open_drain
Definition T32CM11_gpio.h:327
bool enable_debounce
Definition T32CM11_gpio.h:344
tr_hal_pullopt_t pull_mode
Definition T32CM11_gpio.h:340