RTC DS3234 library

Dependencies:   mbed

Fork of WDtester by green rosh

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers DS3234.h Source File

DS3234.h

00001 #include <mbed.h>
00002 #include <SPI.h>
00003 
00004 #ifndef DS3234_h
00005 #define DS3234_h
00006 
00007 //Time Register bits  - Read Mode
00008 #define secR 0x00
00009 #define minR 0x01
00010 #define hoR  0x02
00011 #define dayR 0x03
00012 #define datR 0x04
00013 #define monR 0x05
00014 #define yeaR 0x06
00015 
00016 //Time Register bits-Write Mode
00017 #define secW 0x80
00018 #define minW 0x81
00019 #define hoW  0x82
00020 #define dayW 0x83
00021 #define datW 0x84
00022 #define monW 0x85
00023 #define yeaW 0x86
00024 
00025 struct ts {
00026     uint8_t sec;         /* seconds */
00027     uint8_t min;         /* minutes */
00028     uint8_t hour;        /* hours */
00029     uint8_t mday;        /* day of the month */
00030     uint8_t mon;         /* month */
00031     int year;            /* year */
00032     uint8_t wday;        /* day of the week */
00033     uint8_t yday;        /* day in the year */
00034     uint8_t year_s;      /* year in short notation*/
00035 };
00036 
00037 void init(PinName pin, const uint8_t ctrl_reg);
00038 void get(PinName pin, struct ts *t);
00039 void set(PinName pin, struct ts t);
00040 
00041 // Helping Functions
00042 
00043 uint8_t dectobcd(const uint8_t val);
00044 uint8_t bcdtodec(const uint8_t val);
00045 
00046 
00047 #endif
00048 
00049 
00050