All pastes #803658 Raw Edit

Stuff

public c v1 · immutable
·published 2007-12-02 14:05 UTC
rendered paste body
#include <avr/io.h>#include <avr/interrupt.h>#include <stdint.h>#include <avr/sfr_defs.h>#include <util/delay.h>#define F_CPU 4000000#define STOP 0#define RUN 1#define OUTPUT 1#define INPUT 0volatile uint8_t state;volatile uint8_t ledCount = 0;void enableAllStops(){        PORTB |=(1<<PB0)|(1<<PB1)|(1<<PB2)|(1<<PB3);}void disableAllStops(){        PORTB &=~(1<<PB0)&~(1<<PB1)&~(1<<PB2)&~(1<<PB3);}void enableRun(){        PORTD |=(1<<PD4);}void disableRun(){        PORTD &=~(1<<PD4);}void enableMCURunning(){        PORTD |=(1<<PD5);}SIGNAL(SIG_INTERRUPT0){        ledCount=1;        //RESET        if(bit_is_set(PINC,PC6) && state==STOP){                enableRun();                disableAllStops();                //PORTD |=(1<<PD4);                state=RUN;        }        //SW1        if(bit_is_set(PINC,PC5) && state==RUN){                PORTD &=~(1<<PD4);                disableRun();                PORTB |=(1<<PB0);                state=STOP;        }        //SW2        if(bit_is_set(PINA,PA2) && state==RUN){                disableRun();                PORTD |=(1<<PD4);                state=STOP;        }}int main(void){        state=STOP;        GICR=0xC0;        MCUCR=0x01;        sei();        DDRD |= (OUTPUT<<PD6)|(OUTPUT<<PD5)|(OUTPUT<<PD4)|(OUTPUT<<PD7);        DDRB |= (OUTPUT<<PB0)|(OUTPUT<<PB1)|(OUTPUT<<PB2)|(OUTPUT<<PB3);        DDRA = (INPUT << PA0 | INPUT << PA1 |INPUT << PA2 |INPUT << PA3 |INPUT << PA4 |INPUT << PA5 |INPUT << PA6 |INPUT << PA7);        DDRC = 0x00; //PORTC == INPUT PORT        //      PORTD &=~(1 << PD2);        PORTA = 0x00; //pullup 0  pa alla pinnar        PORTC = 0xFF;        enableMCURunning();        enableAllStops();        disableRun();        while (1) {        }        return 0;}