Contiki-NG

Driver for the RE-Mote on-board ultra-low power RTCC (Real Time Clock Calendar) More...

Files

file  rtcc-config.h
 RTCC configuration file.
 
file  rtcc.c
 Driver for the RE-Mote RF Real Time Clock Calendar (RTCC)
 
file  rtcc.h
 Header file for the RE-Mote RF antenna switch.
 

RTCC enumeration and options

enum  
 
enum  
 
enum  
 
enum  
 
enum  
 
enum  
 
enum  
 
enum  
 
enum  
 
enum  
 

RTCC default configuration structure

typedef struct ab080x_register_config ab080x_register_config_t
 
static const ab080x_register_config_t ab080x_default_setting []
 

Readable Date and time memory map implementation

This simplified structure allows the user to set date/alarms with a reduced structure, without the bit-defined restrictions of the memory map, using decimal values

typedef struct ab0805_struct_simple_td_reg simple_td_map
 

Callback function to handle the RTCC alarm interrupt and macro

void(* rtcc_int1_callback )(uint8_t value)
 
#define RTCC_REGISTER_INT1(ptr)   rtcc_int1_callback = ptr;
 

RTCC User functions

int8_t rtcc_set_time_date (simple_td_map *data)
 Set the time and date. More...
 
int8_t rtcc_get_time_date (simple_td_map *data)
 Get the current time and date. More...
 
int8_t rtcc_set_alarm_time_date (simple_td_map *data, uint8_t state, uint8_t repeat, uint8_t trigger)
 Configure the RTCC to match an alarm counter. More...
 
int8_t rtcc_date_increment_seconds (simple_td_map *data, uint16_t seconds)
 Increments the current date by a number of seconds. More...
 
int8_t rtcc_print (uint8_t value)
 Print data from the RTCC module, either from the memory map (values in BCD) or actual readable data (decimal). More...
 
int8_t rtcc_set_autocalibration (uint8_t period)
 Set the autocallibration period. More...
 
int8_t rtcc_set_calibration (uint8_t mode, int32_t adjust)
 Manually calibrate the RTCC. More...
 
int8_t rtcc_init (void)
 Initialize the RTCC, configures the I2C bus, interrupts and registers. More...
 

RTCC configuration macros

#define RTCC_SET_DEFAULT_CONFIG   1
 
#define RTCC_CLEAR_INT_MANUALLY   1
 
#define RTCC_SET_AUTOCAL   1
 

RTCC default configuration (if enabled by RTCC_SET_DEFAULT_CONFIG)

#define RTCC_DEFAULT_STATUS   0x00
 
#define RTCC_DEFAULT_CTRL1   0x11
 
#define RTCC_DEFAULT_CTRL2   0x00
 
#define RTCC_DEFAULT_INTMASK   0xE0
 
#define RTCC_DEFAULT_SQW   0x26
 
#define RTCC_DEFAULT_TIMER_CTRL   0x23
 

AB08XX Address registers

#define CENTHS_ADDR   0x00
 
#define SEC_ADDR   0x01
 
#define MIN_ADDR   0x02
 
#define HOUR_ADDR   0x03
 
#define DAY_ADDR   0x04
 
#define MONTHS_ADDR   0x05
 
#define YEAR_ADDR   0x06
 
#define WEEKDAYLS_ADDR   0x07
 
#define ALARM_MAP_OFFSET   0x08
 
#define HUNDREDTHS_ALARM_ADDR   0x00
 
#define SECONDS_ALARM_ADDR   0x01
 
#define MINUTES_ALARM_ADDR   0x02
 
#define HOURS_ALARM_ADDR   0x03
 
#define DAY_ALARMS_ADDR   0x04
 
#define MONTHS_ALARM_ADDR   0x05
 
#define WEEKDAYS_ALARM_ADDR   0x06
 
#define CONFIG_MAP_OFFSET   0x0F
 
#define STATUS_ADDR   0x00
 
#define CTRL_1_ADDR   0x01
 
#define CTRL_2_ADDR   0x02
 
#define INT_MASK_ADDR   0x03
 
#define SQW_ADDR   0x04
 
#define CAL_XT_ADDR   0x05
 
#define CAL_RC_HI_ADDR   0x06
 
#define CAL_RC_LO_ADDR   0x07
 
#define INT_POL_ADDR   0x08
 
#define TIMER_CONTROL_ADDR   0x09
 
#define TIMER_COUNTDOWN_ADDR   0x0A
 
#define TIMER_INITIAL_ADDR   0x0B
 
#define WDT_ADDR   0x0C
 
#define OSC_CONTROL_ADDR   0x0D
 
#define OSC_STATUS_ADDR   0x0E
 
#define CONF_KEY_ADDR   0x10
 
#define TRICKLE_ADDR   0x11
 
#define BREF_CTRL_ADDR   0x12
 
#define AF_CTRL_ADDR   0x17
 
#define BAT_MODE_IO_ADDR   0x18
 
#define ASTAT_ADDR   0x20
 
#define OCTRL_ADDR   0x21
 
#define EXT_ADDR   0x30
 
#define RAM_1_ADDR   (CONFIG_MAP_OFFSET + 0x31)
 
#define RAM_2_ADDR   (CONFIG_MAP_OFFSET + 0x71)
 

RTCC Bitmasks and shifts

#define STATUS_CB   0x80
 
#define STATUS_BAT   0x40
 
#define STATUS_WDT   0x20
 
#define STATUS_BL   0x10
 
#define STATUS_TIM   0x08
 
#define STATUS_ALM   0x04
 
#define STATUS_EX2   0x02
 
#define STATUS_EX1   0x01
 
#define CTRL1_WRTC   0x01
 
#define CTRL1_ARST   0x04
 
#define CTRL1_OUT   0x10
 
#define CTRL1_OUTB   0x20
 
#define CTRL1_1224   0x40
 
#define CTRL1_STOP   0x80
 
#define CTRL2_OUT1S_NIRQ_OUT   0x00
 
#define CTRL2_OUT1S_NIRQ_SQW_OUT   0x01
 
#define CTRL2_OUT1S_NIRQ_SQW_NIRQ   0x02
 
#define CTRL2_OUT1S_NIRQ_NAIRQ_OUT   0x03
 
#define CTRL2_OUT2S_SQW_OUT   0x04
 
#define CTRL2_OUT2S_NAIRQ_OUTB   0x0C
 
#define CTRL2_OUT2S_TIRQ_OUTB   0x10
 
#define CTRL2_OUT2S_NTIRQ_OUTB   0x14
 
#define CTRL2_OUT2S_OUTB   0x1C
 
#define INTMASK_EX1E   0x01
 
#define INTMASK_EX2E   0x02
 
#define INTMASK_AIE   0x04
 
#define INTMASK_TIE   0x08
 
#define INTMASK_BLIE   0x10
 
#define INTMASK_IM_HIGH   0x20
 
#define INTMASK_IM_MED   0x40
 
#define INTMASK_IM_LOW   0x60
 
#define INTMASK_CEB   0x80
 
#define COUNTDOWN_TIMER_TE   0x80
 
#define COUNTDOWN_TIMER_TM   0x40
 
#define COUNTDOWN_TIMER_TRPT   0x20
 
#define COUNTDOWN_TIMER_RPT_SECOND   0x1C
 
#define COUNTDOWN_TIMER_RPT_MINUTE   0x18
 
#define COUNTDOWN_TIMER_RPT_HOUR   0x24
 
#define COUNTDOWN_TIMER_RPT_DAY   0x10
 
#define COUNTDOWN_TIMER_RPT_WEEK   0x0C
 
#define COUNTDOWN_TIMER_RPT_MONTH   0x08
 
#define COUNTDOWN_TIMER_RPT_YEAR   0x04
 
#define COUNTDOWN_TIMER_RPT_SHIFT   0x02
 
#define COUNTDOWN_TIMER_TFS_ONE   0x01
 
#define COUNTDOWN_TIMER_TFS_TWO   0x02
 
#define COUNTDOWN_TIMER_TFS_THREE   0x03
 
#define OSCONTROL_ACIE   0x01
 
#define OSCONTROL_OFIE   0x02
 
#define OSCONTROL_FOS   0x08
 
#define OSCONTROL_AOS   0x10
 
#define OSCONTROL_ACAL_NO_CAL   0x00
 
#define OSCONTROL_ACAL_17_MIN   0x40
 
#define OSCONTROL_ACAL_9_MIN   0x60
 
#define OSCONTROL_OSEL   0x80
 

RTCC operational values

#define AB08XX_ADDR   0x69
 
#define INT_BUFF_SIZE   20L
 
#define TCS_DIODE_3K   (TCS_ENABLE + 0x05)
 
#define TCS_DIODE_6K   (TCS_ENABLE + 0x06)
 
#define TCS_DIODE_11K   (TCS_ENABLE + 0x07)
 
#define RTCC_TOGGLE_PM_BIT   0x20
 
#define RTCC_FIX_10THS_HUNDRETHS   0xF0
 
#define RTCC_FIX_100THS_HUNDRETHS   0xFF
 
#define RTCC_TD_MAP_SIZE   (WEEKDAYLS_ADDR + 1)
 
#define RTCC_ALARM_MAP_SIZE   (WEEKDAYS_ALARM_ADDR + 1)
 
#define RTCC_CONFIG_MAP_SIZE   (BREF_CTRL_ADDR + 1)
 

RTCC error values

#define AB08_ERROR   (-1)
 
#define AB08_SUCCESS   0x00
 

Detailed Description

Driver for the RE-Mote on-board ultra-low power RTCC (Real Time Clock Calendar)

Driver for the RE-Mote RTCC (Real Time Clock Calendar)

Function Documentation

◆ rtcc_date_increment_seconds()

int8_t rtcc_date_increment_seconds ( simple_td_map *  data,
uint16_t  seconds 
)

Increments the current date by a number of seconds.

Parameters
datastructure to store the date
secondsthe numberof seconds to increment the date
Returns
\ AB08_SUCCESS updated date values \ AB08_ERROR failed to return the values

Definition at line 568 of file rtcc.c.

◆ rtcc_get_time_date()

int8_t rtcc_get_time_date ( simple_td_map *  data)

Get the current time and date.

Parameters
*databuffer to store the results
Returns
\ AB08_SUCCESS date/time set \ AB08_ERROR failed to set time/date (enable DEBUG for more info)

Definition at line 368 of file rtcc.c.

◆ rtcc_init()

int8_t rtcc_init ( void  )

Initialize the RTCC, configures the I2C bus, interrupts and registers.

Returns
\ AB08_SUCCESS date/time set \ AB08_ERROR failed to set time/date (enable DEBUG for more info)

Definition at line 922 of file rtcc.c.

References i2c_init().

◆ rtcc_print()

int8_t rtcc_print ( uint8_t  value)

Print data from the RTCC module, either from the memory map (values in BCD) or actual readable data (decimal).

Parameters
valuevalue to print, see RTCC_PRINT_* options available
Returns
\ AB08_SUCCESS date/time set \ AB08_ERROR failed to set time/date (enable DEBUG for more info)

Definition at line 668 of file rtcc.c.

◆ rtcc_set_alarm_time_date()

int8_t rtcc_set_alarm_time_date ( simple_td_map *  data,
uint8_t  state,
uint8_t  repeat,
uint8_t  trigger 
)

Configure the RTCC to match an alarm counter.

Parameters
datadate and time values (in decimal) to match against
stateset on/off the alarm interruption
repeatset the frequency of the alarm (minute, hourly, daily, etc.)
triggerinterrupt trigger (INT1, INT2 or both)
Returns
\ AB08_SUCCESS date/time set \ AB08_ERROR failed to set time/date (enable DEBUG for more info)

Definition at line 391 of file rtcc.c.

◆ rtcc_set_autocalibration()

int8_t rtcc_set_autocalibration ( uint8_t  period)

Set the autocallibration period.

Parameters
periodautocalibration configuration
Returns
\ AB08_SUCCESS date/time set \ AB08_ERROR failed to set time/date (enable DEBUG for more info)

Definition at line 744 of file rtcc.c.

◆ rtcc_set_calibration()

int8_t rtcc_set_calibration ( uint8_t  mode,
int32_t  adjust 
)

Manually calibrate the RTCC.

Parameters
modeoscillator to calibrate
adjustvalue (in ppm) to adjust the oscillator
Returns
\ AB08_SUCCESS date/time set \ AB08_ERROR failed to set time/date (enable DEBUG for more info)

Definition at line 800 of file rtcc.c.

◆ rtcc_set_time_date()

int8_t rtcc_set_time_date ( simple_td_map *  data)

Set the time and date.

Parameters
*dataTime and date value (decimal format)
Returns
\ AB08_SUCCESS date/time set \ AB08_ERROR failed to set time/date (enable DEBUG for more info)

Definition at line 271 of file rtcc.c.