timers/mcp794xx: add option to digital trimming

MCP794XX supports digital trimming that periodically adds or subtracts
clock cycles, resulting in small adjustments in the internal timing.
This way inaccuracies of clock source can be compensated.

This commit adds option to set the trimming register for MCP794XX.

Signed-off-by: Michal Lenc <michallenc@seznam.cz>
This commit is contained in:
Michal Lenc
2024-05-28 11:01:40 +02:00
committed by Alan Carvalho de Assis
parent c59b48355c
commit 3cc65d5d35
2 changed files with 128 additions and 3 deletions
+24
View File
@@ -41,6 +41,30 @@ extern "C"
#define EXTERN extern
#endif
/****************************************************************************
* Name: mcp794xx_rtc_set_trim
*
* Description:
* Sets the digital trimming to correct for inaccuracies of clock source.
* Digital trimming consists of the MCP794XX periodically adding or
* subtracting clock cycles, resulting in small adjustments in the internal
* timing.
*
* Input Parameters:
* trim_val - Calculated trimming value, refer to MCP794XX reference
* manual.
* rtc_slow - True indicates RTC is behind real clock, false otherwise.
* This has to be set to ensure correct trimming direction.
* coarse_mode - MCP794XX allows coarse mode that trims every second
* instead of every minute.
*
* Returned Value:
* Zero (OK) on success; a negated errno on failure
*
****************************************************************************/
int mcp794xx_rtc_set_trim(uint8_t trim_val, bool rtc_slow, bool coarse_mode);
/****************************************************************************
* Name: mcp794xx_rtc_initialize
*