felias-fogg / SoftI2CMaster

Software I2C Arduino library
GNU General Public License v3.0
368 stars 100 forks source link

Doesn't compile for ATMEGA32u4 #18

Closed dHutchings closed 7 years ago

dHutchings commented 7 years ago

the Atmega 32u4 is used on Arduino Leonardo & Micros. I believe it is an AVR chip, which this library supports.

The exact stack trace:

/root/Arduino/libraries/SoftI2CMaster-master/SoftI2CMaster.h: In function 'void i2c_wait_scl_high()':
/root/Arduino/libraries/SoftI2CMaster-master/SoftI2CMaster.h:185:31: error: 'SCL_PORT' was not declared in this scope
 #define SCL_IN  (_SFR_IO_ADDR(SCL_PORT) - 2)
                               ^
/root/Arduino/libraries/SoftI2CMaster-master/SoftI2CMaster.h:223:23: note: in expansion of macro 'SCL_IN'
      : : [SCLIN] "I" (SCL_IN), [SCLPIN] "I" (SCL_PIN));
                       ^
In file included from /home/douglash/Desktop/double_pendulum/code/integrated/DAC.ino:1:0:
/root/Arduino/libraries/SoftI2CMaster-master/SoftI2CMaster.h:223:46: error: 'SCL_PIN' was not declared in this scope
      : : [SCLIN] "I" (SCL_IN), [SCLPIN] "I" (SCL_PIN));
                                              ^
In file included from /root/.arduino15/packages/arduino/tools/avr-gcc/4.9.2-atmel3.5.3-arduino2/avr/include/avr/io.h:99:0,
                 from /root/.arduino15/packages/arduino/tools/avr-gcc/4.9.2-atmel3.5.3-arduino2/avr/include/avr/pgmspace.h:90,
                 from /root/.arduino15/packages/arduino/hardware/avr/1.6.15/cores/arduino/Arduino.h:28,
                 from sketch/integrated.ino.cpp:1:
/root/Arduino/libraries/SoftI2CMaster-master/SoftI2CMaster.h: In function 'bool i2c_init()':
/root/Arduino/libraries/SoftI2CMaster-master/SoftI2CMaster.h:181:38: error: 'SCL_PORT' was not declared in this scope
 #define SCL_DDR        (_SFR_IO_ADDR(SCL_PORT) - 1)
                                      ^
/root/Arduino/libraries/SoftI2CMaster-master/SoftI2CMaster.h:277:23: note: in expansion of macro 'SCL_DDR'
        [SCLDDR] "I"  (SCL_DDR), [SCLPIN] "I" (SCL_PIN), 
                       ^
In file included from /home/douglash/Desktop/double_pendulum/code/integrated/DAC.ino:1:0:
/root/Arduino/libraries/SoftI2CMaster-master/SoftI2CMaster.h:277:47: error: 'SCL_PIN' was not declared in this scope
        [SCLDDR] "I"  (SCL_DDR), [SCLPIN] "I" (SCL_PIN), 
                                               ^
In file included from /root/.arduino15/packages/arduino/tools/avr-gcc/4.9.2-atmel3.5.3-arduino2/avr/include/avr/io.h:99:0,
                 from /root/.arduino15/packages/arduino/tools/avr-gcc/4.9.2-atmel3.5.3-arduino2/avr/include/avr/pgmspace.h:90,
                 from /root/.arduino15/packages/arduino/hardware/avr/1.6.15/cores/arduino/Arduino.h:28,
                 from sketch/integrated.ino.cpp:1:
/root/Arduino/libraries/SoftI2CMaster-master/SoftI2CMaster.h:180:38: error: 'SDA_PORT' was not declared in this scope
 #define SDA_DDR        (_SFR_IO_ADDR(SDA_PORT) - 1)
                                      ^
/root/Arduino/libraries/SoftI2CMaster-master/SoftI2CMaster.h:279:23: note: in expansion of macro 'SDA_DDR'
        [SDADDR] "I"  (SDA_DDR), [SDAPIN] "I" (SDA_PIN), 
                       ^
In file included from /home/douglash/Desktop/double_pendulum/code/integrated/DAC.ino:1:0:
/root/Arduino/libraries/SoftI2CMaster-master/SoftI2CMaster.h:279:47: error: 'SDA_PIN' was not declared in this scope
        [SDADDR] "I"  (SDA_DDR), [SDAPIN] "I" (SDA_PIN), 
                                               ^
In file included from /root/.arduino15/packages/arduino/tools/avr-gcc/4.9.2-atmel3.5.3-arduino2/avr/include/avr/io.h:99:0,
                 from /root/.arduino15/packages/arduino/tools/avr-gcc/4.9.2-atmel3.5.3-arduino2/avr/include/avr/pgmspace.h:90,
                 from /root/.arduino15/packages/arduino/hardware/avr/1.6.15/cores/arduino/Arduino.h:28,
                 from sketch/integrated.ino.cpp:1:
/root/Arduino/libraries/SoftI2CMaster-master/SoftI2CMaster.h: In function 'bool i2c_start(uint8_t)':
/root/Arduino/libraries/SoftI2CMaster-master/SoftI2CMaster.h:180:38: error: 'SDA_PORT' was not declared in this scope
 #define SDA_DDR        (_SFR_IO_ADDR(SDA_PORT) - 1)
                                      ^
/root/Arduino/libraries/SoftI2CMaster-master/SoftI2CMaster.h:297:25: note: in expansion of macro 'SDA_DDR'
      : : [SDADDR] "I"  (SDA_DDR), [SDAPIN] "I" (SDA_PIN),
                         ^
In file included from /home/douglash/Desktop/double_pendulum/code/integrated/DAC.ino:1:0:
/root/Arduino/libraries/SoftI2CMaster-master/SoftI2CMaster.h:297:49: error: 'SDA_PIN' was not declared in this scope
      : : [SDADDR] "I"  (SDA_DDR), [SDAPIN] "I" (SDA_PIN),
                                                 ^
In file included from /root/.arduino15/packages/arduino/tools/avr-gcc/4.9.2-atmel3.5.3-arduino2/avr/include/avr/io.h:99:0,
                 from /root/.arduino15/packages/arduino/tools/avr-gcc/4.9.2-atmel3.5.3-arduino2/avr/include/avr/pgmspace.h:90,
                 from /root/.arduino15/packages/arduino/hardware/avr/1.6.15/cores/arduino/Arduino.h:28,
                 from sketch/integrated.ino.cpp:1:
/root/Arduino/libraries/SoftI2CMaster-master/SoftI2CMaster.h:185:31: error: 'SCL_PORT' was not declared in this scope
 #define SCL_IN  (_SFR_IO_ADDR(SCL_PORT) - 2)
                               ^
/root/Arduino/libraries/SoftI2CMaster-master/SoftI2CMaster.h:298:21: note: in expansion of macro 'SCL_IN'
        [SCLIN] "I" (SCL_IN),[SCLPIN] "I" (SCL_PIN)); 
                     ^
In file included from /home/douglash/Desktop/double_pendulum/code/integrated/DAC.ino:1:0:
/root/Arduino/libraries/SoftI2CMaster-master/SoftI2CMaster.h:298:43: error: 'SCL_PIN' was not declared in this scope
        [SCLIN] "I" (SCL_IN),[SCLPIN] "I" (SCL_PIN)); 
                                           ^
In file included from /root/.arduino15/packages/arduino/tools/avr-gcc/4.9.2-atmel3.5.3-arduino2/avr/include/avr/io.h:99:0,
                 from /root/.arduino15/packages/arduino/tools/avr-gcc/4.9.2-atmel3.5.3-arduino2/avr/include/avr/pgmspace.h:90,
                 from /root/.arduino15/packages/arduino/hardware/avr/1.6.15/cores/arduino/Arduino.h:28,
                 from sketch/integrated.ino.cpp:1:
/root/Arduino/libraries/SoftI2CMaster-master/SoftI2CMaster.h: In function 'bool i2c_rep_start(uint8_t)':
/root/Arduino/libraries/SoftI2CMaster-master/SoftI2CMaster.h:181:38: error: 'SCL_PORT' was not declared in this scope
 #define SCL_DDR        (_SFR_IO_ADDR(SCL_PORT) - 1)
                                      ^
/root/Arduino/libraries/SoftI2CMaster-master/SoftI2CMaster.h:322:25: note: in expansion of macro 'SCL_DDR'
      : : [SCLDDR] "I"  (SCL_DDR), [SCLPIN] "I" (SCL_PIN),[SCLIN] "I" (SCL_IN),
                         ^
In file included from /home/douglash/Desktop/double_pendulum/code/integrated/DAC.ino:1:0:
/root/Arduino/libraries/SoftI2CMaster-master/SoftI2CMaster.h:322:49: error: 'SCL_PIN' was not declared in this scope
      : : [SCLDDR] "I"  (SCL_DDR), [SCLPIN] "I" (SCL_PIN),[SCLIN] "I" (SCL_IN),
                                                 ^
In file included from /root/.arduino15/packages/arduino/tools/avr-gcc/4.9.2-atmel3.5.3-arduino2/avr/include/avr/io.h:99:0,
                 from /root/.arduino15/packages/arduino/tools/avr-gcc/4.9.2-atmel3.5.3-arduino2/avr/include/avr/pgmspace.h:90,
                 from /root/.arduino15/packages/arduino/hardware/avr/1.6.15/cores/arduino/Arduino.h:28,
                 from sketch/integrated.ino.cpp:1:
/root/Arduino/libraries/SoftI2CMaster-master/SoftI2CMaster.h:180:38: error: 'SDA_PORT' was not declared in this scope
 #define SDA_DDR        (_SFR_IO_ADDR(SDA_PORT) - 1)
                                      ^
/root/Arduino/libraries/SoftI2CMaster-master/SoftI2CMaster.h:323:25: note: in expansion of macro 'SDA_DDR'
          [SDADDR] "I"  (SDA_DDR), [SDAPIN] "I" (SDA_PIN)); 
                         ^
In file included from /home/douglash/Desktop/double_pendulum/code/integrated/DAC.ino:1:0:
/root/Arduino/libraries/SoftI2CMaster-master/SoftI2CMaster.h:323:49: error: 'SDA_PIN' was not declared in this scope
          [SDADDR] "I"  (SDA_DDR), [SDAPIN] "I" (SDA_PIN)); 
                                                 ^
In file included from /root/.arduino15/packages/arduino/tools/avr-gcc/4.9.2-atmel3.5.3-arduino2/avr/include/avr/io.h:99:0,
                 from /root/.arduino15/packages/arduino/tools/avr-gcc/4.9.2-atmel3.5.3-arduino2/avr/include/avr/pgmspace.h:90,
                 from /root/.arduino15/packages/arduino/hardware/avr/1.6.15/cores/arduino/Arduino.h:28,
                 from sketch/integrated.ino.cpp:1:
/root/Arduino/libraries/SoftI2CMaster-master/SoftI2CMaster.h: In function 'void i2c_start_wait(uint8_t)':
/root/Arduino/libraries/SoftI2CMaster-master/SoftI2CMaster.h:180:38: error: 'SDA_PORT' was not declared in this scope
 #define SDA_DDR        (_SFR_IO_ADDR(SDA_PORT) - 1)
                                      ^
/root/Arduino/libraries/SoftI2CMaster-master/SoftI2CMaster.h:350:24: note: in expansion of macro 'SDA_DDR'
     : : [SDADDR] "I"  (SDA_DDR), [SDAPIN] "I" (SDA_PIN),
                        ^
In file included from /home/douglash/Desktop/double_pendulum/code/integrated/DAC.ino:1:0:
/root/Arduino/libraries/SoftI2CMaster-master/SoftI2CMaster.h:350:48: error: 'SDA_PIN' was not declared in this scope
     : : [SDADDR] "I"  (SDA_DDR), [SDAPIN] "I" (SDA_PIN),
                                                ^
In file included from /root/.arduino15/packages/arduino/tools/avr-gcc/4.9.2-atmel3.5.3-arduino2/avr/include/avr/io.h:99:0,
                 from /root/.arduino15/packages/arduino/tools/avr-gcc/4.9.2-atmel3.5.3-arduino2/avr/include/avr/pgmspace.h:90,
                 from /root/.arduino15/packages/arduino/hardware/avr/1.6.15/cores/arduino/Arduino.h:28,
                 from sketch/integrated.ino.cpp:1:
/root/Arduino/libraries/SoftI2CMaster-master/SoftI2CMaster.h:185:31: error: 'SCL_PORT' was not declared in this scope
 #define SCL_IN  (_SFR_IO_ADDR(SCL_PORT) - 2)
                               ^
/root/Arduino/libraries/SoftI2CMaster-master/SoftI2CMaster.h:351:20: note: in expansion of macro 'SCL_IN'
       [SCLIN] "I" (SCL_IN),[SCLPIN] "I" (SCL_PIN)); 
                    ^
In file included from /home/douglash/Desktop/double_pendulum/code/integrated/DAC.ino:1:0:
/root/Arduino/libraries/SoftI2CMaster-master/SoftI2CMaster.h:351:42: error: 'SCL_PIN' was not declared in this scope
       [SCLIN] "I" (SCL_IN),[SCLPIN] "I" (SCL_PIN)); 
                                          ^
In file included from /root/.arduino15/packages/arduino/tools/avr-gcc/4.9.2-atmel3.5.3-arduino2/avr/include/avr/io.h:99:0,
                 from /root/.arduino15/packages/arduino/tools/avr-gcc/4.9.2-atmel3.5.3-arduino2/avr/include/avr/pgmspace.h:90,
                 from /root/.arduino15/packages/arduino/hardware/avr/1.6.15/cores/arduino/Arduino.h:28,
                 from sketch/integrated.ino.cpp:1:
/root/Arduino/libraries/SoftI2CMaster-master/SoftI2CMaster.h: In function 'void i2c_stop()':
/root/Arduino/libraries/SoftI2CMaster-master/SoftI2CMaster.h:181:38: error: 'SCL_PORT' was not declared in this scope
 #define SCL_DDR        (_SFR_IO_ADDR(SCL_PORT) - 1)
                                      ^
/root/Arduino/libraries/SoftI2CMaster-master/SoftI2CMaster.h:370:25: note: in expansion of macro 'SCL_DDR'
      : : [SCLDDR] "I"  (SCL_DDR), [SCLPIN] "I" (SCL_PIN), [SCLIN] "I" (SCL_IN),
                         ^
In file included from /home/douglash/Desktop/double_pendulum/code/integrated/DAC.ino:1:0:
/root/Arduino/libraries/SoftI2CMaster-master/SoftI2CMaster.h:370:49: error: 'SCL_PIN' was not declared in this scope
      : : [SCLDDR] "I"  (SCL_DDR), [SCLPIN] "I" (SCL_PIN), [SCLIN] "I" (SCL_IN),
                                                 ^
In file included from /root/.arduino15/packages/arduino/tools/avr-gcc/4.9.2-atmel3.5.3-arduino2/avr/include/avr/io.h:99:0,
                 from /root/.arduino15/packages/arduino/tools/avr-gcc/4.9.2-atmel3.5.3-arduino2/avr/include/avr/pgmspace.h:90,
                 from /root/.arduino15/packages/arduino/hardware/avr/1.6.15/cores/arduino/Arduino.h:28,
                 from sketch/integrated.ino.cpp:1:
/root/Arduino/libraries/SoftI2CMaster-master/SoftI2CMaster.h:180:38: error: 'SDA_PORT' was not declared in this scope
 #define SDA_DDR        (_SFR_IO_ADDR(SDA_PORT) - 1)
                                      ^
/root/Arduino/libraries/SoftI2CMaster-master/SoftI2CMaster.h:371:25: note: in expansion of macro 'SDA_DDR'
          [SDADDR] "I"  (SDA_DDR), [SDAPIN] "I" (SDA_PIN)); 
                         ^
In file included from /home/douglash/Desktop/double_pendulum/code/integrated/DAC.ino:1:0:
/root/Arduino/libraries/SoftI2CMaster-master/SoftI2CMaster.h:371:49: error: 'SDA_PIN' was not declared in this scope
          [SDADDR] "I"  (SDA_DDR), [SDAPIN] "I" (SDA_PIN)); 
                                                 ^
In file included from /root/.arduino15/packages/arduino/tools/avr-gcc/4.9.2-atmel3.5.3-arduino2/avr/include/avr/io.h:99:0,
                 from /root/.arduino15/packages/arduino/tools/avr-gcc/4.9.2-atmel3.5.3-arduino2/avr/include/avr/pgmspace.h:90,
                 from /root/.arduino15/packages/arduino/hardware/avr/1.6.15/cores/arduino/Arduino.h:28,
                 from sketch/integrated.ino.cpp:1:
/root/Arduino/libraries/SoftI2CMaster-master/SoftI2CMaster.h: In function 'bool i2c_write(uint8_t)':
/root/Arduino/libraries/SoftI2CMaster-master/SoftI2CMaster.h:181:38: error: 'SCL_PORT' was not declared in this scope
 #define SCL_DDR        (_SFR_IO_ADDR(SCL_PORT) - 1)
                                      ^
/root/Arduino/libraries/SoftI2CMaster-master/SoftI2CMaster.h:446:22: note: in expansion of macro 'SCL_DDR'
       [SCLDDR] "I"  (SCL_DDR), [SCLPIN] "I" (SCL_PIN), [SCLIN] "I" (SCL_IN),
                      ^
In file included from /home/douglash/Desktop/double_pendulum/code/integrated/DAC.ino:1:0:
/root/Arduino/libraries/SoftI2CMaster-master/SoftI2CMaster.h:446:46: error: 'SCL_PIN' was not declared in this scope
       [SCLDDR] "I"  (SCL_DDR), [SCLPIN] "I" (SCL_PIN), [SCLIN] "I" (SCL_IN),
                                              ^
In file included from /root/.arduino15/packages/arduino/tools/avr-gcc/4.9.2-atmel3.5.3-arduino2/avr/include/avr/io.h:99:0,
                 from /root/.arduino15/packages/arduino/tools/avr-gcc/4.9.2-atmel3.5.3-arduino2/avr/include/avr/pgmspace.h:90,
                 from /root/.arduino15/packages/arduino/hardware/avr/1.6.15/cores/arduino/Arduino.h:28,
                 from sketch/integrated.ino.cpp:1:
/root/Arduino/libraries/SoftI2CMaster-master/SoftI2CMaster.h:180:38: error: 'SDA_PORT' was not declared in this scope
 #define SDA_DDR        (_SFR_IO_ADDR(SDA_PORT) - 1)
                                      ^
/root/Arduino/libraries/SoftI2CMaster-master/SoftI2CMaster.h:447:22: note: in expansion of macro 'SDA_DDR'
       [SDADDR] "I"  (SDA_DDR), [SDAPIN] "I" (SDA_PIN), [SDAIN] "I" (SDA_IN)); 
                      ^
In file included from /home/douglash/Desktop/double_pendulum/code/integrated/DAC.ino:1:0:
/root/Arduino/libraries/SoftI2CMaster-master/SoftI2CMaster.h:447:46: error: 'SDA_PIN' was not declared in this scope
       [SDADDR] "I"  (SDA_DDR), [SDAPIN] "I" (SDA_PIN), [SDAIN] "I" (SDA_IN)); 
                                              ^
In file included from /root/.arduino15/packages/arduino/tools/avr-gcc/4.9.2-atmel3.5.3-arduino2/avr/include/avr/io.h:99:0,
                 from /root/.arduino15/packages/arduino/tools/avr-gcc/4.9.2-atmel3.5.3-arduino2/avr/include/avr/pgmspace.h:90,
                 from /root/.arduino15/packages/arduino/hardware/avr/1.6.15/cores/arduino/Arduino.h:28,
                 from sketch/integrated.ino.cpp:1:
/root/Arduino/libraries/SoftI2CMaster-master/SoftI2CMaster.h: In function 'uint8_t i2c_read(bool)':
/root/Arduino/libraries/SoftI2CMaster-master/SoftI2CMaster.h:181:38: error: 'SCL_PORT' was not declared in this scope
 #define SCL_DDR        (_SFR_IO_ADDR(SCL_PORT) - 1)
                                      ^
/root/Arduino/libraries/SoftI2CMaster-master/SoftI2CMaster.h:515:22: note: in expansion of macro 'SCL_DDR'
       [SCLDDR] "I"  (SCL_DDR), [SCLPIN] "I" (SCL_PIN), [SCLIN] "I" (SCL_IN),
                      ^
In file included from /home/douglash/Desktop/double_pendulum/code/integrated/DAC.ino:1:0:
/root/Arduino/libraries/SoftI2CMaster-master/SoftI2CMaster.h:515:46: error: 'SCL_PIN' was not declared in this scope
       [SCLDDR] "I"  (SCL_DDR), [SCLPIN] "I" (SCL_PIN), [SCLIN] "I" (SCL_IN),
                                              ^
In file included from /root/.arduino15/packages/arduino/tools/avr-gcc/4.9.2-atmel3.5.3-arduino2/avr/include/avr/io.h:99:0,
                 from /root/.arduino15/packages/arduino/tools/avr-gcc/4.9.2-atmel3.5.3-arduino2/avr/include/avr/pgmspace.h:90,
                 from /root/.arduino15/packages/arduino/hardware/avr/1.6.15/cores/arduino/Arduino.h:28,
                 from sketch/integrated.ino.cpp:1:
/root/Arduino/libraries/SoftI2CMaster-master/SoftI2CMaster.h:180:38: error: 'SDA_PORT' was not declared in this scope
 #define SDA_DDR        (_SFR_IO_ADDR(SDA_PORT) - 1)
                                      ^
/root/Arduino/libraries/SoftI2CMaster-master/SoftI2CMaster.h:516:22: note: in expansion of macro 'SDA_DDR'
       [SDADDR] "I"  (SDA_DDR), [SDAPIN] "I" (SDA_PIN), [SDAIN] "I" (SDA_IN) 
                      ^
In file included from /home/douglash/Desktop/double_pendulum/code/integrated/DAC.ino:1:0:
/root/Arduino/libraries/SoftI2CMaster-master/SoftI2CMaster.h:516:46: error: 'SDA_PIN' was not declared in this scope
       [SDADDR] "I"  (SDA_DDR), [SDAPIN] "I" (SDA_PIN), [SDAIN] "I" (SDA_IN) 
                                              ^
exit status 1
Error compiling for board Arduino/Genuino Micro.
dHutchings commented 7 years ago

I'd just like to follow up.

I was able to work around my issues by using your soft-slow libraries. Thank you for making these libraries! They were a great help.

felias-fogg commented 7 years ago

Hi Doug,

the error messages say that you haven’t declared SCL_PORT, SDA_PORT, SCL_PIN, and SDA_PIN. As described in the the playground, you need to declare these constants before importing the library.

/root/Arduino/libraries/SoftI2CMaster-master/SoftI2CMaster.h:185:31: error: 'SCL_PORT' was not declared in this scope

define SCL_IN (_SFR_IO_ADDR(SCL_PORT) - 2)

                           ^