Halfway RTC driver refactoring
This commit is contained in:
@@ -191,3 +191,67 @@ void datetime_to_str(char *datetime_str, datetime_t time)
|
||||
sprintf(datetime_str, " %d.%d.%d %d:%d:%d %s", time.year, time.month,
|
||||
time.day, time.hour, time.minute, time.second, Week[time.dotw]);
|
||||
}
|
||||
|
||||
namespace drivers
|
||||
{
|
||||
|
||||
PCF85063::PCF85063(I2C &i2c, const uint8_t address) : m_i2c(i2c), m_address(address)
|
||||
{
|
||||
}
|
||||
|
||||
const bool PCF85063::reset(void)
|
||||
{
|
||||
}
|
||||
|
||||
const bool PCF85063::setTime(datetime_t time)
|
||||
{
|
||||
}
|
||||
|
||||
const bool PCF85063::setDate(datetime_t date)
|
||||
{
|
||||
}
|
||||
|
||||
const bool PCF85063::setDatetime(datetime_t datetime)
|
||||
{
|
||||
}
|
||||
|
||||
const bool PCF85063::readDate(datetime_t &datetime)
|
||||
{
|
||||
}
|
||||
|
||||
const bool PCF85063::readTime(datetime_t &datetime)
|
||||
{
|
||||
}
|
||||
|
||||
const bool PCF85063::readDatetime(datetime_t &datetime)
|
||||
{
|
||||
}
|
||||
|
||||
const bool PCF85063::enableAlarm(const bool enable)
|
||||
{
|
||||
}
|
||||
|
||||
const bool PCF85063::setAlarm(datetime_t time)
|
||||
{
|
||||
}
|
||||
|
||||
const bool PCF85063::readAlarm(datetime_t &time)
|
||||
{
|
||||
}
|
||||
|
||||
const bool PCF85063::getAlarmFlafs(uint8_t &flags)
|
||||
{
|
||||
}
|
||||
|
||||
const std::string PCF85063::datetime2str(datetime_t &time)
|
||||
{
|
||||
}
|
||||
|
||||
const uint8_t PCF85063::decToBcd(int val)
|
||||
{
|
||||
}
|
||||
|
||||
const int PCF85063::bcdToDec(uint8_t val)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "I2C_Driver.h"
|
||||
#include <string>
|
||||
|
||||
// PCF85063_ADDRESS
|
||||
#define PCF85063_ADDRESS (0x51)
|
||||
@@ -90,3 +91,48 @@ void PCF85063_Set_Alarm(datetime_t time);
|
||||
void PCF85063_Read_Alarm(datetime_t *time);
|
||||
|
||||
void datetime_to_str(char *datetime_str, datetime_t time);
|
||||
|
||||
namespace drivers
|
||||
{
|
||||
|
||||
class PCF85063
|
||||
{
|
||||
I2C &m_i2c;
|
||||
uint8_t m_address;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint16_t year;
|
||||
uint8_t month;
|
||||
uint8_t day;
|
||||
uint8_t dotw;
|
||||
uint8_t hour;
|
||||
uint8_t minute;
|
||||
uint8_t second;
|
||||
} datetime_t;
|
||||
|
||||
public:
|
||||
PCF85063(I2C &i2c, const uint8_t address, const uint8_t ctrl1, const uint8_t ctrl2);
|
||||
|
||||
const bool reset(void);
|
||||
|
||||
const bool setTime(datetime_t time);
|
||||
const bool setDate(datetime_t date);
|
||||
const bool setDatetime(datetime_t datetime);
|
||||
|
||||
const bool readDate(datetime_t &datetime);
|
||||
const bool readTime(datetime_t &datetime);
|
||||
const bool readDatetime(datetime_t &datetime);
|
||||
|
||||
const bool enableAlarm(const bool enable);
|
||||
const bool setAlarm(datetime_t time);
|
||||
const bool readAlarm(datetime_t &time);
|
||||
const bool getAlarmFlafs(uint8_t& flags);
|
||||
|
||||
private:
|
||||
const std::string datetime2str(datetime_t &time);
|
||||
const uint8_t decToBcd(int val);
|
||||
const int bcdToDec(uint8_t val);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ void setup() {
|
||||
Flash_test();
|
||||
GPIO_Init(); // RGB . Buzzer GPIO
|
||||
//I2C_Init();
|
||||
RTC_Init();// RTC
|
||||
//RTC_Init(); // RTC
|
||||
SD_Init();
|
||||
Serial_Init(); // UART(RS485/CAN)
|
||||
MQTT_Init();// MQTT
|
||||
|
||||
Reference in New Issue
Block a user