Contiki 3.x
Macros | Functions | Variables
ds3231-sensor.h File Reference

            Sensors for DS3231 (RTC with Temperature Sensor).
More...

#include <lib/sensors.h>
#include <stdbool.h>
#include "utc_time.h"

Go to the source code of this file.

Macros

#define DS3231_SENSOR_TEMP   0
 DS3231 Sensor and Config Command List.
 

Functions

int ds3231_get_time (struct tm *t)
 ds3231_get_time More...
 
int ds3231_set_time (struct tm *t)
 ds3231_set_time More...
 
int ds3231_set_alarm (struct tm *t)
 ds3231_set_alarm More...
 
int ds3231_clear_alarm (void)
 ds3231_clear_alarm More...
 
int ds3231_temperature (void)
 ds3231_temperature More...
 
int configure (int type, int c)
 configure
 
int status (int type)
 status
 

Variables

const struct sensors_sensor ds3231_sensor
 Export the DS3231 sensor object. More...
 

Detailed Description

            Sensors for DS3231 (RTC with Temperature Sensor).
Author
Timothy Rule trule.nosp@m..git.nosp@m.hub@n.nosp@m.ym.h.nosp@m.ush.c.nosp@m.om
Note
See http://www.maxim-ic.com/datasheet/index.mvp/id/4627

Definition in file ds3231-sensor.h.

Function Documentation

int ds3231_clear_alarm ( void  )

ds3231_clear_alarm

Clears and disables Alarm 1.

Returns
0 for success, -ve for error.

Definition at line 230 of file ds3231-sensor.c.

References I2C(), and NULL.

Referenced by configure().

int ds3231_get_time ( struct tm t)

ds3231_get_time

Returns
0 for success, -ve for error.
Note
The base date of tm struct is 1900-01-01 and the base date stored in the RTC for this application is 2000-01-01. An adjustment of 100 is made before getting the time.

Definition at line 100 of file ds3231-sensor.c.

References I2C().

int ds3231_set_alarm ( struct tm t)

ds3231_set_alarm

Sets the first alarm of the DS3231. Alarm Mask Bits A1M1-4 are all set to 0 which means the alarm will fire on the complete alarm setting (date, hour, minute & second).

When the alarm is triggered the INT pin of the DS3231 will be pulled low. This pin is connected to Port C Pin 2 of the AVR XMega.

Returns
0 for success, -ve for error.

Definition at line 180 of file ds3231-sensor.c.

References I2C(), and NULL.

Referenced by configure().

int ds3231_set_time ( struct tm t)

ds3231_set_time

Returns
0 for success, -ve for error.
Note
The base date of tm struct is 1900-01-01 and the base date stored in the RTC for this application is 2000-01-01. An adjustment of 100 is made before setting the time.

Definition at line 136 of file ds3231-sensor.c.

References I2C(), and NULL.

Referenced by configure().

int ds3231_temperature ( void  )

ds3231_temperature

Register 11h: bit 7 is sign, bit 6-0 are temperature. Register 12h: bit 7 & 6 are decimal point (0.25 * xxb).

Returns
Temperature * 100 (centi %) however accuracy is limited to 0.25 degree increments.

Definition at line 262 of file ds3231-sensor.c.

References I2C().

Variable Documentation

const struct sensors_sensor ds3231_sensor

Export the DS3231 sensor object.

Can be called as follows:

            #include <dev/ds3231-sensor.h>

            SENSORS_ACTIVATE(ds3231_sensor);
    ds3231_sensor.configure(DS3231_CONFIG_SET_TIME, (int)&t);
    ds3231_sensor.configure(DS3231_CONFIG_SET_ALARM, (int)&t);
    ds3231_sensor.value(DS3231_SENSOR_TEMP);
    ds3231_sensor.value(DS3231_SENSOR_GET_EPOCH_SECONDS_LSB);
    ds3231_sensor.value(DS3231_SENSOR_GET_EPOCH_SECONDS_MSB);
    ds3231_sensor.configure(DS3231_CONFIG_CLEAR_ALARM, 0);

Definition at line 82 of file ds3231-sensor.c.