Make it work
This commit is contained in:
parent
2b17bb1dae
commit
340f0329fa
11 changed files with 187 additions and 125 deletions
|
@ -13,15 +13,15 @@
|
|||
|
||||
namespace f1ll {
|
||||
|
||||
class console_handler : public usart_core, public singleton<console_handler> {
|
||||
class console_handler : public usart_core, public singleton<console_handler>
|
||||
{
|
||||
friend class singleton<console_handler>;
|
||||
|
||||
public:
|
||||
void print(char const *s);
|
||||
|
||||
private:
|
||||
console_handler(USART_TypeDef *usart, DMA_TypeDef *dma, uint32_t channelRx,
|
||||
uint32_t channelTx);
|
||||
console_handler(USART_TypeDef *usart, DMA_TypeDef *dma, uint32_t channelRx, uint32_t channelTx);
|
||||
|
||||
// LL_UsartCore pure virtual function implementations
|
||||
virtual void receiver_idle(void);
|
||||
|
|
|
@ -11,39 +11,38 @@
|
|||
#include <inttypes.h>
|
||||
#include <platform/dma_ll.h>
|
||||
|
||||
namespace f1ll
|
||||
namespace f1ll {
|
||||
|
||||
class dma_helper
|
||||
{
|
||||
public:
|
||||
dma_helper(DMA_TypeDef *dma, uint32_t channel);
|
||||
dma_helper(dma_helper const &base) = default;
|
||||
|
||||
class dma_helper
|
||||
{
|
||||
public:
|
||||
dma_helper(DMA_TypeDef *dma, uint32_t channel);
|
||||
dma_helper(dma_helper const &base) = default;
|
||||
inline DMA_TypeDef *get_dma() const { return m_dma; }
|
||||
inline uint32_t get_channel() const { return m_channel; }
|
||||
inline volatile uint32_t *get_is_reg() const { return m_is_reg; }
|
||||
inline volatile uint32_t *get_ifc_reg() const { return m_ifc_reg; }
|
||||
inline uint32_t get_te_mask() const { return m_te_masks[m_channel - 1]; }
|
||||
inline uint32_t get_ht_mask() const { return m_ht_masks[m_channel - 1]; }
|
||||
inline uint32_t get_tc_mask() const { return m_tc_masks[m_channel - 1]; }
|
||||
inline uint32_t get_gi_mask() const { return m_gi_masks[m_channel - 1]; }
|
||||
|
||||
inline DMA_TypeDef *get_dma() const { return m_dma; }
|
||||
inline uint32_t get_channel() const { return m_channel; }
|
||||
inline volatile uint32_t *get_is_reg() const { return m_is_reg; }
|
||||
inline volatile uint32_t *get_ifc_reg() const { return m_ifc_reg; }
|
||||
inline uint32_t get_te_mask() const { return m_te_masks[m_channel - 1]; }
|
||||
inline uint32_t get_ht_mask() const { return m_ht_masks[m_channel - 1]; }
|
||||
inline uint32_t get_tc_mask() const { return m_tc_masks[m_channel - 1]; }
|
||||
inline uint32_t get_gi_mask() const { return m_gi_masks[m_channel - 1]; }
|
||||
inline bool is_enabled_it_te() { return LL_DMA_IsEnabledIT_TE(m_dma, m_channel) != 0; }
|
||||
inline bool is_enabled_it_ht() { return LL_DMA_IsEnabledIT_HT(m_dma, m_channel) != 0; }
|
||||
inline bool is_enabled_it_tc() { return LL_DMA_IsEnabledIT_TC(m_dma, m_channel) != 0; }
|
||||
|
||||
inline bool is_enabled_it_te() { return LL_DMA_IsEnabledIT_TE(m_dma, m_channel) != 0; }
|
||||
inline bool is_enabled_it_ht() { return LL_DMA_IsEnabledIT_HT(m_dma, m_channel) != 0; }
|
||||
inline bool is_enabled_it_tc() { return LL_DMA_IsEnabledIT_TC(m_dma, m_channel) != 0; }
|
||||
private:
|
||||
DMA_TypeDef *m_dma;
|
||||
uint32_t m_channel;
|
||||
volatile uint32_t *m_is_reg;
|
||||
volatile uint32_t *m_ifc_reg;
|
||||
|
||||
private:
|
||||
DMA_TypeDef *m_dma;
|
||||
uint32_t m_channel;
|
||||
volatile uint32_t *m_is_reg;
|
||||
volatile uint32_t *m_ifc_reg;
|
||||
|
||||
static const uint32_t m_te_masks[7];
|
||||
static const uint32_t m_ht_masks[7];
|
||||
static const uint32_t m_tc_masks[7];
|
||||
static const uint32_t m_gi_masks[7];
|
||||
};
|
||||
static const uint32_t m_te_masks[7];
|
||||
static const uint32_t m_ht_masks[7];
|
||||
static const uint32_t m_tc_masks[7];
|
||||
static const uint32_t m_gi_masks[7];
|
||||
};
|
||||
|
||||
} /* namespace f4ll */
|
||||
|
||||
|
|
|
@ -3,10 +3,12 @@
|
|||
|
||||
#include <utility>
|
||||
|
||||
template <typename T> class singleton {
|
||||
template <typename T> class singleton
|
||||
{
|
||||
public:
|
||||
static T &instance() { return *m_instance; }
|
||||
template <typename... args_t> static T &init(args_t &&...args) {
|
||||
template <typename... args_t> static T &init(args_t &&...args)
|
||||
{
|
||||
static T instance{std::forward<args_t>(args)...};
|
||||
m_instance = &instance;
|
||||
return instance;
|
||||
|
|
|
@ -13,7 +13,8 @@
|
|||
|
||||
namespace f1ll {
|
||||
|
||||
class usart_core {
|
||||
class usart_core
|
||||
{
|
||||
public:
|
||||
static inline void usart_irq(usart_core *_this) { _this->usart_isr(); }
|
||||
static inline void rx_dma_irq(usart_core *_this) { _this->rx_dma_isr(); }
|
||||
|
@ -23,8 +24,7 @@ public:
|
|||
void setup_receive(void *buffer, uint16_t length);
|
||||
|
||||
protected:
|
||||
usart_core(USART_TypeDef *usart, DMA_TypeDef *dma, uint32_t channel_rx,
|
||||
uint32_t stream_tx);
|
||||
usart_core(USART_TypeDef *usart, DMA_TypeDef *dma, uint32_t channel_rx, uint32_t stream_tx);
|
||||
|
||||
USART_TypeDef *m_usart;
|
||||
dma_helper m_rxDma;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue