altos/attiny: Eliminate warnings from -Wconversion
authorKeith Packard <keithp@keithp.com>
Thu, 27 Jan 2022 23:52:44 +0000 (15:52 -0800)
committerKeith Packard <keithp@keithp.com>
Thu, 17 Feb 2022 01:26:49 +0000 (17:26 -0800)
These have no effect on the generated code as they simply make
implicit conversions explicit.

Signed-off-by: Keith Packard <keithp@keithp.com>
src/attiny/ao_arch_funcs.h
src/attiny/ao_async.c
src/attiny/ao_exti.c
src/attiny/ao_exti.h
src/attiny/ao_led_tiny.c
src/attiny/ao_spi_attiny.c

index e51f456b5965594aa4f075257109d8d292bcef79..1f422a37645bd92d7d7c2764a29c5f3b26a7efde 100644 (file)
@@ -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 {     \
index f7a29d3b799f88e0ab71dd2e92f4db3f167d4e30..945f4b1414b153867669f056417e10f958bdce2e 100644 (file)
@@ -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();
 
index c5b7eb2b078380b531b200058e7dc3a0470a781d..076cecc1f54d0939ce12be191f98129c257d6e05 100644 (file)
@@ -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);
 }
index 8b22458e2ccd672c04475020a1b686ef3968ad04..1d1426e9d9bac47fa67da04bbb886ef6e9346f3c 100644 (file)
@@ -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()
 
index cd620f4672f80318dbcb3e685b64a2726faffaa7..dab74fee1851a5ee40b1f711380c8b8278da7f61 100644 (file)
@@ -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;
 }
index 1c90ad56082326a9981aef4f538f1584159ab6fc..506ebf1550d84b1ee4ddec58045f175bc7fc4cd1 100644 (file)
@@ -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 */
 }