Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LPC1768: RAM end adjust fix #5189

Merged
merged 3 commits into from
Sep 25, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ define symbol __ICFEDIT_region_ROM_end__ = 0x0007FFFF;
define symbol __ICFEDIT_region_NVIC_start__ = 0x10000000;
define symbol __ICFEDIT_region_NVIC_end__ = 0x100000C7;
define symbol __ICFEDIT_region_RAM_start__ = 0x100000C8;
define symbol __ICFEDIT_region_RAM_end__ = 0x10007FDF;
define symbol __ICFEDIT_region_RAM_end__ = 0x10007FE0;

/*-Sizes-*/
/*Heap 1/4 of ram and stack 1/8*/
Expand Down
12 changes: 6 additions & 6 deletions targets/TARGET_NXP/TARGET_LPC176X/device/flash_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ int32_t flash_erase_sector(flash_t *obj, uint32_t address)

n = GetSecNum(address); // Get Sector Number

core_util_critical_section_enter();
IAP.cmd = 50;// Prepare Sector for Erase
IAP.par[0] = n;// Start Sector
IAP.par[1] = n;// End Sector
Expand All @@ -98,6 +99,7 @@ int32_t flash_erase_sector(flash_t *obj, uint32_t address)
IAP.par[1] = n;// End Sector
IAP.par[2] = CCLK;// CCLK in kHz
IAP_Call (&IAP.cmd, &IAP.stat);// Call IAP Command
core_util_critical_section_exit();
if (IAP.stat) {
return (1); // Command Failed
}
Expand All @@ -106,18 +108,16 @@ int32_t flash_erase_sector(flash_t *obj, uint32_t address)

}

/* IAP Call */
typedef void (*IAP_Entry) (unsigned long *cmd, unsigned long *stat);
#define IAP_Call ((IAP_Entry) 0x1FFF1FF1)

int32_t flash_program_page(flash_t *obj, uint32_t address,
const uint8_t *data, uint32_t size)
{
unsigned long n;
uint8_t *alignedData = 0;
// always malloc outside critical section
uint8_t *alignedData = malloc(size);

n = GetSecNum(address); // Get Sector Number

core_util_critical_section_enter();
IAP.cmd = 50;// Prepare Sector for Write
IAP.par[0] = n;// Start Sector
IAP.par[1] = n;// End Sector
Expand All @@ -132,14 +132,14 @@ int32_t flash_program_page(flash_t *obj, uint32_t address,
if ((unsigned long)data%4==0) { // Word boundary
IAP.par[1] = (unsigned long)data;// Source RAM Address
} else {
alignedData = malloc(size);
memcpy(alignedData,data,size);
IAP.par[1] = (unsigned long)alignedData; // Source RAM Address
}

IAP.par[2] = 1024; // Fixed Page Size
IAP.par[3] = CCLK;// CCLK in kHz
IAP_Call (&IAP.cmd, &IAP.stat);// Call IAP Command
core_util_critical_section_exit();

if(alignedData !=0) { // We allocated our own memory
free(alignedData);
Expand Down