int main() { LEDInit(); display.changed = 1; display.number = 233; display.blinkPos = 0b0000; display.pointPos = 0b1000; display.isNegative = 1; display.skipZeros = 1; display.forceFractZero = 1; while(1) { LEDTest(); LEDshowOnDisplay(); } }
void main () { int R_B,L_B,inputOn; coldstart(); // Grundinitialisierung enable_interrupts(GLOBAL); while (TRUE) // Beginn Hauptprogramm { /* inputOn = 0; set_adc_channel(2); delay_ms (1); inputOn += read_adc(); set_adc_channel(3); delay_ms (1); inputOn += read_adc(); set_adc_channel(4); delay_ms (1); inputOn += read_adc(); */ // VU-Meter set_adc_channel(0); delay_ms (1); L_B = Makevu (read_adc()); set_adc_channel(1); delay_ms (1); R_B = Makevu (read_adc()); if((R_B+L_B) > 1){ // VU-Meter - Portout Portout (L_B,R_B); // Bass, mid, treble set_adc_channel(2); delay_ms (1); if (read_adc() > 560) output_low (Ledb_p); else output_high (Ledb_p); set_adc_channel(3); delay_ms (1); if (read_adc() > 570) output_low (Ledm_p); else output_high (Ledm_p); set_adc_channel(4); delay_ms (1); if (read_adc() > 550) output_low (Ledt_p); else output_high (Ledt_p); } else { LEDTest(); } // Tasten if(input(Minus_p)==0) SendSPI(0x0004); if(input(Plus_p)==0) SendSPI(0x0002); if(input(Up_p)==0) SendSPI(0x0008); if(input(Down_p)==0) SendSPI(0x0010); SendSPI(0x0000); } }
void main () { int R_B,L_B, R_VU, L_VU, avg_R=0, avg_L=0, LEDMuster=0; coldstart(); // Grundinitialisierung enable_interrupts(GLOBAL); set_adc_channel(0); delay_ms (1); avg_L = read_adc(); set_adc_channel(1); delay_ms (1); avg_R = read_adc(); while (TRUE) // Beginn Hauptprogramm { // VU-Meter set_adc_channel(0); delay_ms (1); L_VU = read_adc(); set_adc_channel(1); delay_ms (1); R_VU = read_adc(); avg_L = (avg_L + L_VU) /2; avg_R = (avg_R + R_VU) /2; if((avg_L + avg_R) >= 3){ // VU-Meter - Portout L_B = Makevu (L_VU); R_B = Makevu (R_VU); Portout (L_B,R_B); // Bass, mid, treble set_adc_channel(2); delay_ms (1); if (read_adc() > 560) output_low (Ledb_p); else output_high (Ledb_p); set_adc_channel(3); delay_ms (1); if (read_adc() > 570) output_low (Ledm_p); else output_high (Ledm_p); set_adc_channel(4); delay_ms (1); if (read_adc() > 550) output_low (Ledt_p); else output_high (Ledt_p); } else { LEDTest(LEDMuster); if(++LEDMuster == 3){ LEDMuster = 0; } } } }
//****************************************************************************** // Main Menu //****************************************************************************** void MainMenu(void) { char choice[1]; char LED; char UART; char Audio; char Switch; char TempSensor; char* test="blank"; unsigned int validChoice = 0; ConsoleUtilsPrintf("\n\n\n\n"); ConsoleUtilsPrintf("\n**************************************************************\n"); ConsoleUtilsPrintf("* PRU Cape Demo *\n"); ConsoleUtilsPrintf("**************************************************************\n"); ConsoleUtilsPrintf(" \n"); while(!validChoice) { ConsoleUtilsPrintf("\n\nWhat test would you like to run?\n\n"); ConsoleUtilsPrintf("1. LEDs\n"); ConsoleUtilsPrintf("2. Switches\n"); ConsoleUtilsPrintf("3. Audio\n"); ConsoleUtilsPrintf("4. Uart\n"); ConsoleUtilsPrintf("5. Temp sensor\n"); ConsoleUtilsPrintf("6. All\n"); ConsoleUtilsGets(choice, 3); switch(choice[0]) { case '1': test = "LEDs"; ConsoleUtilsPrintf("\nYou chose %s\n", test); LED = LEDTest(); break; case '2': test = "Switch"; ConsoleUtilsPrintf("\nYou chose %s\n", test); Switch = SwitchTest(); break; case '3': test = "Audio"; ConsoleUtilsPrintf("\nYou chose %s\n", test); Audio = AudioTest(); break; case '4': test = "Uart"; ConsoleUtilsPrintf("\nYou chose %s\n", test); UART = UARTTest(); break; case '5': test = "Temp sensor"; ConsoleUtilsPrintf("\nYou chose %s\n", test); TempSensor = HDQTest(); break; case '6': test = "All"; ConsoleUtilsPrintf("\nYou chose %s\n", test); ConsoleUtilsPrintf("\nRunning all tests, loading... \n"); LED = LEDTest(); PRUICSSReset(); Switch = SwitchTest(); PRUICSSReset(); Audio = AudioTest(); PRUICSSReset(); UART = UARTTest(); PRUICSSReset(); TempSensor = HDQTest(); PRUICSSReset(); ConsoleUtilsPrintf("\n\n\n**************************************************************\n"); ConsoleUtilsPrintf("\n TEST RESULTS \n"); ConsoleUtilsPrintf("\n**************************************************************\n"); if((LED =='y') || (LED =='Y')) ConsoleUtilsPrintf("\nLED Pass"); else ConsoleUtilsPrintf("\nLED Fail"); if((Switch =='y') || (Switch =='Y')) ConsoleUtilsPrintf("\nSwitch Pass"); else ConsoleUtilsPrintf("\nSwitch Fail"); if((Audio =='y') || (Audio =='Y')) ConsoleUtilsPrintf("\nAUDIO Pass"); else ConsoleUtilsPrintf("\nAUDIO Fail"); if((UART =='y') || (UART =='Y')) ConsoleUtilsPrintf("\nUART Pass"); else ConsoleUtilsPrintf("\nUART Fail"); if((TempSensor =='y') || (TempSensor =='Y')) ConsoleUtilsPrintf("\nTemp Sensor Pass"); else ConsoleUtilsPrintf("\nTemp Sensor Fail"); ConsoleUtilsPrintf("\n\n\n"); break; default: ConsoleUtilsPrintf("\nInvalid input.\n\n"); break; } } validChoice = 0; }