Skip to content

Commit

Permalink
Fix the LED numbering for Sonata 1.0 and later.
Browse files Browse the repository at this point in the history
  • Loading branch information
davidchisnall committed Jan 24, 2025
1 parent 4857c58 commit bdf7c8d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
3 changes: 3 additions & 0 deletions sdk/include/cdefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -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_
15 changes: 13 additions & 2 deletions sdk/include/platform/sunburst/platform-gpio.hh
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down

0 comments on commit bdf7c8d

Please sign in to comment.