Trident IoT SDK
 
Loading...
Searching...
No Matches
+ Collaboration diagram for RTC CM11:

Data Structures

struct  tr_hal_rtc_date
 convenience structs for use when passing around dates, times, or both More...
 
struct  tr_hal_rtc_time
 
struct  tr_hal_rtc_date_time
 
struct  RTC_REGISTERS_T
 the struct we use so we can address registers using field names More...
 
struct  tr_hal_rtc_settings_t
 

Macros

#define TR_HAL_RTC_YEAR_MINIMUM   2000
 min and max values for the six units of time/date
 
#define TR_HAL_RTC_YEAR_MAXIMUM   2099
 
#define TR_HAL_RTC_MONTH_MINIMUM   1
 
#define TR_HAL_RTC_MONTH_MAXIMUM   12
 
#define TR_HAL_RTC_DAY_MINIMUM   1
 
#define TR_HAL_RTC_DAY_MAXIMUM   31
 
#define TR_HAL_RTC_SHORT_MONTH_DAY_MAXIMUM   30
 
#define TR_HAL_RTC_FEB_DAY_MAXIMUM   28
 
#define TR_HAL_RTC_FEB_LEAP_YEAR_DAY_MAXIMUM   29
 
#define TR_HAL_RTC_HOUR_MINIMUM   0
 
#define TR_HAL_RTC_HOUR_MAXIMUM   23
 
#define TR_HAL_RTC_MINUTE_MINIMUM   0
 
#define TR_HAL_RTC_MINUTE_MAXIMUM   59
 
#define TR_HAL_RTC_SECOND_MINIMUM   0
 
#define TR_HAL_RTC_SECOND_MAXIMUM   59
 
#define TR_HAL_MONTH_JANUARY   1
 
#define TR_HAL_MONTH_FEBRUARY   2
 
#define TR_HAL_MONTH_MARCH   3
 
#define TR_HAL_MONTH_APRIL   4
 
#define TR_HAL_MONTH_MAY   5
 
#define TR_HAL_MONTH_JUNE   6
 
#define TR_HAL_MONTH_JULY   7
 
#define TR_HAL_MONTH_AUGUST   8
 
#define TR_HAL_MONTH_SEPTEMBER   9
 
#define TR_HAL_MONTH_OCTOBER   10
 
#define TR_HAL_MONTH_NOVEMBER   11
 
#define TR_HAL_MONTH_DECEMBER   12
 
#define TR_HAL_INVALID_DATE_TIME_VALUE   255
 special invalid value for any of the 6 time units: this define is used for the COMBO EVENT. If the caller does not want to use one or more of the time units, then the value of those time units should be set to this value
 
#define CHIP_MEMORY_MAP_RTC_BASE   (0x40600000UL)
 chip register addresses section 3.1 of the data sheet explains the Memory map. this gives the base address for how to write the chip registers the chip registers are how the software interacts and configures the SPI peripherals. We create a struct below that addresses the individual registers. This makes it so we can use this base address and a struct field to read or write a chip register
 
#define TR_HAL_DEFAULT_CLOCK_DIVISOR   39999
 
#define TR_HAL_REG_SETTING_EVENT_OFF   0x0000
 
#define TR_HAL_REG_SETTING_EVENT_ON_CHANGE   0x0100
 
#define TR_HAL_REG_SETTING_EVENT_ON_VALUE   0x0000
 
#define TR_HAL_REG_SETTING_COMBO_EVENT   0x0200
 
#define TR_HAL_RTC_INTERRUPT_NONE   0x00
 
#define TR_HAL_RTC_INTERRUPT_SECONDS   0x01
 
#define TR_HAL_RTC_INTERRUPT_MINUTES   0x02
 
#define TR_HAL_RTC_INTERRUPT_HOURS   0x04
 
#define TR_HAL_RTC_INTERRUPT_DAYS   0x08
 
#define TR_HAL_RTC_INTERRUPT_MONTHS   0x10
 
#define TR_HAL_RTC_INTERRUPT_YEARS   0x20
 
#define TR_HAL_RTC_INTERRUPT_COMBINED_EVENT   0x40
 
#define TR_HAL_RTC_INTERRUPT_ALL   0x7F
 
#define TR_HAL_RTC_UPDATE_TIME_VALUES   0x01
 
#define TR_HAL_RTC_UPDATE_EVENT_TRIGGER   0x02
 
#define TR_HAL_RTC_UPDATE_CLOCK_DIVISOR   0x04
 
#define RTC_REGISTERS   ((RTC_REGISTERS_T *) CHIP_MEMORY_MAP_RTC_BASE)
 
#define TR_HAL_RTC_EVENT_TRIGGERED_SECONDS   0x00000001
 
#define TR_HAL_RTC_EVENT_TRIGGERED_MINUTES   0x00000002
 
#define TR_HAL_RTC_EVENT_TRIGGERED_HOURS   0x00000004
 
#define TR_HAL_RTC_EVENT_TRIGGERED_DAYS   0x00000008
 
#define TR_HAL_RTC_EVENT_TRIGGERED_MONTHS   0x00000010
 
#define TR_HAL_RTC_EVENT_TRIGGERED_YEARS   0x00000020
 
#define TR_HAL_RTC_EVENT_TRIGGERED_COMBINED_EVENT   0x00000040
 
#define DEFAULT_RTC_CONFIG
 

Typedefs

typedef void(* tr_hal_rtc_event_callback_t) (uint32_t event_bitmask, tr_hal_rtc_date_time current_date_time)
 

Enumerations

enum  tr_hal_rtc_time_unit_t {
  TR_HAL_RTC_TIME_UNIT_SECONDS = 0 ,
  TR_HAL_RTC_TIME_UNIT_MINUTES = 1 ,
  TR_HAL_RTC_TIME_UNIT_HOURS = 2 ,
  TR_HAL_RTC_TIME_UNIT_DAYS = 3 ,
  TR_HAL_RTC_TIME_UNIT_MONTHS = 4 ,
  TR_HAL_RTC_TIME_UNIT_YEARS = 5 ,
  TR_HAL_RTC_TIME_UNIT_INVALID = 255
}
 this enum is used when we set up a time unit event, to tell which units we are using More...
 
enum  tr_hal_rtc_event_trigger_t {
  TR_HAL_EVENT_TRIGGER_OFF = 0 ,
  TR_HAL_EVENT_TRIGGER_ON_UNIT_CHANGE = 1 ,
  TR_HAL_EVENT_TRIGGER_ON_SPECIFIC_VALUE = 2 ,
  TR_HAL_EVENT_TRIGGER_INVALID = 255
}
 this enum is the trigger setting for time unit events OFF = not enabled ON_CHANGE = whenever the time unit changes ON_VALUE = only when time unit == a specific value INVALID = used when setting up a combo event when a time unit should not be used More...
 
enum  tr_hal_rtc_speedup_unit_t {
  TR_HAL_RTC_SPEEDUP_NONE = 0x01 ,
  TR_HAL_RTC_SPEEDUP_MINUTES = 0x02 ,
  TR_HAL_RTC_SPEEDUP_HOURS = 0x04 ,
  TR_HAL_RTC_SPEEDUP_DAYS = 0x08 ,
  TR_HAL_RTC_SPEEDUP_MONTHS = 0x10 ,
  TR_HAL_RTC_SPEEDUP_YEARS = 0x20
}
 

Functions

RTC_REGISTERS_Ttr_hal_rtc_get_register_address (void)
 
tr_hal_status_t tr_hal_rtc_speedup_for_testing (tr_hal_rtc_speedup_unit_t speedup_unit)
 
uint32_t convert_bcd_to_int (uint32_t register_value)
 
uint32_t convert_int_to_bcd (uint32_t int_value)
 

Detailed Description



Macro Definition Documentation

◆ CHIP_MEMORY_MAP_RTC_BASE

#define CHIP_MEMORY_MAP_RTC_BASE   (0x40600000UL)

chip register addresses section 3.1 of the data sheet explains the Memory map. this gives the base address for how to write the chip registers the chip registers are how the software interacts and configures the SPI peripherals. We create a struct below that addresses the individual registers. This makes it so we can use this base address and a struct field to read or write a chip register



◆ DEFAULT_RTC_CONFIG

#define DEFAULT_RTC_CONFIG
Value:
{ \
.rtc_date_time.time.seconds = 0, \
.rtc_date_time.time.minutes = 0, \
.rtc_date_time.time.hours = 0, \
.rtc_date_time.date.days = 1, \
.rtc_date_time.date.months = 1, \
.rtc_date_time.date.years = 2025, \
.clock_divisor = TR_HAL_DEFAULT_CLOCK_DIVISOR, \
.event_handler_fx = NULL, \
.enable_chip_interrupts = true, \
.interrupt_priority = TR_HAL_INTERRUPT_PRIORITY_5, \
.wake_on_interrupt = false, \
.seconds_event_trigger = TR_HAL_EVENT_TRIGGER_OFF, \
.minutes_event_trigger = TR_HAL_EVENT_TRIGGER_OFF, \
.hours_event_trigger = TR_HAL_EVENT_TRIGGER_OFF, \
.days_event_trigger = TR_HAL_EVENT_TRIGGER_OFF, \
.months_event_trigger = TR_HAL_EVENT_TRIGGER_OFF, \
.years_event_trigger = TR_HAL_EVENT_TRIGGER_OFF, \
.combo_event_enabled = false, \
}
@ TR_HAL_INTERRUPT_PRIORITY_5
Definition tr_hal_platform.h:44
#define TR_HAL_DEFAULT_CLOCK_DIVISOR
Definition T32CM11_rtc.h:255
@ TR_HAL_EVENT_TRIGGER_OFF
Definition T32CM11_rtc.h:177

default RTC settings

date/time: Jan 1, 2025 at midnight (about to be 12:01 am on Jan 1) clock is set for 32 KHz (this could be tuned and based on an NV setting) event handler should be set by the app interrupts are enabled, with a reasonable priority, and are disabled on power off


◆ RTC_REGISTERS

#define RTC_REGISTERS   ((RTC_REGISTERS_T *) CHIP_MEMORY_MAP_RTC_BASE)

◆ TR_HAL_DEFAULT_CLOCK_DIVISOR

#define TR_HAL_DEFAULT_CLOCK_DIVISOR   39999

◆ TR_HAL_INVALID_DATE_TIME_VALUE

#define TR_HAL_INVALID_DATE_TIME_VALUE   255

special invalid value for any of the 6 time units: this define is used for the COMBO EVENT. If the caller does not want to use one or more of the time units, then the value of those time units should be set to this value



◆ TR_HAL_MONTH_APRIL

#define TR_HAL_MONTH_APRIL   4

◆ TR_HAL_MONTH_AUGUST

#define TR_HAL_MONTH_AUGUST   8

◆ TR_HAL_MONTH_DECEMBER

#define TR_HAL_MONTH_DECEMBER   12

◆ TR_HAL_MONTH_FEBRUARY

#define TR_HAL_MONTH_FEBRUARY   2

◆ TR_HAL_MONTH_JANUARY

#define TR_HAL_MONTH_JANUARY   1

defines for months


◆ TR_HAL_MONTH_JULY

#define TR_HAL_MONTH_JULY   7

◆ TR_HAL_MONTH_JUNE

#define TR_HAL_MONTH_JUNE   6

◆ TR_HAL_MONTH_MARCH

#define TR_HAL_MONTH_MARCH   3

◆ TR_HAL_MONTH_MAY

#define TR_HAL_MONTH_MAY   5

◆ TR_HAL_MONTH_NOVEMBER

#define TR_HAL_MONTH_NOVEMBER   11

◆ TR_HAL_MONTH_OCTOBER

#define TR_HAL_MONTH_OCTOBER   10

◆ TR_HAL_MONTH_SEPTEMBER

#define TR_HAL_MONTH_SEPTEMBER   9

◆ TR_HAL_REG_SETTING_COMBO_EVENT

#define TR_HAL_REG_SETTING_COMBO_EVENT   0x0200

◆ TR_HAL_REG_SETTING_EVENT_OFF

#define TR_HAL_REG_SETTING_EVENT_OFF   0x0000

◆ TR_HAL_REG_SETTING_EVENT_ON_CHANGE

#define TR_HAL_REG_SETTING_EVENT_ON_CHANGE   0x0100

◆ TR_HAL_REG_SETTING_EVENT_ON_VALUE

#define TR_HAL_REG_SETTING_EVENT_ON_VALUE   0x0000

◆ TR_HAL_RTC_DAY_MAXIMUM

#define TR_HAL_RTC_DAY_MAXIMUM   31

◆ TR_HAL_RTC_DAY_MINIMUM

#define TR_HAL_RTC_DAY_MINIMUM   1

◆ TR_HAL_RTC_EVENT_TRIGGERED_COMBINED_EVENT

#define TR_HAL_RTC_EVENT_TRIGGERED_COMBINED_EVENT   0x00000040

◆ TR_HAL_RTC_EVENT_TRIGGERED_DAYS

#define TR_HAL_RTC_EVENT_TRIGGERED_DAYS   0x00000008

◆ TR_HAL_RTC_EVENT_TRIGGERED_HOURS

#define TR_HAL_RTC_EVENT_TRIGGERED_HOURS   0x00000004

◆ TR_HAL_RTC_EVENT_TRIGGERED_MINUTES

#define TR_HAL_RTC_EVENT_TRIGGERED_MINUTES   0x00000002

◆ TR_HAL_RTC_EVENT_TRIGGERED_MONTHS

#define TR_HAL_RTC_EVENT_TRIGGERED_MONTHS   0x00000010

◆ TR_HAL_RTC_EVENT_TRIGGERED_SECONDS

#define TR_HAL_RTC_EVENT_TRIGGERED_SECONDS   0x00000001

these are the EVENTS that can be received into the RTC event handler functions. These are BITMASKs since we can have more than 1 in an event these are what the APP needs to handle in its event_handler_fx


◆ TR_HAL_RTC_EVENT_TRIGGERED_YEARS

#define TR_HAL_RTC_EVENT_TRIGGERED_YEARS   0x00000020

◆ TR_HAL_RTC_FEB_DAY_MAXIMUM

#define TR_HAL_RTC_FEB_DAY_MAXIMUM   28

◆ TR_HAL_RTC_FEB_LEAP_YEAR_DAY_MAXIMUM

#define TR_HAL_RTC_FEB_LEAP_YEAR_DAY_MAXIMUM   29

◆ TR_HAL_RTC_HOUR_MAXIMUM

#define TR_HAL_RTC_HOUR_MAXIMUM   23

◆ TR_HAL_RTC_HOUR_MINIMUM

#define TR_HAL_RTC_HOUR_MINIMUM   0

◆ TR_HAL_RTC_INTERRUPT_ALL

#define TR_HAL_RTC_INTERRUPT_ALL   0x7F

◆ TR_HAL_RTC_INTERRUPT_COMBINED_EVENT

#define TR_HAL_RTC_INTERRUPT_COMBINED_EVENT   0x40

◆ TR_HAL_RTC_INTERRUPT_DAYS

#define TR_HAL_RTC_INTERRUPT_DAYS   0x08

◆ TR_HAL_RTC_INTERRUPT_HOURS

#define TR_HAL_RTC_INTERRUPT_HOURS   0x04

◆ TR_HAL_RTC_INTERRUPT_MINUTES

#define TR_HAL_RTC_INTERRUPT_MINUTES   0x02

◆ TR_HAL_RTC_INTERRUPT_MONTHS

#define TR_HAL_RTC_INTERRUPT_MONTHS   0x10

◆ TR_HAL_RTC_INTERRUPT_NONE

#define TR_HAL_RTC_INTERRUPT_NONE   0x00

◆ TR_HAL_RTC_INTERRUPT_SECONDS

#define TR_HAL_RTC_INTERRUPT_SECONDS   0x01

◆ TR_HAL_RTC_INTERRUPT_YEARS

#define TR_HAL_RTC_INTERRUPT_YEARS   0x20

◆ TR_HAL_RTC_MINUTE_MAXIMUM

#define TR_HAL_RTC_MINUTE_MAXIMUM   59

◆ TR_HAL_RTC_MINUTE_MINIMUM

#define TR_HAL_RTC_MINUTE_MINIMUM   0

◆ TR_HAL_RTC_MONTH_MAXIMUM

#define TR_HAL_RTC_MONTH_MAXIMUM   12

◆ TR_HAL_RTC_MONTH_MINIMUM

#define TR_HAL_RTC_MONTH_MINIMUM   1

◆ TR_HAL_RTC_SECOND_MAXIMUM

#define TR_HAL_RTC_SECOND_MAXIMUM   59

◆ TR_HAL_RTC_SECOND_MINIMUM

#define TR_HAL_RTC_SECOND_MINIMUM   0

◆ TR_HAL_RTC_SHORT_MONTH_DAY_MAXIMUM

#define TR_HAL_RTC_SHORT_MONTH_DAY_MAXIMUM   30

◆ TR_HAL_RTC_UPDATE_CLOCK_DIVISOR

#define TR_HAL_RTC_UPDATE_CLOCK_DIVISOR   0x04

◆ TR_HAL_RTC_UPDATE_EVENT_TRIGGER

#define TR_HAL_RTC_UPDATE_EVENT_TRIGGER   0x02

◆ TR_HAL_RTC_UPDATE_TIME_VALUES

#define TR_HAL_RTC_UPDATE_TIME_VALUES   0x01

◆ TR_HAL_RTC_YEAR_MAXIMUM

#define TR_HAL_RTC_YEAR_MAXIMUM   2099

◆ TR_HAL_RTC_YEAR_MINIMUM

#define TR_HAL_RTC_YEAR_MINIMUM   2000

min and max values for the six units of time/date



Typedef Documentation

◆ tr_hal_rtc_event_callback_t

typedef void(* tr_hal_rtc_event_callback_t) (uint32_t event_bitmask, tr_hal_rtc_date_time current_date_time)

prototype for callback from the Trident HAL to the app when an event happens


Enumeration Type Documentation

◆ tr_hal_rtc_event_trigger_t

this enum is the trigger setting for time unit events OFF = not enabled ON_CHANGE = whenever the time unit changes ON_VALUE = only when time unit == a specific value INVALID = used when setting up a combo event when a time unit should not be used



Enumerator
TR_HAL_EVENT_TRIGGER_OFF 
TR_HAL_EVENT_TRIGGER_ON_UNIT_CHANGE 
TR_HAL_EVENT_TRIGGER_ON_SPECIFIC_VALUE 
TR_HAL_EVENT_TRIGGER_INVALID 

◆ tr_hal_rtc_speedup_unit_t

Enumerator
TR_HAL_RTC_SPEEDUP_NONE 
TR_HAL_RTC_SPEEDUP_MINUTES 
TR_HAL_RTC_SPEEDUP_HOURS 
TR_HAL_RTC_SPEEDUP_DAYS 
TR_HAL_RTC_SPEEDUP_MONTHS 
TR_HAL_RTC_SPEEDUP_YEARS 

◆ tr_hal_rtc_time_unit_t

this enum is used when we set up a time unit event, to tell which units we are using



Enumerator
TR_HAL_RTC_TIME_UNIT_SECONDS 
TR_HAL_RTC_TIME_UNIT_MINUTES 
TR_HAL_RTC_TIME_UNIT_HOURS 
TR_HAL_RTC_TIME_UNIT_DAYS 
TR_HAL_RTC_TIME_UNIT_MONTHS 
TR_HAL_RTC_TIME_UNIT_YEARS 
TR_HAL_RTC_TIME_UNIT_INVALID 

Function Documentation

◆ convert_bcd_to_int()

uint32_t convert_bcd_to_int ( uint32_t register_value)

◆ convert_int_to_bcd()

uint32_t convert_int_to_bcd ( uint32_t int_value)

◆ tr_hal_rtc_get_register_address()

RTC_REGISTERS_T * tr_hal_rtc_get_register_address ( void )

if the app wants to directly interface with the chip registers, this is a convenience function for getting the address/struct of the RTC registers


◆ tr_hal_rtc_speedup_for_testing()

tr_hal_status_t tr_hal_rtc_speedup_for_testing ( tr_hal_rtc_speedup_unit_t speedup_unit)