@@ -103,23 +103,23 @@ class Twi
103103 ETSTimer timer;
104104
105105// Event/IRQ callbacks, so they can't use "this" and need to be static
106- static void ICACHE_RAM_ATTR onSclChange (void );
107- static void ICACHE_RAM_ATTR onSdaChange (void );
106+ static void IRAM_ATTR onSclChange (void );
107+ static void IRAM_ATTR onSdaChange (void );
108108static void eventTask (ETSEvent *e);
109- static void ICACHE_RAM_ATTR onTimer (void *unused);
109+ static void IRAM_ATTR onTimer (void *unused);
110110
111111// Allow not linking in the slave code if there is no call to setAddress
112112bool _slaveEnabled =false ;
113113
114114// Internal use functions
115- void ICACHE_RAM_ATTR busywait (unsigned int v);
115+ void IRAM_ATTR busywait (unsigned int v);
116116bool write_start (void );
117117bool write_stop (void );
118118bool write_bit (bool bit);
119119bool read_bit (void );
120120bool write_byte (unsigned char byte);
121121unsigned char read_byte (bool nack);
122- void ICACHE_RAM_ATTR onTwipEvent (uint8_t status);
122+ void IRAM_ATTR onTwipEvent (uint8_t status);
123123
124124// Handle the case where a slave needs to stretch the clock with a time-limited busy wait
125125inline void WAIT_CLOCK_STRETCH ()
@@ -149,8 +149,8 @@ class Twi
149149uint8_t transmit (const uint8_t * data,uint8_t length);
150150void attachSlaveRxEvent (void (*function)(uint8_t *,size_t ));
151151void attachSlaveTxEvent (void (*function)(void ));
152- void ICACHE_RAM_ATTR reply (uint8_t ack);
153- void ICACHE_RAM_ATTR releaseBus (void );
152+ void IRAM_ATTR reply (uint8_t ack);
153+ void IRAM_ATTR releaseBus (void );
154154void enableSlave ();
155155};
156156
@@ -229,7 +229,7 @@ void Twi::enableSlave()
229229 }
230230}
231231
232- void ICACHE_RAM_ATTR Twi::busywait (unsigned int v)
232+ void IRAM_ATTR Twi::busywait (unsigned int v)
233233{
234234unsigned int i;
235235for (i =0 ; i < v; i++)// loop time is 5 machine cycles: 31.25ns @ 160MHz, 62.5ns @ 80MHz
@@ -472,9 +472,9 @@ void Twi::attachSlaveTxEvent(void (*function)(void))
472472}
473473
474474// DO NOT INLINE, inlining reply() in combination with compiler optimizations causes function breakup into
475- // parts and theICACHE_RAM_ATTR isn't propagated correctly to all parts, which of course causes crashes.
475+ // parts and theIRAM_ATTR isn't propagated correctly to all parts, which of course causes crashes.
476476// TODO: test with gcc 9.x and if it still fails, disable optimization with -fdisable-ipa-fnsplit
477- void ICACHE_RAM_ATTR Twi::reply (uint8_t ack)
477+ void IRAM_ATTR Twi::reply (uint8_t ack)
478478{
479479// transmit master read ready signal, with or without ack
480480if (ack)
@@ -492,7 +492,7 @@ void ICACHE_RAM_ATTR Twi::reply(uint8_t ack)
492492}
493493
494494
495- void ICACHE_RAM_ATTR Twi::releaseBus (void )
495+ void IRAM_ATTR Twi::releaseBus (void )
496496{
497497// release bus
498498// TWCR = _BV(TWEN) | _BV(TWIE) | _BV(TWEA) | _BV(TWINT);
@@ -505,7 +505,7 @@ void ICACHE_RAM_ATTR Twi::releaseBus(void)
505505}
506506
507507
508- void ICACHE_RAM_ATTR Twi::onTwipEvent (uint8_t status)
508+ void IRAM_ATTR Twi::onTwipEvent (uint8_t status)
509509{
510510 twip_status = status;
511511switch (status)
@@ -612,7 +612,7 @@ void ICACHE_RAM_ATTR Twi::onTwipEvent(uint8_t status)
612612 }
613613}
614614
615- void ICACHE_RAM_ATTR Twi::onTimer (void *unused)
615+ void IRAM_ATTR Twi::onTimer (void *unused)
616616{
617617 (void )unused;
618618 twi.releaseBus ();
@@ -662,7 +662,7 @@ void Twi::eventTask(ETSEvent *e)
662662// Shorthand for if the state is any of the or'd bitmask x
663663#define IFSTATE (x )if (twip_state_mask & (x))
664664
665- void ICACHE_RAM_ATTR Twi::onSclChange (void )
665+ void IRAM_ATTR Twi::onSclChange (void )
666666{
667667unsigned int sda;
668668unsigned int scl;
@@ -860,7 +860,7 @@ void ICACHE_RAM_ATTR Twi::onSclChange(void)
860860 }
861861}
862862
863- void ICACHE_RAM_ATTR Twi::onSdaChange (void )
863+ void IRAM_ATTR Twi::onSdaChange (void )
864864{
865865unsigned int sda;
866866unsigned int scl;