Compatibility
Overview:
The GPIO (General-Purpose Input/Output) code module presented here offers a versatile and efficient mechanism to handle GPIO operations across various platforms. The functions are designed to cater to both dynamic/runtime checks and compile-time/static checks to ensure maximum flexibility and reliability during development.
MCU platforms:
Platform | Supported |
---|---|
Atmel SAMD21 | YES |
Atmel SAMD51 | YES |
Raspberry Pi Pico | YES |
Compatibility:
-
Platform Independence with Platform-specific Implementations: While the core functionalities and interface of the GPIO module are designed to be platform-agnostic, the underlying implementations for each platform differ. Each platform's specific implementation is contained in a source file named in the pattern gpio_<platform_name>.c. This allows for unique and optimized handling of GPIO operations for each platform while maintaining a consistent interface for the developers.
-
Platform-specific Options: Any platform-specific parameters or settings, such as enumerations and typedefs, are segregated into the gpio_platform_specific.h header file. This ensures a clear separation between generic functionalities and platform-dependent configurations. When porting the module to a new platform, developers should focus on adapting the contents of gpio_platform_specific.h to match the platform's specifications.
-
Compile-time vs. Runtime Checks: For every major GPIO function, there are two variants provided:
-
Functions without static (compile-time) parameter checking: These are suited for dynamic scenarios where parameters might change during runtime.
-
Functions with static (compile-time) parameter checking: Useful during development phases, these offer compile-time error notifications if any incorrect parameter is passed, ensuring early error detection.
-
Recommendations for Developers:
-
Optimal Usage: While both dynamic and static checking functions are available, developers are advised to use the compile-time checking functions (uppercase function names) during the development phase for early error detection. Once the code is stable, you can switch to runtime functions if dynamic behavior is desired.
-
Integration with New Platforms: For integrating with a new platform or microcontroller:
- Focus on updating and modifying the gpio_platform_specific.h file. Ensure that platform-specific enumerations, typedefs, and settings align with the new platform's GPIO specifications.
- Implement the GPIO functions specific to the new platform in a new source file following the naming convention gpio_<platform_name>.c.
-
Error Handling: The return type uhal_status_t is designed to offer feedback on the function's execution. It is recommended to always check the returned status after calling a GPIO function to ensure the desired operation was completed successfully.
-
Extensibility: If there are additional platform-specific GPIO functionalities not covered in the current module, developers can extend the module by adding new functions. However, it's crucial to maintain the pattern of providing both compile-time and runtime checking variants for consistency and flexibility.
In summary, this GPIO code module provides a unified interface for GPIO operations across different platforms. The structure ensures both a high degree of compatibility and the flexibility to optimize operations for individual platforms.