/* Name: main.c
 * Author: James Fletcher
 * Simple and rather broken basic test for the Fab Hello World board
 *
 * Board designed with:
 * Switch pulling PA7 down
 * LED from PB2 to VCC
 *
 * Re-worked board has:
 * Switch pulling PA7 down
 * LED form PA3 to VCC
 *
 */

#include <avr/io.h>
#include <util/delay.h>

int main(void)
{
    int i;
    
    PORTA = (1<<PA7) | (1<<PA3);
    DDRA = (1<<PA3); //0x08;
    
    PORTB = (1<<PB2);
    DDRB = (1<<DDB2);
    
    for(;;){
        for(i = 0; i < 20; i++){
            _delay_ms(25);
        }
        
        PORTB = 0;
        PORTA = (1<<PA7);
        
        for(i = 0; i < 20; i++){
            _delay_ms(25);
        }
        
        if(PINA&(1<<PA7))
        {
            PORTB = (1<<PB2);
            PORTA = (1<<PA7) | (1<<PA3);
        }
        else
        {
            PORTB = 0;
            PORTA = (1<<PA7);
        }
    }
    return 0;   /* never reached */
}
