int main(void) { int i; MAMCR = 2; // MAM functions fully enabled LED_INIT(); YELLOW_LED_OFF(); GREEN_LED_OFF(); BUTTON_INIT(); i=0; while (i<10) { YELLOW_LED_ON(); GREEN_LED_OFF(); delay(); YELLOW_LED_OFF(); GREEN_LED_ON(); delay(); i++; } while (1) { if (BUTTTON1_OFF()) { YELLOW_LED_ON(); } else { YELLOW_LED_OFF(); } if (BUTTTON2_OFF()) { GREEN_LED_ON(); } else { GREEN_LED_OFF(); } } return 0; // never reached }
int main (void) { /// Configure Devices ////////////////////////////////////// // Display configuration: frontLCD.ddr = &DDRD; frontLCD.port = &PORTD; frontLCD.pin = &PIND; frontLCD.pinNr_EN = PD5; frontLCD.pinNr_RS = PD4; frontLCD.pinNr_D4 = PD0; frontLCD.pinNr_D5 = PD1; frontLCD.pinNr_D6 = PD2; frontLCD.pinNr_D7 = PD3; // Buttion A configuration button_A.ddr = &DDRC; button_A.port = &PORTC; button_A.pin = &PINC; button_A.pinNr = PC7; button_A.internPullup = True; button_A.bounce_ms = 40; // Buttion B configuration button_B.ddr = &DDRC; button_B.port = &PORTC; button_B.pin = &PINC; button_B.pinNr = PC4; button_B.internPullup = True; button_B.bounce_ms = 40; // Rotary encoder A configuration encoder_A.ddr = &DDRC; encoder_A.port = &PORTC; encoder_A.pin = &PINC; encoder_A.pinNr_A = PC6; encoder_A.pinNr_B = PC5; encoder_A.internPullup = True; encoder_A.autoAcceleration = True; encoder_A.accerelationFactor = 200; // Rotary encoder B configuration encoder_B.ddr = &DDRC; encoder_B.port = &PORTC; encoder_B.pin = &PINC; encoder_B.pinNr_A = PC3; encoder_B.pinNr_B = PC2; encoder_B.internPullup = True; encoder_B.autoAcceleration = True; encoder_B.accerelationFactor = 100; /// END Configure Devices ////////////////////////////////// /// INIT Devices /////////////////////////////////////////// // INIT display LCD_INIT(&frontLCD); LCD_CLEAR(&frontLCD); // INIT buttons BUTTON_INIT(&button_A); BUTTON_INIT(&button_B); // INIT rotary encoders ROTARYENC_INIT(&encoder_A); ROTARYENC_INIT(&encoder_B); /// END INIT Devices /////////////////////////////////////// while(1) MainMenu(); // Enter main-menu (see below) return 0; }