.
Dependencies: mbed EthernetInterface mbed-rtos
Fork of Bootloader_K64F by
FreescaleIAP/FreescaleIAP.h@10:fb5121bcc468, 2016-04-24 (annotated)
- Committer:
- Sissors
- Date:
- Sun Apr 24 12:46:37 2016 +0000
- Revision:
- 10:fb5121bcc468
- Parent:
- 8:00cefe0d59ed
I just committed already
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Sissors | 8:00cefe0d59ed | 1 | #ifndef FREESCALEIAP_H |
Sissors | 8:00cefe0d59ed | 2 | #define FREESCALEIAP_H |
Sissors | 8:00cefe0d59ed | 3 | |
Sissors | 8:00cefe0d59ed | 4 | #include "mbed.h" |
Sissors | 8:00cefe0d59ed | 5 | |
Sissors | 8:00cefe0d59ed | 6 | #if defined(TARGET_KLXX) | defined(TARGET_K20D50M) |
Sissors | 8:00cefe0d59ed | 7 | #define SECTOR_SIZE 1024 |
Sissors | 8:00cefe0d59ed | 8 | #elif (TARGET_K22F) |
Sissors | 8:00cefe0d59ed | 9 | #define SECTOR_SIZE 2048 |
Sissors | 8:00cefe0d59ed | 10 | #elif defined(TARGET_K64F) |
Sissors | 8:00cefe0d59ed | 11 | #define SECTOR_SIZE 4096 |
Sissors | 8:00cefe0d59ed | 12 | #else |
Sissors | 8:00cefe0d59ed | 13 | #warning FreescaleIAP unknown target, using default 1024B |
Sissors | 8:00cefe0d59ed | 14 | #define SECTOR_SIZE 1024 |
Sissors | 8:00cefe0d59ed | 15 | #endif |
Sissors | 8:00cefe0d59ed | 16 | |
Sissors | 8:00cefe0d59ed | 17 | enum IAPCode { |
Sissors | 8:00cefe0d59ed | 18 | BoundaryError = -99, //Commands may not span several sectors |
Sissors | 8:00cefe0d59ed | 19 | AlignError, //Data must be aligned on longword (two LSBs zero) |
Sissors | 8:00cefe0d59ed | 20 | ProtectionError, //Flash sector is protected |
Sissors | 8:00cefe0d59ed | 21 | AccessError, //Something went wrong |
Sissors | 8:00cefe0d59ed | 22 | CollisionError, //During writing something tried to flash which was written to |
Sissors | 8:00cefe0d59ed | 23 | LengthError, //The length must be multiples of 4 |
Sissors | 8:00cefe0d59ed | 24 | RuntimeError, |
Sissors | 8:00cefe0d59ed | 25 | EraseError, //The flash was not erased before writing to it |
Sissors | 8:00cefe0d59ed | 26 | Success = 0 |
Sissors | 8:00cefe0d59ed | 27 | }; |
Sissors | 8:00cefe0d59ed | 28 | |
Sissors | 8:00cefe0d59ed | 29 | /** Erase a flash sector |
Sissors | 8:00cefe0d59ed | 30 | * |
Sissors | 8:00cefe0d59ed | 31 | * The size erased depends on the used device |
Sissors | 8:00cefe0d59ed | 32 | * |
Sissors | 8:00cefe0d59ed | 33 | * @param address address in the sector which needs to be erased |
Sissors | 8:00cefe0d59ed | 34 | * @param return Success if no errors were encountered, otherwise one of the error states |
Sissors | 8:00cefe0d59ed | 35 | */ |
Sissors | 8:00cefe0d59ed | 36 | IAPCode erase_sector(int address); |
Sissors | 8:00cefe0d59ed | 37 | |
Sissors | 8:00cefe0d59ed | 38 | /** Program flash |
Sissors | 8:00cefe0d59ed | 39 | * |
Sissors | 8:00cefe0d59ed | 40 | * Before programming the used area needs to be erased. The erase state is checked |
Sissors | 8:00cefe0d59ed | 41 | * before programming, and will return an error if not erased. |
Sissors | 8:00cefe0d59ed | 42 | * |
Sissors | 8:00cefe0d59ed | 43 | * @param address starting address where the data needs to be programmed (must be longword alligned: two LSBs must be zero) |
Sissors | 8:00cefe0d59ed | 44 | * @param data pointer to array with the data to program |
Sissors | 8:00cefe0d59ed | 45 | * @param length number of bytes to program (must be a multiple of 4. must be a multiple of 8 when K64F) |
Sissors | 8:00cefe0d59ed | 46 | * @param return Success if no errors were encountered, otherwise one of the error states |
Sissors | 8:00cefe0d59ed | 47 | */ |
Sissors | 8:00cefe0d59ed | 48 | IAPCode program_flash(int address, char *data, unsigned int length); |
Sissors | 8:00cefe0d59ed | 49 | |
Sissors | 8:00cefe0d59ed | 50 | /** |
Sissors | 8:00cefe0d59ed | 51 | * Returns size of flash memory |
Sissors | 8:00cefe0d59ed | 52 | * |
Sissors | 8:00cefe0d59ed | 53 | * This is the first address which is not flash |
Sissors | 8:00cefe0d59ed | 54 | * |
Sissors | 8:00cefe0d59ed | 55 | * @param return length of flash memory in bytes |
Sissors | 8:00cefe0d59ed | 56 | */ |
Sissors | 8:00cefe0d59ed | 57 | uint32_t flash_size(void); |
Sissors | 8:00cefe0d59ed | 58 | |
Sissors | 8:00cefe0d59ed | 59 | #endif |