![]() |
MCUXpresso SDK API Reference Manual
Rev. 0
NXP Semiconductors
|
Data Structures | |
struct | hal_gpio_pin_config_t |
The pin config struct of GPIO adapter. More... | |
Macros | |
#define | HAL_GPIO_HANDLE_SIZE (16U) |
Definition of GPIO adapter handle size. More... | |
#define | HAL_GPIO_ISR_PRIORITY (3U) |
Definition of GPIO adapter isr priority. More... | |
#define | GPIO_HANDLE_BUFFER_DEFINE(name) uint32_t gpioHandleBuffer##name[((HAL_GPIO_HANDLE_SIZE - 1) >> 2) + 1] = {0} |
Defines the gpio handle buffer. More... | |
#define | GPIO_HANDLE_BUFFER_GET(name) (hal_gpio_handle_t) & gpioHandleBuffer##name[0] |
\ More... | |
Typedefs | |
typedef void * | hal_gpio_handle_t |
The handle of GPIO adapter. More... | |
typedef void(* | hal_gpio_callback_t )(void *param) |
The callback function of GPIO adapter. More... | |
Enumerations | |
enum | hal_gpio_interrupt_trigger_t { kHAL_GpioInterruptDisable = 0x0U, kHAL_GpioInterruptLogicZero = 0x1U, kHAL_GpioInterruptRisingEdge = 0x2U, kHAL_GpioInterruptFallingEdge = 0x3U, kHAL_GpioInterruptEitherEdge = 0x4U, kHAL_GpioInterruptLogicOne = 0x5U } |
The interrupt trigger of GPIO adapter. More... | |
enum | hal_gpio_status_t { kStatus_HAL_GpioSuccess = kStatus_Success, kStatus_HAL_GpioError = MAKE_STATUS(kStatusGroup_HAL_GPIO, 1), kStatus_HAL_GpioLackSource = MAKE_STATUS(kStatusGroup_HAL_GPIO, 2), kStatus_HAL_GpioPinConflict = MAKE_STATUS(kStatusGroup_HAL_GPIO, 3) } |
The status of GPIO adapter. More... | |
enum | hal_gpio_direction_t { kHAL_GpioDirectionOut = 0x00U, kHAL_GpioDirectionIn } |
The direction of GPIO adapter. More... | |
Functions | |
hal_gpio_status_t | HAL_GpioInit (hal_gpio_handle_t gpioHandle, hal_gpio_pin_config_t *pinConfig) |
Initializes an GPIO instance with the GPIO handle and the user configuration structure. More... | |
hal_gpio_status_t | HAL_GpioDeinit (hal_gpio_handle_t gpioHandle) |
Deinitializes a GPIO instance. More... | |
hal_gpio_status_t | HAL_GpioGetInput (hal_gpio_handle_t gpioHandle, uint8_t *pinState) |
Gets the pin voltage. More... | |
hal_gpio_status_t | HAL_GpioSetOutput (hal_gpio_handle_t gpioHandle, uint8_t pinState) |
Sets the pin voltage. More... | |
hal_gpio_status_t | HAL_GpioGetTriggerMode (hal_gpio_handle_t gpioHandle, hal_gpio_interrupt_trigger_t *gpioTrigger) |
Gets the pin interrupt trigger mode. More... | |
hal_gpio_status_t | HAL_GpioSetTriggerMode (hal_gpio_handle_t gpioHandle, hal_gpio_interrupt_trigger_t gpioTrigger) |
Sets the pin interrupt trigger mode. More... | |
hal_gpio_status_t | HAL_GpioInstallCallback (hal_gpio_handle_t gpioHandle, hal_gpio_callback_t callback, void *callbackParam) |
Installs a callback and callback parameter. More... | |
hal_gpio_status_t | HAL_GpioWakeUpSetting (hal_gpio_handle_t gpioHandle, uint8_t enable) |
Enables or disables the GPIO wake-up feature. More... | |
hal_gpio_status_t | HAL_GpioEnterLowpower (hal_gpio_handle_t gpioHandle) |
Prepares to enter low power consumption. More... | |
hal_gpio_status_t | HAL_GpioExitLowpower (hal_gpio_handle_t gpioHandle) |
Restores from low power consumption. More... | |
struct hal_gpio_pin_config_t |
#define HAL_GPIO_HANDLE_SIZE (16U) |
#define HAL_GPIO_ISR_PRIORITY (3U) |
#define GPIO_HANDLE_BUFFER_DEFINE | ( | name | ) | uint32_t gpioHandleBuffer##name[((HAL_GPIO_HANDLE_SIZE - 1) >> 2) + 1] = {0} |
This macro is used to define the gpio handle buffer for gpio queue. And then uses the macro GPIO_HANDLE_BUFFER_GET to get the gpio handle buffer pointer. The macro should not be used in a suitable position for its user.
This macro is optional, gpio handle buffer could also be defined by yourself.
This is a example,
name | The name string of the gpio handle buffer. |
#define GPIO_HANDLE_BUFFER_GET | ( | name | ) | (hal_gpio_handle_t) & gpioHandleBuffer##name[0] |
Gets the gpio buffer pointer \ \ This macro is used to get the gpio buffer pointer. The macro should \ not be used before the macro GPIO_HANDLE_BUFFER_DEFINE is used. \ \
name | The memory name string of the buffer. \ |
typedef void* hal_gpio_handle_t |
typedef void(* hal_gpio_callback_t)(void *param) |
enum hal_gpio_status_t |
enum hal_gpio_direction_t |
hal_gpio_status_t HAL_GpioInit | ( | hal_gpio_handle_t | gpioHandle, |
hal_gpio_pin_config_t * | pinConfig | ||
) |
This function configures the GPIO module with user-defined settings. The user can configure the configuration structure. The parameter handle is a pointer to point to a memory space of size HAL_GPIO_HANDLE_SIZE allocated by the caller. Example below shows how to use this API to configure the GPIO.
gpioHandle | GPIO handle pointer. The handle should be 4 byte aligned, because unaligned access does not support on some devices. The macro GPIO_HANDLE_BUFFER_GET is used to get the gpio buffer pointer, and should not be used before the macro GPIO_HANDLE_BUFFER_DEFINE is used. |
pinConfig | Pointer to user-defined configuration structure. |
kStatus_HAL_GpioError | An error occurred while initializing the GPIO. |
kStatus_HAL_GpioPinConflict | The pair of the pin and port passed by pinConfig is initialized. |
kStatus_HAL_GpioSuccess | GPIO initialization succeed |
hal_gpio_status_t HAL_GpioDeinit | ( | hal_gpio_handle_t | gpioHandle | ) |
This function disables the trigger mode.
gpioHandle | GPIO handle pointer. The macro GPIO_HANDLE_BUFFER_GET is used to get the gpio buffer pointer, and should not be used before the macro GPIO_HANDLE_BUFFER_DEFINE is used. |
kStatus_HAL_GpioSuccess | GPIO de-initialization succeed |
hal_gpio_status_t HAL_GpioGetInput | ( | hal_gpio_handle_t | gpioHandle, |
uint8_t * | pinState | ||
) |
This function gets the pin voltage. 0 - low level voltage, 1 - high level voltage.
gpioHandle | GPIO handle pointer. The macro GPIO_HANDLE_BUFFER_GET is used to get the gpio buffer pointer, and should not be used before the macro GPIO_HANDLE_BUFFER_DEFINE is used. |
pinState | A pointer to save the pin state. |
kStatus_HAL_GpioSuccess | Get successfully. |
hal_gpio_status_t HAL_GpioSetOutput | ( | hal_gpio_handle_t | gpioHandle, |
uint8_t | pinState | ||
) |
This function sets the pin voltage. 0 - low level voltage, 1 - high level voltage.
gpioHandle | GPIO handle pointer. The macro GPIO_HANDLE_BUFFER_GET is used to get the gpio buffer pointer, and should not be used before the macro GPIO_HANDLE_BUFFER_DEFINE is used. |
pinState | Pin state. |
kStatus_HAL_GpioSuccess | Set successfully. |
hal_gpio_status_t HAL_GpioGetTriggerMode | ( | hal_gpio_handle_t | gpioHandle, |
hal_gpio_interrupt_trigger_t * | gpioTrigger | ||
) |
This function gets the pin interrupt trigger mode. The trigger mode please refer to hal_gpio_interrupt_trigger_t.
gpioHandle | GPIO handle pointer. The macro GPIO_HANDLE_BUFFER_GET is used to get the gpio buffer pointer, and should not be used before the macro GPIO_HANDLE_BUFFER_DEFINE is used. |
gpioTrigger | A pointer to save the pin trigger mode value. |
kStatus_HAL_GpioSuccess | Get successfully. |
kStatus_HAL_GpioError | The pin is the ouput setting. |
hal_gpio_status_t HAL_GpioSetTriggerMode | ( | hal_gpio_handle_t | gpioHandle, |
hal_gpio_interrupt_trigger_t | gpioTrigger | ||
) |
This function sets the pin interrupt trigger mode. The trigger mode please refer to hal_gpio_interrupt_trigger_t.
gpioHandle | GPIO handle pointer. The macro GPIO_HANDLE_BUFFER_GET is used to get the gpio buffer pointer, and should not be used before the macro GPIO_HANDLE_BUFFER_DEFINE is used. |
gpioTrigger | The pin trigger mode value. |
kStatus_HAL_GpioSuccess | Set successfully. |
kStatus_HAL_GpioError | The pin is the ouput setting. |
hal_gpio_status_t HAL_GpioInstallCallback | ( | hal_gpio_handle_t | gpioHandle, |
hal_gpio_callback_t | callback, | ||
void * | callbackParam | ||
) |
This function is used to install the callback and callback parameter for GPIO module. When the pin state interrupt happened, the driver will notify the upper layer by the installed callback function. After the callback called, the GPIO pin state can be got by calling function HAL_GpioGetInput.
gpioHandle | GPIO handle pointer. The macro GPIO_HANDLE_BUFFER_GET is used to get the gpio buffer pointer, and should not be used before the macro GPIO_HANDLE_BUFFER_DEFINE is used. |
callback | The callback function. |
callbackParam | The parameter of the callback function. |
kStatus_HAL_GpioSuccess | Successfully install the callback. |
hal_gpio_status_t HAL_GpioWakeUpSetting | ( | hal_gpio_handle_t | gpioHandle, |
uint8_t | enable | ||
) |
This function enables or disables the GPIO wake-up feature.
gpioHandle | GPIO handle pointer. The macro GPIO_HANDLE_BUFFER_GET is used to get the gpio buffer pointer, and should not be used before the macro GPIO_HANDLE_BUFFER_DEFINE is used. |
enable | enable or disable (0 - disable, 1 - enable). |
kStatus_HAL_GpioError | An error occurred. |
kStatus_HAL_GpioSuccess | Set successfully. |
hal_gpio_status_t HAL_GpioEnterLowpower | ( | hal_gpio_handle_t | gpioHandle | ) |
This function is used to prepare to enter low power consumption.
gpioHandle | GPIO handle pointer. The macro GPIO_HANDLE_BUFFER_GET is used to get the gpio buffer pointer, and should not be used before the macro GPIO_HANDLE_BUFFER_DEFINE is used. |
kStatus_HAL_GpioSuccess | Successful operation. |
hal_gpio_status_t HAL_GpioExitLowpower | ( | hal_gpio_handle_t | gpioHandle | ) |
This function is used to restore from low power consumption.
gpioHandle | GPIO handle pointer. The macro GPIO_HANDLE_BUFFER_GET is used to get the gpio buffer pointer, and should not be used before the macro GPIO_HANDLE_BUFFER_DEFINE is used. |
kStatus_HAL_GpioSuccess | Successful operation. |