TM STM32Fxxx HAL Libraries  v1.0.0
Libraries for STM32Fxxx (F0, F4 and F7 series) devices based on HAL drivers from ST from Tilen Majerle

Library Functions. More...

Functions

uint32_t TM_RTC_Init (TM_RTC_ClockSource_t source)
 Initializes RTC and starts counting. More...
 
uint32_t TM_RTC_GetUnixTimeStamp (TM_RTC_t *data)
 Gets number of seconds from date and time since 01.01.1970 00:00:00. More...
 
TM_RTC_Result_t TM_RTC_GetDateTimeFromUnix (TM_RTC_t *data, uint32_t unix)
 Gets formatted time from seconds till 01.01.1970 00:00:00 It fills struct with valid data. More...
 
TM_RTC_Result_t TM_RTC_Interrupts (TM_RTC_Int_t int_value)
 Selects RTC wakeup interrupts interval. More...
 
TM_RTC_Result_t TM_RTC_SetDateTime (TM_RTC_t *data, TM_RTC_Format_t format)
 Sets date and time to internal RTC registers. More...
 
TM_RTC_Result_t TM_RTC_SetDateTimeString (char *str)
 Sets date and time using string formatted date time. More...
 
TM_RTC_Result_t TM_RTC_GetDateTime (TM_RTC_t *data, TM_RTC_Format_t format)
 Gets date and time from internal RTC registers. More...
 
uint8_t TM_RTC_GetDaysInMonth (uint8_t month, uint8_t year)
 Gets number of days in month. More...
 
uint16_t TM_RTC_GetDaysInYear (uint8_t year)
 Gets number of days in specific year. More...
 
void TM_RTC_WriteBackupRegister (uint8_t location, uint32_t value)
 Writes RTC backup register value. This method allows you to write 32bit value from backup register 0 - 18 for STM32F4xx and 0 - 30 for STM32F7xx. More...
 
uint32_t TM_RTC_ReadBackupRegister (uint8_t location)
 Reads RTC backup register value. This method allows you to read 32bit value from backup register 0 - 18 for STM32F4xx and 0 - 30 for STM32F7xx. More...
 
TM_RTC_Result_t TM_RTC_EnableAlarm (TM_RTC_Alarm_t Alarm, TM_RTC_AlarmTime_t *AlarmTime, TM_RTC_Format_t format)
 Enables alarm A or alarm B. More...
 
TM_RTC_Result_t TM_RTC_DisableAlarm (TM_RTC_Alarm_t Alarm)
 Disables specific alarm. More...
 
void TM_RTC_WakeupHandler (void)
 RTC Wakeup handler function. Called when wakeup interrupt is triggered. More...
 
void TM_RTC_AlarmAHandler (void)
 RTC Alarm A handler function. Called when interrupt is triggered for alarm A. More...
 
void TM_RTC_AlarmBHandler (void)
 RTC Alarm B handler function. Called when interrupt is triggered for alarm B. More...
 

Detailed Description

Library Functions.

Function Documentation

void TM_RTC_AlarmAHandler ( void  )

RTC Alarm A handler function. Called when interrupt is triggered for alarm A.

Note
Called from my RTC library
Parameters
None
Return values
None
Note
With __weak parameter to prevent link errors if not defined by user
void TM_RTC_AlarmBHandler ( void  )

RTC Alarm B handler function. Called when interrupt is triggered for alarm B.

Note
Called from my RTC library
Parameters
None
Return values
None
Note
With __weak parameter to prevent link errors if not defined by user
TM_RTC_Result_t TM_RTC_DisableAlarm ( TM_RTC_Alarm_t  Alarm)

Disables specific alarm.

Parameters
AlarmSelect which alarm you want to disable. This parameter can be a value of TM_RTC_Alarm_t enumeration
Return values
Memberof TM_RTC_Result_t enumeration
TM_RTC_Result_t TM_RTC_EnableAlarm ( TM_RTC_Alarm_t  Alarm,
TM_RTC_AlarmTime_t AlarmTime,
TM_RTC_Format_t  format 
)

Enables alarm A or alarm B.

Parameters
AlarmSpecify which alarm to set. This parameter can be a value of TM_RTC_Alarm_t enumeration
*AlarmTimePointer to TM_RTC_AlarmTime_t structure to get data from.
formatRTC date and time format. This parameter can be a value of TM_RTC_Format_t enumeration.
Return values
Memberof TM_RTC_Result_t enumeration
TM_RTC_Result_t TM_RTC_GetDateTime ( TM_RTC_t data,
TM_RTC_Format_t  format 
)

Gets date and time from internal RTC registers.

Parameters
*dataPointer to TM_RTC_t structure to save data to
formatFormat of your structure. This parameter can be a value of TM_RTC_Format_t enumeration
Return values
Memberof TM_RTC_Result_t enumeration
TM_RTC_Result_t TM_RTC_GetDateTimeFromUnix ( TM_RTC_t data,
uint32_t  unix 
)

Gets formatted time from seconds till 01.01.1970 00:00:00 It fills struct with valid data.

Note
Valid if year is greater or equal (>=) than 2000
Parameters
*dataPointer to TM_RTC_Time_t struct to store formatted data in
unixSeconds from 01.01.1970 00:00:00 to calculate user friendly time
Return values
Memberof TM_RTC_Result_t enumeration
uint8_t TM_RTC_GetDaysInMonth ( uint8_t  month,
uint8_t  year 
)

Gets number of days in month.

Note
This function also detects if it is leap year and returns different number for February
Parameters
monthMonth number in year, valid numbers are 1 - 12
yearYear number where you want to get days in month, last 2 digits
Return values
Numberof days in specific month and year
uint16_t TM_RTC_GetDaysInYear ( uint8_t  year)

Gets number of days in specific year.

Note
This function also detects if it is leap year
Parameters
yearYear number where you want to get days in month, last 2 digits
Return values
Numberof days in year
uint32_t TM_RTC_GetUnixTimeStamp ( TM_RTC_t data)

Gets number of seconds from date and time since 01.01.1970 00:00:00.

Parameters
*dataPointer to TM_RTC_t data structure
Return values
Calculatedseconds from date and time since 01.01.1970 00:00:00
uint32_t TM_RTC_Init ( TM_RTC_ClockSource_t  source)

Initializes RTC and starts counting.

Parameters
source.RTC Clock source TM_RTC_ClockSource_t to be used for RTC
Note
Internal clock source is not so accurate
If you reset your MCU and RTC still has power, it will count independent of MCU status
Return values
ReturnsRTC status.
  • 1: RTC has already been initialized and time is set
  • 0: RTC was now initialized first time. Now you can set your first clock
TM_RTC_Result_t TM_RTC_Interrupts ( TM_RTC_Int_t  int_value)

Selects RTC wakeup interrupts interval.

Note
This function can also be used to disable interrupt
Parameters
int_valueLook for TM_RTC_Int_t for valid inputs
Return values
Memberof TM_RTC_Result_t enumeration
uint32_t TM_RTC_ReadBackupRegister ( uint8_t  location)

Reads RTC backup register value. This method allows you to read 32bit value from backup register 0 - 18 for STM32F4xx and 0 - 30 for STM32F7xx.

Note
RTC has backup registers where you can store data which will be available all the time RTC is running and has power.
My library uses register 19 to store info about RTC settings and is not available for USER to store data there.
RTC HAS to be initialized first before you can use this method.
Parameters
locationRTC backup register location 0 - 18 for STM32F4xx and 0 - 30 for STM32F7xx are valid
Return values
Valueat specific RTC backup register location
TM_RTC_Result_t TM_RTC_SetDateTime ( TM_RTC_t data,
TM_RTC_Format_t  format 
)

Sets date and time to internal RTC registers.

Parameters
*dataPointer to filled TM_RTC_t structure with date and time
formatFormat of your structure. This parameter can be a value of TM_RTC_Format_t enumeration
Return values
Memberof TM_RTC_Result_t enumeration
  • TM_RTC_Result_Ok: Date and Time set OK
  • TM_RTC_Result_Error: Date and time is wrong
TM_RTC_Result_t TM_RTC_SetDateTimeString ( char *  str)

Sets date and time using string formatted date time.

Note
Valid string format is: dd.mm.YY.x;HH:ii:ss
  • dd: date, 2 digits, decimal
  • mm: month, 2 digits, decimal
  • YY: year, last 2 digits, decimal
  • x: day in a week: 1 digit, 1 = Monday, 7 = Sunday
  • HH: hours, 24-hour mode, 2 digits, decimal
  • ii: minutes, 2 digits, decimal
  • ss: seconds, 2 digits, decimal
Parameters
*strPointer to string with datetime format
Return values
RTCdatetime status TM_RTC_Result_t:
  • TM_RTC_Result_Ok: Date and Time set OK
  • TM_RTC_Result_Error: Date and time is wrong
void TM_RTC_WakeupHandler ( void  )

RTC Wakeup handler function. Called when wakeup interrupt is triggered.

Note
Called from my RTC library
Parameters
None
Return values
None
Note
With __weak parameter to prevent link errors if not defined by user
void TM_RTC_WriteBackupRegister ( uint8_t  location,
uint32_t  value 
)

Writes RTC backup register value. This method allows you to write 32bit value from backup register 0 - 18 for STM32F4xx and 0 - 30 for STM32F7xx.

Note
RTC has backup registers where you can store data which will be available all the time RTC is running and has power.
My library uses register 19 to store info about RTC settings and is not available for USER to store data there.
RTC HAS to be initialized first before you can use this method.
Parameters
locationRTC backup register location 0 - 18 for STM32F4xx and 0 - 30 for STM32F7xx are valid
value32-bit long value to be stored in RTC backup register
Return values
Valueat specific RTC backup register location