High level interface for interacting with the Cypress GPIO.
This driver provides configuration of GPIO pins. It also allows values to be read from and written to a pin directly from firmware.
If a GPIO is to be used as an input to or an output from a fixed function peripheral on the device, this driver should not be used directly. The driver for the fixed function peripheral will perform the necessary function calls to configure its GPIO pins.
|
| enum | cyhal_gpio_event_t { CYHAL_GPIO_IRQ_NONE,
CYHAL_GPIO_IRQ_RISE,
CYHAL_GPIO_IRQ_FALL,
CYHAL_GPIO_IRQ_BOTH
} |
| |
| enum | cyhal_gpio_direction_t { CYHAL_GPIO_DIR_INPUT,
CYHAL_GPIO_DIR_OUTPUT,
CYHAL_GPIO_DIR_BIDIRECTIONAL
} |
| |
| enum | cyhal_gpio_drive_mode_t {
CYHAL_GPIO_DRIVE_NONE,
CYHAL_GPIO_DRIVE_ANALOG,
CYHAL_GPIO_DRIVE_PULLUP,
CYHAL_GPIO_DRIVE_PULLDOWN,
CYHAL_GPIO_DRIVE_OPENDRAINDRIVESLOW,
CYHAL_GPIO_DRIVE_OPENDRAINDRIVESHIGH,
CYHAL_GPIO_DRIVE_STRONG,
CYHAL_GPIO_DRIVE_PULLUPDOWN
} |
| |
|
| cy_rslt_t | cyhal_gpio_init (cyhal_gpio_t pin, cyhal_gpio_direction_t direction, cyhal_gpio_drive_mode_t drvMode, bool initVal) |
| |
| void | cyhal_gpio_free (cyhal_gpio_t pin) |
| |
| cy_rslt_t | cyhal_gpio_configure (cyhal_gpio_t pin, cyhal_gpio_direction_t direction, cyhal_gpio_drive_mode_t drvMode) |
| |
| void | cyhal_gpio_write (cyhal_gpio_t pin, bool value) |
| |
| bool | cyhal_gpio_read (cyhal_gpio_t pin) |
| |
| void | cyhal_gpio_toggle (cyhal_gpio_t pin) |
| |
| void | cyhal_gpio_register_callback (cyhal_gpio_t pin, cyhal_gpio_event_callback_t callback, void *callback_arg) |
| |
| void | cyhal_gpio_enable_event (cyhal_gpio_t pin, cyhal_gpio_event_t event, uint8_t intrPriority, bool enable) |
| |
◆ CYHAL_NC_PIN_VALUE
| #define CYHAL_NC_PIN_VALUE ((cyhal_gpio_t)0xFFFFFFFF) |
Integer representation of no connect pin (required to exist in all BSPs)
◆ cyhal_gpio_event_callback_t
| typedef void(* cyhal_gpio_event_callback_t) (void *callback_arg, cyhal_gpio_event_t event) |
GPIO callback function type
◆ cyhal_gpio_event_t
Pin events
| Enumerator |
|---|
| CYHAL_GPIO_IRQ_NONE | No interrupt
|
| CYHAL_GPIO_IRQ_RISE | Interrupt on rising edge
|
| CYHAL_GPIO_IRQ_FALL | Interrupt on falling edge
|
| CYHAL_GPIO_IRQ_BOTH | Interrupt on both rising and falling edges
|
◆ cyhal_gpio_direction_t
Pin direction
| Enumerator |
|---|
| CYHAL_GPIO_DIR_INPUT | Input pin
|
| CYHAL_GPIO_DIR_OUTPUT | Output pin
|
| CYHAL_GPIO_DIR_BIDIRECTIONAL | Input and output pin
|
◆ cyhal_gpio_drive_mode_t
Pin drive mode
| Enumerator |
|---|
| CYHAL_GPIO_DRIVE_NONE | No drive; Hi-Z
|
| CYHAL_GPIO_DRIVE_ANALOG | Analog Hi-Z
|
| CYHAL_GPIO_DRIVE_PULLUP | Pull-up resistor
|
| CYHAL_GPIO_DRIVE_PULLDOWN | Pull-down resistor
|
| CYHAL_GPIO_DRIVE_OPENDRAINDRIVESLOW | Open-drain, Drives Low
|
| CYHAL_GPIO_DRIVE_OPENDRAINDRIVESHIGH | Open-drain, Drives High
|
| CYHAL_GPIO_DRIVE_STRONG | Strong output
|
| CYHAL_GPIO_DRIVE_PULLUPDOWN | Pull-up and pull-down resistors
|
◆ cyhal_gpio_init()
Initialize the GPIO pin
- Parameters
-
| [in] | pin | The GPIO pin to initialize |
| [in] | direction | The pin direction |
| [in] | drvMode | The pin drive mode |
| [in] | initVal | Initial value on the pin |
- Returns
- The status of the init request
◆ cyhal_gpio_free()
| void cyhal_gpio_free |
( |
cyhal_gpio_t |
pin | ) |
|
Uninitialize the gpio peripheral and the cyhal_gpio_t object
- Parameters
-
◆ cyhal_gpio_configure()
Configure the GPIO pin
- Parameters
-
| [in] | pin | The GPIO pin |
| [in] | direction | The pin direction |
| [in] | drvMode | The pin drive mode |
- Returns
- The status of the configure request
◆ cyhal_gpio_write()
| void cyhal_gpio_write |
( |
cyhal_gpio_t |
pin, |
|
|
bool |
value |
|
) |
| |
Set the output value for the pin. This only works for output & in_out pins.
- Parameters
-
| [in] | pin | The GPIO object |
| [in] | value | The value to be set (high = true, low = false) |
◆ cyhal_gpio_read()
| bool cyhal_gpio_read |
( |
cyhal_gpio_t |
pin | ) |
|
Read the input value. This only works for input & in_out pins.
- Parameters
-
- Returns
- The value of the IO (true = high, false = low)
◆ cyhal_gpio_toggle()
| void cyhal_gpio_toggle |
( |
cyhal_gpio_t |
pin | ) |
|
Toggle the output value
- Parameters
-
◆ cyhal_gpio_register_callback()
Register/clear a callback handler for pin events
- Parameters
-
| [in] | pin | The pin number |
| [in] | callback | The function to call when the specified event happens. Pass NULL to unregister the handler. |
| [in] | callback_arg | Generic argument that will be provided to the callback when called, can be NULL |
◆ cyhal_gpio_enable_event()
| void cyhal_gpio_enable_event |
( |
cyhal_gpio_t |
pin, |
|
|
cyhal_gpio_event_t |
event, |
|
|
uint8_t |
intrPriority, |
|
|
bool |
enable |
|
) |
| |
Enable or Disable the specified GPIO event
- Parameters
-
| [in] | pin | The GPIO object |
| [in] | event | The GPIO event |
| [in] | intrPriority | The priority for NVIC interrupt events |
| [in] | enable | True to turn on interrupts, False to turn off |