|
SmartSnippets DA1459x SDK
|
Go to the documentation of this file.
45 #if dg_configUSE_HW_GPIO
54 #define HW_GPIO_SET_PIN_FUNCTION(X) hw_gpio_set_pin_function(X##_PORT, X##_PIN, X##_MODE, X##_FUNC);
55 #define HW_GPIO_PAD_LATCH_ENABLE(X) hw_gpio_pad_latch_enable(X##_PORT, X##_PIN);
56 #define HW_GPIO_PAD_LATCH_DISABLE(X) hw_gpio_pad_latch_disable(X##_PORT, X##_PIN);
60 #define HW_GPIO_NUM_PORTS (2)
62 #define HW_GPIO_NUM_PINS (HW_GPIO_PORT_0_NUM_PINS + HW_GPIO_PORT_1_NUM_PINS)
64 #define HW_GPIO_PIN_BITS (4)
66 #define HW_GPIO_PORT_0_NUM_PINS (16)
68 #define HW_GPIO_PORT_1_NUM_PINS (16)
70 #define HW_GPIO_PORT_NONE (HW_GPIO_PORT_MAX)
72 #define HW_GPIO_PIN_NONE (HW_GPIO_PIN_MAX)
74 #define HW_GPIO_MODE_NONE (HW_GPIO_MODE_INVALID)
193 HW_GPIO_CLK_XTAL32K = 0,
194 HW_GPIO_CLK_RCLP = 1,
196 HW_GPIO_CLK_XTAL32M = 3,
197 HW_GPIO_CLK_RC32M = 4,
198 HW_GPIO_CLK_DIVN = 5,
241 #define HW_GPIO_PINCONFIG(xport, xpin, xmode, xfunc, xhigh) \
243 .pin = (xport << HW_GPIO_PIN_BITS) | (xpin & ((1 << HW_GPIO_PIN_BITS) - 1)), \
244 .mode = HW_GPIO_MODE_ ## xmode, \
245 .func = HW_GPIO_FUNC_ ## xfunc, \
264 #define HW_GPIO_PINCONFIG_RESERVE(xport, xpin, xmode, xfunc, xhigh) \
266 .pin = (xport << HW_GPIO_PIN_BITS) | (xpin & ((1 << HW_GPIO_PIN_BITS) - 1)), \
267 .mode = HW_GPIO_MODE_ ## xmode, \
268 .func = HW_GPIO_FUNC_ ## xfunc, \
277 #define HW_GPIO_PINCONFIG_END \
349 #if (DEBUG_GPIO_ALLOC_MONITOR_ENABLED == 1)
370 #define RESERVE_GPIO(name, port, pin, func) \
372 if (!hw_gpio_reserve_pin((port), (pin))) { \
381 #define RESERVE_GPIO( name, port, pin, func ) \
386 #endif // (DEBUG_GPIO_ALLOC_MONITOR_ENABLED == 1)
551 CRG_TOP->P0_SET_PAD_LATCH_REG = 1 << pin;
554 CRG_TOP->P1_SET_PAD_LATCH_REG = 1 << pin;
570 CRG_TOP->P0_RESET_PAD_LATCH_REG = 1 << pin;
573 CRG_TOP->P1_RESET_PAD_LATCH_REG = 1 << pin;
589 return (CRG_TOP->P0_PAD_LATCH_REG & (1 << pin));
592 return (CRG_TOP->P1_PAD_LATCH_REG & (1 << pin));
622 case HW_GPIO_CLK_XTAL32M:
623 REG_SET_BIT(GPIO, GPIO_CLK_SEL_REG, XTAL32M_OUTPUT_EN);
625 case HW_GPIO_CLK_RC32M:
626 REG_SET_BIT(GPIO, GPIO_CLK_SEL_REG, RC32M_OUTPUT_EN);
628 case HW_GPIO_CLK_DIVN:
629 REG_SET_BIT(GPIO, GPIO_CLK_SEL_REG, DIVN_OUTPUT_EN);
646 case HW_GPIO_CLK_XTAL32M:
647 REG_CLR_BIT(GPIO, GPIO_CLK_SEL_REG, XTAL32M_OUTPUT_EN);
649 case HW_GPIO_CLK_RC32M:
650 REG_CLR_BIT(GPIO, GPIO_CLK_SEL_REG, RC32M_OUTPUT_EN);
652 case HW_GPIO_CLK_DIVN:
653 REG_CLR_BIT(GPIO, GPIO_CLK_SEL_REG, DIVN_OUTPUT_EN);
667 REG_SET_BIT(GPIO, GPIO_CLK_SEL_REG, FUNC_CLOCK_EN);
676 REG_CLR_BIT(GPIO, GPIO_CLK_SEL_REG, FUNC_CLOCK_EN);
685 REG_SETF(GPIO, GPIO_CLK_SEL_REG, FUNC_CLOCK_SEL, clk_src);
710 uint8_t pin_select =
REG_MSK(CRG_TOP, POR_PIN_REG, POR_PIN_SELECT);
720 CRG_TOP->POR_PIN_REG =
BITS32(CRG_TOP, POR_PIN_REG, POR_PIN_POLARITY, polarity) |
721 BITS32(CRG_TOP, POR_PIN_REG, POR_PIN_SELECT, pin_select);
void hw_gpio_set_pin_function(HW_GPIO_PORT port, HW_GPIO_PIN pin, HW_GPIO_MODE mode, HW_GPIO_FUNC function)
Set the pin type and mode.
Definition: hw_gpio.h:132
Definition: hw_gpio.h:143
Definition: hw_gpio.h:182
Definition: hw_gpio.h:168
Definition: hw_gpio.h:121
#define REG_SETF(base, reg, field, new_val)
Set the value of a register field.
Definition: sdk_defs.h:738
#define REG_CLR_BIT(base, reg, field)
Clear a bit of a register.
Definition: sdk_defs.h:781
__STATIC_FORCEINLINE void hw_gpio_pad_latch_disable(HW_GPIO_PORT port, HW_GPIO_PIN pin)
Disables the latch for the specific gpio.
Definition: hw_gpio.h:564
#define CRG_TOP_P0_RESET_PAD_LATCH_REG_P0_RESET_LATCH_EN_Msk
Definition: DA1459x-00.h:2053
#define REG_SET_BIT(base, reg, field)
Set a bit of a register.
Definition: sdk_defs.h:766
Definition: hw_gpio.h:111
Definition: hw_gpio.h:108
#define HW_GPIO_NUM_PORTS
Definition: hw_gpio.h:60
Definition: hw_gpio.h:135
Definition: hw_gpio.h:162
Definition: hw_gpio.h:181
bool hw_gpio_get_pin_status(HW_GPIO_PORT port, HW_GPIO_PIN pin)
Get the GPIO status.
Definition: hw_gpio.h:133
Definition: hw_gpio.h:155
Definition: hw_gpio.h:157
void hw_gpio_set_pin_drive_strength(HW_GPIO_PORT port, HW_GPIO_PIN pin, HW_GPIO_DRIVE_STRENGTH strength)
Set the pin drive strength.
bool hw_gpio_reserve_and_configure_pin(HW_GPIO_PORT port, HW_GPIO_PIN pin, HW_GPIO_MODE mode, HW_GPIO_FUNC function, bool high)
Reserve GPIO pin and set pin function.
#define CRG_TOP_P1_RESET_PAD_LATCH_REG_P1_RESET_LATCH_EN_Msk
Definition: DA1459x-00.h:2062
Definition: hw_gpio.h:175
Central include header file with platform definitions.
Definition: hw_gpio.h:158
Definition: hw_gpio.h:112
Definition: hw_gpio.h:152
void hw_gpio_set_active(HW_GPIO_PORT port, HW_GPIO_PIN pin)
Set a GPIO in high state.
Definition: hw_gpio.h:141
Definition: hw_gpio.h:149
#define BITS32(base, reg, field, v)
Sets 32-bit wide register bits, indicated by the field, to a value v.
Definition: sdk_defs.h:822
Definition: hw_gpio.h:131
#define HW_GPIO_PORT_1_NUM_PINS
Definition: hw_gpio.h:68
Definition: hw_gpio.h:151
Definition: hw_gpio.h:150
Definition: hw_gpio.h:114
Definition: hw_gpio.h:120
int hw_gpio_get_pins_with_function(HW_GPIO_FUNC func, uint8_t *buf, int buf_size)
Find pins with specific function.
Definition: hw_gpio.h:153
HW_GPIO_PIN
GPIO pin number.
Definition: hw_gpio.h:106
Definition: hw_gpio.h:161
Definition: hw_gpio.h:163
Definition: hw_gpio.h:180
Definition: hw_gpio.h:148
Definition: hw_gpio.h:183
Definition: hw_gpio.h:145
HW_GPIO_PORT
GPIO port number.
Definition: hw_gpio.h:96
Definition: hw_gpio.h:109
typedef __PACKED_STRUCT
GPIO pin configuration.
Definition: hw_gpio.h:209
Definition: hw_gpio.h:113
Definition: hw_gpio.h:167
__STATIC_INLINE void hw_gpio_clk_output_disable(HW_GPIO_CLK clk)
Disable mapping of selected clock to the respective GPIO.
Definition: hw_gpio.h:643
Definition: hw_gpio.h:123
void hw_gpio_set_inactive(HW_GPIO_PORT port, HW_GPIO_PIN pin)
Set a GPIO in low state.
HW_GPIO_FUNC
GPIO function.
Definition: hw_gpio.h:130
__STATIC_INLINE void hw_gpio_configure_por_pin(HW_GPIO_PORT port, HW_GPIO_PIN pin, bool polarity)
Select a pin as a POR trigger source.
Definition: hw_gpio.h:708
Definition: hw_gpio.h:122
Definition: hw_gpio.h:140
__STATIC_INLINE void hw_gpio_clk_output_enable(HW_GPIO_CLK clk)
Enable mapping of selected clock to the respective GPIO.
Definition: hw_gpio.h:619
void hw_gpio_configure(const gpio_config cfg[])
GPIO configuration.
Definition: hw_gpio.h:164
Definition: hw_gpio.h:171
Definition: hw_gpio.h:142
void hw_gpio_configure_pin(HW_GPIO_PORT port, HW_GPIO_PIN pin, HW_GPIO_MODE mode, HW_GPIO_FUNC function, const bool high)
Combined function to set the state and the type and mode of the GPIO pin.
Definition: hw_gpio.h:172
HW_GPIO_FUNC func
Definition: hw_gpio.h:212
__STATIC_FORCEINLINE bool hw_gpio_pad_latch_is_enabled(HW_GPIO_PORT port, HW_GPIO_PIN pin)
Checks if the specific GPIO is latched or not.
Definition: hw_gpio.h:583
Definition: hw_gpio.h:116
bool hw_gpio_reserve_pin(HW_GPIO_PORT port, HW_GPIO_PIN pin)
Reserve GPIO pin.
#define REG_MSK(base, reg, field)
Access register field mask.
Definition: sdk_defs.h:583
HW_GPIO_MODE mode
Definition: hw_gpio.h:211
Definition: hw_gpio.h:134
Definition: hw_gpio.h:169
void hw_gpio_get_pin_function(HW_GPIO_PORT port, HW_GPIO_PIN pin, HW_GPIO_MODE *mode, HW_GPIO_FUNC *function)
Get the pin type and mode.
#define CRG_TOP_P0_SET_PAD_LATCH_REG_P0_SET_LATCH_EN_Msk
Definition: DA1459x-00.h:2056
bool hw_gpio_get_pin_with_function(HW_GPIO_FUNC func, HW_GPIO_PORT *port, HW_GPIO_PIN *pin)
Find GPIO with specific function.
Definition: hw_gpio.h:115
Definition: hw_gpio.h:118
#define HW_GPIO_PORT_0_NUM_PINS
Definition: hw_gpio.h:66
__STATIC_FORCEINLINE void hw_gpio_pad_latch_enable_all(void)
Enables the latches of all gpios.
Definition: hw_gpio.h:531
Definition: hw_gpio.h:136
Definition: hw_gpio.h:110
void hw_gpio_unreserve_pin(HW_GPIO_PORT port, HW_GPIO_PIN pin)
Unreserve GPIO pin.
Definition: hw_gpio.h:173
#define GLOBAL_INT_RESTORE()
Macro to restore all interrupts.
Definition: sdk_defs.h:477
__STATIC_INLINE void hw_gpio_clk_func_enable(void)
Enable the mapping of the selected clock signal, according to FUNC_CLOCK_SEL bit-field.
Definition: hw_gpio.h:665
Definition: hw_gpio.h:139
Definition: hw_gpio.h:184
Definition: hw_gpio.h:174
HW_GPIO_DRIVE_STRENGTH
GPIOs Drive Strength.
Definition: hw_gpio.h:221
Definition: hw_gpio.h:159
Definition: hw_gpio.h:144
Definition: hw_gpio.h:166
__STATIC_FORCEINLINE void hw_gpio_pad_latch_enable(HW_GPIO_PORT port, HW_GPIO_PIN pin)
Enables the latch for the specific gpio.
Definition: hw_gpio.h:545
Definition: hw_gpio.h:137
Definition: hw_gpio.h:165
Definition: hw_gpio.h:154
Definition: hw_gpio.h:170
Definition: hw_gpio.h:178
Definition: hw_gpio.h:156
Definition: hw_gpio.h:147
void hw_gpio_toggle(HW_GPIO_PORT port, HW_GPIO_PIN pin)
Toggle GPIO pin state.
Definition: hw_gpio.h:138
Definition: hw_gpio.h:223
Definition: hw_gpio.h:177
HW_GPIO_CLK
Clocks that can be mapped to GPIOs.
Definition: hw_gpio.h:192
HW_GPIO_MODE
GPIO input/output mode.
Definition: hw_gpio.h:82
HW_GPIO_DRIVE_STRENGTH hw_gpio_get_pin_drive_strength(HW_GPIO_PORT port, HW_GPIO_PIN pin)
Get the pin drive strength.
Definition: hw_gpio.h:179
Definition: hw_gpio.h:146
Definition: hw_gpio.h:222
Definition: hw_gpio.h:107
Definition: hw_gpio.h:119
bool high
Definition: hw_gpio.h:213
#define GLOBAL_INT_DISABLE()
Macro to disable all interrupts.
Definition: sdk_defs.h:452
__STATIC_INLINE void hw_gpio_clk_func_sel(HW_GPIO_CLK clk_src)
Select which clock to map when GPIO function is FUNC_CLOCK.
Definition: hw_gpio.h:683
#define CRG_TOP_P1_SET_PAD_LATCH_REG_P1_SET_LATCH_EN_Msk
Definition: DA1459x-00.h:2065
__STATIC_FORCEINLINE void hw_gpio_pad_latch_disable_all(void)
Disables the latches of all gpios.
Definition: hw_gpio.h:519
__STATIC_INLINE void hw_gpio_clk_func_disable(void)
Disable the mapping of the selected clock signal, according to FUNC_CLOCK_SEL bit-field.
Definition: hw_gpio.h:674
Definition: hw_gpio.h:117
Definition: hw_gpio.h:160
Definition: hw_gpio.h:176