This program hasn't been modified yet it breaks my FRDMK64 board

Dependencies:   mbed

Committer:
STEPHER2
Date:
Fri Jan 06 11:11:18 2017 +0000
Revision:
1:03c972a91ee2
Parent:
0:b963b1cb4a1a
Latest with flash clock enable

Who changed what in which revision?

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