Zephyr API 3.6.99
Loading...
Searching...
No Matches
mcp7940n.h File Reference
#include <zephyr/sys/timeutil.h>
#include <time.h>

Go to the source code of this file.

Data Structures

struct  mcp7940n_rtc_sec
 
struct  mcp7940n_rtc_min
 
struct  mcp7940n_rtc_hours
 
struct  mcp7940n_rtc_weekday
 
struct  mcp7940n_rtc_date
 
struct  mcp7940n_rtc_month
 
struct  mcp7940n_rtc_year
 
struct  mcp7940n_rtc_control
 
struct  mcp7940n_rtc_osctrim
 
struct  mcp7940n_alm_sec
 
struct  mcp7940n_alm_min
 
struct  mcp7940n_alm_hours
 
struct  mcp7940n_alm_weekday
 
struct  mcp7940n_alm_date
 
struct  mcp7940n_alm_month
 
struct  mcp7940n_time_registers
 
struct  mcp7940n_alarm_registers
 

Enumerations

enum  mcp7940n_register {
  REG_RTC_SEC = 0x0 , REG_RTC_MIN = 0x1 , REG_RTC_HOUR = 0x2 , REG_RTC_WDAY = 0x3 ,
  REG_RTC_DATE = 0x4 , REG_RTC_MONTH = 0x5 , REG_RTC_YEAR = 0x6 , REG_RTC_CONTROL = 0x7 ,
  REG_RTC_OSCTRIM = 0x8 , REG_ALM0_SEC = 0xA , REG_ALM0_MIN = 0xB , REG_ALM0_HOUR = 0xC ,
  REG_ALM0_WDAY = 0xD , REG_ALM0_DATE = 0xE , REG_ALM0_MONTH = 0xF , REG_ALM1_SEC = 0x11 ,
  REG_ALM1_MIN = 0x12 , REG_ALM1_HOUR = 0x13 , REG_ALM1_WDAY = 0x14 , REG_ALM1_DATE = 0x15 ,
  REG_ALM1_MONTH = 0x16 , REG_PWR_DWN_MIN = 0x18 , REG_PWR_DWN_HOUR = 0x19 , REG_PWR_DWN_DATE = 0x1A ,
  REG_PWR_DWN_MONTH = 0x1B , REG_PWR_UP_MIN = 0x1C , REG_PWR_UP_HOUR = 0x1D , REG_PWR_UP_DATE = 0x1E ,
  REG_PWR_UP_MONTH = 0x1F , SRAM_MIN = 0x20 , SRAM_MAX = 0x5F , REG_INVAL = 0x60
}
 
enum  mcp7940n_alarm_trigger {
  MCP7940N_ALARM_TRIGGER_SECONDS = 0x0 , MCP7940N_ALARM_TRIGGER_MINUTES = 0x1 , MCP7940N_ALARM_TRIGGER_HOURS = 0x2 , MCP7940N_ALARM_TRIGGER_WDAY = 0x3 ,
  MCP7940N_ALARM_TRIGGER_DATE = 0x4 , MCP7940N_ALARM_TRIGGER_ALL = 0x7
}
 

Functions

int mcp7940n_rtc_set_time (const struct device *dev, time_t unix_time)
 Set the RTC to a given Unix time.
 

Enumeration Type Documentation

◆ mcp7940n_alarm_trigger

Enumerator
MCP7940N_ALARM_TRIGGER_SECONDS 
MCP7940N_ALARM_TRIGGER_MINUTES 
MCP7940N_ALARM_TRIGGER_HOURS 
MCP7940N_ALARM_TRIGGER_WDAY 
MCP7940N_ALARM_TRIGGER_DATE 
MCP7940N_ALARM_TRIGGER_ALL 

◆ mcp7940n_register

Enumerator
REG_RTC_SEC 
REG_RTC_MIN 
REG_RTC_HOUR 
REG_RTC_WDAY 
REG_RTC_DATE 
REG_RTC_MONTH 
REG_RTC_YEAR 
REG_RTC_CONTROL 
REG_RTC_OSCTRIM 
REG_ALM0_SEC 
REG_ALM0_MIN 
REG_ALM0_HOUR 
REG_ALM0_WDAY 
REG_ALM0_DATE 
REG_ALM0_MONTH 
REG_ALM1_SEC 
REG_ALM1_MIN 
REG_ALM1_HOUR 
REG_ALM1_WDAY 
REG_ALM1_DATE 
REG_ALM1_MONTH 
REG_PWR_DWN_MIN 
REG_PWR_DWN_HOUR 
REG_PWR_DWN_DATE 
REG_PWR_DWN_MONTH 
REG_PWR_UP_MIN 
REG_PWR_UP_HOUR 
REG_PWR_UP_DATE 
REG_PWR_UP_MONTH 
SRAM_MIN 
SRAM_MAX 
REG_INVAL 

Function Documentation

◆ mcp7940n_rtc_set_time()

int mcp7940n_rtc_set_time ( const struct device * dev,
time_t unix_time )

Set the RTC to a given Unix time.

The RTC advances one tick per second with no access to sub-second precision. This function will convert the given unix_time into seconds, minutes, hours, day of the week, day of the month, month and year. A Unix time of '0' means a timestamp of 00:00:00 UTC on Thursday 1st January 1970.

Parameters
devthe MCP7940N device pointer.
unix_timeUnix time to set the rtc to.
Return values
return0 on success, or a negative error code from an I2C transaction or invalid parameter.