Cast to matching enumeration type instead of uint32_t

This commit targets the LPC11U24 code, whereas a previous one
targetted similar issues in the LPC1768 mbed HAL code.

These changes were made to silence GCC warnings and fix potential bugs
where they would never be equal when the enumeration wasn't a 32-bit
type.

For example, pinmap.c used to contain this code:
    if (pin == (uint32_t)NC) return;
I switched it to:
    if (pin == (PinName)NC) return;

I wonder why this casting to uint32_t was done in the first place?
Maybe another supported compiler requires it?
pull/24/head
Adam Green 2013-08-12 15:40:35 -07:00
parent 8fe7276b98
commit cc56997a70
3 changed files with 4 additions and 4 deletions

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;