Skip to content

Commit d14419e

Browse files
dok-netdevyte
authored andcommitted
Save 16 bytes RAM by placing esp8266_gpioToFn (core_esp8266_wiring_digital.cpp) array in PROGMEM (esp8266#6703)
* Save 16 bytes RAM by placing the array in PROGMEM. * Reduce runtime computation at expense of switching from uint8_t[16] to uint32_t*[16]
1 parent 60c8975 commit d14419e

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

cores/esp8266/core_esp8266_wiring_digital.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030

3131
extern "C" {
3232

33-
uint8_t esp8266_gpioToFn[16] = {0x34, 0x18, 0x38, 0x14, 0x3C, 0x40, 0x1C, 0x20, 0x24, 0x28, 0x2C, 0x30, 0x04, 0x08, 0x0C, 0x10};
33+
volatile uint32_t* const esp8266_gpioToFn[16] PROGMEM = { &GPF0, &GPF1, &GPF2, &GPF3, &GPF4, &GPF5, &GPF6, &GPF7, &GPF8, &GPF9, &GPF10, &GPF11, &GPF12, &GPF13, &GPF14, &GPF15 };
3434

3535
extern void __pinMode(uint8_t pin, uint8_t mode) {
3636
if(pin < 16){

cores/esp8266/esp8266_peri.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,8 @@
102102
#define GPF14 ESP8266_REG(0x80C)
103103
#define GPF15 ESP8266_REG(0x810)
104104

105-
extern uint8_t esp8266_gpioToFn[16];
106-
#define GPF(p) ESP8266_REG(0x800 + esp8266_gpioToFn[(p & 0xF)])
105+
extern volatile uint32_t* const esp8266_gpioToFn[16];
106+
#define GPF(p) (*esp8266_gpioToFn[(p & 0xF)])
107107

108108
//GPIO (0-15) PIN Function Bits
109109
#define GPFSOE 0 //Sleep OE

0 commit comments

Comments
 (0)