TM STM32F4xx Libraries  v1.0.0
Libraries for STM32F4xx devices from Tilen Majerle
TM_DS1307_Functions

Library Functions. More...

Functions

TM_DS1307_Result_t TM_DS1307_Init (void)
 Initializes DS1307 RTC library. More...
 
uint8_t TM_DS1307_GetSeconds (void)
 Gets seconds from DS1307. More...
 
uint8_t TM_DS1307_GetMinutes (void)
 Gets minutes from DS1307. More...
 
uint8_t TM_DS1307_GetHours (void)
 Gets hours from DS1307. More...
 
uint8_t TM_DS1307_GetDay (void)
 Gets day in a week from DS1307. More...
 
uint8_t TM_DS1307_GetDate (void)
 Gets date from DS1307. More...
 
uint8_t TM_DS1307_GetMonth (void)
 Gets month from DS1307. More...
 
uint8_t TM_DS1307_GetYear (void)
 Gets year from DS1307. More...
 
void TM_DS1307_SetSeconds (uint8_t seconds)
 Sets seconds to DS1307. More...
 
void TM_DS1307_SetMinutes (uint8_t minutes)
 Sets minutes to DS1307. More...
 
void TM_DS1307_SetHours (uint8_t hours)
 Sets hours to DS1307. More...
 
void TM_DS1307_SetDay (uint8_t day)
 Sets day to DS1307. More...
 
void TM_DS1307_SetDate (uint8_t date)
 Sets date to DS1307. More...
 
void TM_DS1307_SetMonth (uint8_t month)
 Sets month to DS1307. More...
 
void TM_DS1307_SetYear (uint8_t year)
 Sets year to DS1307. More...
 
void TM_DS1307_GetDateTime (TM_DS1307_Time_t *time)
 Gets full date and time from DS1307. More...
 
void TM_DS1307_SetDateTime (TM_DS1307_Time_t *time)
 Sets full date and time to DS1307. More...
 
void TM_DS1307_EnableOutputPin (TM_DS1307_OutputFrequency_t frequency)
 DS1307 has SQW/OUT pin, which can be enabled in various modes. It can output 32768Hz, 8192Hz, 4096Hz, 1Hz, Low or High state. This is useful if you need interrupts on MCU. 1Hz can be used to increment time by software each time. This is faster than look for date and time each time. More...
 
void TM_DS1307_DisableOutputPin (void)
 Disables SQW/OUT pin. More...
 
uint8_t TM_DS1307_Bcd2Bin (uint8_t bcd)
 Converts BCD to BIN data. More...
 
uint8_t TM_DS1307_Bin2Bcd (uint8_t bin)
 Converts BIN to BCD data. More...
 
uint8_t TM_DS1307_CheckMinMax (uint8_t val, uint8_t min, uint8_t max)
 Checks for min and max values, which can be stored to DS1307. More...
 

Detailed Description

Library Functions.

Function Documentation

uint8_t TM_DS1307_Bcd2Bin ( uint8_t  bcd)

Converts BCD to BIN data.

Parameters
bcdBCD value to be converted
Return values
BINvalue from given BCD
uint8_t TM_DS1307_Bin2Bcd ( uint8_t  bin)

Converts BIN to BCD data.

Parameters
binBIN value to be converted
Return values
BCDvalue from given BIN
uint8_t TM_DS1307_CheckMinMax ( uint8_t  val,
uint8_t  min,
uint8_t  max 
)

Checks for min and max values, which can be stored to DS1307.

Parameters
valValue to be checked
minMinimal allowed value of val
maxMaximal allowed value of val
Return values
Valuebetween min and max
void TM_DS1307_DisableOutputPin ( void  )

Disables SQW/OUT pin.

This function basically set pin to high state. To get high state you need external pull up resistor (or use pull up from MCU)

Return values
None
void TM_DS1307_EnableOutputPin ( TM_DS1307_OutputFrequency_t  frequency)

DS1307 has SQW/OUT pin, which can be enabled in various modes. It can output 32768Hz, 8192Hz, 4096Hz, 1Hz, Low or High state. This is useful if you need interrupts on MCU. 1Hz can be used to increment time by software each time. This is faster than look for date and time each time.

Note
Also, this pin is Open-Drain. This means that pin cannot supply positive power supply, for that you need external pull up resistor (or pull up from MCU).
Parameters
frequencySQW frequency. This parameter can be a value of TM_DS1307_OutputFrequency_t enumeration
Return values
None
uint8_t TM_DS1307_GetDate ( void  )

Gets date from DS1307.

Parameters
None
Return values
Datefrom DS1307, 01 to 31
void TM_DS1307_GetDateTime ( TM_DS1307_Time_t time)

Gets full date and time from DS1307.

Parameters
*timePointer to TM_DS1307_Time_t structure where to set data
Return values
None
uint8_t TM_DS1307_GetDay ( void  )

Gets day in a week from DS1307.

Parameters
None
Return values
Dayin a week from DS1307, 1 to 7
uint8_t TM_DS1307_GetHours ( void  )

Gets hours from DS1307.

Parameters
None
Return values
Hoursfrom DS1307, 00 to 23
uint8_t TM_DS1307_GetMinutes ( void  )

Gets minutes from DS1307.

Parameters
None
Return values
Minutesfrom DS1307, 00 to 59
uint8_t TM_DS1307_GetMonth ( void  )

Gets month from DS1307.

Parameters
None
Return values
Monthfrom DS1307, 01 to 12
uint8_t TM_DS1307_GetSeconds ( void  )

Gets seconds from DS1307.

Parameters
None
Return values
Secondsfrom DS1307, 00 to 59
uint8_t TM_DS1307_GetYear ( void  )

Gets year from DS1307.

Parameters
NoneReturns year from DS1307, 00 (2000) to 99 (2099)
TM_DS1307_Result_t TM_DS1307_Init ( void  )

Initializes DS1307 RTC library.

Parameters
None
Return values
None
void TM_DS1307_SetDate ( uint8_t  date)

Sets date to DS1307.

Parameters
dateDate to be set to DS1307, 01 to 31
Return values
None
void TM_DS1307_SetDateTime ( TM_DS1307_Time_t time)

Sets full date and time to DS1307.

Parameters
*timePointer to TM_DS1307_Time_t structure where to get data
Return values
None
void TM_DS1307_SetDay ( uint8_t  day)

Sets day to DS1307.

Parameters
dayDay to be set to DS1307, 1 to 7
Return values
None
void TM_DS1307_SetHours ( uint8_t  hours)

Sets hours to DS1307.

Parameters
hoursHours to be set to DS1307, 01 to 23
Return values
None
void TM_DS1307_SetMinutes ( uint8_t  minutes)

Sets minutes to DS1307.

Parameters
minutesMinutes to be set to DS1307, 01 to 59
Return values
None
void TM_DS1307_SetMonth ( uint8_t  month)

Sets month to DS1307.

Parameters
monthMonth to be set to DS1307, 01 to 12
Return values
None
void TM_DS1307_SetSeconds ( uint8_t  seconds)

Sets seconds to DS1307.

Parameters
secondsSeconds to be set to DS1307, 01 to 59
Return values
None
void TM_DS1307_SetYear ( uint8_t  year)

Sets year to DS1307.

Parameters
yearYear to be set to DS1307, 00 (2000) to 99 (2099)
Return values
None