BSP430
20141115
Board Support Package for MSP430 microcontrollers
|
Chip data for Maxim DS3231 I2C RTC/TCXO/Crystal. More...
Go to the source code of this file.
Data Structures | |
struct | sDS3231registers |
Macros | |
#define | DS3231_I2C_ADDRESS 0x68 |
Typedefs | |
typedef struct sDS3231registers | sDS3231registers |
Functions | |
uint8_t | ucDS3231encodeHour (unsigned int hours, int is_12h) |
unsigned int | uiDS3231decodeHour (uint8_t hour_ds3231) |
const struct tm * | xDS3231registersToTm (const sDS3231registers *regp, struct tm *timep) |
const sDS3231registers * | xDS3231tmToRegisters (const struct tm *timep, sDS3231registers *regp) |
Chip data for Maxim DS3231 I2C RTC/TCXO/Crystal.
This file contains the register map for the DS3231 real-time clock chip. There is no abstraction for the functional capability of the chip, except that there are routines to convert between the register map and POSIX standard time structures.
To incorporate the conversion routines add the following to your Makefile:
VPATH += $(BSP430_ROOT)/chips MODULES += chips/ds3231
#define DS3231_I2C_ADDRESS 0x68 |
I2C address for DS3231 I2C RTX/TCXO/Crystal
typedef struct sDS3231registers sDS3231registers |
DS3231 register map
uint8_t ucDS3231encodeHour | ( | unsigned int | hours, |
int | is_12h | ||
) |
Convert from integer hour value to DS3231 encoded hour
The DS3231 represents hours as a register encoding either a 12-hr or 24-hr time, not a basic BCD representation.
hours | the integer hour value in the range 0..23 |
is_12h | non-zero to represent the time as 12h with AM/PM; zero to represent time as a 24-hour value. |
unsigned int uiDS3231decodeHour | ( | uint8_t | hour_ds3231 | ) |
Convert from encoded DS3231 hour value to integer hour
hour_ds3231 | Hour value encoded in DS3231 including 12h/24h flag in BIT6 |
const struct tm* xDS3231registersToTm | ( | const sDS3231registers * | regp, |
struct tm * | timep | ||
) |
Convert DS3231 date/time register settings to POSIX standard structure.
The previous contents of *timep are completely erased. The time conversion supports both 12-hour and 24-hour formats.
regp | pointer to a DS3231 register map complete through byte 0x06. |
timep | pointer to a POSIX time structure that will be cleared and initialized to the time recorded in regp |
const sDS3231registers* xDS3231tmToRegisters | ( | const struct tm * | timep, |
sDS3231registers * | regp | ||
) |
Convert POSIX time structure to DSD3231 date/time register settings.
The first seven bytes of *regp are erased, except that BIT6 of sDS3231registers::hours is preserved to record whether 12-hour or 24-hour time is desired. The remaining bytes of *regp are unmodified.
timep | pointer to the POSIX time |
regp | pointer to a DS3231 register map |