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
131
136#define TR_HAL_NUM_PULL_REGISTERS 4
137#define TR_HAL_PINS_PER_PULL_REG 8
138
139#define TR_HAL_NUM_MODE_REGISTERS 4
140#define TR_HAL_PINS_PER_MODE_REG 8
141
142#define TR_HAL_NUM_DRIVE_REGISTERS 2
143#define TR_HAL_PINS_PER_DRIVE_REG 16
144
145
152typedef struct
153{
154 __IO uint32_t sleep_enable; // 0x00
155 __IO uint32_t system_clock_control; // 0x04
156 __IO uint32_t reserved[2]; // 0x08, 0x0C
157
158 // default is 0 = GPIO
159 __IO uint32_t gpio_pin_map[TR_HAL_NUM_MODE_REGISTERS]; // 0x10, 0x14, 0x18, 0x1C
160
161 // default is 0b110 = 6 = 100K pull up
162 __IO uint32_t gpio_pull_ctrl[TR_HAL_NUM_PULL_REGISTERS]; // 0x20, 0x24, 0x28, 0x2C
163
164 // default is 0b11 = 3 = 20 mA (max)
165 __IO uint32_t gpio_drv_ctrl[TR_HAL_NUM_DRIVE_REGISTERS]; // 0x30, 0x34
166
167 // default is 0 = disabled
168 __IO uint32_t open_drain_enable; // 0x38
169
170 // note this only works for pins 24-31, of which 24-27 are not available
171 // lowest 8 bits are used to enable these 8 pins
172 // bit 0 = pin 24... bit 7 = pin 31
173 __IO uint32_t analog_IO_enable; // 0x3C
174
175 // random number generator registers (see section 20)
176 __IO uint32_t random_number_trigger; // 0x40
177 __IO uint32_t random_number_select; // 0x44
178 __IO uint32_t random_number_status; // 0x48
179 __IO uint32_t random_number_value; // 0x4C
180
181 // reserved
182 __IO uint32_t reserved2[4]; // 0x50, 0x54, 0x58, 0x5C
183 __IO uint32_t scratchpad[8]; // 0x60, 0x64, 0x68, 0x6C, 0x70, 0x74, 0x78, 0x7C
184
185 // wake from sleep on low-to-high transition of GPIO
186 __IO uint32_t enable_wake_on_high; // 0x80
187
188 // wake from sleep on high-to-low transition of GPIO
189 __IO uint32_t enable_wake_on_low; // 0x84
190
191 // reserved
192 __IO uint32_t reserved3[2]; // 0x88, 0x8C
193
194 // chip info
195 // bit 4 to bit 7 (0x000000F0) is the chip revision
196 // bit 8 to bit 15 (0x0000FF00) is the chip ID
197 __IO uint32_t chip_info; // 0x90
198
199
201
202// *****************************************************************
203// this orients the SYSCTRL_REGISTERS struct with the correct addresses
204// so referencing a field will now read/write the correct SYSCTRL register
205// chip address
206#define SYS_CTRL_CHIP_REGISTERS ((SYS_CTRL_REGISTERS_T *) CHIP_MEMORY_MAP_SYS_CTRL_BASE)
207
208// these are for setting the system_clock_control register
209#define SCC_UART0_CLOCK_BIT 16
210#define SCC_UART1_CLOCK_BIT 17
211#define SCC_UART2_CLOCK_BIT 18
212
213#define TR_HAL_ENABLE_LITE_SLEEP 1
214#define TR_HAL_ENABLE_DEEP_SLEEP 2
215
247
248
257
258
267
268
281
282
300
301
320
321
335
336
346
347
351
352// there is only one event that can come back from a GPIO callback currently
353// reserve 0 for none in case we need it later
359
360// GPIO/button interrupt callback function type
361// to create a function in the app that can be used as a callback:
362// void app_gpio_button_callback(tr_hal_gpio_pin_t pin, tr_hal_gpio_event_t event)
363// where pin = the pin triggered
364// and event = what happened (TR_HAL_GPIO_EVENT_xxx)
365// this is set using the tr_hal_gpio_set_interrupt_callback API
367
368
399typedef struct
400{
401 // direction - INPUT or OUTPUT
403
404 // output level
406
407 // open drain
409
410 // output drive strength
412
413 // interrupt trigger (edge high, edge low, etc)
414 // (note: int priority is not set here since it is set for ALL GPIOs)
416
417 // event callback
419
420 // pull up / pull down
422
423 // debounce
424 // (note: debounce time is not set here since it is set for ALL GPIOs)
426
427 // set wake mode for this GPIO
429
431
432
438#define DEFAULT_GPIO_OUTPUT_CONFIG \
439 { \
440 .direction = TR_HAL_GPIO_DIRECTION_OUTPUT, \
441 .output_level = TR_HAL_GPIO_LEVEL_HIGH, \
442 .enable_open_drain = false, \
443 .drive_strength = TR_HAL_DRIVE_STRENGTH_DEFAULT, \
444 .interrupt_trigger = TR_HAL_GPIO_TRIGGER_NONE, \
445 .event_handler_fx = NULL, \
446 .pull_mode = TR_HAL_PULLOPT_PULL_NONE, \
447 .enable_debounce = false, \
448 .wake_mode = TR_HAL_WAKE_MODE_NONE, \
449 }
450
451#define DEFAULT_GPIO_INPUT_CONFIG \
452 { \
453 .direction = TR_HAL_GPIO_DIRECTION_INPUT, \
454 .interrupt_trigger = TR_HAL_GPIO_TRIGGER_EITHER_EDGE, \
455 .event_handler_fx = NULL, \
456 .pull_mode = TR_HAL_PULLOPT_PULL_NONE, \
457 .enable_debounce = true, \
458 .wake_mode = TR_HAL_WAKE_MODE_NONE, \
459 .output_level = TR_HAL_GPIO_LEVEL_HIGH, \
460 .enable_open_drain = false, \
461 .drive_strength = TR_HAL_DRIVE_STRENGTH_DEFAULT \
462 }
463
464
468
469
470#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:327
tr_hal_wake_mode_t
values for setting the GPIO wake mode
Definition T32CM11_gpio.h:341
#define TR_HAL_NUM_DRIVE_REGISTERS
Definition T32CM11_gpio.h:142
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:289
tr_hal_direction_t
values for setting the direction in the Trident HAL GPIO APIs
Definition T32CM11_gpio.h:253
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:222
tr_hal_gpio_event_t
GPIO interrupt callback functions.
Definition T32CM11_gpio.h:355
#define TR_HAL_NUM_PULL_REGISTERS
defines for dealing with the SYS_CTRL pull registers, mode registers, and drive registers
Definition T32CM11_gpio.h:136
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:309
tr_hal_trigger_t
values for setting the interrupt trigger in the Trident HAL GPIO APIs
Definition T32CM11_gpio.h:273
void(* tr_hal_gpio_event_callback_t)(tr_hal_gpio_pin_t pin, tr_hal_gpio_event_t event)
Definition T32CM11_gpio.h:366
#define TR_HAL_NUM_MODE_REGISTERS
Definition T32CM11_gpio.h:139
tr_hal_level_t
values for setting the level in the Trident HAL GPIO APIs
Definition T32CM11_gpio.h:263
@ TR_HAL_DRIVE_STRENGTH_20_MA
Definition T32CM11_gpio.h:331
@ TR_HAL_DRIVE_STRENGTH_DEFAULT
Definition T32CM11_gpio.h:333
@ TR_HAL_DRIVE_STRENGTH_4_MA
Definition T32CM11_gpio.h:328
@ TR_HAL_DRIVE_STRENGTH_14_MA
Definition T32CM11_gpio.h:330
@ TR_HAL_DRIVE_STRENGTH_MAX
Definition T32CM11_gpio.h:332
@ TR_HAL_DRIVE_STRENGTH_10_MA
Definition T32CM11_gpio.h:329
@ TR_HAL_WAKE_MODE_INPUT_LOW
Definition T32CM11_gpio.h:343
@ TR_HAL_WAKE_MODE_INPUT_HIGH
Definition T32CM11_gpio.h:344
@ TR_HAL_WAKE_MODE_NONE
Definition T32CM11_gpio.h:342
@ TR_HAL_PULLOPT_PULL_DOWN_1M
Definition T32CM11_gpio.h:293
@ TR_HAL_PULLOPT_PULL_UP_100K
Definition T32CM11_gpio.h:296
@ TR_HAL_PULLOPT_PULL_NONE
Definition T32CM11_gpio.h:290
@ TR_HAL_PULLOPT_PULL_UP_10K
Definition T32CM11_gpio.h:295
@ TR_HAL_PULLOPT_MAX_VALUE
Definition T32CM11_gpio.h:298
@ TR_HAL_PULLOPT_PULL_ALSO_NONE
Definition T32CM11_gpio.h:294
@ TR_HAL_PULLOPT_PULL_DOWN_10K
Definition T32CM11_gpio.h:291
@ TR_HAL_PULLOPT_PULL_UP_1M
Definition T32CM11_gpio.h:297
@ TR_HAL_PULLOPT_PULL_DOWN_100K
Definition T32CM11_gpio.h:292
@ TR_HAL_GPIO_DIRECTION_INPUT
Definition T32CM11_gpio.h:255
@ TR_HAL_GPIO_DIRECTION_OUTPUT
Definition T32CM11_gpio.h:254
@ TR_HAL_GPIO_MODE_PWM1
Definition T32CM11_gpio.h:231
@ TR_HAL_GPIO_MODE_QSPI0
Definition T32CM11_gpio.h:224
@ TR_HAL_GPIO_MODE_PWM0
Definition T32CM11_gpio.h:230
@ TR_HAL_GPIO_MODE_I2C
Definition T32CM11_gpio.h:225
@ TR_HAL_GPIO_MODE_PWM3
Definition T32CM11_gpio.h:233
@ TR_HAL_GPIO_MODE_I2S
Definition T32CM11_gpio.h:228
@ TR_HAL_GPIO_MODE_SPI0_CS2
Definition T32CM11_gpio.h:242
@ TR_HAL_GPIO_MODE_SPI0_CS1
Definition T32CM11_gpio.h:241
@ TR_HAL_GPIO_MODE_MAX
Definition T32CM11_gpio.h:245
@ TR_HAL_GPIO_MODE_SPI0
Definition T32CM11_gpio.h:237
@ TR_HAL_GPIO_MODE_UART
Definition T32CM11_gpio.h:226
@ TR_HAL_GPIO_MODE_PWM2
Definition T32CM11_gpio.h:232
@ TR_HAL_GPIO_MODE_SPI0_CS3
Definition T32CM11_gpio.h:243
@ TR_HAL_GPIO_MODE_PWM
Definition T32CM11_gpio.h:229
@ TR_HAL_GPIO_MODE_PWM4
Definition T32CM11_gpio.h:234
@ TR_HAL_GPIO_MODE_GPIO
Definition T32CM11_gpio.h:223
@ TR_HAL_GPIO_MODE_SPI1
Definition T32CM11_gpio.h:238
@ TR_HAL_GPIO_EVENT_INPUT_TRIGGERED
Definition T32CM11_gpio.h:357
@ TR_HAL_GPIO_EVENT_NONE
Definition T32CM11_gpio.h:356
@ TR_HAL_DEBOUNCE_TIME_512_CLOCKS
Definition T32CM11_gpio.h:314
@ TR_HAL_DEBOUNCE_TIME_MAX_VALUE
Definition T32CM11_gpio.h:318
@ TR_HAL_DEBOUNCE_TIME_2048_CLOCKS
Definition T32CM11_gpio.h:316
@ TR_HAL_DEBOUNCE_TIME_32_CLOCKS
Definition T32CM11_gpio.h:310
@ TR_HAL_DEBOUNCE_TIME_128_CLOCKS
Definition T32CM11_gpio.h:312
@ TR_HAL_DEBOUNCE_TIME_1024_CLOCKS
Definition T32CM11_gpio.h:315
@ TR_HAL_DEBOUNCE_TIME_4096_CLOCKS
Definition T32CM11_gpio.h:317
@ TR_HAL_DEBOUNCE_TIME_64_CLOCKS
Definition T32CM11_gpio.h:311
@ TR_HAL_DEBOUNCE_TIME_256_CLOCKS
Definition T32CM11_gpio.h:313
@ TR_HAL_GPIO_TRIGGER_LEVEL_LOW
Definition T32CM11_gpio.h:278
@ TR_HAL_GPIO_TRIGGER_EITHER_EDGE
Definition T32CM11_gpio.h:277
@ TR_HAL_GPIO_TRIGGER_LEVEL_HIGH
Definition T32CM11_gpio.h:279
@ TR_HAL_GPIO_TRIGGER_NONE
Definition T32CM11_gpio.h:274
@ TR_HAL_GPIO_TRIGGER_RISING_EDGE
Definition T32CM11_gpio.h:275
@ TR_HAL_GPIO_TRIGGER_FALLING_EDGE
Definition T32CM11_gpio.h:276
@ TR_HAL_GPIO_LEVEL_HIGH
Definition T32CM11_gpio.h:265
@ TR_HAL_GPIO_LEVEL_LOW
Definition T32CM11_gpio.h:264
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:564
tr_hal_wake_mode_t
values for setting the GPIO wake mode
Definition T32CZ20_gpio.h:578
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:525
tr_hal_direction_t
values for setting the direction in the Trident HAL GPIO APIs
Definition T32CZ20_gpio.h:489
tr_hal_trigger_t
values for setting the interrupt trigger in the Trident HAL GPIO APIs
Definition T32CZ20_gpio.h:509
tr_hal_level_t
values for setting the level in the Trident HAL GPIO APIs
Definition T32CZ20_gpio.h:499
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
offsets for where to find chip registers needed for System Control register which is used to configur...
Definition T32CM11_gpio.h:153
__IO uint32_t system_clock_control
Definition T32CM11_gpio.h:155
__IO uint32_t random_number_value
Definition T32CM11_gpio.h:179
__IO uint32_t chip_info
Definition T32CM11_gpio.h:197
__IO uint32_t enable_wake_on_high
Definition T32CM11_gpio.h:186
__IO uint32_t open_drain_enable
Definition T32CM11_gpio.h:168
__IO uint32_t random_number_select
Definition T32CM11_gpio.h:177
__IO uint32_t analog_IO_enable
Definition T32CM11_gpio.h:173
__IO uint32_t random_number_status
Definition T32CM11_gpio.h:178
__IO uint32_t sleep_enable
Definition T32CM11_gpio.h:154
__IO uint32_t enable_wake_on_low
Definition T32CM11_gpio.h:189
__IO uint32_t random_number_trigger
Definition T32CM11_gpio.h:176
pin type
Definition tr_hal_platform.h:23
Definition T32CM11_gpio.h:400
tr_hal_gpio_event_callback_t event_handler_fx
Definition T32CM11_gpio.h:418
tr_hal_wake_mode_t wake_mode
Definition T32CM11_gpio.h:428
tr_hal_level_t output_level
Definition T32CM11_gpio.h:405
tr_hal_trigger_t interrupt_trigger
Definition T32CM11_gpio.h:415
tr_hal_drive_strength_t drive_strength
Definition T32CM11_gpio.h:411
tr_hal_direction_t direction
Definition T32CM11_gpio.h:402
bool enable_open_drain
Definition T32CM11_gpio.h:408
bool enable_debounce
Definition T32CM11_gpio.h:425
tr_hal_pullopt_t pull_mode
Definition T32CM11_gpio.h:421