diff options
Diffstat (limited to 'platforms/avr')
-rw-r--r-- | platforms/avr/_wait.h | 4 | ||||
-rw-r--r-- | platforms/avr/drivers/i2c_master.c | 3 | ||||
-rw-r--r-- | platforms/avr/drivers/ws2812_bitbang.c (renamed from platforms/avr/drivers/ws2812.c) | 8 | ||||
-rw-r--r-- | platforms/avr/drivers/ws2812_i2c.c | 10 |
4 files changed, 14 insertions, 11 deletions
diff --git a/platforms/avr/_wait.h b/platforms/avr/_wait.h index c1a598a428..39cbf618d2 100644 --- a/platforms/avr/_wait.h +++ b/platforms/avr/_wait.h @@ -15,7 +15,11 @@ */ #pragma once +// Need to disable GCC's "maybe-uninitialized" warning for this file, as it causes issues when running `KEEP_INTERMEDIATES=yes`. +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wmaybe-uninitialized" #include <util/delay.h> +#pragma GCC diagnostic pop // http://ww1.microchip.com/downloads/en/devicedoc/atmel-0856-avr-instruction-set-manual.pdf // page 22: Table 4-2. Arithmetic and Logic Instructions diff --git a/platforms/avr/drivers/i2c_master.c b/platforms/avr/drivers/i2c_master.c index 524494c99d..58939f3e00 100644 --- a/platforms/avr/drivers/i2c_master.c +++ b/platforms/avr/drivers/i2c_master.c @@ -23,6 +23,7 @@ #include "i2c_master.h" #include "timer.h" #include "wait.h" +#include "util.h" #ifndef F_SCL # define F_SCL 400000UL // SCL frequency @@ -37,8 +38,6 @@ #define TWBR_val (((F_CPU / F_SCL) - 16) / 2) -#define MAX(X, Y) ((X) > (Y) ? (X) : (Y)) - void i2c_init(void) { TWSR = 0; /* no prescaler */ TWBR = (uint8_t)TWBR_val; diff --git a/platforms/avr/drivers/ws2812.c b/platforms/avr/drivers/ws2812_bitbang.c index 5c0cb3b718..aad10d86b0 100644 --- a/platforms/avr/drivers/ws2812.c +++ b/platforms/avr/drivers/ws2812_bitbang.c @@ -38,10 +38,10 @@ static inline void ws2812_sendarray_mask(uint8_t *data, uint16_t datlen, uint8_t masklo, uint8_t maskhi); void ws2812_setleds(LED_TYPE *ledarray, uint16_t number_of_leds) { - DDRx_ADDRESS(RGB_DI_PIN) |= pinmask(RGB_DI_PIN); + DDRx_ADDRESS(WS2812_DI_PIN) |= pinmask(WS2812_DI_PIN); - uint8_t masklo = ~(pinmask(RGB_DI_PIN)) & PORTx_ADDRESS(RGB_DI_PIN); - uint8_t maskhi = pinmask(RGB_DI_PIN) | PORTx_ADDRESS(RGB_DI_PIN); + uint8_t masklo = ~(pinmask(WS2812_DI_PIN)) & PORTx_ADDRESS(WS2812_DI_PIN); + uint8_t maskhi = pinmask(WS2812_DI_PIN) | PORTx_ADDRESS(WS2812_DI_PIN); ws2812_sendarray_mask((uint8_t *)ledarray, number_of_leds * sizeof(LED_TYPE), masklo, maskhi); @@ -165,7 +165,7 @@ static inline void ws2812_sendarray_mask(uint8_t *data, uint16_t datlen, uint8_t " dec %0 \n\t" // '1' [+2] '0' [+2] " brne loop%=\n\t" // '1' [+3] '0' [+4] : "=&d"(ctr) - : "r"(curbyte), "I"(_SFR_IO_ADDR(PORTx_ADDRESS(RGB_DI_PIN))), "r"(maskhi), "r"(masklo)); + : "r"(curbyte), "I"(_SFR_IO_ADDR(PORTx_ADDRESS(WS2812_DI_PIN))), "r"(maskhi), "r"(masklo)); } SREG = sreg_prev; diff --git a/platforms/avr/drivers/ws2812_i2c.c b/platforms/avr/drivers/ws2812_i2c.c index 709f382254..f4a2fbe0b3 100644 --- a/platforms/avr/drivers/ws2812_i2c.c +++ b/platforms/avr/drivers/ws2812_i2c.c @@ -5,12 +5,12 @@ # error "RGBW not supported" #endif -#ifndef WS2812_ADDRESS -# define WS2812_ADDRESS 0xb0 +#ifndef WS2812_I2C_ADDRESS +# define WS2812_I2C_ADDRESS 0xB0 #endif -#ifndef WS2812_TIMEOUT -# define WS2812_TIMEOUT 100 +#ifndef WS2812_I2C_TIMEOUT +# define WS2812_I2C_TIMEOUT 100 #endif void ws2812_init(void) { @@ -25,5 +25,5 @@ void ws2812_setleds(LED_TYPE *ledarray, uint16_t leds) { s_init = true; } - i2c_transmit(WS2812_ADDRESS, (uint8_t *)ledarray, sizeof(LED_TYPE) * leds, WS2812_TIMEOUT); + i2c_transmit(WS2812_I2C_ADDRESS, (uint8_t *)ledarray, sizeof(LED_TYPE) * leds, WS2812_I2C_TIMEOUT); } |