|
|
@ -21,7 +21,7 @@ void DS1307_SetDate(uint8_t Day, uint8_t Month, uint8_t Year)
|
|
|
|
CurrentRTCDate.Byte3.TenYear = (Year / 10);
|
|
|
|
CurrentRTCDate.Byte3.TenYear = (Year / 10);
|
|
|
|
CurrentRTCDate.Byte3.Year = (Year % 10);
|
|
|
|
CurrentRTCDate.Byte3.Year = (Year % 10);
|
|
|
|
|
|
|
|
|
|
|
|
if (TWI_StartTransmission(DS1307_ADDRESS_WRITE))
|
|
|
|
if (TWI_StartTransmission(DS1307_ADDRESS_WRITE, 10))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
TWI_SendByte(DS1307_DATEREG_START);
|
|
|
|
TWI_SendByte(DS1307_DATEREG_START);
|
|
|
|
TWI_SendByte(CurrentRTCDate.Byte1.IntVal);
|
|
|
|
TWI_SendByte(CurrentRTCDate.Byte1.IntVal);
|
|
|
@ -48,7 +48,7 @@ void DS1307_SetTime(uint8_t Hour, uint8_t Minute, uint8_t Second)
|
|
|
|
CurrentRTCTime.Byte3.Hour = (Hour % 10);
|
|
|
|
CurrentRTCTime.Byte3.Hour = (Hour % 10);
|
|
|
|
CurrentRTCTime.Byte3.TwelveHourMode = false;
|
|
|
|
CurrentRTCTime.Byte3.TwelveHourMode = false;
|
|
|
|
|
|
|
|
|
|
|
|
if (TWI_StartTransmission(DS1307_ADDRESS_WRITE))
|
|
|
|
if (TWI_StartTransmission(DS1307_ADDRESS_WRITE, 10))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
TWI_SendByte(DS1307_TIMEREG_START);
|
|
|
|
TWI_SendByte(DS1307_TIMEREG_START);
|
|
|
|
TWI_SendByte(CurrentRTCTime.Byte1.IntVal);
|
|
|
|
TWI_SendByte(CurrentRTCTime.Byte1.IntVal);
|
|
|
@ -68,7 +68,7 @@ void DS1307_GetDate(uint8_t* Day, uint8_t* Month, uint8_t* Year)
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
if (TWI_StartTransmission(DS1307_ADDRESS_WRITE))
|
|
|
|
if (TWI_StartTransmission(DS1307_ADDRESS_WRITE, 10))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
TWI_SendByte(DS1307_DATEREG_START);
|
|
|
|
TWI_SendByte(DS1307_DATEREG_START);
|
|
|
|
|
|
|
|
|
|
|
@ -77,7 +77,7 @@ void DS1307_GetDate(uint8_t* Day, uint8_t* Month, uint8_t* Year)
|
|
|
|
|
|
|
|
|
|
|
|
DS1307_DateRegs_t CurrentRTCDate;
|
|
|
|
DS1307_DateRegs_t CurrentRTCDate;
|
|
|
|
|
|
|
|
|
|
|
|
if (TWI_StartTransmission(DS1307_ADDRESS_READ))
|
|
|
|
if (TWI_StartTransmission(DS1307_ADDRESS_READ, 10))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
TWI_ReceiveByte(&CurrentRTCDate.Byte1.IntVal, false);
|
|
|
|
TWI_ReceiveByte(&CurrentRTCDate.Byte1.IntVal, false);
|
|
|
|
TWI_ReceiveByte(&CurrentRTCDate.Byte2.IntVal, false);
|
|
|
|
TWI_ReceiveByte(&CurrentRTCDate.Byte2.IntVal, false);
|
|
|
@ -100,7 +100,7 @@ void DS1307_GetTime(uint8_t* Hour, uint8_t* Minute, uint8_t* Second)
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
if (TWI_StartTransmission(DS1307_ADDRESS_WRITE))
|
|
|
|
if (TWI_StartTransmission(DS1307_ADDRESS_WRITE, 10))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
TWI_SendByte(DS1307_TIMEREG_START);
|
|
|
|
TWI_SendByte(DS1307_TIMEREG_START);
|
|
|
|
|
|
|
|
|
|
|
@ -109,7 +109,7 @@ void DS1307_GetTime(uint8_t* Hour, uint8_t* Minute, uint8_t* Second)
|
|
|
|
|
|
|
|
|
|
|
|
DS1307_TimeRegs_t CurrentRTCTime;
|
|
|
|
DS1307_TimeRegs_t CurrentRTCTime;
|
|
|
|
|
|
|
|
|
|
|
|
if (TWI_StartTransmission(DS1307_ADDRESS_READ))
|
|
|
|
if (TWI_StartTransmission(DS1307_ADDRESS_READ, 10))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
TWI_ReceiveByte(&CurrentRTCTime.Byte1.IntVal, false);
|
|
|
|
TWI_ReceiveByte(&CurrentRTCTime.Byte1.IntVal, false);
|
|
|
|
TWI_ReceiveByte(&CurrentRTCTime.Byte2.IntVal, false);
|
|
|
|
TWI_ReceiveByte(&CurrentRTCTime.Byte2.IntVal, false);
|
|
|
|