Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

how can I implement digitalwrite in AVR GCC ?

Status
Not open for further replies.

aliyesami

Full Member level 6
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.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top