Functions and formatted printing of time and date for RTC8563

Dependencies:   mbed

Inhalt

I2C RTC on HIMBED

/media/uploads/bulmecisco/rtc.jpg

Definition der benannten Konstanten für die Register des PCF8563 (Tabelle 4)
Praeprozessor-Direktiven #define werden durch benannte Konstante ersetzt

const.h

/***********************************
name:   const.h    Version: 0.1
author: PE HTL BULME
email:  pe@bulme.at
description:
  Named constants definitions for registers 
  PCF8563 RTC on HIMBED M0 - LPC11U24 
***********************************/

#ifndef CONST_H
#define CONST_H

// Address of RTC
const int RTC8563_ADR = 0xA2;
// Control and status
const int CONTROL1 = 0x00;
const int CONTROL2 = 0x01;
// Time and date
const int SECONDS = 0x02;   
const int MINUTES = 0x03;
const int HOURS = 0x04;
const int DAYS = 0x05;
const int WEEKDAYS = 0x06;
const int MONTHS = 0x07;
const int YEARS = 0x08;
// Alarm
const int MINUTE_ALARM = 0x09;
const int HOUR_ALARM = 0x0A;
const int DAY_ALARM = 0x0B;
const int WEEKDAY_ALARM = 0x0C;
// Clock and timer
const int CLOCKOUT_FREQ = 0x0D;
const int TIMER_CINTROL = 0x0E;
const int _READ = 0x01;

#endif

Register organisation

/media/uploads/bulmecisco/register.jpg

Terminal program

Mit einem Terminal Programm (z.B. HTERM) können die Werte von der seriellen Schnittstelle (COM-Port) angezeigt werden:

/media/uploads/bulmecisco/hterm.jpg

Next

Revision:
2:f75062350241
diff -r 554eb6675279 -r f75062350241 RTC8563.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/RTC8563.h	Thu Apr 16 10:25:33 2015 +0000
@@ -0,0 +1,26 @@
+//
+//  @ Project : RTC8563
+//  @ File Name : RTC8563.h
+//  @ Date : 06.04.2015
+//  @ Author : Franz Pucher
+//  @ Copyright : pe@bulme.at
+//
+#include "mbed.h"
+#include "const.h"
+ 
+#if !defined(_RTC8563_H)
+#define _RTC8563_H
+ 
+class RTC8563
+{
+public:
+    RTC8563();          // delete void
+    RTC8563(PinName sda, PinName scl);
+    char rtc_read(char address);
+    void rtc_write(char address, char value);
+    void rtc_init();
+    void rtc_alarm();
+protected:
+    I2C i2c;
+};
+#endif  //_RTC8563_H
\ No newline at end of file