I don't want to use wire library. How to write my own I2C library for ATmega328/P using Arduino IDE?
I found sample code but that is not for Arduino IDE avr_i2c/twimaster.c at master · alx741/avr_i2c · GitHub
I don't want to use wire library. How to write my own I2C library for ATmega328/P using Arduino IDE?
I found sample code but that is not for Arduino IDE avr_i2c/twimaster.c at master · alx741/avr_i2c · GitHub
Rehan11:
I don't want to use wire library.
One wonders why?
How to write my own I2C library for ATmega328/P using Arduino IDE?
Are you looking for advice about writing code to implement I2C - if so, all the details are in the Atmega 328 datasheet with code snippets. And, of course, you can study the source code for the wire library.
OR, do you know how to implement I2C and want advice about how to create the files for an Arduino library?
...R
Robin2:
One wonders why?
One reason could be that, as implemented, Wire inherits from the Stream class. But, IMO, it’s an awkward, forced fit. The nature and protocol of I2C communications isn’t truly “Stream-like”. I’m assuming it was done this way to make it easier for newbies. If I were implementing an I2C library, I probably wouldn’t do it this way. But, it hasn’t bothered me enough to implement my own.
Minor Correction:
'Wire' is an instance of the TwoWire class which inherits from Stream.
Robin2:
One wonders why?
Are you looking for advice about writing code to implement I2C - if so, all the details are in the Atmega 328 datasheet with code snippets. And, of course, you can study the source code for the wire library....R
I am looking advice to implement i2c without wire library on arduino
I have been read datasheet of Atmega 328 description is given in section 21. 2-wire Serial Interface.
I don't want the complete code I can write my code If I get the code for the data write operation
Rehan11:
I am looking advice to implement i2c without wire library on arduino
It would be helpful for other readers who can learn from your experience if you explain why the wire library is not suitable.
...R
Rehan11:
I don't want the complete code I can write my code If I get the code for the data write operation
Look in twi.h and twi.c. They are in the "src/utility" folder under the "Wire" library.
you might want to look at wikipedia I2C
i believe one shortcoming of the Arduino I2C libraries is that it doesn't have a timeout and will hang