Fixed non-compliant use of constexpr for pointers
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
|
||||
#include <avr/interrupt.h>
|
||||
#include <avr/io.h>
|
||||
#include <avr/sfr_defs.h>
|
||||
|
||||
#include "config.hpp"
|
||||
#include "hardware.hpp"
|
||||
@@ -16,15 +17,29 @@ namespace detail {
|
||||
|
||||
#if defined(__AVR_ATmega1284P__)
|
||||
|
||||
/*
|
||||
The following works in avr-gcc 5.4.0, but is not legal C++, because ptr's are not legal constexpr's
|
||||
constexpr auto *foo = ptr;
|
||||
|
||||
Workaround is to store the the address of the ptr in a uintptr_t and reinterpret_cast it at call site
|
||||
For this to work we need to temporarily disable the _SFR_MEM8 macro so that the register macro just gives the address
|
||||
*/
|
||||
|
||||
#undef _SFR_MEM8
|
||||
#define _SFR_MEM8
|
||||
|
||||
struct Registers1 {
|
||||
static constexpr volatile auto *IO_REG = &UDR1;
|
||||
static constexpr volatile auto *CTRL_STAT_REG_A = &UCSR1A;
|
||||
static constexpr volatile auto *CTRL_STAT_REG_B = &UCSR1B;
|
||||
static constexpr volatile auto *CTRL_STAT_REG_C = &UCSR1C;
|
||||
static constexpr volatile auto *BAUD_REG_L = &UBRR1L;
|
||||
static constexpr volatile auto *BAUD_REG_H = &UBRR1H;
|
||||
static constexpr uintptr_t IO_REG_ADDR = UDR1;
|
||||
static constexpr uintptr_t CTRL_STAT_REG_A_ADDR = UCSR1A;
|
||||
static constexpr uintptr_t CTRL_STAT_REG_B_ADDR = UCSR1B;
|
||||
static constexpr uintptr_t CTRL_STAT_REG_C_ADDR = UCSR1C;
|
||||
static constexpr uintptr_t BAUD_REG_L_ADDR = UBRR1L;
|
||||
static constexpr uintptr_t BAUD_REG_H_ADDR = UBRR1H;
|
||||
};
|
||||
|
||||
#undef _SFR_MEM8
|
||||
#define _SFR_MEM8(mem_addr) _MMIO_BYTE(mem_addr)
|
||||
|
||||
enum class ControlFlagsA1 {
|
||||
MULTI_PROC_COMM_MODE = MPCM1,
|
||||
SPEED_2X = U2X1,
|
||||
|
||||
Reference in New Issue
Block a user