123

Dependencies:   mbed

Fork of LG by igor Apu

Committer:
Diletant
Date:
Sun Jun 05 11:03:33 2016 +0000
Revision:
167:bedc0a9d559a
Parent:
156:e68ee0bcdcda
Device & ... update. Not final!!!

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Diletant 149:abbf7663d27d 1 #ifndef __DEVICE_FLASH_H__
Diletant 149:abbf7663d27d 2 #define __DEVICE_FLASH_H__
Diletant 149:abbf7663d27d 3
Diletant 149:abbf7663d27d 4 #include "IAP.h"
Diletant 149:abbf7663d27d 5
Diletant 149:abbf7663d27d 6 //Flash memory page size: 256|512|1024|4096 allowed
Diletant 149:abbf7663d27d 7 #define FLASH_PAGE_SIZE 256
Diletant 149:abbf7663d27d 8
Diletant 149:abbf7663d27d 9 //Hash sector - 8 bytes per hash
Diletant 149:abbf7663d27d 10 typedef struct _DeviceFlashHash {
Diletant 149:abbf7663d27d 11 uint32_t hash; //Hash
Diletant 149:abbf7663d27d 12 uint32_t address; //Address of data located in data sector
Diletant 149:abbf7663d27d 13 //uint16_t size; //Size of data
Diletant 149:abbf7663d27d 14 } DeviceFlashHash;
Diletant 149:abbf7663d27d 15
Diletant 149:abbf7663d27d 16 typedef struct _DeviceFlashSettings {
Diletant 149:abbf7663d27d 17 uint16_t hashSector; //Sector of "hash - data address" pairs
Diletant 149:abbf7663d27d 18 //uint16_t hashPageLength;
Diletant 149:abbf7663d27d 19 uint16_t dataSector; //Sector of data, referenced from hash sector
Diletant 149:abbf7663d27d 20 //uint16_t dataPageLength;
Diletant 149:abbf7663d27d 21 } DeviceFlashSettings;
Diletant 149:abbf7663d27d 22
Diletant 149:abbf7663d27d 23 typedef struct _DeviceFlashWriteOperation {
Diletant 149:abbf7663d27d 24 uint8_t pageBuffer[FLASH_PAGE_SIZE]; //Page buffer
Diletant 149:abbf7663d27d 25 //uint16_t pageLength;
Diletant 149:abbf7663d27d 26 uint16_t pagePosition; //Position in page buffer to write in
Diletant 149:abbf7663d27d 27
Diletant 149:abbf7663d27d 28 uint16_t sector; //Current sector to write data in
Diletant 149:abbf7663d27d 29 uint32_t sectorAddress; //Starting address of sector to write data from page buffer
Diletant 149:abbf7663d27d 30 uint16_t sectorPosition; //Position in sector to write data from page buffer relative to sector start address
Diletant 149:abbf7663d27d 31 uint16_t sectorLength; //Length of current sector
Diletant 149:abbf7663d27d 32
Diletant 149:abbf7663d27d 33 uint32_t bytes; //Count of bytes written
Diletant 149:abbf7663d27d 34 uint32_t maxBytes; //Maximum allowed bytes to write
Diletant 149:abbf7663d27d 35 } DeviceFlashWriteOperation;
Diletant 149:abbf7663d27d 36
Diletant 149:abbf7663d27d 37 typedef struct _DeviceFlashState {
Diletant 149:abbf7663d27d 38 } DeviceFlashState;
Diletant 149:abbf7663d27d 39
Diletant 149:abbf7663d27d 40 typedef struct _DeviceFlash {
Diletant 149:abbf7663d27d 41 DeviceFlashSettings settings;
Diletant 149:abbf7663d27d 42 DeviceFlashState state;
Diletant 149:abbf7663d27d 43 } DeviceFlash;
Diletant 149:abbf7663d27d 44
Diletant 167:bedc0a9d559a 45 void InitFlashDefaultSettings(void);
Diletant 167:bedc0a9d559a 46 void InitFlashState(void);
Diletant 149:abbf7663d27d 47
Diletant 149:abbf7663d27d 48 uint32_t AddressFromSector(uint8_t sector);
Diletant 149:abbf7663d27d 49 uint16_t LengthFromSector(uint8_t sector);
Diletant 149:abbf7663d27d 50 //uint8_t sectorFromAddress(uint32_t address);
Diletant 149:abbf7663d27d 51
Diletant 156:e68ee0bcdcda 52 void DeviceFlashReadAll(void);
Diletant 156:e68ee0bcdcda 53 void DeviceFlashWriteAll(void);
Diletant 149:abbf7663d27d 54
Diletant 149:abbf7663d27d 55 #endif /* __DEVICE_FLASH_H__ */