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 | GPIO_HANDLE_DEFINE(name) uint32_t name[((HAL_GPIO_HANDLE_SIZE + sizeof(uint32_t) - 1U) / sizeof(uint32_t))] |
Defines the gpio handle. More... | |
#define | HAL_GPIO_ISR_PRIORITY (3U) |
Definition of GPIO adapter isr priority. 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 GPIO_HANDLE_DEFINE | ( | name | ) | uint32_t name[((HAL_GPIO_HANDLE_SIZE + sizeof(uint32_t) - 1U) / sizeof(uint32_t))] |
This macro is used to define a 4 byte aligned gpio handle. Then use "(hal_gpio_handle_t)name" to get the gpio handle.
The macro should be global and could be optional. You could also define gpio handle by yourself.
This is an example,
name | The name string of the gpio handle. |
#define HAL_GPIO_ISR_PRIORITY (3U) |
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 gpioHandle 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 doesn't be supported on some devices. You can define the handle in the following two ways: GPIO_HANDLE_DEFINE(gpioHandle); or uint32_t gpioHandle[((HAL_GPIO_HANDLE_SIZE + sizeof(uint32_t) - 1U) / sizeof(uint32_t))]; |
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 handle should be 4 byte aligned, because unaligned access doesn't be supported on some devices. |
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 handle should be 4 byte aligned, because unaligned access doesn't be supported on some devices. |
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 handle should be 4 byte aligned, because unaligned access doesn't be supported on some devices. |
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 handle should be 4 byte aligned, because unaligned access doesn't be supported on some devices. |
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 handle should be 4 byte aligned, because unaligned access doesn't be supported on some devices. |
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 handle should be 4 byte aligned, because unaligned access doesn't be supported on some devices. |
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 handle should be 4 byte aligned, because unaligned access doesn't be supported on some devices. |
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 handle should be 4 byte aligned, because unaligned access doesn't be supported on some devices. |
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 handle should be 4 byte aligned, because unaligned access doesn't be supported on some devices. |
kStatus_HAL_GpioSuccess | Successful operation. |