diff --git a/flash.c b/flash.c new file mode 100644 --- /dev/null +++ b/flash.c @@ -0,0 +1,179 @@ +#include "stm32f0xx_hal.h" +#include "ssd1306.h" +#include "stm32f0xx_hal_flash.h" +#include "flash.h" + +void flash_init(therm_settings_t* tosave) +{ + uint16_t size = sizeof(therm_settings_t)-1; + uint32_t flash_adr = END_ADDR - size; + flash_adr -= 2; + uint8_t* flash_ptr = (uint8_t *)flash_adr; + + // Check if flash is blank + uint16_t i = 0; + uint16_t count = 0; + + char tempstr[10]; + itoa(flash_adr, tempstr, 10); + ssd1306_DrawString(tempstr, 1, 0); + + uint16_t test; + for(i=0;i