GPIOTE driver
- group nrfx_gpiote
GPIO Task Event (GPIOTE) peripheral driver.
Defines
-
NRFX_GPIOTE_DEFAULT_OUTPUT_CONFIG
Output pin default configuration.
-
NRFX_GPIOTE_DEFAULT_INPUT_CONFIG
Input pin default configuration.
-
NRFX_GPIOTE_APP_CHANNELS_MASK
Bitfield representing all GPIOTE channels available to the application.
Typedefs
-
typedef uint32_t nrfx_gpiote_pin_t
Pin.
-
typedef void (*nrfx_gpiote_interrupt_handler_t)(nrfx_gpiote_pin_t pin, nrfx_gpiote_trigger_t trigger, void *p_context)
Pin interrupt handler prototype.
- Param pin:
[in] Pin that triggered this event.
- Param trigger:
[in] Trigger that led to this event.
- Param p_context:
[in] User context.
Enums
-
enum nrfx_gpiote_trigger_t
Triggering options.
Values:
-
enumerator NRFX_GPIOTE_TRIGGER_NONE
No trigger on a pin.
-
enumerator NRFX_GPIOTE_TRIGGER_LOTOHI
Low to high edge trigger.
-
enumerator NRFX_GPIOTE_TRIGGER_HITOLO
High to low edge trigger.
-
enumerator NRFX_GPIOTE_TRIGGER_TOGGLE
Edge toggle trigger.
-
enumerator NRFX_GPIOTE_TRIGGER_LOW
Level low trigger.
-
enumerator NRFX_GPIOTE_TRIGGER_HIGH
Level high trigger.
-
enumerator NRFX_GPIOTE_TRIGGER_MAX
Triggering options count.
-
enumerator NRFX_GPIOTE_TRIGGER_NONE
Functions
-
nrfx_err_t nrfx_gpiote_init(uint8_t interrupt_priority)
Function for initializing the GPIOTE module.
- Parameters:
interrupt_priority – [in] Interrupt priority.
- Return values:
NRFX_SUCCESS – Initialization was successful.
NRFX_ERROR_INVALID_STATE – The driver was already initialized.
-
bool nrfx_gpiote_is_init(void)
Function for checking if the GPIOTE module is initialized.
The GPIOTE module is a shared module. Therefore, check if the module is already initialized and skip initialization if it is.
- Return values:
true – The module is already initialized.
false – The module is not initialized.
-
void nrfx_gpiote_uninit(void)
Function for uninitializing the GPIOTE module.
-
nrfx_err_t nrfx_gpiote_channel_alloc(uint8_t *p_channel)
Function for allocating a GPIOTE channel.
This function allocates the first unused GPIOTE channel from pool defined in NRFX_GPIOTE_APP_CHANNELS_MASK.
Note
Function is thread safe as it uses nrfx_flag32_alloc.
Note
Routines that allocate and free the GPIOTE channels are independent from the rest of the driver. In particular, the driver does not need to be initialized when this function is called.
- Parameters:
p_channel – [out] Pointer to the GPIOTE channel that has been allocated.
- Return values:
NRFX_SUCCESS – The channel was successfully allocated.
NRFX_ERROR_NO_MEM – There is no available channel to be used.
-
nrfx_err_t nrfx_gpiote_channel_free(uint8_t channel)
Function for freeing a GPIOTE channel.
This function frees a GPIOTE channel that was allocated using nrfx_gpiote_channel_alloc.
Note
Function is thread safe as it uses nrfx_flag32_free.
Note
Routines that allocate and free the GPIOTE channels are independent from the rest of the driver. In particular, the driver does not need to be initialized when this function is called.
- Parameters:
channel – [in] GPIOTE channel to be freed.
- Return values:
NRFX_SUCCESS – The channel was successfully freed.
NRFX_ERROR_INVALID_PARAM – The channel is not user-configurable.
-
nrfx_err_t nrfx_gpiote_input_configure(nrfx_gpiote_pin_t pin, nrfx_gpiote_input_config_t const *p_input_config, nrfx_gpiote_trigger_config_t const *p_trigger_config, nrfx_gpiote_handler_config_t const *p_handler_config)
Function for configuring the specified input pin and input event/interrupt.
Prior to calling this function pin can be uninitialized or configured as input or output. However, following transitions and configurations are invalid and result in error returned by the function:
Setting level trigger (e.g. NRFX_GPIOTE_TRIGGER_HIGH) and using GPIOTE channel for the same pin.
Reconfiguring pin to input (
p_input_config
not NULL) when pin was configured to use GPIOTE task. Prior to that, task must be disabled by configuring it with polarity set to NRF_GPIOTE_POLARITY_NONE.Configuring trigger using GPIOTE channel for pin previously configured as output pin. Only sensing can be used for an output pin.
Function can be used to configure trigger and handler for sensing input changes on an output pin. In that case, prior to that output pin must be configured with input buffer connected. In that case
p_input_config
is NULL to avoid reconfiguration of the pin.- Parameters:
pin – [in] Absolute pin number.
p_input_config – [in] Pin configuration. If NULL, the current configuration is untouched.
p_trigger_config – [in] Interrupt/event configuration. If NULL, the current configuration is untouched.
p_handler_config – [in] Handler configuration. If NULL it is untouched.
- Return values:
NRFX_SUCCESS – Configuration was successful.
NRFX_ERROR_INVALID_PARAM – Invalid configuration.
-
nrfx_err_t nrfx_gpiote_output_configure(nrfx_gpiote_pin_t pin, nrfx_gpiote_output_config_t const *p_config, nrfx_gpiote_task_config_t const *p_task_config)
Function for configuring the specified output pin to be used by the driver.
Prior to calling this function pin can be uninitialized or configured as input or output. However, following transitions and configurations are invalid and result in error returned by the function:
Reconfiguring pin to output when pin was configured as input with trigger using GPIOTE channel. Prior to that, trigger must be disabled by configuring it as NRFX_GPIOTE_TRIGGER_NONE.
Configuring pin as output without input buffer connected when prior to that trigger was configured. In that case input buffer must be connected.
Configuring GPIOTE task for pin which was previously configured as input. Before using GPIOTE task pin must be configured as output by providing
p_config
.
- Parameters:
pin – [in] Absolute pin number.
p_config – [in] Pin configuration. If NULL pin configuration is not applied.
p_task_config – [in] GPIOTE task configuration. If NULL task is not used.
- Return values:
NRFX_SUCCESS – Configuration was successful.
NRFX_ERROR_INVALID_PARAM – Invalid configuration.
-
nrfx_err_t nrfx_gpiote_pin_uninit(nrfx_gpiote_pin_t pin)
Function for deinitializing the specified pin.
Specified pin and associated GPIOTE channel are restored to the default configuration.
Warning
GPIOTE channel used by the pin is not freed.
- Parameters:
pin – [in] Absolute pin number.
- Return values:
NRFX_SUCCESS – Uninitialization was successful.
NRFX_ERROR_INVALID_PARAM – Pin not used by the driver.
-
void nrfx_gpiote_trigger_enable(nrfx_gpiote_pin_t pin, bool int_enable)
Function for enabling trigger for the given pin.
When GPIOTE event is used trigger can be enabled without enabling interrupt, e.g. for PPI.
- Parameters:
pin – [in] Absolute pin number.
int_enable – [in] True to enable the interrupt. Must be true when sensing is used.
-
void nrfx_gpiote_trigger_disable(nrfx_gpiote_pin_t pin)
Function for disabling trigger for the given pin.
- Parameters:
pin – [in] Absolute pin number.
-
void nrfx_gpiote_global_callback_set(nrfx_gpiote_interrupt_handler_t handler, void *p_context)
Set global callback called for each event.
- Parameters:
handler – [in] Global handler.
p_context – [in] Context passed to the handler.
-
nrfx_err_t nrfx_gpiote_channel_get(nrfx_gpiote_pin_t pin, uint8_t *p_channel)
Function for retrieving Task/Event channel index associated with the given pin.
- Parameters:
pin – [in] Absolute pin number.
p_channel – [out] Location to write the channel index.
- Return values:
NRFX_SUCCESS – Channel successfully written.
NRFX_ERROR_INVALID_PARAM – Pin is not configured or not using Task or Event.
-
void nrfx_gpiote_out_set(nrfx_gpiote_pin_t pin)
Function for setting a GPIOTE output pin.
- Parameters:
pin – [in] Pin.
-
void nrfx_gpiote_out_clear(nrfx_gpiote_pin_t pin)
Function for clearing a GPIOTE output pin.
- Parameters:
pin – [in] Pin.
-
void nrfx_gpiote_out_toggle(nrfx_gpiote_pin_t pin)
Function for toggling a GPIOTE output pin.
- Parameters:
pin – [in] Pin.
-
void nrfx_gpiote_out_task_enable(nrfx_gpiote_pin_t pin)
Function for enabling a GPIOTE output pin task.
- Parameters:
pin – [in] Pin.
-
void nrfx_gpiote_out_task_disable(nrfx_gpiote_pin_t pin)
Function for disabling a GPIOTE output pin task.
- Parameters:
pin – [in] Pin.
-
nrf_gpiote_task_t nrfx_gpiote_out_task_get(nrfx_gpiote_pin_t pin)
Function for getting the OUT task for the specified output pin.
The returned task identifier can be used within GPIOTE HAL, for example, to configure a DPPI channel.
- Parameters:
pin – [in] Pin.
- Returns:
OUT task associated with the specified output pin.
-
uint32_t nrfx_gpiote_out_task_address_get(nrfx_gpiote_pin_t pin)
Function for getting the address of the OUT task for the specified output pin.
- Parameters:
pin – [in] Pin.
- Returns:
Address of OUT task.
-
nrf_gpiote_task_t nrfx_gpiote_set_task_get(nrfx_gpiote_pin_t pin)
Function for getting the SET task for the specified output pin.
The returned task identifier can be used within GPIOTE HAL, for example, to configure a DPPI channel.
- Parameters:
pin – [in] Pin.
- Returns:
SET task associated with the specified output pin.
-
uint32_t nrfx_gpiote_set_task_address_get(nrfx_gpiote_pin_t pin)
Function for getting the address of the SET task for the specified output pin.
- Parameters:
pin – [in] Pin.
- Returns:
Address of SET task.
-
nrf_gpiote_task_t nrfx_gpiote_clr_task_get(nrfx_gpiote_pin_t pin)
Function for getting the CLR task for the specified output pin.
The returned task identifier can be used within GPIOTE HAL, for example, to configure a DPPI channel.
- Parameters:
pin – [in] Pin.
- Returns:
CLR task associated with the specified output pin.
-
uint32_t nrfx_gpiote_clr_task_address_get(nrfx_gpiote_pin_t pin)
Function for getting the address of the SET task for the specified output pin.
- Parameters:
pin – [in] Pin.
- Returns:
Address of CLR task.
-
bool nrfx_gpiote_in_is_set(nrfx_gpiote_pin_t pin)
Function for checking if a GPIOTE input pin is set.
- Parameters:
pin – [in] Pin.
- Return values:
true – The input pin is set.
false – The input pin is not set.
-
nrf_gpiote_event_t nrfx_gpiote_in_event_get(nrfx_gpiote_pin_t pin)
Function for getting the GPIOTE event for the specified input pin.
The returned event identifier can be used within GPIOTE HAL, for example, to configure a DPPI channel. If the pin is configured to use low-accuracy mode, the PORT event is returned.
- Parameters:
pin – [in] Pin.
- Returns:
Event associated with the specified input pin.
-
uint32_t nrfx_gpiote_in_event_address_get(nrfx_gpiote_pin_t pin)
Function for getting the address of a GPIOTE input pin event.
If the pin is configured to use low-accuracy mode, the address of the PORT event is returned.
- Parameters:
pin – [in] Pin.
- Returns:
Address of the specified input pin event.
-
void nrfx_gpiote_out_task_force(nrfx_gpiote_pin_t pin, uint8_t state)
Function for forcing a specific state on the pin configured as task.
- Parameters:
pin – [in] Pin.
state – [in] Pin state.
-
void nrfx_gpiote_out_task_trigger(nrfx_gpiote_pin_t pin)
Function for triggering the task OUT manually.
- Parameters:
pin – [in] Pin.
-
void nrfx_gpiote_set_task_trigger(nrfx_gpiote_pin_t pin)
Function for triggering the task SET manually.
- Parameters:
pin – [in] Pin.
-
void nrfx_gpiote_clr_task_trigger(nrfx_gpiote_pin_t pin)
Function for triggering the task CLR manually.
- Parameters:
pin – [in] Pin.
-
NRFX_STATIC_INLINE void nrfx_gpiote_latency_set(nrf_gpiote_latency_t latency)
Function for setting the latency setting.
Note
Available for event mode with rising or falling edge detection on the pin. Toggle task mode can only be used with low latency setting.
- Parameters:
latency – [in] Latency setting to be set.
-
NRFX_STATIC_INLINE nrf_gpiote_latency_t nrfx_gpiote_latency_get(void)
Function for retrieving the latency setting.
- Returns:
Latency setting.
-
struct nrfx_gpiote_task_config_t
- #include <nrfx_gpiote.h>
Structure for configuring a GPIOTE task.
Public Members
-
uint8_t task_ch
GPIOTE channel to be used.
Set to value allocated using nrfx_gpiote_channel_alloc. It is a user responsibility to free the channel.
-
nrf_gpiote_polarity_t polarity
Task polarity configuration.
NRF_GPIOTE_POLARITY_NONE is used to disable previously configured task.
-
nrf_gpiote_outinit_t init_val
Initial pin state.
-
uint8_t task_ch
-
struct nrfx_gpiote_output_config_t
- #include <nrfx_gpiote.h>
Structure for configuring an output pin.
Public Members
-
nrf_gpio_pin_drive_t drive
Drive configuration.
-
nrf_gpio_pin_input_t input_connect
Input buffer connection.
-
nrf_gpio_pin_pull_t pull
Pull configuration.
Pull setting is used together with drive configurations D0 and D1.
-
nrf_gpio_pin_drive_t drive
-
struct nrfx_gpiote_input_config_t
- #include <nrfx_gpiote.h>
Structure for configuring an input pin.
Public Members
-
nrf_gpio_pin_pull_t pull
Pull configuration.
-
nrf_gpio_pin_pull_t pull
-
struct nrfx_gpiote_trigger_config_t
- #include <nrfx_gpiote.h>
Structure for configuring pin interrupt/event.
Public Members
-
nrfx_gpiote_trigger_t trigger
Specify trigger.
-
uint8_t const *p_in_channel
Pointer to GPIOTE channel for IN event.
If NULL, the sensing mechanism is used instead. Note that when channel is provided only edge triggering can be used.
-
nrfx_gpiote_trigger_t trigger
-
struct nrfx_gpiote_handler_config_t
- #include <nrfx_gpiote.h>
Structure for configuring a pin interrupt handler.
Public Members
-
nrfx_gpiote_interrupt_handler_t handler
User handler.
-
void *p_context
Context passed to the event handler.
-
nrfx_gpiote_interrupt_handler_t handler
-
NRFX_GPIOTE_DEFAULT_OUTPUT_CONFIG