The GPIO driver provides an API to configure and access device Input/Output pins.
The functions and other declarations used in this driver are in cy_gpio.h. You can include cy_pdl.h to get access to all functions and declarations in the PDL.
IO pins include all general purpose types such as GPIO, SIO, HSIO, AUXIO, and their variants.
Initialization can be performed either at the port level or by configuring the individual pins. For efficient use of code space, port configuration should be used in the field. Refer to the product device header files for the list of supported ports and pins.
Once the pin/port initialization is complete, each pin can be accessed by specifying the port (GPIO_PRT_Type) and the pin (0-7) in the provided API functions.
Multiple pins on a port can be updated using direct port register writes with an appropriate port mask. An example is shown below, highlighting the different ways of configuring Port 1 pins using:
Refer to the technical reference manual (TRM) and the device datasheet.
The GPIO driver has the following specific deviations:
MISRA Rule | Rule Class (Required/Advisory) | Rule Description | Description of Deviation(s) |
---|---|---|---|
11.4 | A | A cast should not be performed between a pointer to object type and a different pointer to object type. | This code is safe because the elements of both GPIO_PRT_V1_Type and GPIO_PRT_V2_Type types have identical alignment. |
16.7 | A | A pointer parameter in a function prototype should be declared as pointer to const if the pointer is not used to modify the addressed object. | The objects pointed to by the base addresses of the GPIO port are not always modified. While a const qualifier can be used in select scenarios, it brings little benefit in adding this to the affected functions. |
Version | Changes | Reason for Change |
---|---|---|
1.20.1 | Minor documentation updates. | Documentation enhancement. |
1.20 | Flattened the organization of the driver source code into the single source directory and the single include directory. | Driver library directory-structure simplification. |
Added the functions for configuring the AMux bus splitter switch cells: | Added a new functionality related to AMux bus. | |
Added register access layer. Use register access macros instead of direct register access using dereferenced pointers. | Makes register access device-independent, so that the PDL does not need to be recompiled for each supported part number. | |
1.10.1 | Updated description for the functions: Cy_GPIO_GetInterruptStatus, Cy_GPIO_GetInterruptMask, Cy_GPIO_GetInterruptStatusMasked. Minor documentation edits. | Documentation update and clarification |
1.10 | Added input parameter validation to the API functions | |
1.0 | Initial version |
API Reference | |
Macros | |
Functions | |
Data Structures | |
Enumerated Types | |