#define | FLASH_WRITE_SIZE (64ul) |
Device specific minimum flash block size which can be written. | |
#define | FLASH_ERASE_SIZE (1024ul) |
Device specific minimum flash block size which can be erased. | |
#define | INTERNAL_FLASH_SIZE (1024ul*128ul) |
The internal flash size for the pic18f97j60. | |
#define | TOTAL_MEMORY_SIZE (INTERNAL_FLASH_SIZE - BOOTLOADER_SIZE) |
The memory size takes in account the existing bootloader. | |
#define | BOOTLOADER_SIZE (8ul*1024ul) |
Size of the bootloader code. | |
void | RawEraseFlashBlock (auto uint32_t Address) |
Erases the specified page (size of FLASH_ERASE_SIZE). | |
BOOL | RawWriteFlashBlock (auto uint32_t Address, auto uint8_t *BlockData, auto uint8_t *StatusData) |
Writes one FLASH_WRITE_SIZE block of data to the Flash memory. |
void RawEraseFlashBlock | ( | auto uint32_t | Address | ) |
Erases the specified page (size of FLASH_ERASE_SIZE).
This function is bootloader safe. If an attempt to erase the addresses containing the bootloader is made, the function will not perform the erase.
Address | Begining byte address to start erasing at. Note that this address must be page aligned (ie: evenly divisible by FLASH_ERASE_SIZE). |
BOOL RawWriteFlashBlock | ( | auto uint32_t | Address, | |
auto uint8_t * | BlockData, | |||
auto uint8_t * | StatusData | |||
) |
Writes one FLASH_WRITE_SIZE block of data to the Flash memory.
The memory must be erased prior to writing.
Address | Location to write to. This address MUST be an integer multiple of the FLASH_WRITE_SIZE constant. | |
BlockData | Pointer to an array of bytes to write. The array is assumed to be exactly FLASH_WRITE_SIZE in length (or longer). If longer, only the first FLASH_WRITE_SIZE bytes will be written. You must call WriteFlashBlock() again with an updated Address to write more bytes. | |
StatusData | Pointer to a byte array of size FLASH_WRITE_SIZE/8 which will be written with the results of the write. Each bit in the array represents one data byte successfully or unsuccessfully written. If the bit is set, the write was successful. Pointer can be NULL if individual byte status data is not needed. |
TRUE | If the write was successful or no write was needed because the data was already matching. | |
FALSE | If the write failed either because some other data was already in the memory (need to perform Erase first), or if, following the write, the data did not verify correctly (may have run out of Flash Erase-Write cycles). |