Matthias Hemmer
/
PCF8563_RealTimeClock_MatthiasHemmer
Bertl2014 Bulme
I2C/myi2c.h@0:84a4a0aa3ea6, 2017-05-06 (annotated)
- Committer:
- hemmer_matthias
- Date:
- Sat May 06 20:12:01 2017 +0000
- Revision:
- 0:84a4a0aa3ea6
Bertl2014
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
hemmer_matthias | 0:84a4a0aa3ea6 | 1 | #ifndef MBED_PCF8563_H |
hemmer_matthias | 0:84a4a0aa3ea6 | 2 | #define MBED_PCF8563_H |
hemmer_matthias | 0:84a4a0aa3ea6 | 3 | |
hemmer_matthias | 0:84a4a0aa3ea6 | 4 | #include "mbed.h" |
hemmer_matthias | 0:84a4a0aa3ea6 | 5 | |
hemmer_matthias | 0:84a4a0aa3ea6 | 6 | #define PCF8563_FREQ 400000 // bus speed 400 kHz |
hemmer_matthias | 0:84a4a0aa3ea6 | 7 | |
hemmer_matthias | 0:84a4a0aa3ea6 | 8 | class PCF8563 |
hemmer_matthias | 0:84a4a0aa3ea6 | 9 | { |
hemmer_matthias | 0:84a4a0aa3ea6 | 10 | public: |
hemmer_matthias | 0:84a4a0aa3ea6 | 11 | //define the i2c pins |
hemmer_matthias | 0:84a4a0aa3ea6 | 12 | PCF8563(PinName sda, PinName scl); |
hemmer_matthias | 0:84a4a0aa3ea6 | 13 | /**read from an I2C address |
hemmer_matthias | 0:84a4a0aa3ea6 | 14 | *@para: the read address of the I2C device |
hemmer_matthias | 0:84a4a0aa3ea6 | 15 | *@param: for only one i2c address of the device |
hemmer_matthias | 0:84a4a0aa3ea6 | 16 | */ |
hemmer_matthias | 0:84a4a0aa3ea6 | 17 | uint8_t read(int i2c_r,int address); //read class |
hemmer_matthias | 0:84a4a0aa3ea6 | 18 | /**read from an I2C address |
hemmer_matthias | 0:84a4a0aa3ea6 | 19 | * for two different parameters |
hemmer_matthias | 0:84a4a0aa3ea6 | 20 | *@param: the write address of the I2C device |
hemmer_matthias | 0:84a4a0aa3ea6 | 21 | *@param: the read address of the I2C device |
hemmer_matthias | 0:84a4a0aa3ea6 | 22 | *@param: the register where you will read from |
hemmer_matthias | 0:84a4a0aa3ea6 | 23 | */ |
hemmer_matthias | 0:84a4a0aa3ea6 | 24 | uint8_t read(int i2c_w, int i2c_r, int address); //read class |
hemmer_matthias | 0:84a4a0aa3ea6 | 25 | /**wirte from an I2C address |
hemmer_matthias | 0:84a4a0aa3ea6 | 26 | *@param: the write address of the I2C device |
hemmer_matthias | 0:84a4a0aa3ea6 | 27 | *@param: a register address of the I2C device |
hemmer_matthias | 0:84a4a0aa3ea6 | 28 | *@param: set a value to this address of th I2C device |
hemmer_matthias | 0:84a4a0aa3ea6 | 29 | */ |
hemmer_matthias | 0:84a4a0aa3ea6 | 30 | void write(int i2c_w, int address, int value); //write class |
hemmer_matthias | 0:84a4a0aa3ea6 | 31 | /**convert from Binary Coded Decimal to Decimal |
hemmer_matthias | 0:84a4a0aa3ea6 | 32 | *@param: set a value which must be converted |
hemmer_matthias | 0:84a4a0aa3ea6 | 33 | *returns a Decimal value |
hemmer_matthias | 0:84a4a0aa3ea6 | 34 | */ |
hemmer_matthias | 0:84a4a0aa3ea6 | 35 | uint8_t bcdToDec(uint8_t val); //convertation from bcd to dec |
hemmer_matthias | 0:84a4a0aa3ea6 | 36 | |
hemmer_matthias | 0:84a4a0aa3ea6 | 37 | private: |
hemmer_matthias | 0:84a4a0aa3ea6 | 38 | I2C i2c; //unsing the i2c library |
hemmer_matthias | 0:84a4a0aa3ea6 | 39 | }; |
hemmer_matthias | 0:84a4a0aa3ea6 | 40 | #endif |