You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
127 lines
2.0 KiB
127 lines
2.0 KiB
15 years ago
|
/*
|
||
12 years ago
|
Copyright (C) Dean Camera, 2013.
|
||
14 years ago
|
|
||
15 years ago
|
dean [at] fourwalledcubicle [dot] com
|
||
14 years ago
|
www.lufa-lib.org
|
||
15 years ago
|
*/
|
||
|
|
||
11 years ago
|
#ifndef _RTC_H_
|
||
|
#define _RTC_H_
|
||
15 years ago
|
|
||
|
/* Includes: */
|
||
|
#include <avr/io.h>
|
||
|
|
||
|
#include <LUFA/Drivers/Peripheral/TWI.h>
|
||
11 years ago
|
|
||
13 years ago
|
#include "Config/AppConfig.h"
|
||
15 years ago
|
|
||
|
/* Type Defines: */
|
||
14 years ago
|
typedef struct
|
||
|
{
|
||
|
uint8_t Hour;
|
||
|
uint8_t Minute;
|
||
|
uint8_t Second;
|
||
|
uint8_t Day;
|
||
|
uint8_t Month;
|
||
|
uint8_t Year;
|
||
|
} TimeDate_t;
|
||
13 years ago
|
|
||
15 years ago
|
typedef struct
|
||
|
{
|
||
|
union
|
||
|
{
|
||
|
struct
|
||
|
{
|
||
14 years ago
|
unsigned Sec : 4;
|
||
|
unsigned TenSec : 3;
|
||
|
unsigned CH : 1;
|
||
15 years ago
|
} Fields;
|
||
14 years ago
|
|
||
15 years ago
|
uint8_t IntVal;
|
||
|
} Byte1;
|
||
14 years ago
|
|
||
15 years ago
|
union
|
||
|
{
|
||
|
struct
|
||
|
{
|
||
14 years ago
|
unsigned Min : 4;
|
||
|
unsigned TenMin : 3;
|
||
|
unsigned Reserved : 1;
|
||
15 years ago
|
} Fields;
|
||
14 years ago
|
|
||
15 years ago
|
uint8_t IntVal;
|
||
|
} Byte2;
|
||
14 years ago
|
|
||
15 years ago
|
union
|
||
|
{
|
||
|
struct
|
||
|
{
|
||
14 years ago
|
unsigned Hour : 4;
|
||
|
unsigned TenHour : 2;
|
||
|
unsigned TwelveHourMode : 1;
|
||
|
unsigned Reserved : 1;
|
||
15 years ago
|
} Fields;
|
||
14 years ago
|
|
||
15 years ago
|
uint8_t IntVal;
|
||
|
} Byte3;
|
||
|
|
||
14 years ago
|
union
|
||
|
{
|
||
|
struct
|
||
|
{
|
||
14 years ago
|
unsigned DayOfWeek : 3;
|
||
|
unsigned Reserved : 5;
|
||
14 years ago
|
} Fields;
|
||
|
|
||
|
uint8_t IntVal;
|
||
|
} Byte4;
|
||
13 years ago
|
|
||
15 years ago
|
union
|
||
|
{
|
||
|
struct
|
||
|
{
|
||
14 years ago
|
unsigned Day : 4;
|
||
|
unsigned TenDay : 2;
|
||
|
unsigned Reserved : 2;
|
||
15 years ago
|
} Fields;
|
||
14 years ago
|
|
||
15 years ago
|
uint8_t IntVal;
|
||
14 years ago
|
} Byte5;
|
||
15 years ago
|
|
||
|
union
|
||
|
{
|
||
|
struct
|
||
|
{
|
||
14 years ago
|
unsigned Month : 4;
|
||
|
unsigned TenMonth : 1;
|
||
|
unsigned Reserved : 3;
|
||
15 years ago
|
} Fields;
|
||
14 years ago
|
|
||
15 years ago
|
uint8_t IntVal;
|
||
14 years ago
|
} Byte6;
|
||
14 years ago
|
|
||
15 years ago
|
union
|
||
|
{
|
||
|
struct
|
||
|
{
|
||
14 years ago
|
unsigned Year : 4;
|
||
|
unsigned TenYear : 4;
|
||
15 years ago
|
} Fields;
|
||
14 years ago
|
|
||
15 years ago
|
uint8_t IntVal;
|
||
14 years ago
|
} Byte7;
|
||
|
} DS1307_DateTimeRegs_t;
|
||
15 years ago
|
|
||
|
/* Macros: */
|
||
13 years ago
|
/** TWI address of the DS1307 device on the bus. */
|
||
14 years ago
|
#define DS1307_ADDRESS 0xD0
|
||
15 years ago
|
|
||
|
/* Function Prototypes: */
|
||
11 years ago
|
void RTC_Init(void);
|
||
|
void RTC_Tick500ms(void);
|
||
|
bool RTC_SetTimeDate(const TimeDate_t* NewTimeDate);
|
||
|
bool RTC_GetTimeDate(TimeDate_t* const TimeDate);
|
||
15 years ago
|
|
||
|
#endif
|
||
14 years ago
|
|