Trident IoT SDK
 
Loading...
Searching...
No Matches
T32CZ20_rtc.h File Reference

This is the chip specific include file for T32CZ20 RTC Driver note that there is a common include file for this HAL module that contains the APIs (such as the init function) that should be used by the application. More...

#include "tr_hal_platform.h"
+ Include dependency graph for T32CZ20_rtc.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

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_RTC_MILLISECOND_MINIMUM   0
 
#define TR_HAL_RTC_MILLISECOND_MAXIMUM   999
 
#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   (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 TR_HAL_RTC_CONTROL_REG_ENABLE_BIT   0x100
 
#define TR_HAL_DEFAULT_CLOCK_DIVISOR   2110000
 
#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_MILLISECONDS   0x80
 
#define TR_HAL_RTC_INTERRUPT_ALL   0xFF
 
#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 TR_HAL_RTC_EVENT_TRIGGERED_MILLISECONDS   0x00000080
 
#define TR_HAL_RTC_MILLISECOND_TRIGGER_OFF_VALUE   1001
 
#define TR_HAL_RTC_SECOND_TRIGGER_OFF_VALUE   62
 
#define TR_HAL_RTC_MINUTE_TRIGGER_OFF_VALUE   62
 
#define TR_HAL_RTC_HOUR_TRIGGER_OFF_VALUE   25
 
#define TR_HAL_RTC_DAY_TRIGGER_OFF_VALUE   32
 
#define TR_HAL_RTC_MONTH_TRIGGER_OFF_VALUE   0
 
#define TR_HAL_RTC_YEAR_TRIGGER_OFF_VALUE   0
 
#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_MILLISECONDS = 1 ,
  TR_HAL_RTC_TIME_UNIT_SECONDS = 2 ,
  TR_HAL_RTC_TIME_UNIT_MINUTES = 3 ,
  TR_HAL_RTC_TIME_UNIT_HOURS = 4 ,
  TR_HAL_RTC_TIME_UNIT_DAYS = 5 ,
  TR_HAL_RTC_TIME_UNIT_MONTHS = 6 ,
  TR_HAL_RTC_TIME_UNIT_YEARS = 7 ,
  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

This is the chip specific include file for T32CZ20 RTC Driver note that there is a common include file for this HAL module that contains the APIs (such as the init function) that should be used by the application.


the RTC module keeps track of 6 time units: seconds, minutes, hours, days, months, and years.

The RTC module also supports events (interrupts) triggered on time units There are 3 types of events (interrupts) that can be set for these time units:

  1. ON_UNIT_CHANGE - whenever a time unit changes, get an event. For instance, if this is set for days, then each time the day value changes (a new day starts) then an event would be generated. One of these events can be set for each time unit. (in other words, there could be 6 of these events setup at one time, one event for each time unit)
  2. ON_SPECIFIC_VALUE - whenever a time unit gets to a specific value. For instance, if this was set for minutes=15, then this event would trigger at times 0:15:00, 1:15:00, 2:15:00, etc. One of these events can be set for each time unit.
  3. COMBO EVENT - this event is set for a specific second, minute, hour, day, month, year. If this event is set, it is the only event that can be set (no ON_UNIT_CHANGE and no ON_SPECIFIC_VALUE can also be set at the same time). This event can be set so some time units are ignored, but if a time unit is ignored, all time units greater than the ignored time unit must also be ignored. For instance, days can be ignored but then months and years must ALSO be ignored (and sec, min, hours are NOT ignored)

SPDX-License-Identifier: LicenseRef-TridentMSLA SPDX-FileCopyrightText: 2025 Trident IoT, LLC https://www.tridentiot.com