#include "ringfs_api.h"
#include "rtc.h"
#include "FreeRTOS.h"
#include "task.h"
#include "semphr.h"
#include "event_groups.h"
#include "rtc.h"
#include "settings_api.h"
#include "digital_input.h"
#include "log_ai.h"
#include "log_dio.h"
#include <string.h>
#include <stdio.h>
#include <inttypes.h>

#undef DBG
#define DBG if(0)




//
int op_sector_erase(struct ringfs_flash_partition *flash, int address) {
	(void)flash;
	int ret;
	ret = spi_flash_erase_sector(address, 0);
	return ret;
}

//
ssize_t op_program(struct ringfs_flash_partition *flash, int address, const void *data, size_t size) {
	(void)flash;
	int ret;
	ret = spi_flash_write(address, data, size, 0);
	return ret;
}

//
ssize_t op_read(struct ringfs_flash_partition *flash, int address, void *data, size_t size) {
	(void)flash;
	int ret;
	ret = spi_flash_read(address, data, size, 0);
	return ret;
}

#if 0
//
static struct ringfs_flash_partition ringfs_flash_log = 
{
	.sector_offset = LOG_FLASH_SECTOR_OFFSET,
	.sector_erase = op_sector_erase,
	.program = op_program,
	.read = op_read,
};


//
static struct ringfs_flash_partition ringfs_flash_archive = 
{
	.sector_offset = ARCHIVE_FLASH_SECTOR_OFFSET,
	.sector_erase = op_sector_erase,
	.program = op_program,
	.read = op_read,
};


#endif