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

Committer:
bulmecisco
Date:
Thu Apr 16 10:25:33 2015 +0000
Revision:
2:f75062350241
rtc functions in class RTC8563 transferred

Who changed what in which revision?

UserRevisionLine numberNew contents of line
bulmecisco 2:f75062350241 1 //
bulmecisco 2:f75062350241 2 // @ Project : RTC8563
bulmecisco 2:f75062350241 3 // @ File Name : RTC8563.h
bulmecisco 2:f75062350241 4 // @ Date : 06.04.2015
bulmecisco 2:f75062350241 5 // @ Author : Franz Pucher
bulmecisco 2:f75062350241 6 // @ Copyright : pe@bulme.at
bulmecisco 2:f75062350241 7 //
bulmecisco 2:f75062350241 8 #include "mbed.h"
bulmecisco 2:f75062350241 9 #include "const.h"
bulmecisco 2:f75062350241 10
bulmecisco 2:f75062350241 11 #if !defined(_RTC8563_H)
bulmecisco 2:f75062350241 12 #define _RTC8563_H
bulmecisco 2:f75062350241 13
bulmecisco 2:f75062350241 14 class RTC8563
bulmecisco 2:f75062350241 15 {
bulmecisco 2:f75062350241 16 public:
bulmecisco 2:f75062350241 17 RTC8563(); // delete void
bulmecisco 2:f75062350241 18 RTC8563(PinName sda, PinName scl);
bulmecisco 2:f75062350241 19 char rtc_read(char address);
bulmecisco 2:f75062350241 20 void rtc_write(char address, char value);
bulmecisco 2:f75062350241 21 void rtc_init();
bulmecisco 2:f75062350241 22 void rtc_alarm();
bulmecisco 2:f75062350241 23 protected:
bulmecisco 2:f75062350241 24 I2C i2c;
bulmecisco 2:f75062350241 25 };
bulmecisco 2:f75062350241 26 #endif //_RTC8563_H