Skip to content

Latest commit

 

History

History
176 lines (130 loc) · 4.06 KB

time.md

File metadata and controls

176 lines (130 loc) · 4.06 KB

time


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.

Base Methods

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
  1. For I2C-connected devices:

    • startx(SCL_PIN, SDA_PIN, I2C_FREQ, ADDR_BITS): status
    • Not all devices support alternate I2C addresses.
  2. startx() returns the launched cog number+1 of com engine used on success.

  3. startx() returns FALSE (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)
  4. stop() performs the following tasks:

    • Stop any extra cogs that were started (if applicable)
    • Clear all global variable space used to 0

Methods

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

date()

Get the current date/day of month

  • Parameters: none
  • Returns: date/day of month (1..31)

hours()

Get the current hour (24hr)

  • Parameters: none
  • Returns: hour (0..23)

minutes()

Get the current minute

  • Parameters: none
  • Returns: minute (0..59)

month()

Get current month

  • Parameters: none
  • Returns: month (1..12)

seconds()

Get current second

  • Parameters: none
  • Returns: second (0..59)

weekday()

Get the current week day

  • Parameters: none
  • Returns: weekday (1..7)

year()

Get the current year

  • Parameters: none
  • Returns: year (0..99)

set_date(d)

Set the current date/day of month

  • Parameters:
    • d: date/day of month (1..31)
  • Returns: none

set_hours(h)

Set the current hour

  • Parameters:
    • h: hour (0..23)
  • Returns: none

set_minutes(m)

Set current minute

  • Parameters:
    • m: minute (0..59)
  • Returns: none

set_month(m)

Set current month

  • Parameters:
    • m: month (1..12)
  • Returns: none

set_seconds(s)

Set current second

  • Parameters:
    • s: second (0..59)
  • Returns: none

set_weekday(w)

Set current week day

  • Parameters:
    • w: weekday (1..7)
  • Returns: none

set_year(y)

Set current year

  • Parameters:
    • y: year (0..99)
  • Returns: none

Notes:

  1. 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.

File Structure

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)