diff options
Diffstat (limited to 'platforms/avr')
-rw-r--r-- | platforms/avr/drivers/i2c_master.c | 2 | ||||
-rw-r--r-- | platforms/avr/drivers/i2c_slave.h | 4 | ||||
-rw-r--r-- | platforms/avr/gpio.h | 6 | ||||
-rw-r--r-- | platforms/avr/platform.mk | 13 |
4 files changed, 16 insertions, 9 deletions
diff --git a/platforms/avr/drivers/i2c_master.c b/platforms/avr/drivers/i2c_master.c index 64083d862a..9136f4a7b9 100644 --- a/platforms/avr/drivers/i2c_master.c +++ b/platforms/avr/drivers/i2c_master.c @@ -315,4 +315,4 @@ __attribute__((weak)) i2c_status_t i2c_ping_address(uint8_t address, uint16_t ti i2c_status_t status = i2c_start(address, timeout); i2c_stop(); return status; -}
\ No newline at end of file +} diff --git a/platforms/avr/drivers/i2c_slave.h b/platforms/avr/drivers/i2c_slave.h index 178b6a29df..8614bd865a 100644 --- a/platforms/avr/drivers/i2c_slave.h +++ b/platforms/avr/drivers/i2c_slave.h @@ -22,6 +22,8 @@ #pragma once +#include "compiler_support.h" + #ifndef I2C_SLAVE_REG_COUNT # if defined(USE_I2C) && defined(SPLIT_COMMON_TRANSACTIONS) @@ -33,7 +35,7 @@ #endif // I2C_SLAVE_REG_COUNT -_Static_assert(I2C_SLAVE_REG_COUNT < 256, "I2C target registers must be single byte"); +STATIC_ASSERT(I2C_SLAVE_REG_COUNT < 256, "I2C target registers must be single byte"); extern volatile uint8_t i2c_slave_reg[I2C_SLAVE_REG_COUNT]; diff --git a/platforms/avr/gpio.h b/platforms/avr/gpio.h index 6f089bc663..4c09619772 100644 --- a/platforms/avr/gpio.h +++ b/platforms/avr/gpio.h @@ -16,6 +16,8 @@ #pragma once #include <avr/io.h> + +#include "compiler_support.h" #include "pin_defs.h" typedef uint8_t pin_t; @@ -24,9 +26,9 @@ typedef uint8_t pin_t; #define gpio_set_pin_input(pin) (DDRx_ADDRESS(pin) &= ~_BV((pin)&0xF), PORTx_ADDRESS(pin) &= ~_BV((pin)&0xF)) #define gpio_set_pin_input_high(pin) (DDRx_ADDRESS(pin) &= ~_BV((pin)&0xF), PORTx_ADDRESS(pin) |= _BV((pin)&0xF)) -#define gpio_set_pin_input_low(pin) _Static_assert(0, "GPIO pulldowns in input mode are not available on AVR") +#define gpio_set_pin_input_low(pin) STATIC_ASSERT(0, "GPIO pulldowns in input mode are not available on AVR") #define gpio_set_pin_output_push_pull(pin) (DDRx_ADDRESS(pin) |= _BV((pin)&0xF)) -#define gpio_set_pin_output_open_drain(pin) _Static_assert(0, "Open-drain outputs are not available on AVR") +#define gpio_set_pin_output_open_drain(pin) STATIC_ASSERT(0, "Open-drain outputs are not available on AVR") #define gpio_set_pin_output(pin) gpio_set_pin_output_push_pull(pin) #define gpio_write_pin_high(pin) (PORTx_ADDRESS(pin) |= _BV((pin)&0xF)) diff --git a/platforms/avr/platform.mk b/platforms/avr/platform.mk index a625f2e5d0..f0187457b3 100644 --- a/platforms/avr/platform.mk +++ b/platforms/avr/platform.mk @@ -12,9 +12,10 @@ HEX = $(OBJCOPY) -O $(FORMAT) -R .eeprom -R .fuse -R .lock -R .signature EEP = $(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" --change-section-lma .eeprom=0 --no-change-warnings -O $(FORMAT) BIN = -ifeq ("$(shell echo "int main(){}" | $(CC) --param=min-pagesize=0 -x c - -o /dev/null 2>&1)", "") -COMPILEFLAGS += --param=min-pagesize=0 -endif +COMPILEFLAGS += $(call cc-option,--param=min-pagesize=0) + +# Fix ICE's: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116389 +COMPILEFLAGS += $(call cc-option,-mlra) COMPILEFLAGS += -funsigned-char COMPILEFLAGS += -funsigned-bitfields @@ -25,10 +26,12 @@ COMPILEFLAGS += -fshort-enums COMPILEFLAGS += -mcall-prologues COMPILEFLAGS += -fno-builtin-printf -# Linker relaxation is only possible if -# link time optimizations are not enabled. +# On older compilers, linker relaxation is only possible if link time optimizations are not enabled. ifeq ($(strip $(LTO_ENABLE)), no) COMPILEFLAGS += -mrelax +else + # Newer compilers may support both, so quickly check before adding `-mrelax`. + COMPILEFLAGS += $(call cc-option,-mrelax,,-flto=auto) endif ASFLAGS += $(AVR_ASFLAGS) |