rendered paste bodyint main(void)
{
DDRB = 0xFF; // outport for monitoring result
DDRD = 0b00000111; // port connected to spi slave devices
PORTD = 0b00000011;
uint32_t result=0; // buffer for result
uint8_t i; // counter variable
Delay(100);
PORTD &= ~_BV(0); // pull pin 0 low (enable slave #1)
Delay(100);
while(1)
{
result = 0; // clear result buffer
for (i=0; i<19; i++)
{
PORTD |= _BV(2); // pull clock high
Delay(100);
result |= ((PIND & _BV(3))!=0)<<18; // read data bit
result >>= 1; // and shift right
Delay(100);
PORTD &= ~_BV(2); // pull clock low
Delay(100);
}
PORTB = result;
}
return 0;
}