RX8025 library

Dependents:   mbed_RX8025 MAPLEminiA MAPLEminiA

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers RX8025.h Source File

RX8025.h

00001 //**********************
00002 // RX8025.h for mbed
00003 //
00004 // (C)Copyright 2014 All rights reserved by Y.Onodera
00005 // http://einstlab.web.fc2.com
00006 //**********************
00007 
00008 #ifndef RX8025_H_
00009 #define RX8025_H_
00010 
00011 #define RX8025_ADDR                 0x64
00012 #define RX8025_SECONDS              0x00
00013 #define RX8025_MINUTES              0x10
00014 #define RX8025_HOURS                0x20
00015 #define RX8025_WEEKDAYS             0x30
00016 #define RX8025_DAYS                 0x40
00017 #define RX8025_MONTHS               0x50
00018 #define RX8025_YEARS                0x60
00019 #define RX8025_OFFSET               0x70
00020 #define RX8025_ALARM_W_M            0x80
00021 #define RX8025_ALARM_W_H            0x90
00022 #define RX8025_ALARM_W_W            0xA0
00023 #define RX8025_ALARM_D_M            0xB0
00024 #define RX8025_ALARM_D_H            0xC0
00025 #define RX8025_CONTROL1             0xE0
00026 #define RX8025_CONTROL2             0xF0
00027 
00028 #include "mbed.h"
00029 
00030 typedef struct {
00031     unsigned char seconds;
00032     unsigned char minutes;
00033     unsigned char hours;
00034     unsigned char weekdays;
00035     unsigned char days;
00036     unsigned char months;
00037     unsigned char years;
00038 }Times;
00039 
00040 
00041 typedef struct {
00042     unsigned char minute;
00043     unsigned char hour;
00044     unsigned char weekday;
00045 }Alarmw;
00046 
00047 
00048 typedef struct{
00049     unsigned char minute;
00050     unsigned char hour;
00051 }Alarmd;
00052 
00053 
00054 typedef struct{
00055     unsigned char control1;
00056     unsigned char control2;
00057     unsigned char offset;
00058 }Control;
00059 
00060 
00061 class RX8025{
00062 public:
00063     RX8025 (PinName sda, PinName scl);
00064     RX8025 (I2C& p_i2c);
00065     void init();
00066 
00067     void put(unsigned char a, unsigned char b);
00068     void get(unsigned char a);
00069     Times getTIME();
00070     void setTIME(Times t);
00071     Alarmw getALARMw();
00072     void setALARMw(Alarmw a);
00073     Alarmd getALARMd();
00074     void setALARMd(Alarmd a);
00075     Control getCONTROL();
00076     void setCONTROL(Control c);
00077 
00078 protected:
00079     
00080     I2C _i2c;
00081 
00082     Times time;
00083     Alarmw alarmw;
00084     Alarmd alarmd;
00085     Control control;
00086     char buf[2];
00087 
00088 };
00089 
00090 #endif /* RX8025_H_ */
00091 
00092