123
Fork of LG by
DeviceFlash.h
- Committer:
- Kovalev_D
- Date:
- 2016-10-19
- Revision:
- 197:7a05523bf588
- Parent:
- 167:bedc0a9d559a
File content as of revision 197:7a05523bf588:
#ifndef __DEVICE_FLASH_H__ #define __DEVICE_FLASH_H__ #include "IAP.h" //Flash memory page size: 256|512|1024|4096 allowed #define FLASH_PAGE_SIZE 256 //Hash sector - 8 bytes per hash typedef struct _DeviceFlashHash { uint32_t hash; //Hash uint32_t address; //Address of data located in data sector //uint16_t size; //Size of data } DeviceFlashHash; typedef struct _DeviceFlashSettings { uint16_t hashSector; //Sector of "hash - data address" pairs //uint16_t hashPageLength; uint16_t dataSector; //Sector of data, referenced from hash sector //uint16_t dataPageLength; } DeviceFlashSettings; typedef struct _DeviceFlashWriteOperation { uint8_t pageBuffer[FLASH_PAGE_SIZE]; //Page buffer //uint16_t pageLength; uint16_t pagePosition; //Position in page buffer to write in uint16_t sector; //Current sector to write data in uint32_t sectorAddress; //Starting address of sector to write data from page buffer uint16_t sectorPosition; //Position in sector to write data from page buffer relative to sector start address uint16_t sectorLength; //Length of current sector uint32_t bytes; //Count of bytes written uint32_t maxBytes; //Maximum allowed bytes to write } DeviceFlashWriteOperation; typedef struct _DeviceFlashState { } DeviceFlashState; typedef struct _DeviceFlash { DeviceFlashSettings settings; DeviceFlashState state; } DeviceFlash; void InitFlashDefaultSettings(void); void InitFlashState(void); uint32_t AddressFromSector(uint8_t sector); uint16_t LengthFromSector(uint8_t sector); //uint8_t sectorFromAddress(uint32_t address); void DeviceFlashReadAll(void); void DeviceFlashWriteAll(void); #endif /* __DEVICE_FLASH_H__ */