|
Contiki 3.x
|
Sensors for DS3231 (RTC with Temperature Sensor).More...
#include "ds3231-sensor.h"#include <stdio.h>#include <stdint.h>#include <string.h>#include <contiki.h>#include "i2c.h"#include <inttypes.h>Go to the source code of this file.
Functions | |
| int | I2C (uint8_t *write, uint16_t write_len, uint8_t *read, uint16_t read_len) |
| DS3231 is connected to TWI Master on Port C (Pins 0 & 1). More... | |
| 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_get_temperature (int *temperature) |
| 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... | |
Sensors for DS3231 (RTC with Temperature Sensor).
Definition in file ds3231-sensor.c.
| int ds3231_clear_alarm | ( | void | ) |
ds3231_clear_alarm
Clears and disables Alarm 1.
Definition at line 231 of file ds3231-sensor.c.
| int ds3231_get_temperature | ( | int * | temperature | ) |
ds3231_temperature
Register 11h: bit 7 is sign, bit 6-0 are temperature. Register 12h: bit 7 & 6 are decimal point (0.25 * xxb).
Definition at line 263 of file ds3231-sensor.c.
References I2C().
| int ds3231_get_time | ( | struct tm * | t | ) |
ds3231_get_time
Definition at line 101 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.
Definition at line 181 of file ds3231-sensor.c.
| int ds3231_set_time | ( | struct tm * | t | ) |
ds3231_set_time
Definition at line 137 of file ds3231-sensor.c.
| int I2C | ( | uint8_t * | write, |
| uint16_t | write_len, | ||
| uint8_t * | read, | ||
| uint16_t | read_len | ||
| ) |
DS3231 is connected to TWI Master on Port C (Pins 0 & 1).
The active low Interrupt from the DS3231 is connected in Pin 2 of Port C.
Definition at line 60 of file ds3231-sensor.c.
References i2c_burst_receive(), i2c_burst_send(), i2c_master_disable(), and i2c_master_enable().
| 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 83 of file ds3231-sensor.c.
1.8.6