Skip to content

Commit 7126fbf

Browse files
Reduce the IRAM (and heap) usage of I2C code
The I2C code takes a large chunk of IRAM space. Attempt to reduce the size of the routines without impacting functionality. First, remove the `static` classifier on the sda/scl variables in the event handlers. The first instructions in the routines overwrite the last value stored in them, anyway, and their addresses are never taken.
1 parent ac25f32 commit 7126fbf

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

cores/esp8266/core_esp8266_si2c.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -524,8 +524,8 @@ static void eventTask(ETSEvent *e)
524524

525525
void ICACHE_RAM_ATTR onSclChange(void)
526526
{
527-
static uint8_t sda;
528-
static uint8_t scl;
527+
uint8_t sda;
528+
uint8_t scl;
529529

530530
sda = SDA_READ();
531531
scl = SCL_READ();
@@ -682,8 +682,8 @@ void ICACHE_RAM_ATTR onSclChange(void)
682682

683683
void ICACHE_RAM_ATTR onSdaChange(void)
684684
{
685-
static uint8_t sda;
686-
static uint8_t scl;
685+
uint8_t sda;
686+
uint8_t scl;
687687
sda = SDA_READ();
688688
scl = SCL_READ();
689689

0 commit comments

Comments
 (0)