how can I implement digitalwrite in AVR GCC ?

Status
Not open for further replies.

aliyesami

Full Member level 6
Joined
Jan 7, 2010
Messages
369
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,296
Location
USA
Visit site
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))));"

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);            
      } 
}
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…