Merge pull request #24 from adamgreen/gccWarnFixMbedSDK

Update mbed SDK sources to silence GCC warnings
pull/26/head^2
Bogdan Marinescu 2013-08-13 03:04:42 -07:00
commit 5ae0e913b1
18 changed files with 26 additions and 23 deletions

3
.gitignore vendored
View File

@ -45,3 +45,6 @@ uVision Project/
*.bak
debug.log
# Ignore OS X Desktop Services Store files
.DS_Store

View File

@ -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) {

View File

@ -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);
}

View File

@ -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");
}

View File

@ -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");
}

View File

@ -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) {
@ -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;

View File

@ -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;
@ -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);

View File

@ -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;

View File

@ -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) {

View File

@ -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");
}

View File

@ -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;
@ -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;

View File

@ -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;

View File

@ -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");
}

View File

@ -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");
}

View File

@ -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);
}

View File

@ -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;
@ -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;
}
@ -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;
}

View File

@ -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;
@ -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;

View File

@ -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;