RTEMS 6.3
Loading...
Searching...
No Matches
Shared_tod_i2c_rtc

Generic I2C RTC driver. More...

Topics

 Shared_tod_abeoz9_rtc
 RTC driver for the Abracon EOZ9 series.
 Shared_tod_mcp7940m_rtc
 RTC driver for the MCP7940M.

Files

file  bsps/include/libchip/i2c-rtc.h
 This file provides the interfaces of Shared_tod_i2c_rtc.
file  bsps/shared/dev/rtc/i2c-rtc.c
 This file provides the implementation of Shared_tod_i2c_rtc.

Data Structures

struct  i2c_rtc_base
struct  i2c_rtc_base::[struct].order

Macros

#define I2C_RTC_ORDER_sec_min_hour_wkday_day_month_year   { .sec = 0, .min = 1, .hour = 2, .day = 4, .wkday = 3, .month = 5, .year = 6 }
#define I2C_RTC_ORDER_sec_min_hour_day_wkday_month_year   { .sec = 0, .min = 1, .hour = 2, .day = 3, .wkday = 4, .month = 5, .year = 6 }
#define I2C_RTC_INITIALIZER(i2c_path, i2c_address, offset, reg_order, driver_name, hwinit)
#define I2C_RTC_TBL_ENTRY(dev_name, i2c_rtc_ctx)

Functions

bool i2c_rtc_probe (int minor)
int i2c_rtc_read (struct i2c_rtc_base *ctx, uint8_t addr, uint8_t *buf, size_t len)
int i2c_rtc_write (struct i2c_rtc_base *ctx, uint8_t addr, const uint8_t *buf, size_t len)

Variables

const rtc_fns i2c_rtc_fns

Detailed Description

Generic I2C RTC driver.

Base functionality for I2C based RTC drivers. An additional, chip specific initialization is necessary.

Expects a register block with the following time format:

  • <base>+off.second:
    • Bit 0 to 6: Seconds (BCD encoded)
    • Bit 7: Don't care
  • <base>+off.minute:
    • Bit 0 to 6: Minutes (BCD encoded)
    • Bit 7: Don't care
  • <base>+off.hour:
    • Bit 0 to 5: Hours (BCD encoded); Bit 5 indicates AM (0) and PM (1) in 12 hour mode
    • Bit 6: 0 for 24 hour mode; 1 for 12 hour mode
  • <base>+off.wkday:
    • Bit 0 to 2: Day of Week
    • Bit 3 to 7: Don't care
  • <base>+off.day:
    • Bit 0 to 5: Day (BCD encoded)
    • Bit 6 and 7: Don't care
  • <base>+off.month:
    • Bit 0 to 4: Month (BCD encoded)
    • Bit 5 to 7: Don't care
  • <base>+off.year:
    • Bit 0 to 6: Year (BCD encoded)
    • Bit 7: Don't care

See abeoz9 or mcp7940m for how to use this base driver.

Macro Definition Documentation

◆ I2C_RTC_INITIALIZER

#define I2C_RTC_INITIALIZER ( i2c_path,
i2c_address,
offset,
reg_order,
driver_name,
hwinit )
Value:
{ \
.mutex = RTEMS_MUTEX_INITIALIZER(driver_name), \
.i2c_bus_path = i2c_path, \
.i2c_addr = i2c_address, \
.initialized = false, \
.hw_init = hwinit, \
.clock_offset = offset, \
.order = reg_order, \
}

◆ I2C_RTC_TBL_ENTRY

#define I2C_RTC_TBL_ENTRY ( dev_name,
i2c_rtc_ctx )
Value:
{ \
.sDeviceName = dev_name, \
.deviceType = RTC_CUSTOM, \
.pDeviceFns = &i2c_rtc_fns, \
.deviceProbe = i2c_rtc_probe, \
.pDeviceParams = (void *)i2c_rtc_ctx, \
.ulCtrlPort1 = 0, \
.ulDataPort = 0, \
.getRegister = NULL, \
.setRegister = NULL, \
}

Function Documentation

◆ i2c_rtc_read()

int i2c_rtc_read ( struct i2c_rtc_base * ctx,
uint8_t addr,
uint8_t * buf,
size_t len )

Read bytes from the I2C RTC. Can be used in derived drivers.

Returns 0 on success or anything else on error.

◆ i2c_rtc_write()

int i2c_rtc_write ( struct i2c_rtc_base * ctx,
uint8_t addr,
const uint8_t * buf,
size_t len )

Write bytes to the I2C RTC. Can be used in derived drivers.

Returns 0 on success or anything else on error.