Convert illegal constexpr to static const pointers
We cannot get a constexpr definition of the register addresses, and any reinterpret cast is currently illegal for a constexpr in c++17. Change the SPI0, TIFR and TIMSK to volatile const pointers instead. SPI0 has volatile members instead of marking the entire struct as volatile, which is probably not a good idea as it technically drops the volatile from the original pointer.pull/192/head
parent
d34b79b087
commit
4794cfea40
|
|
@ -3,7 +3,10 @@
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#include "gpio.h"
|
#include "gpio.h"
|
||||||
|
|
||||||
#define SPI0 ((hal::spi::SPI_TypeDef *)&SPCR)
|
#ifdef __AVR__
|
||||||
|
#define SPI0 ((hal::spi::SPI_TypeDef *const) & SPCR)
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace hal {
|
namespace hal {
|
||||||
|
|
||||||
/// SPI interface
|
/// SPI interface
|
||||||
|
|
@ -30,9 +33,9 @@ void Init(SPI_TypeDef *const hspi, SPI_InitTypeDef *const conf);
|
||||||
uint8_t TxRx(SPI_TypeDef *hspi, uint8_t val);
|
uint8_t TxRx(SPI_TypeDef *hspi, uint8_t val);
|
||||||
|
|
||||||
#ifdef __AVR__
|
#ifdef __AVR__
|
||||||
constexpr SPI_TypeDef *TmcSpiBus = SPI0;
|
static SPI_TypeDef *const TmcSpiBus = SPI0;
|
||||||
#else
|
#else
|
||||||
constexpr SPI_TypeDef *TmcSpiBus = nullptr;
|
static SPI_TypeDef *const TmcSpiBus = nullptr;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,8 +20,8 @@ struct Tim8bit_TypeDef {
|
||||||
volatile uint8_t OCRxB;
|
volatile uint8_t OCRxB;
|
||||||
};
|
};
|
||||||
|
|
||||||
constexpr volatile uint8_t *TIFR = &TIFR0;
|
static volatile uint8_t *const TIFR = &TIFR0;
|
||||||
constexpr volatile uint8_t *TIMSK = &TIMSK0;
|
static volatile uint8_t *const TIMSK = &TIMSK0;
|
||||||
|
|
||||||
struct Tim8bit_CTC_config {
|
struct Tim8bit_CTC_config {
|
||||||
uint8_t cs : 3; ///clock source as per datasheet. It is not consistent between timer types
|
uint8_t cs : 3; ///clock source as per datasheet. It is not consistent between timer types
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ enum MotorMode : uint8_t {
|
||||||
};
|
};
|
||||||
|
|
||||||
struct MotorParams {
|
struct MotorParams {
|
||||||
const hal::spi::SPI_TypeDef *spi;
|
const hal::spi::SPI_TypeDef *const spi;
|
||||||
uint8_t idx; ///< SHR16 index
|
uint8_t idx; ///< SHR16 index
|
||||||
bool dirOn; ///< forward direction
|
bool dirOn; ///< forward direction
|
||||||
gpio::GPIO_pin csPin; ///< CS pin
|
gpio::GPIO_pin csPin; ///< CS pin
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue