/*
- Copyright (C) Dean Camera, 2010.
-
+ Copyright (C) Dean Camera, 2011.
+
dean [at] fourwalledcubicle [dot] com
- www.fourwalledcubicle.com
+ www.lufa-lib.org
*/
#include "DS1307.h"
return;
#endif
- DS1307_DateRegs_t CurrentRTCDate;
+ DS1307_DateRegs_t CurrentRTCDate;
CurrentRTCDate.Byte1.Fields.TenDay = (Day / 10);
CurrentRTCDate.Byte1.Fields.Day = (Day % 10);
CurrentRTCDate.Byte2.Fields.TenMonth = (Month / 10);
TWI_SendByte(CurrentRTCDate.Byte1.IntVal);
TWI_SendByte(CurrentRTCDate.Byte2.IntVal);
TWI_SendByte(CurrentRTCDate.Byte3.IntVal);
-
+
TWI_StopTransmission();
}
}
CurrentRTCTime.Byte3.Fields.TenHour = (Hour / 10);
CurrentRTCTime.Byte3.Fields.Hour = (Hour % 10);
CurrentRTCTime.Byte3.Fields.TwelveHourMode = false;
-
+
if (TWI_StartTransmission(DS1307_ADDRESS_WRITE, 10))
{
TWI_SendByte(DS1307_TIMEREG_START);
TWI_SendByte(CurrentRTCTime.Byte1.IntVal);
TWI_SendByte(CurrentRTCTime.Byte2.IntVal);
TWI_SendByte(CurrentRTCTime.Byte3.IntVal);
-
+
TWI_StopTransmission();
}
}
-
+
void DS1307_GetDate(uint8_t* const Day,
uint8_t* const Month,
uint8_t* const Year)
if (TWI_StartTransmission(DS1307_ADDRESS_WRITE, 10))
{
TWI_SendByte(DS1307_DATEREG_START);
-
+
TWI_StopTransmission();
}
TWI_ReceiveByte(&CurrentRTCDate.Byte1.IntVal, false);
TWI_ReceiveByte(&CurrentRTCDate.Byte2.IntVal, false);
TWI_ReceiveByte(&CurrentRTCDate.Byte3.IntVal, true);
-
+
TWI_StopTransmission();
}
if (TWI_StartTransmission(DS1307_ADDRESS_WRITE, 10))
{
TWI_SendByte(DS1307_TIMEREG_START);
-
+
TWI_StopTransmission();
}
-
+
DS1307_TimeRegs_t CurrentRTCTime;
if (TWI_StartTransmission(DS1307_ADDRESS_READ, 10))
TWI_ReceiveByte(&CurrentRTCTime.Byte1.IntVal, false);
TWI_ReceiveByte(&CurrentRTCTime.Byte2.IntVal, false);
TWI_ReceiveByte(&CurrentRTCTime.Byte3.IntVal, true);
-
+
TWI_StopTransmission();
}
*Minute = (CurrentRTCTime.Byte2.Fields.TenMin * 10) + CurrentRTCTime.Byte2.Fields.Min;
*Hour = (CurrentRTCTime.Byte3.Fields.TenHour * 10) + CurrentRTCTime.Byte3.Fields.Hour;
}
+