Custom I2C Protocol on DFRobot beetle esp32

Hi

I do apologize if this is the wrong place to post this. If that's the case then please let me know and I'll remove this an put it in the appropriate place.

So I am currently working on a project that uses a chip that uses a custom I2C protocol. They supply a demo project that compiles successfully for an Uno but when I try to compile for the DFRobot board it gives me the following errors (I get more but I believe they're all link and also because of the word limit):

C:\Users\andre\AppData\Local\Temp\arduino_build_729502\sketch\src\I2C\I2C.cpp: In member function 'uint8_t I2C::read(uint16_t, uint8_t, uint8_t*, I2C_Stop_e)':
C:\Users\andre\AppData\Local\Temp\arduino_build_729502\sketch\src\I2C\I2C.cpp:444:12: error: 'TWDR' was not declared in this scope
   *pData = TWDR;
            ^
In file included from C:\Users\andre\AppData\Local\Temp\arduino_build_729502\sketch\src\I2C\I2C.cpp:27:0:
C:\Users\andre\AppData\Local\Temp\arduino_build_729502\sketch\src\I2C\I2C.cpp: In member function 'void I2C::setup()':
C:\Users\andre\AppData\Local\Temp\arduino_build_729502\sketch\src\I2C\I2C.cpp:566:10: error: 'PORTD' was not declared in this scope
   SetBit(PORTD, 0);
          ^
C:\Users\andre\AppData\Local\Temp\arduino_build_729502\sketch\src\I2C\I2C.h:42:28: note: in definition of macro 'SetBit'
 #define SetBit(VAR,Index)  VAR |= (1<<Index)
                            ^
C:\Users\andre\AppData\Local\Temp\arduino_build_729502\sketch\src\I2C\I2C.cpp:572:11: error: 'TWSR' was not declared in this scope
  ClearBit(TWSR, TWPS0);
           ^
C:\Users\andre\AppData\Local\Temp\arduino_build_729502\sketch\src\I2C\I2C.h:43:30: note: in definition of macro 'ClearBit'
 #define ClearBit(VAR,Index)  VAR &= (uint8_t)(~(1<<Index))
                              ^
C:\Users\andre\AppData\Local\Temp\arduino_build_729502\sketch\src\I2C\I2C.cpp:572:17: error: 'TWPS0' was not declared in this scope
  ClearBit(TWSR, TWPS0);
                 ^

From what I understand is that the beetle esp32 doesn't actually have those registers, hence the errors. The board does have I2C functionality and the Wire.h library seems to work with it. I tried looking to see if I can make the wire library use a sort of custom protocol but I can't seem to find all the appropriate information.

So basically I want to know if I can use the sequence in the image attached with the Wire library?

I found this thread which makes me hopeful but I'm still not 100% sure how to go about it?

Note I am also willing to use any other library, wire is just the only one I know

al3gor:
So basically I want to know if I can use the sequence in the image attached with the Wire library?

Yes :smiley:

Figure 7.2 has a a 'repeated start' in the middle. That is created by Wire.endTransmission(false) followed by a Wire.requestFrom(...).

It feels as if I have stepped into a old dark mysterious movie with aliens. Who are "they" ? What kind of aliens would give you a demo project from the dark ages ? What secret spell did they put on you so you can't tell what chip it is ?

What I am trying to say: Is it for school ? Did you look at the date of the files of that project ? It is probably 5 years old or older. Please tell us which chip it is, we like to read its datasheet.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.