Skip to content

Commit 0e778d7

Browse files
committed
Port MCP79412RTC to BoxLambda.
1 parent 24970f2 commit 0e778d7

File tree

2 files changed

+12
-24
lines changed

2 files changed

+12
-24
lines changed

src/MCP79412RTC.cpp

Lines changed: 9 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -18,25 +18,15 @@
1818
// constructor; this parameter defaults to true if not given.
1919

2020
#include <MCP79412RTC.h>
21+
#include <stdlib.h>
22+
#include "i2c.h"
2123

22-
// define consistent I2C functions
23-
#if defined(__AVR_ATtiny44__) || defined(__AVR_ATtiny84__) || defined(__AVR_ATtiny45__) || defined(__AVR_ATtiny85__)
24-
#include <TinyWireM.h>
25-
#define i2cBegin TinyWireM.begin
26-
#define i2cBeginTransmission TinyWireM.beginTransmission
27-
#define i2cEndTransmission TinyWireM.endTransmission
28-
#define i2cRequestFrom TinyWireM.requestFrom
29-
#define i2cRead TinyWireM.receive
30-
#define i2cWrite TinyWireM.send
31-
#else
32-
#include <Wire.h>
33-
#define i2cBegin Wire.begin
34-
#define i2cBeginTransmission Wire.beginTransmission
35-
#define i2cEndTransmission Wire.endTransmission
36-
#define i2cRequestFrom Wire.requestFrom
37-
#define i2cRead Wire.read
38-
#define i2cWrite Wire.write
39-
#endif
24+
#define i2cBegin i2c.begin
25+
#define i2cBeginTransmission i2c.beginTransmission
26+
#define i2cEndTransmission i2c.endTransmission
27+
#define i2cRequestFrom i2c.requestFrom
28+
#define i2cRead i2c.read
29+
#define i2cWrite i2c.write
4030

4131
// MCP7941x I2C Addresses
4232
#define RTC_ADDR 0x6F
@@ -623,6 +613,4 @@ uint8_t __attribute__ ((noinline)) MCP79412RTC::bcd2dec(uint8_t n)
623613
return n - 6 * (n >> 4);
624614
}
625615

626-
#if defined ARDUINO_ARCH_AVR
627-
MCP79412RTC RTC; // instantiate an RTC object for AVR only
628-
#endif
616+
MCP79412RTC RTC;

src/MCP79412RTC.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,10 @@
2020
#ifndef MCP79412RTC_H_INCLUDED
2121
#define MCP79412RTC_H_INCLUDED
2222

23-
#include <Arduino.h>
2423
#include <TimeLib.h> // https://github.com/PaulStoffregen/Time
24+
#include <stdint.h>
25+
26+
typedef uint8_t byte;
2527

2628
// Alarm types for use with the enableAlarm() function
2729
enum {
@@ -90,9 +92,7 @@ class MCP79412RTC
9092
static uint8_t bcd2dec(uint8_t num);
9193
};
9294

93-
#if defined ARDUINO_ARCH_AVR
9495
extern MCP79412RTC RTC;
95-
#endif
9696

9797
#ifndef _BV
9898
#define _BV(bit) (1 << (bit))

0 commit comments

Comments
 (0)