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

#ifndef LL_CONSOLEHANDLER_H_
#define LL_CONSOLEHANDLER_H_

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


namespace f4ll {

class ConsoleHandler: public UsartCore, public Singleton<ConsoleHandler>
{
	friend class Singleton<ConsoleHandler>;

public:
	void PrintStats(uint8_t id, PacketUsart &usart);

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

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

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

} /* namespace f4ll */

#endif /* LL_CONSOLEHANDLER_H_ */
