My code looks like this:
#include <spi_flash.h>
#include "datastructures.h"
accessPointConfig currentAccessPointConfig;
void saveAccessPointConfig( accessPointConfig *pConfig ) {
spi_flash_erase_sector(CONFIG_SECTOR);
spi_flash_write(CONFIG_ADDRESS , (uint32 *)(pConfig), sizeof(accessPointConfig));
}
void loadAccessPointConfigFromSPI( accessPointConfig *pConfig ) {
spi_flash_read(CONFIG_ADDRESS , (uint32 *)(pConfig), sizeof(accessPointConfig));
}
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
pinMode(0, INPUT_PULLUP);
pinMode(2, OUTPUT);
Serial.println( "System start..." );
loadAccessPointConfigFromSPI( ¤tAccessPointConfig );
Serial.println( "SPI flash test result..." );
Serial.println( currentAccessPointConfig.spotNameLen );
}
void loop() {
// some stuff happening here
}
And my helper include file datastructures.h looks like this:
#define CONFIG_SECTOR 0x80-4
#define CONFIG_ADDRESS CONFIG_SECTOR * 4096
typedef struct {
char wifiSpotName[256];
char wifiSpotPassword[256];
uint32_t spotNameLen;
uint32_t spotPasswordLen;
} accessPointConfig;
When I'm trying to compile, I'm getting the following error messages:
Arduino: 1.6.7 (Windows 7), Board: "Generic ESP8266 Module, Serial, 80 MHz, 40MHz, DIO, 115200, 512K (64K SPIFFS), ck"
sketch\sketch_accumulator.ino.cpp.o:(.text._Z28loadAccessPointConfigFromSPIP17accessPointConfig+0x4): undefined reference to `spi_flash_read(unsigned int, unsigned int*, unsigned int)'
sketch\sketch_accumulator.ino.cpp.o: In function `loadAccessPointConfigFromSPI(accessPointConfig*)':
C:\Users\Andrzej\Documents\Arduino\sketch_accumulator/sketch_accumulator.ino:47: undefined reference to `spi_flash_read(unsigned int, unsigned int*, unsigned int)'
collect2.exe: error: ld returned 1 exit status
exit status 1
Error compiling.
I think, I'm missing the actual implementation of spi_flash, or maybe it is a problem with my paths/directiories.
I would be glad, If I get any hint on how to resolve this, since I'm kinda to to MCUs, C and stuff.