Skip to content

Allow yield() to be defined in library code #303

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Oct 4, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- Properly report compile errors in GitHub Actions (#296)
- Put build artifacts in a separate directory to reduce clutter.
- Change 266 files from CRLF to LF.
- Replace `#define yield() _NOP()` with `inline void yield() { _NOP(); }` so that other code can define a `yield()` function.
- Update .gitattributes so we have consistent line endings
- Run tests on push as well as on a pull request so developers can see impact

Expand Down
10 changes: 5 additions & 5 deletions cpp/arduino/Arduino.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ typedef uint8_t byte;
#define highByte(w) ((uint8_t) ((w) >> 8))
#define lowByte(w) ((uint8_t) ((w) & 0xff))

// might as well use that NO-op macro for these, while unit testing
// you need interrupts? interrupt yourself
#define yield() _NOP()
#define interrupts() _NOP()
#define noInterrupts() _NOP()
// using #define for these makes it impossible for other code to use as function
// names!
inline void yield() { _NOP(); }
inline void interrupts() { _NOP(); }
inline void noInterrupts() { _NOP(); }

// TODO: correctly establish this per-board!
#define F_CPU 1000000UL
Expand Down