#pragma once

#include "stm32f4xx_hal.h"

#include <iostream>
#include <string>
using namespace std;

#define RTC_ASYNCH_PREDIV  0x7F   /* LSE as RTC clock */
#define RTC_SYNCH_PREDIV   0x00FF /* LSE as RTC clock */

//Implemented as a singletoon per http://laristra.github.io/flecsi/src/developer-guide/patterns/meyers_singleton.html
//Had to remove destructors
//There may be better implementations like https://stackoverflow.com/questions/1008019/c-singleton-design-pattern/1008289#1008289

class mcuRealTimeClock
{
public:
	static mcuRealTimeClock& getInstance()
	{
		static mcuRealTimeClock instance;
		cout << "\t\tpublic mcuRealTimeClock& getInstance" << endl;
		return instance;
	}

private:
	mcuRealTimeClock()
	{
		cout << "\t\tprivate mcuRealTimeClock constructor" << endl;
		configRTC();
	}
		
public:
	void SynchToPUBX04(string pubx04Msg);
	const string getCPFTimestamp();
	
protected:
	
private:
	void configRTC(void);
	
	RTC_HandleTypeDef RtcHandle;
};
