This is a class for using the BQ32000 Real Time Clock chip from TI.
BQ32000
This is a class for using the BQ32000 Real Time Clock chip from TI.This is supossed to be pin and code compatible with the most usual DS1307. It is pin compatible as you can see:
On the code side it is almost compatible, with some advanced functions added (trickle charge, calibration) and minor differences in the registers, For example is only capable of generating 1 Hz and 512 Hz square wave.
This library is based on the DS1307 library by Henry Leinen http://developer.mbed.org/users/leihen/code/RTC-DS1307/file/ee81f2c5a706
The trickle charge and calibration are included in the code but not tested against the chip.
Revision 1:17f606b5b59b, committed 2014-11-27
- Comitter:
- xeta05
- Date:
- Thu Nov 27 17:05:53 2014 +0000
- Parent:
- 0:c12a004a9113
- Commit message:
- Initial Revision
Changed in this revision
Rtc_bq32k.cpp | Show annotated file Show diff for this revision Revisions of this file |
Rtc_bq32k.h | Show annotated file Show diff for this revision Revisions of this file |
diff -r c12a004a9113 -r 17f606b5b59b Rtc_bq32k.cpp --- a/Rtc_bq32k.cpp Thu Nov 27 16:45:51 2014 +0000 +++ b/Rtc_bq32k.cpp Thu Nov 27 17:05:53 2014 +0000 @@ -1,9 +1,27 @@ +/* Rtc_bq32k.cpp */ +/*2014/11/27 Oskar Lopez de Gamboa +*/ +/* Copyright (c) <2014> <Oskar Lopez de Gamboa>, MIT License + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software + * and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, + * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or + * substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING + * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + #include "mbed.h" #include "Rtc_bq32k.h" - - - const char *Rtc_bq32k::m_weekDays[] = { "Saturday", "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday" }; @@ -164,11 +182,11 @@ char buffer2[2] = {(char)address, 0}; // m_rtc->start(); - if (m_rtc->write(0xd0, buffer2, 1) != 0) { + if (m_rtc->write(BQ32000_ADDRESS, buffer2, 1) != 0) { m_rtc->stop(); return false; } - if (m_rtc->read(0xd0, buffer, len) != 0) {return false;} + if (m_rtc->read(BQ32000_ADDRESS, buffer, len) != 0) {return false;} m_rtc->stop(); return true; } @@ -181,7 +199,7 @@ buffer2[i+1] = buffer[i]; // m_rtc->start(); - if (m_rtc->write(0xd0, buffer2, len+1) != 0) + if (m_rtc->write(BQ32000_ADDRESS, buffer2, len+1) != 0) { m_rtc->stop(); return false;
diff -r c12a004a9113 -r 17f606b5b59b Rtc_bq32k.h --- a/Rtc_bq32k.h Thu Nov 27 16:45:51 2014 +0000 +++ b/Rtc_bq32k.h Thu Nov 27 17:05:53 2014 +0000 @@ -1,25 +1,24 @@ /* Rtc_bq32k.h */ -/* -Copyright (c) 2013 Henry Leinen (henry[dot]leinen [at] online [dot] de) - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. +/*2014/11/27 Oskar Lopez de Gamboa */ +/* Copyright (c) <2014> <Oskar Lopez de Gamboa>, MIT License + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software + * and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, + * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or + * substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING + * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + #ifndef __Rtc_bq32k_H__ #define __Rtc_bq32k_H__ @@ -36,7 +35,7 @@ #define BQ32000__FT 0x06 // CAL_CFG1 - IRQ square wave enable #define BQ32000__CAL_S 0x05 // CAL_CFG1 - Calibration sign #define BQ32000__TCH2_BIT 0x05 // TCH2 - Trickle charger switch 2 -#define BQ32000__TCFE_BIT 0x06 // CFG2 - Trickle FET control +#define BQ32000__TCFE_BIT 0x06 // CFG2 - Trickle FET control // BQ32000 config values: #define BQ32000_CHARGE_ENABLE 0x05 // CFG2 - Trickle charger switch 1 enable #define BQ32000_SFKEY1_VAL 0x5E