aliyesami
Full Member level 6
- Joined
- Jan 7, 2010
- Messages
- 369
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1,296
- Location
- USA
- Activity points
- 4,190
I am trying to do what arduino SHIFTOUT function does, but not sure how to code the following line in AVR gcc :
"digitalWrite(dataPin, !!(val & (1 << (7 - i))));"
"digitalWrite(dataPin, !!(val & (1 << (7 - i))));"
Code:
void shiftOut(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder, uint8_t val)
{
uint8_t i;
for (i = 0; i < 8; i++) {
if (bitOrder == LSBFIRST)
digitalWrite(dataPin, !!(val & (1 << i)));
else
digitalWrite(dataPin, !!(val & (1 << (7 - i))));
digitalWrite(clockPin, HIGH);
digitalWrite(clockPin, LOW);
}
}