#include "gpio.c"
int main(void){
GpioMode(GPIOA, 1<<7, MODE_IPU); // Config A7 (pin 17) as input with internal pull-up resistor
GpioMode(GPIOA, 1<<6, MODE_PP); // Config A6 (pin 16) as output (PP = Pusp-Pull), if no speed is defined: default = SPEED_50MHz
GpioMode(GPIOB, 1<<10, MODE_IPU); // Config B10 (pin 21) as input with internal pull-up resistor
GpioMode(GPIOB, (1<<5 | 1<<8 | 1<<9), (MODE_PP | SPEED_50MHz)); // Config B5 (pin 41), B8 and B9 as output (PP = Pusp-Pull), Speed = SPEED_50MHz
sbi(PORTB, 8); // Set PB8 high, 3,3V: Led 2 is turned on
sbi(PORTB, 9); // Set PB9 high, 3,3V: Led 3 is turned on
// infinite loop
while(1){
if(rbi(PINA, 7)){ // Read Bit 7 from PINA
sbi(PORTA, 6); // Set Bit 6 from PORTA
}
else{
cbi(PORTA, 6); // Clear Bit 6 from PORTA
}
if(rbi(PINB, 10)){ // Read Bit 10 from PINB
sbi(PORTB, 5); // Set Bit 5 from PORTB
}
else{
cbi(PORTB, 5); // Clear Bit 5 from PORTB
}
}
}