/*
 * ll_consolehandler.h
 *
 *  Created on: Nov 7, 2019
 *      Author: abody
 */

#ifndef LL_CONSOLEHANDLER_H_
#define LL_CONSOLEHANDLER_H_

#include "f4ll/ll_hsusart.h"
#include "singleton.h"


namespace f4ll {

class LL_ConsoleHandler: public LL_UsartCore, public Singleton<LL_ConsoleHandler>
{
	friend class Singleton<LL_ConsoleHandler>;

public:
	// LL_UsartCore pure virtual function implementations
	virtual void ReceiverIdle(void);
	virtual void TransmissionComplete(void);
	virtual void RxDmaTransferComplete(void);
	virtual void RxDmaHalfTransfer(void);
	virtual void RxDmaError(LL_DmaHelper::DmaErrorType reason);
	virtual void TxDmaTransferComplete(void);
	virtual void TxDmaHalfTransfer(void);
	virtual void TxDmaError(LL_DmaHelper::DmaErrorType reason);

	void PrintStats(uint8_t id, LL_HsUsart &usart);

private:
	LL_ConsoleHandler(USART_TypeDef *usart, DMA_TypeDef *dma, uint32_t streamRx, uint32_t streamTx);

	char		m_buffer[128];
	uint16_t	m_used = 0;
};

} /* namespace f4ll */

#endif /* LL_CONSOLEHANDLER_H_ */
