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 |
Typedefs | |
typedef void(* | tr_hal_rtc_event_callback_t) (uint32_t event_bitmask, tr_hal_rtc_date_time current_date_time) |
Functions | |
RTC_REGISTERS_T * | tr_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) |
#define CHIP_MEMORY_MAP_RTC_BASE (0x40004000UL) |
chip register addresses section 2.2 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 DEFAULT_RTC_CONFIG |
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
#define RTC_REGISTERS ((RTC_REGISTERS_T *) CHIP_MEMORY_MAP_RTC_BASE) |
#define TR_HAL_DEFAULT_CLOCK_DIVISOR 2110000 |
#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 TR_HAL_MONTH_APRIL 4 |
#define TR_HAL_MONTH_AUGUST 8 |
#define TR_HAL_MONTH_DECEMBER 12 |
#define TR_HAL_MONTH_FEBRUARY 2 |
#define TR_HAL_MONTH_JANUARY 1 |
defines for months
#define TR_HAL_MONTH_JULY 7 |
#define TR_HAL_MONTH_JUNE 6 |
#define TR_HAL_MONTH_MARCH 3 |
#define TR_HAL_MONTH_MAY 5 |
#define TR_HAL_MONTH_NOVEMBER 11 |
#define TR_HAL_MONTH_OCTOBER 10 |
#define TR_HAL_MONTH_SEPTEMBER 9 |
#define TR_HAL_REG_SETTING_COMBO_EVENT 0x0200 |
#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_RTC_CONTROL_REG_ENABLE_BIT 0x100 |
#define TR_HAL_RTC_DAY_MAXIMUM 31 |
#define TR_HAL_RTC_DAY_MINIMUM 1 |
#define TR_HAL_RTC_DAY_TRIGGER_OFF_VALUE 32 |
#define TR_HAL_RTC_EVENT_TRIGGERED_COMBINED_EVENT 0x00000040 |
#define TR_HAL_RTC_EVENT_TRIGGERED_DAYS 0x00000008 |
#define TR_HAL_RTC_EVENT_TRIGGERED_HOURS 0x00000004 |
#define TR_HAL_RTC_EVENT_TRIGGERED_MILLISECONDS 0x00000080 |
#define TR_HAL_RTC_EVENT_TRIGGERED_MINUTES 0x00000002 |
#define TR_HAL_RTC_EVENT_TRIGGERED_MONTHS 0x00000010 |
#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
#define TR_HAL_RTC_EVENT_TRIGGERED_YEARS 0x00000020 |
#define TR_HAL_RTC_FEB_DAY_MAXIMUM 28 |
#define TR_HAL_RTC_FEB_LEAP_YEAR_DAY_MAXIMUM 29 |
#define TR_HAL_RTC_HOUR_MAXIMUM 23 |
#define TR_HAL_RTC_HOUR_MINIMUM 0 |
#define TR_HAL_RTC_HOUR_TRIGGER_OFF_VALUE 25 |
#define TR_HAL_RTC_INTERRUPT_ALL 0xFF |
#define TR_HAL_RTC_INTERRUPT_COMBINED_EVENT 0x40 |
#define TR_HAL_RTC_INTERRUPT_DAYS 0x08 |
#define TR_HAL_RTC_INTERRUPT_HOURS 0x04 |
#define TR_HAL_RTC_INTERRUPT_MILLISECONDS 0x80 |
#define TR_HAL_RTC_INTERRUPT_MINUTES 0x02 |
#define TR_HAL_RTC_INTERRUPT_MONTHS 0x10 |
#define TR_HAL_RTC_INTERRUPT_NONE 0x00 |
#define TR_HAL_RTC_INTERRUPT_SECONDS 0x01 |
#define TR_HAL_RTC_INTERRUPT_YEARS 0x20 |
#define TR_HAL_RTC_MILLISECOND_MAXIMUM 999 |
#define TR_HAL_RTC_MILLISECOND_MINIMUM 0 |
#define TR_HAL_RTC_MILLISECOND_TRIGGER_OFF_VALUE 1001 |
we want to be able to set events off, but we really can set events to trigger on change or trigger on value. To turn an event off we set to trigger on value and put an out-of-range value in the trigger register
#define TR_HAL_RTC_MINUTE_MAXIMUM 59 |
#define TR_HAL_RTC_MINUTE_MINIMUM 0 |
#define TR_HAL_RTC_MINUTE_TRIGGER_OFF_VALUE 62 |
#define TR_HAL_RTC_MONTH_MAXIMUM 12 |
#define TR_HAL_RTC_MONTH_MINIMUM 1 |
#define TR_HAL_RTC_MONTH_TRIGGER_OFF_VALUE 0 |
#define TR_HAL_RTC_SECOND_MAXIMUM 59 |
#define TR_HAL_RTC_SECOND_MINIMUM 0 |
#define TR_HAL_RTC_SECOND_TRIGGER_OFF_VALUE 62 |
#define TR_HAL_RTC_SHORT_MONTH_DAY_MAXIMUM 30 |
#define TR_HAL_RTC_UPDATE_CLOCK_DIVISOR 0x04 |
#define TR_HAL_RTC_UPDATE_EVENT_TRIGGER 0x02 |
#define TR_HAL_RTC_UPDATE_TIME_VALUES 0x01 |
#define TR_HAL_RTC_YEAR_MAXIMUM 2099 |
#define TR_HAL_RTC_YEAR_MINIMUM 2000 |
min and max values for the six units of time/date
#define TR_HAL_RTC_YEAR_TRIGGER_OFF_VALUE 0 |
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
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 |
this enum is used when we set up a time unit event, to tell which units we are using
uint32_t convert_bcd_to_int | ( | uint32_t | register_value | ) |
uint32_t convert_int_to_bcd | ( | uint32_t | int_value | ) |
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_status_t tr_hal_rtc_speedup_for_testing | ( | tr_hal_rtc_speedup_unit_t | speedup_unit | ) |