Hi all,
I am trying to do a software implementation of the I2C protocol on an Atmega 1284 because the dedicated pins for hardware I2C are being used. I tried writing my own software I2C library, got stuck, but found a previously written one.
I had some questions regarding how the code (attached) works:
1) In the header file, the lines:
#define SCL PD0 //PORTD.0 PIN AS SCL PIN
#define SDA PD1 //PORTD.1 PIN AS SDA PIN
PD0 and PD1 aren't predefined pin values in iom1284p.h nor is it a type that the user #typedef, what exactly do they refer to? According to the user comment, shouldn't it be PORTD0 and PORTD1 instead?
2)
I don't understand how the user defined SDA_LOW, SDA_HIGH, SCL_LOW, SCL_HIGH...
Taking SDA_HIGH for instance, I think the code tells us it's HIGH when the DDRD register at location SDA is 0? As I understand, DDRD register bits set to 0 simply means that the PORT at location SDA is set to input and it doesn't mean that the PORT at the location has a high or low value...
Anyhow, clarifications would be greatly appreciated!
I am trying to do a software implementation of the I2C protocol on an Atmega 1284 because the dedicated pins for hardware I2C are being used. I tried writing my own software I2C library, got stuck, but found a previously written one.
I had some questions regarding how the code (attached) works:
1) In the header file, the lines:
#define SCL PD0 //PORTD.0 PIN AS SCL PIN
#define SDA PD1 //PORTD.1 PIN AS SDA PIN
PD0 and PD1 aren't predefined pin values in iom1284p.h nor is it a type that the user #typedef, what exactly do they refer to? According to the user comment, shouldn't it be PORTD0 and PORTD1 instead?
2)
I don't understand how the user defined SDA_LOW, SDA_HIGH, SCL_LOW, SCL_HIGH...
Taking SDA_HIGH for instance, I think the code tells us it's HIGH when the DDRD register at location SDA is 0? As I understand, DDRD register bits set to 0 simply means that the PORT at location SDA is set to input and it doesn't mean that the PORT at the location has a high or low value...
Anyhow, clarifications would be greatly appreciated!
Attachments
-
2.6 KB Views: 16
-
1.8 KB Views: 17