Trying to understand an example which uses I2Cmaster to communicate with MLX90614 IR Temperature sensor, I have basic C experience many years ago and trying to get back into it.
the code is:
PORTC = (1 << PORTC4) | (1 << PORTC5); //enable pullups
I understand this as shift '1' left 'PORTC4' spaces? How is this ok - or does it write '1' to 'PortC4'? I can't find another example like this.
Secondly I see the datasheet mentions the internal pull-ups in the ATMEGA328P - is this the same as setting a pin to an output and setting it high?
Sorry this is all probably elementary and I'll regret asking but can't find the answers searching and have to start somewhere...
Secondly I see the datasheet mentions the internal pull-ups in the ATMEGA328P - is this the same as setting a pin to an output and setting it high?
No.
You can enable the pull up resistors by setting a pin as an input and writing high to it.
However, enabling the internal pull up resistors on the I2C line is a bad idea. They are not strong enough, you require 4K7 external ones. Also if trying to talk to a 3V3 device they put out too much voltage. And finally you only use port mapping for speed and there is zero point in using them for an operation you do only once.
However, enabling the internal pull up resistors on the I2C line is a bad idea.
But keep in mind that the Arduino Wire library is doing exactly that (enabling the internal pull ups), especially if you connect to a 3V3 device using a 5V Arduino.