sysparam fixes, tests, spi flash refactoring (#299)
Original work by @ourairquality * Sysparam threadsafe and SPI access * Sysparam test cases * Fix for negative int8 * Sysparam getting bool without memory allocation. Bool tests. * SPI flash refactoring. * Extract common spiflash.c into core. * Use spiflash.c in sysparam. * Use memcpy in spiflash.c insted of hand-written version. * Tests for spiflash.c
This commit is contained in:
parent
07ca0d2e9e
commit
a91ec6eb61
10 changed files with 724 additions and 406 deletions
|
@ -7,11 +7,10 @@
|
|||
*/
|
||||
#include "esp_spiffs.h"
|
||||
#include "spiffs.h"
|
||||
#include <espressif/spi_flash.h>
|
||||
#include <spiflash.h>
|
||||
#include <stdbool.h>
|
||||
#include <esp/uart.h>
|
||||
#include <fcntl.h>
|
||||
#include "esp_spiffs_flash.h"
|
||||
|
||||
spiffs fs;
|
||||
|
||||
|
@ -34,7 +33,7 @@ static fs_buf_t cache_buf = {0};
|
|||
|
||||
static s32_t esp_spiffs_read(u32_t addr, u32_t size, u8_t *dst)
|
||||
{
|
||||
if (esp_spiffs_flash_read(addr, dst, size) == ESP_SPIFFS_FLASH_ERROR) {
|
||||
if (!spiflash_read(addr, dst, size)) {
|
||||
return SPIFFS_ERR_INTERNAL;
|
||||
}
|
||||
|
||||
|
@ -43,7 +42,7 @@ static s32_t esp_spiffs_read(u32_t addr, u32_t size, u8_t *dst)
|
|||
|
||||
static s32_t esp_spiffs_write(u32_t addr, u32_t size, u8_t *src)
|
||||
{
|
||||
if (esp_spiffs_flash_write(addr, src, size) == ESP_SPIFFS_FLASH_ERROR) {
|
||||
if (!spiflash_write(addr, src, size)) {
|
||||
return SPIFFS_ERR_INTERNAL;
|
||||
}
|
||||
|
||||
|
@ -52,11 +51,10 @@ static s32_t esp_spiffs_write(u32_t addr, u32_t size, u8_t *src)
|
|||
|
||||
static s32_t esp_spiffs_erase(u32_t addr, u32_t size)
|
||||
{
|
||||
uint32_t sectors = size / SPI_FLASH_SEC_SIZE;
|
||||
uint32_t sectors = size / SPI_FLASH_SECTOR_SIZE;
|
||||
|
||||
for (uint32_t i = 0; i < sectors; i++) {
|
||||
if (esp_spiffs_flash_erase_sector(addr + (SPI_FLASH_SEC_SIZE * i))
|
||||
== ESP_SPIFFS_FLASH_ERROR) {
|
||||
if (!spiflash_erase_sector(addr + (SPI_FLASH_SECTOR_SIZE * i))) {
|
||||
return SPIFFS_ERR_INTERNAL;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue