2525
2626static int iSCL, iSDA; // keep requested pin numbers in private statics
2727static int iDelay; // bit delay in ms for the requested clock rate
28- #ifdef __AVR__
28+ #if defined ( __AVR__ ) && !defined( ARDUINO_ARCH_MEGAAVR )
2929volatile uint8_t *iDDR_SCL, *iPort_SCL_Out;
3030volatile uint8_t *iDDR_SDA, *iPort_SDA_In, *iPort_SDA_Out;
3131uint8_t iSDABit, iSCLBit;
@@ -37,7 +37,7 @@ volatile uint32_t *iDDR_SDA, *iPort_SDA_In, *iPort_SDA_Out;
3737uint32_t iSDABit, iSCLBit;
3838#endif
3939
40- #ifdef __AVR__
40+ #if defined ( __AVR__ ) && !defined( ARDUINO_ARCH_MEGAAVR )
4141uint8_t getPinInfo (uint8_t pin, volatile uint8_t **iDDR, volatile uint8_t **iPort, int bInput)
4242{
4343 uint8_t port, bit;
@@ -111,7 +111,7 @@ uint32_t getPinInfo(uint8_t pin, volatile uint32_t **iDDR, volatile uint32_t **i
111111
112112inline uint8_t SDA_READ (void )
113113{
114- #ifdef __AVR__
114+ #if defined ( __AVR__ ) && !defined( ARDUINO_ARCH_MEGAAVR )
115115 if (iSDA >= 0xa0 ) // direct pin numbering
116116 {
117117 if (*iPort_SDA_In & iSDABit)
@@ -129,7 +129,7 @@ inline uint8_t SDA_READ(void)
129129}
130130inline void SCL_HIGH (void )
131131{
132- #ifdef __AVR__
132+ #if defined ( __AVR__ ) && !defined( ARDUINO_ARCH_MEGAAVR )
133133 if (iSCL >= 0xa0 ) // direct pin numbering
134134 {
135135 *iDDR_SCL &= ~iSCLBit;
@@ -145,7 +145,7 @@ inline void SCL_HIGH(void)
145145
146146inline void SCL_LOW (void )
147147{
148- #ifdef __AVR__
148+ #if defined ( __AVR__ ) && !defined( ARDUINO_ARCH_MEGAAVR )
149149 if (iSCL >= 0xa0 ) // direct pin numbering
150150 {
151151 *iDDR_SCL |= iSCLBit;
@@ -161,7 +161,7 @@ inline void SCL_LOW(void)
161161
162162inline void SDA_HIGH (void )
163163{
164- #ifdef __AVR__
164+ #if defined ( __AVR__ ) && !defined( ARDUINO_ARCH_MEGAAVR )
165165 if (iSDA >= 0xa0 ) // direct pin numbering
166166 {
167167 *iDDR_SDA &= ~iSDABit;
@@ -177,7 +177,7 @@ inline void SDA_HIGH(void)
177177
178178inline void SDA_LOW (void )
179179{
180- #ifdef __AVR__
180+ #if defined ( __AVR__ ) && !defined( ARDUINO_ARCH_MEGAAVR )
181181 if (iSDA >= 0xa0 ) // direct pin numbering
182182 {
183183 *iDDR_SDA |= iSDABit;
@@ -238,7 +238,7 @@ uint8_t i, ack;
238238} /* i2cByteOut() */
239239#endif
240240
241- #ifdef __AVR__
241+ #if defined ( __AVR__ ) && !defined( ARDUINO_ARCH_MEGAAVR )
242242#define SDA_LOW_AVR *iDDR_sda |= sdabit;
243243#define SDA_HIGH_AVR *iDDR_sda &= ~sdabit;
244244#define SCL_LOW_AVR *iDDR_scl |= sclbit;
@@ -419,7 +419,7 @@ int rc, iOldLen = iLen;
419419#ifdef __AVR_ATtiny85__
420420 rc = i2cByteOutAVRFast (b);
421421#else
422- #ifdef __AVR__
422+ #if defined ( __AVR__ ) && !defined( ARDUINO_ARCH_MEGAAVR )
423423 if (iSDA >= 0xa0 )
424424 {
425425 rc = i2cByteOutAVRFast (b);
@@ -474,7 +474,7 @@ void I2CInit(int iSDA_Pin, int iSCL_Pin, int32_t iClock)
474474 digitalWrite (iSCL, LOW);
475475#endif
476476 }
477- #ifdef __AVR__
477+ #if defined ( __AVR__ ) && !defined( ARDUINO_ARCH_MEGAAVR )
478478 else // direct pin mode, get port address and bit
479479 {
480480// iSDABit = 1 << (iSDA & 0x7);
0 commit comments