fiatlux/firmware/system.c
jedi 0edf0e80c2
All checks were successful
continuous-integration/drone/push Build is passing
add function to clear config in flash
2021-07-06 22:55:38 +02:00

23 lines
No EOL
569 B
C

//
// Created by jedi on 25.06.21.
//
#include "system.h"
#include <FreeRTOS.h>
#include <task.h>
#include <sysparam.h>
#include <spiflash.h>
#include <espressif/esp_common.h>
#include <espressif/user_interface.h>
void system_clear_config(){
vPortEnterCritical();
uint32_t num_sectors = 5 + DEFAULT_SYSPARAM_SECTORS;
uint32_t start = sdk_flashchip.chip_size - num_sectors * sdk_flashchip.sector_size;
for (uint32_t i = 0; i < num_sectors; i++) {
spiflash_erase_sector(start + i * sdk_flashchip.sector_size);
}
sdk_system_restart();
}