We are using Atmel's ASF (3.48) with Studio 7 (on an ATSAM4E series MCU), with the arm-gnu-toolchain 9-2020-q2-update. The team has recently decided to write more higher interface layers with C++, while still using the CMSIS and ASF drivers in C as they are. With that in mind, I am trying to replace the following in my interface file:
#define MY_DEBUG_UART UART0
with
constexpr Uart *MY_DEBUG_UART = UART0;
Now, UART0 is defined in the relevant CMSIS/SAM4E file as
#define UART0 ((Uart *)0x400E0600U) /**< \brief (UART0 ) Base Address */
So upon building, an error is returned with this UART0 #define.
Error reinterpret_cast from integer to pointer
I think I see why. But the examples I have seen seem to involve setting up a register class. I don't want to duplicate things and would like to use the drivers provided, have the readability of #defines without its accompanying issues, and utilise the C++ advantages. What's the cleanest way to achieve this please?