RTC library for Max31341/2 devices
Fork of max3134x by
RtcBase Class Reference
RTC base driver class for Maxim Max3134x RTC series. More...
#include <RtcBase.h>
Inherited by Max31341, and Max31342.
Public Types | |
enum | power_mgmt_mode_t { POW_MGMT_MODE_COMPARATOR, POW_MGMT_MODE_POWER_MANAGEMENT } |
Mode of the comparator. More... | |
enum | comp_thresh_t { COMP_THRESH_1V4, COMP_THRESH_1V6, COMP_THRESH_1V8, COMP_THRESH_2V0 } |
Analog comparator threshold voltage. More... | |
enum | power_mgmt_supply_t { POW_MGMT_SUPPLY_SEL_AUTO, POW_MGMT_SUPPLY_SEL_VCC, POW_MGMT_SUPPLY_SEL_AIN } |
Supply voltage select. More... | |
enum | trickle_charger_ohm_t { TRICKLE_CHARGER_3K5, TRICKLE_CHARGER_3K5_2, TRICKLE_CHARGER_7K, TRICKLE_CHARGER_13K } |
Selection of charging path's resistor value. More... | |
enum | timer_freq_t { TIMER_FREQ_1024HZ, TIMER_FREQ_256HZ, TIMER_FREQ_64HZ, TIMER_FREQ_16HZ } |
Timer frequency selection. More... | |
enum | clkin_freq_t { CLKIN_FREQ_1HZ, CLKIN_FREQ_50HZ, CLKIN_FREQ_60HZ, CLKIN_FREQ_32HZ768 } |
CLKIN frequency selection. More... | |
enum | square_wave_out_freq_t { SQUARE_WAVE_OUT_FREQ_1HZ, SQUARE_WAVE_OUT_FREQ_4096HZ, SQUARE_WAVE_OUT_FREQ_8192HZ, SQUARE_WAVE_OUT_FREQ_32768HZ } |
Square wave output frequency selection on CLKOUT pin. More... | |
enum | intr_id_t { INTR_ID_ALARM1, INTR_ID_ALARM2, INTR_ID_TIMER , INTR_ID_EXTERNAL, INTR_ID_ANALOG, INTR_ID_OSF, INTR_ID_LOS } |
Selection of interrupt ids. More... | |
enum | alarm_no_t { ALARM1, ALARM2 } |
Alarm number selection. More... | |
enum | alarm_period_t { ALARM_PERIOD_EVERYSECOND, ALARM_PERIOD_EVERYMINUTE, ALARM_PERIOD_HOURLY, ALARM_PERIOD_DAILY, ALARM_PERIOD_WEEKLY, ALARM_PERIOD_MONTHLY, ALARM_PERIOD_YEARLY, ALARM_PERIOD_ONETIME } |
Alarm periodicity selection. More... | |
enum | config_inta_clkin_pin_t { CONFIGURE_PIN_AS_INTA, CONFIGURE_PIN_AS_CLKIN } |
Selection of INTA/CLKIN pin function. More... | |
enum | config_intb_clkout_pin_t { CONFIGURE_PIN_AS_CLKOUT, CONFIGURE_PIN_AS_INTB } |
Selection of INTB/CLKOUT pin function. More... | |
enum | sync_delay_t { SYNC_DLY_LESS_THAN_1SEC = 0, SYNC_DLY_LESS_THAN_100MS, SYNC_DLY_LESS_THAN_20MS } |
Selection of sync delay. More... | |
typedef void(* | interrupt_handler_function )(void *) |
Function pointer type to interrupt handler function. | |
Public Member Functions | |
int | read_register (uint8_t reg, uint8_t *value, uint8_t len) |
Read from a register. | |
int | write_register (uint8_t reg, const uint8_t *value, uint8_t len) |
Write to a register. | |
int | get_time (struct tm *rtc_ctime) |
Read time info from RTC. | |
int | set_time (const struct tm *rtc_ctime) |
Set time info to RTC. | |
int | nvram_write (const uint8_t *buffer, int offset, int length) |
Non-volatile memory write. | |
int | nvram_read (uint8_t *buffer, int offset, int length) |
Non-volatile memory read. | |
int | nvram_size () |
NVRAM size of the part. | |
int | set_alarm (alarm_no_t alarm_no, const struct tm *alarm_time, alarm_period_t period) |
Set an alarm condition. | |
int | get_alarm (alarm_no_t alarm_no, struct tm *alarm_time, alarm_period_t *period, bool *is_enabled) |
Get alarm data & time. | |
int | set_power_mgmt_mode (power_mgmt_mode_t mode) |
Select power management mode of operation. | |
int | comparator_threshold_level (comp_thresh_t th) |
Set comparator threshold. | |
int | supply_select (power_mgmt_supply_t supply) |
Select device power source. | |
int | trickle_charger_enable (trickle_charger_ohm_t res, bool diode) |
Configure trickle charger charging path, also enable it. | |
int | trickle_charger_disable () |
Disable trickle charger. | |
int | set_output_square_wave_frequency (square_wave_out_freq_t freq) |
Select square wave output frequency selection. | |
int | set_clkin_frequency (clkin_freq_t freq) |
Select external clock input frequency. | |
int | configure_intb_clkout_pin (config_intb_clkout_pin_t sel) |
Select direction of INTB/CLKOUT pin. | |
int | configure_inta_clkin_pin (config_inta_clkin_pin_t sel) |
Select direction of INTA/CLKIN pin. | |
int | timer_init (uint8_t value, bool repeat, timer_freq_t freq) |
Initialize timer. | |
uint8_t | timer_get () |
Read timer value. | |
int | timer_start () |
Enable timer. | |
int | timer_pause () |
Pause timer, timer value is preserved. | |
int | timer_continue () |
Start timer from the paused value. | |
int | timer_stop () |
Disable timer. | |
int | data_retention_mode_enter () |
Put device into data retention mode. | |
int | data_retention_mode_exit () |
Remove device from data retention mode. | |
int | i2c_timeout_enable () |
Enable I2C bus timeout mechanism. | |
int | i2c_timeout_disable () |
Disable I2C bus timeout mechanism. | |
int | irq_enable (intr_id_t id) |
Enable interrupt. | |
int | irq_disable (intr_id_t id) |
Disable interrupt. | |
int | irq_disable_all () |
Disable all interrupts. | |
void | set_intr_handler (intr_id_t id, interrupt_handler_function func, void *cb) |
Set interrupt handler for a specific interrupt id. | |
int | sw_reset_assert () |
Put device into reset state. | |
int | sw_reset_release () |
Release device from state state. | |
int | rtc_start () |
Enable the RTC oscillator. | |
int | rtc_stop () |
Disable the RTC oscillator. | |
~RtcBase () | |
Base class destructor. | |
Protected Member Functions | |
RtcBase (const regmap_t *regmap, I2C *i2c, PinName inta_pin, PinName intb_pin) | |
Base class constructor. |
Detailed Description
RTC base driver class for Maxim Max3134x RTC series.
Definition at line 44 of file RtcBase.h.
Member Typedef Documentation
typedef void(* interrupt_handler_function)(void *) |
Member Enumeration Documentation
enum alarm_no_t |
enum alarm_period_t |
Alarm periodicity selection.
- Enumerator:
enum clkin_freq_t |
enum comp_thresh_t |
enum intr_id_t |
Selection of interrupt ids.
enum power_mgmt_mode_t |
enum power_mgmt_supply_t |
enum sync_delay_t |
Selection of sync delay.
enum timer_freq_t |
Constructor & Destructor Documentation
~RtcBase | ( | ) |
Base class destructor.
Definition at line 85 of file RtcBase.cpp.
RtcBase | ( | const regmap_t * | regmap, |
I2C * | i2c, | ||
PinName | inta_pin = NC , |
||
PinName | intb_pin = NC |
||
) | [protected] |
Base class constructor.
- Parameters:
-
[in] regmap Pointer to device register mappings. [in] i2c Pointer to I2C bus object for this device. [in] inta_pin MCU's pin number that device's INTA pin connected [in] intb_pin MCU's pin number that device's INTB pin connected
Definition at line 44 of file RtcBase.cpp.
Member Function Documentation
int comparator_threshold_level | ( | comp_thresh_t | th ) |
Set comparator threshold.
- Parameters:
-
[in] th Set Analog Comparator Threshold level, one of COMP_THRESH_*
- Returns:
- 0 on success, error code on failure
Definition at line 572 of file RtcBase.cpp.
int configure_inta_clkin_pin | ( | config_inta_clkin_pin_t | sel ) |
Select direction of INTA/CLKIN pin.
- Parameters:
-
[in] sel Pin function, one of CONFIGURE_PIN_B3_AS_INTA or CONFIGURE_PIN_B3_AS_CLKIN
- Returns:
- 0 on success, error code on failure
Definition at line 771 of file RtcBase.cpp.
int configure_intb_clkout_pin | ( | config_intb_clkout_pin_t | sel ) |
Select direction of INTB/CLKOUT pin.
- Parameters:
-
[in] sel Pin function, one of CONFIGURE_PIN_B3_AS_INTB or CONFIGURE_PIN_B3_AS_CLKOUT
- Returns:
- 0 on success, error code on failure
Definition at line 751 of file RtcBase.cpp.
int data_retention_mode_enter | ( | ) |
Put device into data retention mode.
- Returns:
- 0 on success, error code on failure
Definition at line 961 of file RtcBase.cpp.
int data_retention_mode_exit | ( | ) |
Remove device from data retention mode.
- Returns:
- 0 on success, error code on failure
Definition at line 966 of file RtcBase.cpp.
int get_alarm | ( | alarm_no_t | alarm_no, |
struct tm * | alarm_time, | ||
alarm_period_t * | period, | ||
bool * | is_enabled | ||
) |
Get alarm data & time.
- Parameters:
-
[in] alarm_no Alarm number, ALARM1 or ALARM2 [out] alarm_time Pointer to alarm time to be filled in [out] period Pointer to the period of alarm, one of ALARM_PERIOD_* [out] is_enabled Pointer to the state of alarm
- Returns:
- 0 on success, error code on failure
Definition at line 506 of file RtcBase.cpp.
int get_time | ( | struct tm * | rtc_ctime ) |
Read time info from RTC.
- Parameters:
-
[out] rtc_time Time info from RTC.
- Returns:
- 0 on success, negative error code on failure.
Definition at line 230 of file RtcBase.cpp.
int i2c_timeout_disable | ( | ) |
Disable I2C bus timeout mechanism.
- Returns:
- 0 on success, error code on failure
Definition at line 996 of file RtcBase.cpp.
int i2c_timeout_enable | ( | ) |
Enable I2C bus timeout mechanism.
- Returns:
- 0 on success, error code on failure
Definition at line 991 of file RtcBase.cpp.
int irq_disable | ( | intr_id_t | id ) |
Disable interrupt.
- Parameters:
-
[in] id Interrupt id, one of INTR_ID_*
- Returns:
- 0 on success, error code on failure
Definition at line 1021 of file RtcBase.cpp.
int irq_disable_all | ( | ) |
Disable all interrupts.
- Returns:
- 0 on success, error code on failure
Definition at line 1041 of file RtcBase.cpp.
int irq_enable | ( | intr_id_t | id ) |
Enable interrupt.
- Parameters:
-
[in] id Interrupt id, one of INTR_ID_*
- Returns:
- 0 on success, error code on failure
Definition at line 1001 of file RtcBase.cpp.
int nvram_read | ( | uint8_t * | buffer, |
int | offset, | ||
int | length | ||
) |
Non-volatile memory read.
- Parameters:
-
[in] buffer Buffer to read in to [in] offset Offset of location in NVRAM [in] length Number of bytes to read
- Returns:
- 0 on success, error code on failure
Definition at line 323 of file RtcBase.cpp.
int nvram_size | ( | ) |
NVRAM size of the part.
- Returns:
- 0 if part does not have a NVRAM, otherwise returns size
Definition at line 349 of file RtcBase.cpp.
int nvram_write | ( | const uint8_t * | buffer, |
int | offset, | ||
int | length | ||
) |
Non-volatile memory write.
- Parameters:
-
[out] buffer Pointer to the data to be written [in] offset Offset of location in NVRAM [in] length Number of bytes to write
- Returns:
- 0 on success, error code on failure
Definition at line 297 of file RtcBase.cpp.
int read_register | ( | uint8_t | reg, |
uint8_t * | value, | ||
uint8_t | len | ||
) |
Read from a register.
- Parameters:
-
[in] reg Address of a register to be read. [out] value Pointer to save result value. [in] len Size of result to be read.
- Returns:
- 0 on success, negative error code on failure.
Definition at line 100 of file RtcBase.cpp.
int rtc_start | ( | ) |
Enable the RTC oscillator.
- Returns:
- 0 on success, error code on failure
Definition at line 1139 of file RtcBase.cpp.
int rtc_stop | ( | ) |
Disable the RTC oscillator.
- Returns:
- 0 on success, error code on failure
Definition at line 1161 of file RtcBase.cpp.
int set_alarm | ( | alarm_no_t | alarm_no, |
const struct tm * | alarm_time, | ||
alarm_period_t | period | ||
) |
Set an alarm condition.
- Parameters:
-
[in] alarm_no Alarm number, ALARM1 or ALARM2 [in] alarm_time Pointer to alarm time to be set [in] period Alarm periodicity, one of ALARM_PERIOD_*
- Returns:
- 0 on success, error code on failure
Definition at line 482 of file RtcBase.cpp.
int set_clkin_frequency | ( | clkin_freq_t | freq ) |
Select external clock input frequency.
- Parameters:
-
[in] freq Clock frequency, one of CLKIN_FREQ_*
- Returns:
- 0 on success, error code on failure
Definition at line 725 of file RtcBase.cpp.
void set_intr_handler | ( | intr_id_t | id, |
interrupt_handler_function | func, | ||
void * | cb | ||
) |
Set interrupt handler for a specific interrupt id.
- Parameters:
-
[in] id Interrupt id, one of INTR_ID_* [in] func Interrupt handler function [in] cb Interrupt handler data
Definition at line 1054 of file RtcBase.cpp.
int set_output_square_wave_frequency | ( | square_wave_out_freq_t | freq ) |
Select square wave output frequency selection.
- Parameters:
-
[in] freq Clock frequency, one of CLKOUT_FREQ_*
- Returns:
- 0 on success, error code on failure
Definition at line 685 of file RtcBase.cpp.
int set_power_mgmt_mode | ( | power_mgmt_mode_t | mode ) |
Select power management mode of operation.
- Parameters:
-
[in] mode Mode selection, one of COMP_MODE_*
- Returns:
- 0 on success, error code on failure
Definition at line 547 of file RtcBase.cpp.
int set_time | ( | const struct tm * | rtc_ctime ) |
Set time info to RTC.
- Parameters:
-
[in] rtc_time Time info to be written to RTC.
- Returns:
- 0 on success, negative error code on failure.
Definition at line 277 of file RtcBase.cpp.
int supply_select | ( | power_mgmt_supply_t | supply ) |
Select device power source.
- Parameters:
-
[in] supply Supply selection, one of POW_MGMT_SUPPLY_SEL_*
- Returns:
- 0 on success, error code on failure
Definition at line 597 of file RtcBase.cpp.
int sw_reset_assert | ( | ) |
Put device into reset state.
- Returns:
- 0 on success, error code on failure
Definition at line 1095 of file RtcBase.cpp.
int sw_reset_release | ( | ) |
Release device from state state.
- Returns:
- 0 on success, error code on failure
Definition at line 1117 of file RtcBase.cpp.
int timer_continue | ( | ) |
Start timer from the paused value.
- Returns:
- 0 on success, error code on failure
Definition at line 882 of file RtcBase.cpp.
uint8_t timer_get | ( | ) |
Read timer value.
- Returns:
- 0 on success, error code on failure
Definition at line 827 of file RtcBase.cpp.
int timer_init | ( | uint8_t | value, |
bool | repeat, | ||
timer_freq_t | freq | ||
) |
Initialize timer.
- Parameters:
-
[in] value Timer initial value [in] repeat Timer repeat mode enable/disable [in] freq Timer frequency, one of TIMER_FREQ_* [in] mode Timer mode, 0 or 1
- Returns:
- 0 on success, error code on failure
- Note:
mode
controls the countdown timer interrupt function along withrepeat
. Pulse interrupt whenmode
= 0, irrespective ofrepeat
(true or false) Pulse interrupt whenmode
= 1 andrepeat
= true Level interrupt whenmode
= 1 andrepeat
= false
Definition at line 799 of file RtcBase.cpp.
int timer_pause | ( | ) |
Pause timer, timer value is preserved.
- Returns:
- 0 on success, error code on failure
Definition at line 861 of file RtcBase.cpp.
int timer_start | ( | ) |
Enable timer.
- Returns:
- 0 on success, error code on failure
Definition at line 840 of file RtcBase.cpp.
int timer_stop | ( | ) |
Disable timer.
- Returns:
- 0 on success, error code on failure
Definition at line 903 of file RtcBase.cpp.
int trickle_charger_disable | ( | ) |
Disable trickle charger.
- Returns:
- 0 on success, error code on failure
Definition at line 664 of file RtcBase.cpp.
int trickle_charger_enable | ( | trickle_charger_ohm_t | res, |
bool | diode | ||
) |
Configure trickle charger charging path, also enable it.
- Parameters:
-
[in] res Value of resister [in] diode Enable diode
- Returns:
- 0 on success, error code on failure
Definition at line 635 of file RtcBase.cpp.
int write_register | ( | uint8_t | reg, |
const uint8_t * | value, | ||
uint8_t | len | ||
) |
Write to a register.
- Parameters:
-
[in] reg Address of a register to be written. [out] value Pointer of value to be written to register. [in] len Size of result to be written.
- Returns:
- 0 on success, negative error code on failure.
Definition at line 124 of file RtcBase.cpp.
Generated on Sun Aug 7 2022 16:13:41 by 1.7.2