How to change this code to wirk in arduino
TCNT0 = c_6ms; // load Timer0
TCCR0 = c_Timer0_run; // start Timer0
// wait for idle time between two packets, then start receiving
while(bit_is_clear(TIFR, TOV0)) // wait for MOSI high for minimum of 6ms
{
if (bit_is_clear(PINB, b_MOSI)) TCNT0 = c_6ms; // load Timer0 if MOSI is not high
};// wait until timer0 overflow
TIFR |= _BV(TOV0); // clear timer0 overflow flag
TCNT0 = c_6ms; // load Timer0
while(bit_is_clear(TIFR, TOV0)) // wait for MOSI low for minimum of 6ms
{
if (bit_is_set(PINB, b_MOSI)) TCNT0 = c_6ms; // load Timer0 if MOSI is not low
};// wait until timer overflow
TCNT0 = c_Timer0_stop; // stop timer0
and this
TCNT0 = c_7ms; // load Timer0
TCCR0 = c_Timer0_run; // start Timer0
TIFR |= _BV(TOV0); // clear timer0 overflow flag
// wait for idle time between two packets, then do slave break
//
// wait for data line low for minimum of 7ms
//
while(bit_is_clear(TIFR, TOV0))
{
if (bit_is_clear(PINB, b_MOSI)) TCNT0 = c_7ms; // load Timer0 if MOSI is low == high on bus
};
// wait until timer0 overflow
TIFR |= _BV(TOV0); // clear timer0 overflow flag
TCNT0 = c_2ms; // load Timer0
//
// wait for data line high for 2ms
//
while(bit_is_clear(TIFR, TOV0))
{
if (bit_is_set(PINB, b_MOSI)) TCNT0 = c_2ms; // load Timer0 if MOSI is high == low on bus
};
// wait until timer overflow
//
// force data line 3ms low
//
TIFR |= _BV(TOV0); // clear timer0 overflow flag
TCNT0 = c_3ms; // load timer0 for 3ms
DDRB |= _BV(b_MISO); // MISO output and high (inverted by hardware to low)
PORTB |= _BV(b_MISO);
while(bit_is_clear(TIFR, TOV0));