51 lines
1.2 KiB
C++
51 lines
1.2 KiB
C++
/*
|
|
* ll_dmadrivenusartcore.h
|
|
*
|
|
* Created on: Nov 4, 2019
|
|
* Author: abody
|
|
*/
|
|
|
|
#ifndef LL_USARTCORE_H_
|
|
#define LL_USARTCORE_H_
|
|
#include <platform/usart_ll.h>
|
|
|
|
#include "f4ll/dmahelper.h"
|
|
|
|
namespace f4ll {
|
|
|
|
class UsartCore
|
|
{
|
|
public:
|
|
static inline void HandleUsartIrq(UsartCore *_this) { _this->UsartIsr(); }
|
|
static inline void HandleRxDmaIrq(UsartCore *_this) { _this->RxDmaIsr(); }
|
|
static inline void HandleTxDmaIrq(UsartCore *_this) { _this->TxDmaIsr(); }
|
|
|
|
protected:
|
|
UsartCore(USART_TypeDef *usart, DMA_TypeDef *dma, uint32_t streamRx, uint32_t streamTx);
|
|
|
|
virtual void ReceiverIdle() = 0;
|
|
virtual void TransmissionComplete() = 0;
|
|
|
|
virtual void RxDmaTransferComplete() = 0;
|
|
virtual void RxDmaHalfTransfer() = 0;
|
|
virtual void RxDmaError(DmaHelper::DmaErrorType reason) = 0;
|
|
|
|
virtual void TxDmaTransferComplete() = 0;
|
|
virtual void TxDmaHalfTransfer() = 0;
|
|
virtual void TxDmaError(DmaHelper::DmaErrorType reason) = 0;
|
|
|
|
void SetupTransmit(void const *buffer, uint16_t length);
|
|
void SetupReceive(void *buffer, uint16_t length);
|
|
|
|
void UsartIsr();
|
|
void RxDmaIsr();
|
|
void TxDmaIsr();
|
|
|
|
USART_TypeDef *m_usart;
|
|
DmaHelper m_rxDma;
|
|
DmaHelper m_txDma;
|
|
};
|
|
|
|
} /* namespace f4ll */
|
|
|
|
#endif /* LL_USARTCORE_H_ */
|