diff --git a/sdk/include/cdefs.h b/sdk/include/cdefs.h index 0a916978..13de20ed 100644 --- a/sdk/include/cdefs.h +++ b/sdk/include/cdefs.h @@ -129,4 +129,7 @@ unsigned __builtin_strlen(const char *str) __asm__("_Z6strlenPKc"); # error Your compiler is too old for this version of CHERIoT RTOS, please upgrade to a newer version #endif +#define CHERIOT_VERSION_TRIPLE(major, minor, patch) \ + ((major * 10000) + (minor * 100) + (patch)) + #endif // _CDEFS_H_ diff --git a/sdk/include/platform/sunburst/platform-gpio.hh b/sdk/include/platform/sunburst/platform-gpio.hh index 9aae88b1..d7c3d3ad 100644 --- a/sdk/include/platform/sunburst/platform-gpio.hh +++ b/sdk/include/platform/sunburst/platform-gpio.hh @@ -39,14 +39,25 @@ struct SonataGPIO uint32_t arduinoShieldHeader; uint32_t arduinoShieldMask; + /** + * Is the current target Sonata 1.0.0 or later? + */ + static bool constexpr Sonata1OrLater = +#if SONATA >= CHERIOT_VERSION_TRIPLE(1, 0, 0) + true +#else + false +#endif + ; + /** * The bit index of the first GPIO pin connected to a user LED. */ - static constexpr uint32_t FirstLED = 4; + static constexpr uint32_t FirstLED = Sonata1OrLater? 0 : 4; /** * The bit index of the last GPIO pin connected to a user LED. */ - static constexpr uint32_t LastLED = 11; + static constexpr uint32_t LastLED = Sonata1OrLater ? 7 : 11; /** * The number of user LEDs. */