Skip to content

Commit e900d5a

Browse files
committed
Squash warnings by defining 'NC' as unsigned type
1 parent 73bd5ff commit e900d5a

File tree

8 files changed

+37
-30
lines changed

8 files changed

+37
-30
lines changed

targets/TARGET_Silicon_Labs/TARGET_EFM32/analogin_api.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,10 @@ void analogin_init(analogin_t *obj, PinName pin)
4040

4141
/* Init structure */
4242
obj->adc = (ADC_TypeDef *) pinmap_peripheral(pin, PinMap_ADC);
43-
MBED_ASSERT((int) obj->adc != NC);
43+
MBED_ASSERT((unsigned int) obj->adc != NC);
4444

4545
obj->channel = pin_location(pin, PinMap_ADC);
46-
MBED_ASSERT((int) obj->channel != NC);
46+
MBED_ASSERT((unsigned int) obj->channel != NC);
4747

4848
/* Only initialize the ADC once */
4949
if (!adc_initialized) {

targets/TARGET_Silicon_Labs/TARGET_EFM32/analogout_api.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,11 @@ void analogout_init(dac_t *obj, PinName pin)
4141
{
4242
/* init in-memory structure */
4343
obj->dac = (DAC_TypeDef *) pinmap_peripheral(pin, PinMap_DAC);
44-
MBED_ASSERT((int) obj->dac != NC);
44+
MBED_ASSERT((unsigned int) obj->dac != NC);
4545

4646
obj->channel = pin_location(pin, PinMap_DAC);
47-
MBED_ASSERT((int) obj->channel != NC);
48-
47+
MBED_ASSERT((unsigned int) obj->channel != NC);
48+
4949
pin_mode(pin, Disabled);
5050

5151
if (!dac_initialized) {
@@ -78,7 +78,7 @@ void analogout_free(dac_t *obj)
7878
DAC_InitChannel_TypeDef initChannel = DAC_INITCHANNEL_DEFAULT;
7979
initChannel.enable = false;
8080
DAC_InitChannel(obj->dac, &initChannel, obj->channel);
81-
81+
8282
//Check all channels to see if we can disable the DAC completely
8383
if((DAC0->CH0CTRL & DAC_CH0CTRL_EN) == 0 && (DAC0->CH1CTRL & DAC_CH1CTRL_EN) == 0) {
8484
CMU_ClockEnable(cmuClock_DAC0, false);

targets/TARGET_Silicon_Labs/TARGET_EFM32/common/CommonPinNames.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
PI0 = 8 << 4, PI1, PI2, PI3, PI4, PI5, PI6, PI7, PI8, PI9, PI10, PI11, PI12, PI13, PI14, PI15, \
4242
PJ0 = 9 << 4, PJ1, PJ2, PJ3, PJ4, PJ5, PJ6, PJ7, PJ8, PJ9, PJ10, PJ11, PJ12, PJ13, PJ14, PJ15, \
4343
PK0 = 10 << 4, PK1, PK2, PK3, PK4, PK5, PK6, PK7, PK8, PK9, PK10, PK11, PK12, PK13, PK14, PK15, \
44-
NC = (int) 0xFFFFFFFF
44+
NC = (unsigned int) 0xFFFFFFFFUL
4545

4646
#ifdef __cplusplus
4747
extern "C" {

targets/TARGET_Silicon_Labs/TARGET_EFM32/flash_api.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,17 @@ uint32_t flash_get_sector_size(const flash_t *obj, uint32_t address)
9393
(void)obj;
9494
(void)address;
9595

96+
#if FLASH_BASE > 0
9697
if (address < FLASH_BASE || address >= FLASH_BASE + FLASH_SIZE) {
9798
// Address outside of flash -- invalid sector
9899
return MBED_FLASH_INVALID_SIZE;
99100
}
101+
#else
102+
if (address >= FLASH_BASE + FLASH_SIZE) {
103+
// Address outside of flash -- invalid sector
104+
return MBED_FLASH_INVALID_SIZE;
105+
}
106+
#endif
100107

101108
return FLASH_PAGE_SIZE;
102109
}

targets/TARGET_Silicon_Labs/TARGET_EFM32/i2c_api.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -99,11 +99,11 @@ void i2c_init(i2c_t *obj, PinName sda, PinName scl)
9999
I2CName i2c_sda = (I2CName) pinmap_peripheral(sda, PinMap_I2C_SDA);
100100
I2CName i2c_scl = (I2CName) pinmap_peripheral(scl, PinMap_I2C_SCL);
101101
obj->i2c.i2c = (I2C_TypeDef*) pinmap_merge(i2c_sda, i2c_scl);
102-
MBED_ASSERT(((int) obj->i2c.i2c) != NC);
103-
102+
MBED_ASSERT(((unsigned int) obj->i2c.i2c) != NC);
103+
104104
/* You need both SDA and SCL for I2C, so configuring one of them to NC is illegal */
105-
MBED_ASSERT((uint32_t)sda != (uint32_t)NC);
106-
MBED_ASSERT((uint32_t)scl != (uint32_t)NC);
105+
MBED_ASSERT((unsigned int)sda != NC);
106+
MBED_ASSERT((unsigned int)scl != NC);
107107

108108
/* Enable clock for the peripheral */
109109
CMU_ClockEnable(i2c_get_clock(obj), true);
@@ -116,9 +116,9 @@ void i2c_init(i2c_t *obj, PinName sda, PinName scl)
116116
/* Enable pins at correct location */
117117
#ifdef I2C_ROUTE_SDAPEN
118118
/* Find common location in pinmap */
119-
int loc_sda = pin_location(sda, PinMap_I2C_SDA);
120-
int loc_scl = pin_location(scl, PinMap_I2C_SCL);
121-
int loc = pinmap_merge(loc_sda, loc_scl);
119+
unsigned int loc_sda = pin_location(sda, PinMap_I2C_SDA);
120+
unsigned int loc_scl = pin_location(scl, PinMap_I2C_SCL);
121+
unsigned int loc = pinmap_merge(loc_sda, loc_scl);
122122
MBED_ASSERT(loc != NC);
123123
/* Set location */
124124
obj->i2c.location = I2C_ROUTE_SDAPEN | I2C_ROUTE_SCLPEN | (loc << _I2C_ROUTE_LOCATION_SHIFT);

targets/TARGET_Silicon_Labs/TARGET_EFM32/pwmout_api.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ void pwmout_init(pwmout_t *obj, PinName pin)
214214
if(pwmout_all_inactive()) {
215215
PWM_TIMER->ROUTE |= pinmap_find_function(pin,PinMap_PWM) << _TIMER_ROUTE_LOCATION_SHIFT;
216216
} else {
217-
MBED_ASSERT(PWM_TIMER->ROUTE & _TIMER_ROUTE_LOCATION_MASK == pinmap_find_function(pin,PinMap_PWM) << _TIMER_ROUTE_LOCATION_SHIFT);
217+
MBED_ASSERT((PWM_TIMER->ROUTE & _TIMER_ROUTE_LOCATION_MASK) == pinmap_find_function(pin,PinMap_PWM) << _TIMER_ROUTE_LOCATION_SHIFT);
218218
}
219219
#endif
220220

@@ -230,14 +230,14 @@ void pwmout_free(pwmout_t *obj)
230230
} else {
231231
//This channel was disabled already
232232
}
233-
233+
234234
pwmout_enable_pins(obj, false);
235-
235+
236236
if(pwmout_all_inactive()) {
237237
//Stop timer
238238
PWM_TIMER->CMD = TIMER_CMD_STOP;
239239
while(PWM_TIMER->STATUS & TIMER_STATUS_RUNNING);
240-
240+
241241
//Disable clock
242242
CMU_ClockEnable(PWM_TIMER_CLOCK, false);
243243
}

targets/TARGET_Silicon_Labs/TARGET_EFM32/serial_api.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,7 @@ void serial_preinit(serial_t *obj, PinName tx, PinName rx)
467467
UARTName uart_rx = (UARTName) pinmap_peripheral(rx, PinMap_UART_RX);
468468
/* Check that pins are connected to same UART */
469469
UARTName uart = (UARTName) pinmap_merge(uart_tx, uart_rx);
470-
MBED_ASSERT((int) uart != NC);
470+
MBED_ASSERT((unsigned int) uart != NC);
471471

472472
obj->serial.periph.uart = (USART_TypeDef *) uart;
473473

@@ -478,7 +478,7 @@ void serial_preinit(serial_t *obj, PinName tx, PinName rx)
478478
#if defined(_SILICON_LABS_32B_PLATFORM_1)
479479
/* Check that pins are used by same location for the given UART */
480480
obj->serial.location = pinmap_merge(uart_tx_loc, uart_rx_loc);
481-
MBED_ASSERT(obj->serial.location != (uint32_t)NC);
481+
MBED_ASSERT(obj->serial.location != NC);
482482
#else
483483
obj->serial.location_tx = uart_tx_loc;
484484
obj->serial.location_rx = uart_rx_loc;
@@ -588,25 +588,25 @@ static void serial_set_route(serial_t *obj)
588588
if(LEUART_REF_VALID(obj->serial.periph.leuart)) {
589589
#ifdef _LEUART_ROUTE_LOCATION_SHIFT
590590
obj->serial.periph.leuart->ROUTE = (obj->serial.location << _LEUART_ROUTE_LOCATION_SHIFT);
591-
if(obj->serial.tx_pin != (uint32_t)NC) {
591+
if(obj->serial.tx_pin != NC) {
592592
obj->serial.periph.leuart->ROUTE |= LEUART_ROUTE_TXPEN;
593593
} else {
594594
obj->serial.periph.leuart->ROUTE &= ~LEUART_ROUTE_TXPEN;
595595
}
596-
if(obj->serial.rx_pin != (uint32_t)NC) {
596+
if(obj->serial.rx_pin != NC) {
597597
obj->serial.periph.leuart->ROUTE |= LEUART_ROUTE_RXPEN;
598598
} else {
599599
obj->serial.periph.leuart->CMD = LEUART_CMD_RXBLOCKEN;
600600
obj->serial.periph.leuart->ROUTE &= ~LEUART_ROUTE_RXPEN;
601601
}
602602
#else
603-
if(obj->serial.location_tx != (uint32_t)NC) {
603+
if(obj->serial.location_tx != NC) {
604604
obj->serial.periph.leuart->ROUTELOC0 = (obj->serial.periph.leuart->ROUTELOC0 & (~_LEUART_ROUTELOC0_TXLOC_MASK)) | (obj->serial.location_tx << _LEUART_ROUTELOC0_TXLOC_SHIFT);
605605
obj->serial.periph.leuart->ROUTEPEN = (obj->serial.periph.leuart->ROUTEPEN & (~_LEUART_ROUTEPEN_TXPEN_MASK)) | LEUART_ROUTEPEN_TXPEN;
606606
} else {
607607
obj->serial.periph.leuart->ROUTEPEN = (obj->serial.periph.leuart->ROUTEPEN & (~_LEUART_ROUTEPEN_TXPEN_MASK));
608608
}
609-
if(obj->serial.location_rx != (uint32_t)NC) {
609+
if(obj->serial.location_rx != NC) {
610610
obj->serial.periph.leuart->ROUTELOC0 = (obj->serial.periph.leuart->ROUTELOC0 & (~_LEUART_ROUTELOC0_RXLOC_MASK)) | (obj->serial.location_rx << _LEUART_ROUTELOC0_RXLOC_SHIFT);
611611
obj->serial.periph.leuart->ROUTEPEN = (obj->serial.periph.leuart->ROUTEPEN & (~_LEUART_ROUTEPEN_RXPEN_MASK)) | LEUART_ROUTEPEN_RXPEN;
612612
} else {
@@ -617,25 +617,25 @@ static void serial_set_route(serial_t *obj)
617617
} else {
618618
#ifdef _USART_ROUTE_LOCATION_SHIFT
619619
obj->serial.periph.uart->ROUTE = (obj->serial.location << _LEUART_ROUTE_LOCATION_SHIFT);
620-
if(obj->serial.tx_pin != (uint32_t)NC) {
620+
if(obj->serial.tx_pin != NC) {
621621
obj->serial.periph.uart->ROUTE |= USART_ROUTE_TXPEN;
622622
} else {
623623
obj->serial.periph.uart->ROUTE &= ~USART_ROUTE_TXPEN;
624624
}
625-
if(obj->serial.rx_pin != (uint32_t)NC) {
625+
if(obj->serial.rx_pin != NC) {
626626
obj->serial.periph.uart->ROUTE |= USART_ROUTE_RXPEN;
627627
} else {
628628
obj->serial.periph.uart->CMD = USART_CMD_RXBLOCKEN;
629629
obj->serial.periph.uart->ROUTE &= ~USART_ROUTE_RXPEN;
630630
}
631631
#else
632-
if(obj->serial.location_tx != (uint32_t)NC) {
632+
if(obj->serial.location_tx != NC) {
633633
obj->serial.periph.uart->ROUTELOC0 = (obj->serial.periph.uart->ROUTELOC0 & (~_USART_ROUTELOC0_TXLOC_MASK)) | (obj->serial.location_tx << _USART_ROUTELOC0_TXLOC_SHIFT);
634634
obj->serial.periph.uart->ROUTEPEN = (obj->serial.periph.uart->ROUTEPEN & (~_USART_ROUTEPEN_TXPEN_MASK)) | USART_ROUTEPEN_TXPEN;
635635
} else {
636636
obj->serial.periph.uart->ROUTEPEN = (obj->serial.periph.uart->ROUTEPEN & (~_USART_ROUTEPEN_TXPEN_MASK));
637637
}
638-
if(obj->serial.location_rx != (uint32_t)NC) {
638+
if(obj->serial.location_rx != NC) {
639639
obj->serial.periph.uart->ROUTELOC0 = (obj->serial.periph.uart->ROUTELOC0 & (~_USART_ROUTELOC0_RXLOC_MASK)) | (obj->serial.location_rx << _USART_ROUTELOC0_RXLOC_SHIFT);
640640
obj->serial.periph.uart->ROUTEPEN = (obj->serial.periph.uart->ROUTEPEN & (~_USART_ROUTEPEN_RXPEN_MASK)) | USART_ROUTEPEN_RXPEN;
641641
} else {

targets/TARGET_Silicon_Labs/TARGET_EFM32/spi_api.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ void spi_preinit(spi_t *obj, PinName mosi, PinName miso, PinName clk, PinName cs
150150
SPIName spi_ctrl = (SPIName) pinmap_merge(spi_clk, spi_cs);
151151

152152
obj->spi.spi = (USART_TypeDef *) pinmap_merge(spi_data, spi_ctrl);
153-
MBED_ASSERT((int) obj->spi.spi != NC);
153+
MBED_ASSERT((unsigned int) obj->spi.spi != NC);
154154

155155
if (cs != NC) { /* Slave mode */
156156
obj->spi.master = false;
@@ -1306,7 +1306,7 @@ uint32_t spi_irq_handler_asynch(spi_t* obj)
13061306
rx_pointer = ((uint16_t *)obj->rx_buff.buffer) + obj->rx_buff.pos;
13071307
} else {
13081308
rx_pointer = ((uint8_t *)obj->rx_buff.buffer) + obj->rx_buff.pos;
1309-
}
1309+
}
13101310
}
13111311
uint32_t rx_length = obj->rx_buff.length - obj->rx_buff.pos;
13121312

0 commit comments

Comments
 (0)