int main(void) { //Code geoptimaliseerd voor bordje 3 //###1### //Initialize subsystems ClockInit(); //Initialize system clock (16 MHz) USARTInit(); //Initialize USART and bind to stdout,stdin AnalogInit(); //Initialize ADC AccInit(); //Initialize accelerometer system LEDInit(); //Initialize LEDs SwitchInit(); //Initialize switches EncoderInit(); //Initialize encoder SpeakerInit(); //Initialize speaker system //Enable interrupts PMIC.CTRL|=0b00000111; //Enable low, medium, high priority interrupts SREG|=0b10000000; //Globale interrupt enable //###2### //Print the digits 0 to 9 5x on terminal device //Reason this section didn't work: de variabelen 'a' is globaal gedefinieerd. In het subprogramma 'SimpleFunction()' wordt //de variabelen 'a' gebruikt. Na dit subprogramma is de waarde van 'a' gelijk aan 10 en zal de lus (a<5) onderbroken worden. for (a=0; a<5; a++) { SimpleFunction(); printf ("\r\n"); } //###3### //Main program loop a=0; ledOn=0b00001000; //Beeps(); //Genereer 3 beeps van 500hz, 1000hz, 1500hz (500 ms) setNotes(); //Stel een reeks van noten in playNextNote(); //Speel de eerste noot uit de reeks while(1) { LoopLicht(); //LoopLicht sequentie AccLezen(); //Accelerometer lezen printf("$SWITCH %d\r\n", SwitchGet()); //Switchwaarde over USARTD: 1: center, 2: rechts, 4: beneden, 8: links, 16: boven printf("$ACCRAW %d %d %d\r\n", RawAccX, RawAccY, RawAccZ); //Ongecalibreerde waardes accelerometer x, y, z over USARTD printf("$ACC__ %d %d %d\r\n", AccGetXAxis(RawAccX), AccGetYAxis(RawAccY), AccGetZAxis(RawAccZ)); //Gecalibreerde waardes accelerometer x, y, z over USARTD printf("$ENC__ %d\r\n", EncoderGetPos()); //printf ("Counter:%d\r\n",a); //printf("%c", 0x55); //Stuur de waarde 0x55 uit (0b01010101) //a++; _delay_ms(20); } }
SimpleFunction adapter ( const size_t dim , SimpleFunction::Function3 function ) { return SimpleFunction ( function , dim ) ; }
SimpleFunction adapter ( SimpleFunction::Function1 function ) { return SimpleFunction ( function ) ; }
void CallerFunction() { SimpleFunction(); Class c; c.SimpleMethod(); }