-
Notifications
You must be signed in to change notification settings - Fork 13.3k
put inline helpers in IRAM for slave ISRs [issue 6875] #6894
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
Closed
Closed
Changes from 1 commit
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -95,31 +95,32 @@ class Twi | |
unsigned char read_byte(bool nack); | ||
void ICACHE_RAM_ATTR onTwipEvent(uint8_t status); | ||
|
||
// Inline helpers | ||
inline void SDA_LOW() | ||
// !Inline helpers (linker doesn't bring them inline) | ||
ICACHE_RAM_ATTR void SDA_LOW() | ||
{ | ||
GPES = (1 << twi_sda); | ||
} | ||
inline void SDA_HIGH() | ||
ICACHE_RAM_ATTR void SDA_HIGH() | ||
{ | ||
GPEC = (1 << twi_sda); | ||
} | ||
inline bool SDA_READ() | ||
ICACHE_RAM_ATTR bool SDA_READ() | ||
{ | ||
return (GPI & (1 << twi_sda)) != 0; | ||
} | ||
inline void SCL_LOW() | ||
ICACHE_RAM_ATTR void SCL_LOW() | ||
{ | ||
GPES = (1 << twi_scl); | ||
} | ||
inline void SCL_HIGH() | ||
ICACHE_RAM_ATTR void SCL_HIGH() | ||
{ | ||
GPEC = (1 << twi_scl); | ||
} | ||
inline bool SCL_READ() | ||
ICACHE_RAM_ATTR bool SCL_READ() | ||
{ | ||
return (GPI & (1 << twi_scl)) != 0; | ||
} | ||
|
||
// Handle the case where a slave needs to stretch the clock with a time-limited busy wait | ||
inline void WAIT_CLOCK_STRETCH() | ||
{ | ||
|
@@ -439,6 +440,14 @@ unsigned char Twi::readFrom(unsigned char address, unsigned char* buf, unsigned | |
return 0; | ||
} | ||
|
||
void Twi::twi_scl_valley(void) | ||
{ | ||
SCL_LOW(); | ||
busywait(twi_dcount); | ||
SCL_HIGH(); | ||
WAIT_CLOCK_STRETCH(); | ||
} | ||
|
||
uint8_t Twi::status() | ||
{ | ||
WAIT_CLOCK_STRETCH(); // wait for a slow slave to finish | ||
|
@@ -650,14 +659,6 @@ void ICACHE_RAM_ATTR Twi::onTwipEvent(uint8_t status) | |
} | ||
} | ||
|
||
void Twi::twi_scl_valley(void) | ||
{ | ||
SCL_LOW(); | ||
busywait(twi_dcount); | ||
SCL_HIGH(); | ||
WAIT_CLOCK_STRETCH(); | ||
} | ||
|
||
void ICACHE_RAM_ATTR Twi::onTimer(void *unused) | ||
{ | ||
(void)unused; | ||
|
@@ -714,8 +715,8 @@ void ICACHE_RAM_ATTR Twi::onSclChange(void) | |
unsigned int scl; | ||
|
||
// Store bool return in int to reduce final code size. | ||
sda = twi.SDA_READ(); | ||
scl = twi.SCL_READ(); | ||
sda = (GPI & (1 << twi.twi_sda)) != 0; // SDA_READ() fast, no time for a call | ||
scl = (GPI & (1 << twi.twi_scl)) != 0; // SCL_READ() | ||
devyte marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
twi.twip_status = 0xF8; // reset TWI status | ||
|
||
|
@@ -911,8 +912,8 @@ void ICACHE_RAM_ATTR Twi::onSdaChange(void) | |
unsigned int scl; | ||
|
||
// Store bool return in int to reduce final code size. | ||
sda = twi.SDA_READ(); | ||
scl = twi.SCL_READ(); | ||
sda = (GPI & (1 << twi.twi_sda)) != 0; // SDA_READ() | ||
devyte marked this conversation as resolved.
Show resolved
Hide resolved
|
||
scl = (GPI & (1 << twi.twi_scl)) != 0; // SCL_READ() | ||
|
||
int twip_state_mask = S2M(twi.twip_state); | ||
if (scl) /* !DATA */ | ||
|
@@ -1073,4 +1074,4 @@ extern "C" { | |
twi.enableSlave(); | ||
} | ||
|
||
}; | ||
}; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. eof newline |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.