Skip to content

Commit

Permalink
Merge pull request #66 from dinau/lpc2368_mod
Browse files Browse the repository at this point in the history
LPC2368 mod
  • Loading branch information
emilmont committed Sep 16, 2013
2 parents 061259c + efbc524 commit 96ea3db
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 8 deletions.
7 changes: 7 additions & 0 deletions libraries/mbed/common/retarget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -439,13 +439,20 @@ extern "C" int __end__;
#undef errno
extern "C" int errno;

// For ARM7 only
register unsigned char * stack_ptr __asm ("sp");

// Dynamic memory allocation related syscall.
extern "C" caddr_t _sbrk(int incr) {
static unsigned char* heap = (unsigned char*)&__end__;
unsigned char* prev_heap = heap;
unsigned char* new_heap = heap + incr;

#ifdef __get_MSP
if (new_heap >= (unsigned char*)__get_MSP()) {
#else
if (new_heap >= stack_ptr) {
#endif
errno = ENOMEM;
return (caddr_t)-1;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ SECTIONS
. = ALIGN( 8 ) ;
__heap_start__ = . ;
end = . ;
__end__ = . ;

.stab 0 (NOLOAD) : { *(.stab) }
.stabstr 0 (NOLOAD) : { *(.stabstr) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ static const PinMap PinMap_ADC[] = {

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ static const PinMap PinMap_DAC[] = {

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -697,7 +697,7 @@ int ethernet_receive() {
if(receive_idx == -1) {
receive_idx = LPC_EMAC->RxConsumeIndex;
} else {
while(!(rxstat[receive_idx].Info & RINFO_LAST_FLAG) && (receive_idx != LPC_EMAC->RxProduceIndex)) {
while(!(rxstat[receive_idx].Info & RINFO_LAST_FLAG) && ((uint32_t)receive_idx != LPC_EMAC->RxProduceIndex)) {
receive_idx = rinc(receive_idx, NUM_RX_FRAG);
}
unsigned int info = rxstat[receive_idx].Info;
Expand All @@ -713,7 +713,7 @@ int ethernet_receive() {
LPC_EMAC->RxConsumeIndex = receive_idx;
}

if(receive_idx == LPC_EMAC->RxProduceIndex) {
if((uint32_t)receive_idx == LPC_EMAC->RxProduceIndex) {
receive_idx = -1;
return 0;
}
Expand Down Expand Up @@ -762,7 +762,7 @@ int ethernet_read(char *data, int dlen) {
void *pdst, *psrc;
int doff = 0;

if(receive_idx == LPC_EMAC->RxProduceIndex || receive_idx == -1) {
if((uint32_t)receive_idx == LPC_EMAC->RxProduceIndex || receive_idx == -1) {
return 0;
}

Expand Down
4 changes: 2 additions & 2 deletions libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC23XX/pinmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#include "error.h"

void pin_function(PinName pin, int function) {
if (pin == (uint32_t)NC) return;
if (pin == (PinName)NC) return;

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

void pin_mode(PinName pin, PinMode mode) {
if (pin == (uint32_t)NC) { return; }
if (pin == (PinName)NC) { return; }

uint32_t pin_number = (uint32_t)pin - (uint32_t)P0_0;
int index = pin_number >> 5;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ static unsigned int pwm_clock_mhz;
void pwmout_init(pwmout_t* obj, PinName pin) {
// determine the channel
PWMName pwm = (PWMName)pinmap_peripheral(pin, PinMap_PWM);
if (pwm == (uint32_t)NC)
if (pwm == (PWMName)NC)
error("PwmOut pin mapping failed");

obj->pwm = pwm;
Expand Down

0 comments on commit 96ea3db

Please sign in to comment.