rtc_class

Committer:
c0ld
Date:
Thu Apr 30 10:48:43 2015 +0000
Revision:
0:8c666c6f7483
rtc_class

Who changed what in which revision?

UserRevisionLine numberNew contents of line
c0ld 0:8c666c6f7483 1 //
c0ld 0:8c666c6f7483 2 // @ Project : RTC Date Time Clock
c0ld 0:8c666c6f7483 3 // @ File Name : RTC8563.cpp
c0ld 0:8c666c6f7483 4 // @ Date : 06.04.2015
c0ld 0:8c666c6f7483 5 // @ Author : Franz Pucher
c0ld 0:8c666c6f7483 6 // @ Copyright : pe@bulme.at
c0ld 0:8c666c6f7483 7 //
c0ld 0:8c666c6f7483 8
c0ld 0:8c666c6f7483 9 #include "mbed.h"
c0ld 0:8c666c6f7483 10 #include "const.h"
c0ld 0:8c666c6f7483 11
c0ld 0:8c666c6f7483 12 #include "RTC8563.h"
c0ld 0:8c666c6f7483 13
c0ld 0:8c666c6f7483 14 RTC8563::RTC8563() : i2c(p28, p27) // delete void and add call to base constructor
c0ld 0:8c666c6f7483 15 {
c0ld 0:8c666c6f7483 16 // Initialise I2C
c0ld 0:8c666c6f7483 17 i2c.frequency(40000);
c0ld 0:8c666c6f7483 18 char init1[2] = {0x6, 0x00};
c0ld 0:8c666c6f7483 19 char init2[2] = {0x7, 0xff};
c0ld 0:8c666c6f7483 20 i2c.write(0x40, init1, 2);
c0ld 0:8c666c6f7483 21 i2c.write(0x40, init2, 2);
c0ld 0:8c666c6f7483 22 }
c0ld 0:8c666c6f7483 23
c0ld 0:8c666c6f7483 24 RTC8563::RTC8563(PinName sda, PinName scl) : i2c(sda, scl)
c0ld 0:8c666c6f7483 25 {
c0ld 0:8c666c6f7483 26 // Initialise I2C
c0ld 0:8c666c6f7483 27 i2c.frequency(40000);
c0ld 0:8c666c6f7483 28 char init1[2] = {0x6, 0x00};
c0ld 0:8c666c6f7483 29 char init2[2] = {0x7, 0xff};
c0ld 0:8c666c6f7483 30 i2c.write(0x40, init1, 2);
c0ld 0:8c666c6f7483 31 i2c.write(0x40, init2, 2);
c0ld 0:8c666c6f7483 32 }
c0ld 0:8c666c6f7483 33
c0ld 0:8c666c6f7483 34 char RTC8563::rtc_read(char address)
c0ld 0:8c666c6f7483 35 {
c0ld 0:8c666c6f7483 36 char value;
c0ld 0:8c666c6f7483 37 i2c.start();
c0ld 0:8c666c6f7483 38 i2c.write(RTC8563_ADR);
c0ld 0:8c666c6f7483 39 i2c.write(address);
c0ld 0:8c666c6f7483 40 i2c.start();
c0ld 0:8c666c6f7483 41 i2c.write(RTC8563_ADR | _READ);
c0ld 0:8c666c6f7483 42 value = i2c.read(0);
c0ld 0:8c666c6f7483 43 i2c.stop();
c0ld 0:8c666c6f7483 44
c0ld 0:8c666c6f7483 45 return value;
c0ld 0:8c666c6f7483 46 }
c0ld 0:8c666c6f7483 47
c0ld 0:8c666c6f7483 48 void RTC8563::rtc_write(char address, char value)
c0ld 0:8c666c6f7483 49 {
c0ld 0:8c666c6f7483 50 i2c.start();
c0ld 0:8c666c6f7483 51 i2c.write(RTC8563_ADR);
c0ld 0:8c666c6f7483 52 i2c.write(address);
c0ld 0:8c666c6f7483 53 i2c.write(value);
c0ld 0:8c666c6f7483 54 i2c.stop();
c0ld 0:8c666c6f7483 55 }
c0ld 0:8c666c6f7483 56
c0ld 0:8c666c6f7483 57 void RTC8563::rtc_init()
c0ld 0:8c666c6f7483 58 {
c0ld 0:8c666c6f7483 59 }
c0ld 0:8c666c6f7483 60
c0ld 0:8c666c6f7483 61 void RTC8563::rtc_alarm()
c0ld 0:8c666c6f7483 62 {
c0ld 0:8c666c6f7483 63 }