Skip to content

Commit

Permalink
Added I2C speed support
Browse files Browse the repository at this point in the history
Issue #15  fixed
  • Loading branch information
SV-Zanshin authored and SV-Zanshin committed Jun 30, 2018
1 parent c6806c5 commit be13d05
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 89 deletions.
87 changes: 0 additions & 87 deletions WorkInProgress/BatteryBackup/BatteryBackup.ino

This file was deleted.

3 changes: 2 additions & 1 deletion src/MCP7940.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,9 @@ MCP7940_Class::~MCP7940_Class() {} // of class destructor //
** Method begin starts I2C communications with the device, using a default address if one is not specified and **
** return true if the device has been detected and false if it was not **
*******************************************************************************************************************/
bool MCP7940_Class::begin() { // Start I2C communications //
bool MCP7940_Class::begin(const uint16_t i2cSpeed) { // Start I2C communications //
Wire.begin(); // Start I2C as master device //
Wire.setClock(i2cSpeed); // Set the I2C bus speed //
Wire.beginTransmission(MCP7940_ADDRESS); // Address the MCP7940M //
uint8_t errorCode = Wire.endTransmission(); // See if there's a device present //
if (errorCode == 0) { // If we have a MCP7940M //
Expand Down
7 changes: 6 additions & 1 deletion src/MCP7940.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
** **
** Vers. Date Developer Comments **
** ====== ========== ============================= ============================================================== **
** 1.0.8 2018-06-30 https://github.com/SV-Zanshin Enh #15 - Added I2C Speed selection **
** 1.0.7 2018-06-21 https://github.com/SV-Zanshin Bug #13 - DateTime.dayOfTheWeek() is 0-6 instead of 1-7 **
** 1.0.6 2018-04-29 https://github.com/SV-Zanshin Bug #7 - Moved setting of param defaults to prototypes **
** 1.0.6 2018-04-29 https://github.com/SV-Zanshin Bug #10 - incorrect setting of alarm with WKDAY to future date **
Expand Down Expand Up @@ -55,6 +56,10 @@
/*****************************************************************************************************************
** Declare constants used in the class **
*****************************************************************************************************************/
const uint16_t I2C_STANDARD_MODE = 100000; // Default normal I2C comms speed //
const uint16_t I2C_FAST_MODE = 400000; // Fast mode //
const uint16_t I2C_FAST_MODE_PLUS_MODE = 1000000; // Really fast mode //
const uint16_t I2C_HIGH_SPEED_MODE = 3400000; // Turbo mode //
const uint8_t MCP7940_ADDRESS = 0x6F; // Device address, fixed value //
const uint8_t MCP7940_RTCSEC = 0x00; // Register definitions //
const uint8_t MCP7940_RTCMIN = 0x01; // //
Expand Down Expand Up @@ -139,7 +144,7 @@
public: // Publicly visible methods //
MCP7940_Class(); // Class constructor //
~MCP7940_Class(); // Class destructor //
bool begin(); // Start I2C Comms with device //
bool begin(const uint16_t i2cSpeed = I2C_STANDARD_MODE); // Start I2C device communications //
bool deviceStatus(); // return true when MCP7940 is on //
bool deviceStart(); // Start the MCP7940 clock //
bool deviceStop(); // Stop the MCP7940 clock //
Expand Down

0 comments on commit be13d05

Please sign in to comment.