open-ameba/sdk/component/common/mbed/hal_ext/flash_eep.h

53 lines
2 KiB
C
Raw Permalink Normal View History

2016-11-09 00:56:41 +00:00
/******************************************************************************
* FileName: flash_eep.h
* Description: FLASH
* Alternate SDK
* Author: PV`
* (c) PV` 2015
*******************************************************************************/
#ifndef __FLASH_EEP_H_
#define __FLASH_EEP_H_
2017-02-01 11:37:57 +00:00
#ifdef __cplusplus
extern "C" {
#endif
2016-11-09 00:56:41 +00:00
#include <basic_types.h>
#include <FreeRTOS.h>
#include <queue.h>
2017-02-01 11:37:57 +00:00
2016-11-09 00:56:41 +00:00
//-----------------------------------------------------------------------------
#ifndef FLASH_SECTOR_SIZE
#define FLASH_SECTOR_SIZE 4096
#endif
#define FLASH_SECTORS 256 // 1 Mbytes
#define FLASH_CHIP_SIZE (FLASH_SECTORS * FLASH_SECTOR_SIZE)
#define FMEMORY_SCFG_BANK_SIZE FLASH_SECTOR_SIZE // размер сектора, 4096 bytes
#define FMEMORY_SCFG_BANKS 2 // кол-во секторов для работы 2...
2017-02-01 11:37:57 +00:00
#define FMEMORY_SCFG_BASE_ADDR (FLASH_CHIP_SIZE - (FMEMORY_SCFG_BANKS*FMEMORY_SCFG_BANK_SIZE)) // = 0xFE000
2016-11-09 00:56:41 +00:00
//-----------------------------------------------------------------------------
#define FLASH_EEP_ATTR
//-----------------------------------------------------------------------------
enum eFMEMORY_ERRORS {
FMEM_NOT_FOUND = -1, // -1 - не найден
FMEM_FLASH_ERR = -2, // -2 - flash rd/wr/erase error
2017-04-28 02:00:05 +00:00
FMEM_ERROR = -3, // -3 - error
FMEM_OVR_ERR = -4, // -4 - переполнение FMEMORY_SCFG_BANK_SIZE
FMEM_MEM_ERR = -5 // -5 - heap alloc error
2016-11-09 00:56:41 +00:00
};
//-----------------------------------------------------------------------------
// extern QueueHandle_t flash_mutex;
2017-02-01 11:37:57 +00:00
signed short flash_read_cfg(void *ptr, unsigned short id, unsigned short maxsize) FLASH_EEP_ATTR; // возврат: размер объекта последнего сохранения, -1 - не найден, -2 - error
bool flash_write_cfg(void *ptr, unsigned short id, unsigned short size) FLASH_EEP_ATTR;
2016-11-09 00:56:41 +00:00
//-----------------------------------------------------------------------------
#ifndef USE_FLASH_EEP
#define USE_FLASH_EEP 1
#endif
2017-02-01 11:37:57 +00:00
#ifdef __cplusplus
}
#endif
2016-11-09 00:56:41 +00:00
#endif /* __FLASH_EEP_H_ */