From e88ebc1c8453e2666b72e7bb5e1422ac456cf73b Mon Sep 17 00:00:00 2001 From: Oleg Hahm Date: Sat, 28 Nov 2015 12:40:50 +0100 Subject: [PATCH] cpu nrf51: fix pedantic compiler warnings Make compiler doesn't complain about unused variables and unnamed unions. --- cpu/nrf51/include/nrf51.h | 6 +++--- cpu/nrf51/periph/adc.c | 1 + cpu/nrf51/periph/gpio.c | 2 ++ cpu/nrf51/periph/spi.c | 7 ++++++- 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/cpu/nrf51/include/nrf51.h b/cpu/nrf51/include/nrf51.h index 9c98da12b3..d2508551a3 100644 --- a/cpu/nrf51/include/nrf51.h +++ b/cpu/nrf51/include/nrf51.h @@ -1077,7 +1077,7 @@ typedef struct { /*!< NVMC Structure union { __IO uint32_t ERASEPCR1; /*!< Register for erasing a non-protected non-volatile memory page. */ __IO uint32_t ERASEPAGE; /*!< Register for erasing a non-protected non-volatile memory page. */ - }; + } nrf51_unnamed1; __IO uint32_t ERASEALL; /*!< Register for erasing all non-volatile user memory. */ __IO uint32_t ERASEPCR0; /*!< Register for erasing a protected non-volatile memory page. */ __IO uint32_t ERASEUICR; /*!< Register for start erasing User Information Congfiguration Registers. */ @@ -1130,7 +1130,7 @@ typedef struct { /*!< FICR Structure kept for backward compatinility purposes. Use SIZERAMBLOCKS instead. */ __I uint32_t SIZERAMBLOCKS; /*!< Size of RAM blocks in bytes. */ - }; + } nrf51_unnamed2; __I uint32_t RESERVED3[5]; __I uint32_t CONFIGID; /*!< Configuration identifier. */ __I uint32_t DEVICEID[2]; /*!< Device identifier. */ @@ -1167,7 +1167,7 @@ typedef struct { /*!< UICR Structure union { __IO uint32_t NRFFW[15]; /*!< Reserved for Nordic firmware design. */ __IO uint32_t BOOTLOADERADDR; /*!< Bootloader start address. */ - }; + } nrf51_unnamed3; __IO uint32_t NRFHW[12]; /*!< Reserved for Nordic hardware design. */ __IO uint32_t CUSTOMER[32]; /*!< Reserved for customer. */ } NRF_UICR_Type; diff --git a/cpu/nrf51/periph/adc.c b/cpu/nrf51/periph/adc.c index 64b8a443f6..ca35449704 100644 --- a/cpu/nrf51/periph/adc.c +++ b/cpu/nrf51/periph/adc.c @@ -127,6 +127,7 @@ int adc_map(adc_t dev, int value, int min, int max) float adc_mapf(adc_t dev, int value, float min, float max) { + (void) dev; return ((max - min) / ((float)adc_max_value)) * value; } diff --git a/cpu/nrf51/periph/gpio.c b/cpu/nrf51/periph/gpio.c index 00d34c144f..ff66fd3b43 100644 --- a/cpu/nrf51/periph/gpio.c +++ b/cpu/nrf51/periph/gpio.c @@ -78,11 +78,13 @@ int gpio_init_int(gpio_t pin, gpio_pp_t pullup, gpio_flank_t flank, void gpio_irq_enable(gpio_t pin) { + (void) pin; NRF_GPIOTE->INTENSET |= GPIOTE_INTENSET_IN0_Msk; } void gpio_irq_disable(gpio_t dev) { + (void) dev; NRF_GPIOTE->INTENCLR |= GPIOTE_INTENSET_IN0_Msk; } diff --git a/cpu/nrf51/periph/spi.c b/cpu/nrf51/periph/spi.c index ceb5abae83..6470e4562c 100644 --- a/cpu/nrf51/periph/spi.c +++ b/cpu/nrf51/periph/spi.c @@ -123,6 +123,9 @@ int spi_init_master(spi_t dev, spi_conf_t conf, spi_speed_t speed) int spi_init_slave(spi_t dev, spi_conf_t conf, char (*cb)(char data)) { + (void) dev; + (void) conf; + (void) cb; /* This API is incompatible with nRF51 SPIS */ return -1; } @@ -189,7 +192,7 @@ int spi_transfer_bytes(spi_t dev, char *out, char *in, unsigned int length) return -1; } - for (int i = 0; i < length; i++) { + for (unsigned i = 0; i < length; i++) { char tmp = (out) ? out[i] : 0; spi[dev]->EVENTS_READY = 0; spi[dev]->TXD = (uint8_t)tmp; @@ -217,6 +220,8 @@ int spi_transfer_regs(spi_t dev, uint8_t reg, char *out, char *in, unsigned int void spi_transmission_begin(spi_t dev, char reset_val) { + (void) dev; + (void) reset_val; /* spi slave is not implemented */ }