Skip to content

Commit

Permalink
Merge pull request #24 from adamgreen/gccWarnFixMbedSDK
Browse files Browse the repository at this point in the history
Update mbed SDK sources to silence GCC warnings
  • Loading branch information
bogdanm committed Aug 13, 2013
2 parents 0e013cf + 692e666 commit 5ae0e91
Show file tree
Hide file tree
Showing 18 changed files with 26 additions and 23 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,6 @@ uVision Project/

*.bak
debug.log

# Ignore OS X Desktop Services Store files
.DS_Store
2 changes: 1 addition & 1 deletion libraries/mbed/common/pinmap_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ uint32_t pinmap_merge(uint32_t a, uint32_t b) {
}

uint32_t pinmap_peripheral(PinName pin, const PinMap* map) {
if (pin == (uint32_t)NC)
if (pin == (PinName)NC)
return (uint32_t)NC;

while (map->pin != NC) {
Expand Down
2 changes: 1 addition & 1 deletion libraries/mbed/common/wait_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,5 @@ void wait_ms(int ms) {

void wait_us(int us) {
uint32_t start = us_ticker_read();
while ((us_ticker_read() - start) < us);
while ((us_ticker_read() - start) < (uint32_t)us);
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,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 @@ -28,7 +28,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 @@ -215,7 +215,7 @@ void i2c_frequency(i2c_t *obj, int hz) {
for (i = 1; i < 5; i*=2) {
for (j = 0; j < 0x40; j++) {
ref = PCLK / (i*ICR[j]);
if (ref > hz)
if (ref > (uint32_t)hz)
continue;
error = hz - ref;
if (error < p_error) {
Expand Down Expand Up @@ -392,7 +392,7 @@ int i2c_slave_read(i2c_t *obj, char *data, int length) {
}

int i2c_slave_write(i2c_t *obj, const char *data, int length) {
uint32_t i, count = 0;
int i, count = 0;

// set tx mode
obj->i2c->C1 |= I2C_C1_TX_MASK;
Expand Down
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 port_n = (uint32_t)pin >> PORT_SHIFT;
uint32_t pin_n = (uint32_t)(pin & 0x7C) >> 2;
Expand All @@ -30,7 +30,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; }

__IO uint32_t* pin_pcr = (__IO uint32_t*)(PORTA_BASE + pin);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ static const PinMap PinMap_PWM[] = {
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");

unsigned int port = (unsigned int)pin >> PORT_SHIFT;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ void spi_frequency(spi_t *obj, int hz) {
divisor = 2;
for (spr = 0; spr <= 8; spr++, divisor *= 2) {
ref = PCLK / (prescaler*divisor);
if (ref > hz)
if (ref > (uint32_t)hz)
continue;
error = hz - ref;
if (error < p_error) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,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 @@ -20,7 +20,7 @@
#define LPC_IOCON1_BASE (LPC_IOCON_BASE + 0x60)

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;

Expand All @@ -33,7 +33,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 drain = ((uint32_t) mode & (uint32_t) OpenDrain) >> 2;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,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
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,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 @@ -26,7 +26,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 @@ -164,7 +164,7 @@ void can_irq_set(can_t *obj, CanIrqType type, uint32_t enable) {
obj->dev->MOD &= ~(1);

// Enable NVIC if at least 1 interrupt is active
if(LPC_CAN1->IER | LPC_CAN2->IER != 0) {
if(LPC_CAN1->IER | LPC_CAN2->IER) {
NVIC_SetVector(CAN_IRQn, (uint32_t) &can_irq_n);
NVIC_EnableIRQ(CAN_IRQn);
}
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_LPC176X/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 5ae0e91

Please sign in to comment.