Skip to content

Commit 96ea3db

Browse files
committed
Merge pull request #66 from dinau/lpc2368_mod
LPC2368 mod
2 parents 061259c + efbc524 commit 96ea3db

File tree

7 files changed

+16
-8
lines changed

7 files changed

+16
-8
lines changed

libraries/mbed/common/retarget.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -439,13 +439,20 @@ extern "C" int __end__;
439439
#undef errno
440440
extern "C" int errno;
441441

442+
// For ARM7 only
443+
register unsigned char * stack_ptr __asm ("sp");
444+
442445
// Dynamic memory allocation related syscall.
443446
extern "C" caddr_t _sbrk(int incr) {
444447
static unsigned char* heap = (unsigned char*)&__end__;
445448
unsigned char* prev_heap = heap;
446449
unsigned char* new_heap = heap + incr;
447450

451+
#ifdef __get_MSP
448452
if (new_heap >= (unsigned char*)__get_MSP()) {
453+
#else
454+
if (new_heap >= stack_ptr) {
455+
#endif
449456
errno = ENOMEM;
450457
return (caddr_t)-1;
451458
}

libraries/mbed/targets/cmsis/TARGET_NXP/TARGET_LPC23XX/TOOLCHAIN_GCC_ARM/LPC2368.ld

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ SECTIONS
143143
. = ALIGN( 8 ) ;
144144
__heap_start__ = . ;
145145
end = . ;
146+
__end__ = . ;
146147

147148
.stab 0 (NOLOAD) : { *(.stab) }
148149
.stabstr 0 (NOLOAD) : { *(.stabstr) }

libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC23XX/analogin_api.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ static const PinMap PinMap_ADC[] = {
4242

4343
void analogin_init(analogin_t *obj, PinName pin) {
4444
obj->adc = (ADCName)pinmap_peripheral(pin, PinMap_ADC);
45-
if (obj->adc == (uint32_t)NC) {
45+
if (obj->adc == (ADCName)NC) {
4646
error("ADC pin mapping failed");
4747
}
4848

libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC23XX/analogout_api.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ static const PinMap PinMap_DAC[] = {
2525

2626
void analogout_init(dac_t *obj, PinName pin) {
2727
obj->dac = (DACName)pinmap_peripheral(pin, PinMap_DAC);
28-
if (obj->dac == (uint32_t)NC) {
28+
if (obj->dac == (DACName)NC) {
2929
error("DAC pin mapping failed");
3030
}
3131

libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC23XX/ethernet_api.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -697,7 +697,7 @@ int ethernet_receive() {
697697
if(receive_idx == -1) {
698698
receive_idx = LPC_EMAC->RxConsumeIndex;
699699
} else {
700-
while(!(rxstat[receive_idx].Info & RINFO_LAST_FLAG) && (receive_idx != LPC_EMAC->RxProduceIndex)) {
700+
while(!(rxstat[receive_idx].Info & RINFO_LAST_FLAG) && ((uint32_t)receive_idx != LPC_EMAC->RxProduceIndex)) {
701701
receive_idx = rinc(receive_idx, NUM_RX_FRAG);
702702
}
703703
unsigned int info = rxstat[receive_idx].Info;
@@ -713,7 +713,7 @@ int ethernet_receive() {
713713
LPC_EMAC->RxConsumeIndex = receive_idx;
714714
}
715715

716-
if(receive_idx == LPC_EMAC->RxProduceIndex) {
716+
if((uint32_t)receive_idx == LPC_EMAC->RxProduceIndex) {
717717
receive_idx = -1;
718718
return 0;
719719
}
@@ -762,7 +762,7 @@ int ethernet_read(char *data, int dlen) {
762762
void *pdst, *psrc;
763763
int doff = 0;
764764

765-
if(receive_idx == LPC_EMAC->RxProduceIndex || receive_idx == -1) {
765+
if((uint32_t)receive_idx == LPC_EMAC->RxProduceIndex || receive_idx == -1) {
766766
return 0;
767767
}
768768

libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC23XX/pinmap.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
#include "error.h"
1818

1919
void pin_function(PinName pin, int function) {
20-
if (pin == (uint32_t)NC) return;
20+
if (pin == (PinName)NC) return;
2121

2222
uint32_t pin_number = (uint32_t)pin - (uint32_t)P0_0;
2323
int index = pin_number >> 4;
@@ -28,7 +28,7 @@ void pin_function(PinName pin, int function) {
2828
}
2929

3030
void pin_mode(PinName pin, PinMode mode) {
31-
if (pin == (uint32_t)NC) { return; }
31+
if (pin == (PinName)NC) { return; }
3232

3333
uint32_t pin_number = (uint32_t)pin - (uint32_t)P0_0;
3434
int index = pin_number >> 5;

libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC23XX/pwmout_api.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ static unsigned int pwm_clock_mhz;
5757
void pwmout_init(pwmout_t* obj, PinName pin) {
5858
// determine the channel
5959
PWMName pwm = (PWMName)pinmap_peripheral(pin, PinMap_PWM);
60-
if (pwm == (uint32_t)NC)
60+
if (pwm == (PWMName)NC)
6161
error("PwmOut pin mapping failed");
6262

6363
obj->pwm = pwm;

0 commit comments

Comments
 (0)