API for realtime clock device drivers (hardware and emulated)
Object filename description:
time.rtc.model.spin2
model indicates the manufacturer's model/part number of the RTC (e.g., ds1302), or soft
,
if emulated.
These are methods that are common to all RTC drivers
Method | Description | Param | Returns |
---|---|---|---|
startx() |
Start driver using explicitly defined settings | Notes 1-3 | cog id+1 |
stop() |
Stop the driver | n/a | n/a |
-
For I2C-connected devices:
startx(SCL_PIN, SDA_PIN, I2C_FREQ, ADDR_BITS): status
- Not all devices support alternate I2C addresses.
-
startx()
returns the launched cog number+1 of com engine used on success. -
startx()
returnsFALSE
(0) if the driver fails to start, for these possible reasons:- No more cogs available
- One or more specified I/O pins are outside allowed range
- Bus frequency is outside allowed range
- If supported by the device,
dev_id()
didn't return the expected value (or presence of the device's address wasn't detected on the I2C bus)
-
stop()
performs the following tasks:- Stop any extra cogs that were started (if applicable)
- Clear all global variable space used to 0
Method | Description |
---|---|
date() |
Get current date/day of month |
hours() |
Get current hour (24hr) |
minutes() |
Get current minute |
month() |
Get current month |
seconds() |
Get current second |
weekday() |
Get current week day |
year() |
Get current year |
set_date() |
Set current date/day of month |
set_hours() |
Set current hour |
set_minutes() |
Set current minute |
set_month() |
Set current month |
set_seconds() |
Set current second |
set_weekday() |
Set current week day |
set_year() |
Set current year |
Get the current date/day of month
- Parameters: none
- Returns: date/day of month (1..31)
Get the current hour (24hr)
- Parameters: none
- Returns: hour (0..23)
Get the current minute
- Parameters: none
- Returns: minute (0..59)
Get current month
- Parameters: none
- Returns: month (1..12)
Get current second
- Parameters: none
- Returns: second (0..59)
Get the current week day
- Parameters: none
- Returns: weekday (1..7)
Get the current year
- Parameters: none
- Returns: year (0..99)
Set the current date/day of month
- Parameters:
d
: date/day of month (1..31)
- Returns: none
Set the current hour
- Parameters:
h
: hour (0..23)
- Returns: none
Set current minute
- Parameters:
m
: minute (0..59)
- Returns: none
Set current month
- Parameters:
m
: month (1..12)
- Returns: none
Set current second
- Parameters:
s
: second (0..59)
- Returns: none
Set current week day
- Parameters:
w
: weekday (1..7)
- Returns: none
Set current year
- Parameters:
y
: year (0..99)
- Returns: none
Notes:
- Though not part of the
time
category, GPS device drivers shall utilize the read-only portion of the above API for equivalent time-related methods.
time.rtc.model.spin - driver object
|-- #include: time.rtc.common.spinh - provides standard API
|-- OBJ: HW-specific constants (core.con.model.spin)
|-- OBJ: Low-level communications engine (I2C, SPI, OneWire, etc)