Skip to content

Commit 3759d03

Browse files
Merge pull request #5189 from 0xc0170/fix_lpc1768_iarramend
LPC1768: RAM end adjust fix
2 parents 482c2ae + 9a191de commit 3759d03

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

targets/TARGET_NXP/TARGET_LPC176X/device/TOOLCHAIN_IAR/LPC17xx.icf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ define symbol __ICFEDIT_region_ROM_end__ = 0x0007FFFF;
99
define symbol __ICFEDIT_region_NVIC_start__ = 0x10000000;
1010
define symbol __ICFEDIT_region_NVIC_end__ = 0x100000C7;
1111
define symbol __ICFEDIT_region_RAM_start__ = 0x100000C8;
12-
define symbol __ICFEDIT_region_RAM_end__ = 0x10007FDF;
12+
define symbol __ICFEDIT_region_RAM_end__ = 0x10007FE0;
1313

1414
/*-Sizes-*/
1515
/*Heap 1/4 of ram and stack 1/8*/

targets/TARGET_NXP/TARGET_LPC176X/device/flash_api.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ int32_t flash_erase_sector(flash_t *obj, uint32_t address)
8585

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

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

107109
}
108110

109-
/* IAP Call */
110-
typedef void (*IAP_Entry) (unsigned long *cmd, unsigned long *stat);
111-
#define IAP_Call ((IAP_Entry) 0x1FFF1FF1)
112-
113111
int32_t flash_program_page(flash_t *obj, uint32_t address,
114112
const uint8_t *data, uint32_t size)
115113
{
116114
unsigned long n;
117-
uint8_t *alignedData = 0;
115+
// always malloc outside critical section
116+
uint8_t *alignedData = malloc(size);
118117

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

120+
core_util_critical_section_enter();
121121
IAP.cmd = 50;// Prepare Sector for Write
122122
IAP.par[0] = n;// Start Sector
123123
IAP.par[1] = n;// End Sector
@@ -132,14 +132,14 @@ int32_t flash_program_page(flash_t *obj, uint32_t address,
132132
if ((unsigned long)data%4==0) { // Word boundary
133133
IAP.par[1] = (unsigned long)data;// Source RAM Address
134134
} else {
135-
alignedData = malloc(size);
136135
memcpy(alignedData,data,size);
137136
IAP.par[1] = (unsigned long)alignedData; // Source RAM Address
138137
}
139138

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

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

0 commit comments

Comments
 (0)