Integrate f1ll (compiles, untested)
This commit is contained in:
parent
0159a9cb45
commit
2b17bb1dae
32 changed files with 924 additions and 128 deletions
44
f1ll/inc/f1ll/console_handler.h
Normal file
44
f1ll/inc/f1ll/console_handler.h
Normal file
|
@ -0,0 +1,44 @@
|
|||
/*
|
||||
* ll_consolehandler.h
|
||||
*
|
||||
* Created on: Nov 7, 2019
|
||||
* Author: abody
|
||||
*/
|
||||
|
||||
#ifndef LL_CONSOLEHANDLER_H_
|
||||
#define LL_CONSOLEHANDLER_H_
|
||||
|
||||
#include "f1ll/usart_core.h"
|
||||
#include "singleton.h"
|
||||
|
||||
namespace f1ll {
|
||||
|
||||
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);
|
||||
|
||||
// LL_UsartCore pure virtual function implementations
|
||||
virtual void receiver_idle(void);
|
||||
virtual void transmission_complete(void);
|
||||
virtual void framing_error(void);
|
||||
virtual void overrun(void);
|
||||
virtual void rx_dma_transfer_complete(void);
|
||||
virtual void rx_dma_half_transfer(void);
|
||||
virtual void rx_dma_error(void);
|
||||
virtual void tx_dma_transfer_complete(void);
|
||||
virtual void tx_dma_half_transfer(void);
|
||||
virtual void tx_dma_error(void);
|
||||
|
||||
char m_buffer[128];
|
||||
uint16_t m_used = 0;
|
||||
};
|
||||
|
||||
} // namespace f1ll
|
||||
|
||||
#endif /* LL_CONSOLEHANDLER_H_ */
|
50
f1ll/inc/f1ll/dma_helper.h
Normal file
50
f1ll/inc/f1ll/dma_helper.h
Normal file
|
@ -0,0 +1,50 @@
|
|||
/*
|
||||
* ll_dmahelper.h
|
||||
*
|
||||
* Created on: Oct 25, 2019
|
||||
* Author: abody
|
||||
*/
|
||||
|
||||
#ifndef LL_DMAHELPER_H_
|
||||
#define LL_DMAHELPER_H_
|
||||
|
||||
#include <inttypes.h>
|
||||
#include <platform/dma_ll.h>
|
||||
|
||||
namespace f1ll
|
||||
{
|
||||
|
||||
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 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;
|
||||
|
||||
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 */
|
||||
|
||||
#endif /* LL_DMAHELPER_H_ */
|
24
f1ll/inc/f1ll/singleton.h
Normal file
24
f1ll/inc/f1ll/singleton.h
Normal file
|
@ -0,0 +1,24 @@
|
|||
#ifndef SINGLETON_H_
|
||||
#define SINGLETON_H_
|
||||
|
||||
#include <utility>
|
||||
|
||||
template <typename T> class singleton {
|
||||
public:
|
||||
static T &instance() { return *m_instance; }
|
||||
template <typename... args_t> static T &init(args_t &&...args) {
|
||||
static T instance{std::forward<args_t>(args)...};
|
||||
m_instance = &instance;
|
||||
return instance;
|
||||
}
|
||||
|
||||
protected:
|
||||
singleton() = default;
|
||||
singleton(const singleton &) = delete;
|
||||
singleton &operator=(const singleton &) = delete;
|
||||
static T *m_instance;
|
||||
};
|
||||
|
||||
template <typename T> T *singleton<T>::m_instance = nullptr;
|
||||
|
||||
#endif /* SINGLETON_H_ */
|
31
f1ll/inc/f1ll/str_util.h
Normal file
31
f1ll/inc/f1ll/str_util.h
Normal file
|
@ -0,0 +1,31 @@
|
|||
/*
|
||||
* strutil.h
|
||||
*
|
||||
* Created on: Feb 11, 2017
|
||||
* Author: compi
|
||||
*/
|
||||
|
||||
#ifndef _STM32PLUS_STRUTIL_H_
|
||||
#define _STM32PLUS_STRUTIL_H_
|
||||
|
||||
#include <stddef.h>
|
||||
#include <inttypes.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
size_t strcpy_ex(char *dst, char const *src);
|
||||
size_t uitodec(char* buffer, uint32_t data);
|
||||
size_t uitohex(char* buffer, uint32_t data, uint8_t chars);
|
||||
size_t itodec(char* buffer, int data);
|
||||
size_t itohex(char* buffer, int data);
|
||||
void strrev(char *first, char *last);
|
||||
char tochr(const uint8_t in, const uint8_t upper);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _STM32PLUS_STRUTIL_H_ */
|
55
f1ll/inc/f1ll/usart_core.h
Normal file
55
f1ll/inc/f1ll/usart_core.h
Normal file
|
@ -0,0 +1,55 @@
|
|||
/*
|
||||
* ll_dmadrivenusartcore.h
|
||||
*
|
||||
* Created on: Nov 4, 2019
|
||||
* Author: abody
|
||||
*/
|
||||
|
||||
#ifndef LL_USARTCORE_H_
|
||||
#define LL_USARTCORE_H_
|
||||
#include <platform/usart_ll.h>
|
||||
|
||||
#include "f1ll/dma_helper.h"
|
||||
|
||||
namespace f1ll {
|
||||
|
||||
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(); }
|
||||
static inline void tx_dma_irq(usart_core *_this) { _this->tx_dma_isr(); }
|
||||
|
||||
void setup_transmit(void const *buffer, uint16_t length);
|
||||
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_TypeDef *m_usart;
|
||||
dma_helper m_rxDma;
|
||||
dma_helper m_txDma;
|
||||
|
||||
private:
|
||||
virtual void receiver_idle(void) = 0;
|
||||
virtual void transmission_complete(void) = 0;
|
||||
virtual void framing_error(void) = 0;
|
||||
virtual void overrun(void) = 0;
|
||||
|
||||
virtual void rx_dma_transfer_complete(void) = 0;
|
||||
virtual void rx_dma_half_transfer(void) = 0;
|
||||
virtual void rx_dma_error(void) = 0;
|
||||
|
||||
virtual void tx_dma_transfer_complete(void) = 0;
|
||||
virtual void tx_dma_half_transfer(void) = 0;
|
||||
virtual void tx_dma_error(void) = 0;
|
||||
|
||||
public:
|
||||
void usart_isr();
|
||||
void rx_dma_isr();
|
||||
void tx_dma_isr();
|
||||
};
|
||||
|
||||
} // namespace f1ll
|
||||
|
||||
#endif /* LL_USARTCORE_H_ */
|
Loading…
Add table
Add a link
Reference in a new issue