From 5bdb250a43c9e87185f3ddedbd8364f24306bbfd Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Thu, 27 Jan 2022 15:52:44 -0800 Subject: [PATCH] altos/attiny: Eliminate warnings from -Wconversion These have no effect on the generated code as they simply make implicit conversions explicit. Signed-off-by: Keith Packard --- src/attiny/ao_arch_funcs.h | 2 +- src/attiny/ao_async.c | 10 +++++----- src/attiny/ao_exti.c | 2 +- src/attiny/ao_exti.h | 2 +- src/attiny/ao_led_tiny.c | 8 ++++---- src/attiny/ao_spi_attiny.c | 2 +- 6 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/attiny/ao_arch_funcs.h b/src/attiny/ao_arch_funcs.h index e51f456b..1f422a37 100644 --- a/src/attiny/ao_arch_funcs.h +++ b/src/attiny/ao_arch_funcs.h @@ -21,7 +21,7 @@ */ #define ao_spi_get_mask(reg,mask,bus,speed) do { \ - (reg) &= ~(mask); \ + (reg) &= (uint8_t) ~(mask); \ } while (0) #define ao_spi_put_mask(reg,mask,bus) do { \ diff --git a/src/attiny/ao_async.c b/src/attiny/ao_async.c index f7a29d3b..945f4b14 100644 --- a/src/attiny/ao_async.c +++ b/src/attiny/ao_async.c @@ -33,7 +33,7 @@ ao_async_start(void) void ao_async_stop(void) { - LED_PORT &= ~(1 << AO_LED_SERIAL); + LED_PORT &= (uint8_t) ~(1 << AO_LED_SERIAL); } void @@ -45,11 +45,11 @@ ao_async_byte(uint8_t byte) uint8_t bit; uint8_t w_hi, w_lo; - /* start data stop */ - w = (0x000 << 0) | (byte << 1) | (0x001 << 9); + /* start data stop */ + w = (uint16_t) ((0x000 << 0) | (byte << 1) | (0x001 << 9)); - w_hi = w >> 8; - w_lo = w; + w_hi = (uint8_t) (w >> 8); + w_lo = (uint8_t) w; ao_arch_block_interrupts(); diff --git a/src/attiny/ao_exti.c b/src/attiny/ao_exti.c index c5b7eb2b..076cecc1 100644 --- a/src/attiny/ao_exti.c +++ b/src/attiny/ao_exti.c @@ -33,7 +33,7 @@ ao_exti_setup_port(uint8_t pin, uint8_t mode, void (*callback)(void)) { (void) mode; pcint_callback = callback; - pcint_mask = (1 << pin); + pcint_mask = (uint8_t) (1 << pin); ao_exti_disable(PORTB, pin); GIMSK |= (1 << PCIE); } diff --git a/src/attiny/ao_exti.h b/src/attiny/ao_exti.h index 8b22458e..1d1426e9 100644 --- a/src/attiny/ao_exti.h +++ b/src/attiny/ao_exti.h @@ -26,7 +26,7 @@ ao_exti_setup_port(uint8_t pin, uint8_t mode, void (*callback)(void)); #define ao_exti_enable(gpio, pin) (PCMSK |= (1 << (pin))) -#define ao_exti_disable(gpio, pin) (PCMSK &= ~(1 << (pin))) +#define ao_exti_disable(gpio, pin) (PCMSK &= (uint8_t) ~(1 << (pin))) #define ao_exti_init() diff --git a/src/attiny/ao_led_tiny.c b/src/attiny/ao_led_tiny.c index cd620f46..dab74fee 100644 --- a/src/attiny/ao_led_tiny.c +++ b/src/attiny/ao_led_tiny.c @@ -30,19 +30,19 @@ ao_led_on(uint8_t colors) void ao_led_off(uint8_t colors) { - LED_PORT &= ~colors; + LED_PORT &= (uint8_t) ~colors; } void ao_led_set(uint8_t colors) { - LED_PORT = (LED_PORT & ~LEDS_AVAILABLE) | (colors & LEDS_AVAILABLE); + LED_PORT = (uint8_t) ((LED_PORT & ~LEDS_AVAILABLE) | (colors & LEDS_AVAILABLE)); } void ao_led_toggle(uint8_t colors) { - LED_PORT ^= (colors & LEDS_AVAILABLE); + LED_PORT = (uint8_t) (LED_PORT ^ (colors & LEDS_AVAILABLE)); } void @@ -56,6 +56,6 @@ ao_led_for(uint8_t colors, AO_TICK_TYPE ticks) void ao_led_init(void) { - LED_PORT &= ~LEDS_AVAILABLE; + LED_PORT &= (uint8_t) ~LEDS_AVAILABLE; LED_DDR |= LEDS_AVAILABLE; } diff --git a/src/attiny/ao_spi_attiny.c b/src/attiny/ao_spi_attiny.c index 1c90ad56..506ebf15 100644 --- a/src/attiny/ao_spi_attiny.c +++ b/src/attiny/ao_spi_attiny.c @@ -117,7 +117,7 @@ ao_spi_init(void) #else USICR = SPI_USICR_FAST_2; #endif - SPI_DIR &= ~(1 << DDB0); /* DI */ + SPI_DIR &= (uint8_t) ~(1 << DDB0); /* DI */ SPI_DIR |= (1 << DDB1); /* DO */ SPI_DIR |= (1 << DDB2); /* SCLK */ } -- 2.30.2