Skip to content

drivers/saul: Improved stringification#11394

Merged
benpicco merged 1 commit intoRIOT-OS:masterfrom
maribu:saul_stringification
Nov 26, 2019
Merged

drivers/saul: Improved stringification#11394
benpicco merged 1 commit intoRIOT-OS:masterfrom
maribu:saul_stringification

Conversation

@maribu
Copy link
Member

@maribu maribu commented Apr 15, 2019

Contribution description

  • Changed declaration of SAUL classes (while keeping the format)
    • Termed "class of SAUL classes" category of SAUL classes in the doc to avoid confusion. (E.g. a SAUL class will now be in category sensor or actuator.)
    • Separate enums for SAUL category and intra-category ID. Numbers will now but auto-assigned by the compiler
  • Use constant look-up tables for stringification (one table per SAUL category).
    ==> This saves 512B in .data section of AVR

TL;DR:

Pro:

  • Smaller RAM footprint
  • No manual management of class numbers

Cons:

  • Adding new classes requires changing 2 lines instead of 1 (or 3 lines instead of 2 when counting stringification)

Testing procedure

examples/saul should still work with your favorite board

Issues/PRs references

Split off from #11392

@maribu maribu added Type: enhancement The issue suggests enhanceable parts / The PR enhances parts of the codebase / documentation Area: SAUL Area: Sensor/Actuator Uber Layer labels Apr 15, 2019
@maribu maribu requested review from leandrolanzieri and smlng April 15, 2019 10:26
@maribu maribu requested a review from haukepetersen April 17, 2019 08:49
@maribu
Copy link
Member Author

maribu commented Oct 14, 2019

@haukepetersen: Please have a look. This reduces RAM requirements on ATmegas by 512B (or 25% of the available RAM of e.g. the Arduino Uno, the Arduino Duemilanove, or the Arduino Nano). I would love to see this merged.

@maribu maribu requested a review from benpicco October 17, 2019 09:56
@maribu
Copy link
Member Author

maribu commented Oct 17, 2019

I'll solve the merge conflicts now

@maribu maribu force-pushed the saul_stringification branch from 40dc243 to f6764d7 Compare October 17, 2019 10:02
@benpicco benpicco added the CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR label Oct 17, 2019
@maribu maribu force-pushed the saul_stringification branch 2 times, most recently from b678f1e to 05e8244 Compare November 22, 2019 22:51
@maribu
Copy link
Member Author

maribu commented Nov 22, 2019

Rebased to solve merge conflict

@maribu
Copy link
Member Author

maribu commented Nov 22, 2019

An underscore followed by an upper case letter is a reserved identifier according to the C standard. I fixed the code to stop using them.

@benpicco: Would you mind to have a look? To me, this PR is super uncontroversial and would be a huge step in getting examples/default compiling again on the bottom end platforms. (E.g. 512B RAM safe on AVR, with only 2048B available on the ATmega328P this is quite a chunk.)

Copy link
Contributor

@benpicco benpicco left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a nice cleanup.
I see no functional changes - please squash.

- Changed declaration of SAUL classes (while keeping the format)
    - Termed "class of SAUL classes" category of SAUL classes in the doc to
      avoid confusion. (E.g. a SAUL class will now be in category sensor or
      actuator.)
    - Separate enums for SAUL category and intra-category ID. Numbers will now
      but auto-assigned by the compiler
- Use constant look-up tables for stringification (one table per SAUL category).
  ==> This saves 512B in .data section of AVR
@maribu maribu force-pushed the saul_stringification branch from 88e6da1 to 837e9c1 Compare November 25, 2019 09:09
@maribu
Copy link
Member Author

maribu commented Nov 26, 2019

please squash.

Done. All green :-)

@benpicco benpicco merged commit ffe208a into RIOT-OS:master Nov 26, 2019
@fjmolinas fjmolinas added this to the Release 2020.01 milestone Dec 13, 2019
@maribu maribu deleted the saul_stringification branch February 6, 2020 20:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: SAUL Area: Sensor/Actuator Uber Layer CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR Type: enhancement The issue suggests enhanceable parts / The PR enhances parts of the codebase / documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants