.
Dependencies: mbed EthernetInterface mbed-rtos
Fork of Bootloader_K64F by
Diff: FreescaleIAP/FreescaleIAP.h
- Revision:
- 8:00cefe0d59ed
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/FreescaleIAP/FreescaleIAP.h Sat Apr 23 18:24:07 2016 +0000 @@ -0,0 +1,59 @@ +#ifndef FREESCALEIAP_H +#define FREESCALEIAP_H + +#include "mbed.h" + +#if defined(TARGET_KLXX) | defined(TARGET_K20D50M) +#define SECTOR_SIZE 1024 +#elif (TARGET_K22F) +#define SECTOR_SIZE 2048 +#elif defined(TARGET_K64F) +#define SECTOR_SIZE 4096 +#else +#warning FreescaleIAP unknown target, using default 1024B +#define SECTOR_SIZE 1024 +#endif + +enum IAPCode { + BoundaryError = -99, //Commands may not span several sectors + AlignError, //Data must be aligned on longword (two LSBs zero) + ProtectionError, //Flash sector is protected + AccessError, //Something went wrong + CollisionError, //During writing something tried to flash which was written to + LengthError, //The length must be multiples of 4 + RuntimeError, + EraseError, //The flash was not erased before writing to it + Success = 0 + }; + +/** Erase a flash sector + * + * The size erased depends on the used device + * + * @param address address in the sector which needs to be erased + * @param return Success if no errors were encountered, otherwise one of the error states + */ +IAPCode erase_sector(int address); + +/** Program flash + * + * Before programming the used area needs to be erased. The erase state is checked + * before programming, and will return an error if not erased. + * + * @param address starting address where the data needs to be programmed (must be longword alligned: two LSBs must be zero) + * @param data pointer to array with the data to program + * @param length number of bytes to program (must be a multiple of 4. must be a multiple of 8 when K64F) + * @param return Success if no errors were encountered, otherwise one of the error states + */ +IAPCode program_flash(int address, char *data, unsigned int length); + +/** + * Returns size of flash memory + * + * This is the first address which is not flash + * + * @param return length of flash memory in bytes + */ +uint32_t flash_size(void); + +#endif \ No newline at end of file