Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: 18_PT1000 RDA5807M-FM-Radio flashaccess TF_conops_BAEFLAGIMAN ... more
Diff: FreescaleIAP.cpp
- Revision:
- 2:70ade1638644
- Parent:
- 1:702fd2d53c17
- Child:
- 3:0f127a8ba79b
--- a/FreescaleIAP.cpp Sun May 11 13:01:44 2014 +0000
+++ b/FreescaleIAP.cpp Mon May 12 19:45:04 2014 +0000
@@ -1,6 +1,6 @@
#include "FreescaleIAP.h"
-#define IAPDEBUG
+//#define IAPDEBUG
enum FCMD {
Read1s = 0x01,
@@ -61,6 +61,13 @@
return Success;
}
+uint32_t flash_size(void) {
+ uint32_t retval = (SIM->FCFG2 & 0x7F000000u) >> (24-13);
+ if (SIM->FCFG2 & (1<<23)) //Possible second flash bank
+ retval += (SIM->FCFG2 & 0x007F0000u) >> (16-13);
+ return retval;
+}
+
IAPCode program_word(int address, char *data) {
#ifdef IAPDEBUG
printf("IAP: Programming word at %x, %d - %d - %d - %d\r\n", address, data[0], data[1], data[2], data[3]);
@@ -96,8 +103,8 @@
/* Check if no flash boundary is violated
Returns true on violation */
bool check_boundary(int address, unsigned int length) {
- address &= ~1023;
- int temp = (address+length - 1) & (~1023);
+ int temp = (address+length - 1) / SECTOR_SIZE;
+ address /= SECTOR_SIZE;
bool retval = (address != temp);
#ifdef IAPDEBUG
if (retval)
