SG RFID nRF51822 fork

Fork of nRF51822 by Nordic Semiconductor

Embed: (wiki syntax)

« Back to documentation index

GPIOTE Handler

GPIOTE Handler

GPIOTE handler module. More...

Typedefs

typedef void(* app_gpiote_event_handler_t )(uint32_t event_pins_low_to_high, uint32_t event_pins_high_to_low)
 GPIOTE event handler type.
typedef void(* app_gpiote_input_event_handler_t )(void)
 GPIOTE input event handler type.

Functions

uint32_t app_gpiote_init (uint8_t max_users, void *p_buffer)
 Function for initializing the GPIOTE module.
uint32_t app_gpiote_user_register (app_gpiote_user_id_t *p_user_id, uint32_t pins_low_to_high_mask, uint32_t pins_high_to_low_mask, app_gpiote_event_handler_t event_handler)
 Function for registering a GPIOTE user.
uint32_t app_gpiote_user_enable (app_gpiote_user_id_t user_id)
 Function for informing the GPIOTE module that the specified user wants to use the GPIOTE module.
uint32_t app_gpiote_user_disable (app_gpiote_user_id_t user_id)
 Function for informing the GPIOTE module that the specified user is done using the GPIOTE module.
uint32_t app_gpiote_pins_state_get (app_gpiote_user_id_t user_id, uint32_t *p_pins)
 Function for getting the state of the pins which are registered for the specified user.
uint32_t app_gpiote_input_event_handler_register (const uint8_t channel, const uint32_t pin, const uint32_t polarity, app_gpiote_input_event_handler_t event_handler)
 Function for registering event handlers for GPIOTE IN events.
uint32_t app_gpiote_input_event_handler_unregister (const uint8_t channel)
 Function for unregistering event handlers for GPIOTE IN events.
uint32_t app_gpiote_end_irq_event_handler_register (app_gpiote_input_event_handler_t event_handler)
 Function for registering event handler invoked at the end of a GPIOTE interrupt.
uint32_t app_gpiote_end_irq_event_handler_unregister (void)
 Function for unregistering event handler invoked at the end of a GPIOTE interrupt.
uint32_t app_gpiote_enable_interrupts (void)
 Function for enabling interrupts in the GPIOTE driver.
uint32_t app_gpiote_disable_interrupts (void)
 Function for disabling interrupts in the GPIOTE driver.

Detailed Description

GPIOTE handler module.

The GPIOTE handler allows several modules ("users") to share the GPIOTE interrupt, each user defining a set of pins able to generate events to the user. When a GPIOTE interrupt occurs, the GPIOTE interrupt handler will call the event handler of each user for which at least one of the pins generated an event.

The GPIOTE users are responsible for configuring all their corresponding pins, except the SENSE field, which should be initialized to GPIO_PIN_CNF_SENSE_Disabled. The SENSE field will be updated by the GPIOTE module when it is enabled or disabled, and also while it is enabled.

The module specifies on which pins events should be generated if the pin(s) goes from low->high or high->low or both directions.

Note:
Even if the application is using the Scheduler, the GPIOTE event handlers will be called directly from the GPIOTE interrupt handler.
Warning:
If multiple users registers for the same pins the behavior for those pins are undefined.

Typedef Documentation

typedef void(* app_gpiote_event_handler_t)(uint32_t event_pins_low_to_high, uint32_t event_pins_high_to_low)

GPIOTE event handler type.

Definition at line 67 of file app_gpiote.h.

typedef void(* app_gpiote_input_event_handler_t)(void)

GPIOTE input event handler type.

Definition at line 71 of file app_gpiote.h.


Function Documentation

uint32_t app_gpiote_disable_interrupts ( void   )

Function for disabling interrupts in the GPIOTE driver.

Returns:
NRF_SUCCESS On success.
Return values:
NRF_ERROR_NOT_SUPPORTEDDriver doesn't support.

Definition at line 358 of file app_gpiote.c.

uint32_t app_gpiote_enable_interrupts ( void   )

Function for enabling interrupts in the GPIOTE driver.

Returns:
NRF_SUCCESS On success.
Return values:
NRF_ERROR_NOT_SUPPORTEDDriver doesn't support.

Definition at line 353 of file app_gpiote.c.

uint32_t app_gpiote_end_irq_event_handler_register ( app_gpiote_input_event_handler_t  event_handler )

Function for registering event handler invoked at the end of a GPIOTE interrupt.

Parameters:
[in]event_handlerEvent handler invoked at the end of the GPIOTE interrupt.
Returns:
NRF_SUCCESS On success.
Return values:
NRF_ERROR_NOT_SUPPORTEDDriver doesn't support IN events.

Definition at line 343 of file app_gpiote.c.

uint32_t app_gpiote_end_irq_event_handler_unregister ( void   )

Function for unregistering event handler invoked at the end of a GPIOTE interrupt.

Returns:
NRF_SUCCESS On success.
Return values:
NRF_ERROR_NOT_SUPPORTEDDriver doesn't support IN events.

Definition at line 348 of file app_gpiote.c.

uint32_t app_gpiote_init ( uint8_t  max_users,
void *  p_buffer 
)

Function for initializing the GPIOTE module.

Note:
Normally initialization should be done using the APP_GPIOTE_INIT() macro, as that will allocate the buffer needed by the GPIOTE module (including aligning the buffer correctly).
Parameters:
[in]max_usersMaximum number of GPIOTE users.
[in]p_bufferPointer to memory buffer for internal use in the app_gpiote module. The size of the buffer can be computed using the APP_GPIOTE_BUF_SIZE() macro. The buffer must be aligned to a 4 byte boundary.
Return values:
NRF_SUCCESSSuccessful initialization.
NRF_ERROR_INVALID_PARAMInvalid parameter (buffer not aligned to a 4 byte boundary).

Definition at line 160 of file app_gpiote.c.

uint32_t app_gpiote_input_event_handler_register ( const uint8_t  channel,
const uint32_t  pin,
const uint32_t  polarity,
app_gpiote_input_event_handler_t  event_handler 
)

Function for registering event handlers for GPIOTE IN events.

Parameters:
[in]channelGPIOTE channel [0..3].
[in]pinPins associated with GPIOTE channel. Changes on following pins will generate events.
[in]polaritySpecify operation on input that shall trigger IN event.
[in]event_handlerEvent handler invoked on the IN event in the GPIOTE interrupt.
Returns:
NRF_SUCCESS On success.
Return values:
NRF_ERROR_INVALID_PARAMInvalid channel or pin number.
NRF_ERROR_NOT_SUPPORTEDDriver doesn't support IN events.

Definition at line 329 of file app_gpiote.c.

uint32_t app_gpiote_input_event_handler_unregister ( const uint8_t  channel )

Function for unregistering event handlers for GPIOTE IN events.

Returns:
NRF_SUCCESS On success.
Return values:
NRF_ERROR_NOT_SUPPORTEDDriver doesn't support IN events.

Definition at line 338 of file app_gpiote.c.

uint32_t app_gpiote_pins_state_get ( app_gpiote_user_id_t  user_id,
uint32_t *  p_pins 
)

Function for getting the state of the pins which are registered for the specified user.

Parameters:
[in]user_idId of user to check.
[out]p_pinsBit mask corresponding to the pins configured to generate events to the specified user. All bits corresponding to pins in the state 'high' will have value '1', all others will have value '0'.
Returns:
NRF_SUCCESS On success.
Return values:
NRF_ERROR_INVALID_PARAMInvalid user_id provided, No a valid user.
NRF_ERROR_INALID_STATEIf app_gpiote_init has not been called on the GPIOTE module.

Definition at line 307 of file app_gpiote.c.

uint32_t app_gpiote_user_disable ( app_gpiote_user_id_t  user_id )

Function for informing the GPIOTE module that the specified user is done using the GPIOTE module.

Parameters:
[in]user_idId of user to enable.
Returns:
NRF_SUCCESS On success.
Return values:
NRF_ERROR_INVALID_PARAMInvalid user_id provided, No a valid user.
NRF_ERROR_INALID_STATEIf app_gpiote_init has not been called on the GPIOTE module.

Definition at line 281 of file app_gpiote.c.

uint32_t app_gpiote_user_enable ( app_gpiote_user_id_t  user_id )

Function for informing the GPIOTE module that the specified user wants to use the GPIOTE module.

Parameters:
[in]user_idId of user to enable.
Return values:
NRF_SUCCESSOn success.
NRF_ERROR_INVALID_PARAMInvalid user_id provided, No a valid user.
NRF_ERROR_INALID_STATEIf app_gpiote_init has not been called on the GPIOTE module.

Definition at line 226 of file app_gpiote.c.

uint32_t app_gpiote_user_register ( app_gpiote_user_id_t *  p_user_id,
uint32_t  pins_low_to_high_mask,
uint32_t  pins_high_to_low_mask,
app_gpiote_event_handler_t  event_handler 
)

Function for registering a GPIOTE user.

Parameters:
[out]p_user_idId for the new GPIOTE user.
[in]pins_low_to_high_maskMask defining which pins will generate events to this user when state is changed from low->high.
[in]pins_high_to_low_maskMask defining which pins will generate events to this user when state is changed from high->low.
[in]event_handlerPointer to function to be executed when an event occurs.
Return values:
NRF_SUCCESSSuccessful initialization.
NRF_ERROR_INVALID_PARAMInvalid parameter (buffer not aligned to a 4 byte boundary).
NRF_ERROR_INALID_STATEIf app_gpiote_init has not been called on the GPIOTE module.
NRF_ERROR_NO_MEMReturned if the application tries to register more users than defined when the GPIOTE module was initialized in app_gpiote_init.

Definition at line 192 of file app_gpiote.c.