int main(int argc, char **argv) { /* Initialize the random number generator */ rlxd_init(2, 12345); /* Initialize the lattice geometry */ init_lattice(X1, X2); //Testing the hermiticity of gam5D_wilson //Operator is Hermitian if for any vectors x and y (y, Ax) = (Ay, x) //1. Write the procedure which fills a spinor field with gaussian-distributed complex random numbers such that <z z*> = 1 //2. Initialize two random spinor fields X and Y (arrays of type spinor and size GRIDPOINTS) //3. Check that (y, Ax) = (Ay, x) spinor X[GRIDPOINTS], Y[GRIDPOINTS], tmp[GRIDPOINTS]; rand_spinor(X); rand_spinor(Y); //Calculating p1 = (y, Ax) gam5D_wilson(tmp, X); complex double p1 = scalar_prod(Y, tmp); //Calculating p2 = (Ax, y) gam5D_wilson(tmp, Y); complex double p2 = scalar_prod(tmp, X); //Check that p1 and p2 are equal double epsilon = cabs(p1 - p2); printf("\n\n\t Hermiticity check: |p1 - p2| = %2.2E - %s \n\n", epsilon, (epsilon < 1E-14)? "OK":"No"); //Testing the performance of the Conjugate Gradient Solver //1. In order to monitor the progress of the solver, #define MONITOR_CG_PROGRESS in linalg.h // This will print the squared norm of the residue at each iteration to the screen //2. Initialize the gauge fields with the coldstart() procedure //3. Generate a random spinor field Y and use cg(X, Y, ITER_MAX, DELTACG, &gam5D_SQR_wilson) // to solve the equation (gamma_5 D)^2 X = Y // (gamma_5 D)^2 is implemented as gam5D_SQR_wilson(out, temp, in), see Dirac.h //4. Now apply gam5D_SQR_wilson to X, subtract Y and calculate the norm of the result //5. Do the same with hotstart() and see how the number of CG iterations changes coldstart(); spinor Y1[GRIDPOINTS]; rand_spinor(Y); cg(X, Y, ITER_MAX, DELTACG, &gam5D_SQR_wilson); gam5D_SQR_wilson(Y1, tmp, X); diff(tmp, Y1, Y); epsilon = sqrt(square_norm(tmp)); printf("\n\n\t Test of CG inverter: |Q X - Y| = %2.2E - %s \n\n", epsilon, (epsilon < 1E-6)? "OK":"No"); free(left1); free(left2); free(right1); free(right2); system("PAUSE"); return 0; }
/* exception(): * This function is called by from vectors_sh3.S when an exception occured. * The global variable ExceptionType is also set in vectors_sh3.S. * Resume after handling an exception is prepared in vectors_sh3.S but not * used so far. Right now exception handling always ends with a restart of * uMon. */ void exception(void) { extern void coldstart(); int vnum; char *vname; ulong pc; vnum = (int)(ExceptionType & 0xff); getreg("PC",&pc); printf("EXCEPTION: #%d ",vnum); /* Choose text for console output depending on the exception offset. */ switch(vnum) { case 1: vname = "(General exception)"; break; case 2: vname = "(TLB miss)"; break; case 3: vname = "(Interrupt)"; break; default: vname = "(Unknown)"; break; } printf("%s @ 0x%lx\n",vname,pc); ExceptionAddr = pc; showregs(); intsoff(); if (pollConsole("coldstart?")) { warmstart(APP_EXIT); } else { coldstart(); } }
//! Main loop. int main(void){ volatile unsigned int i; unsigned char app, verb; unsigned long len; // MSP reboot count for reset input & reboot function located at 0xFFFE volatile unsigned int reset_count = 0; silent=0; //Don't trust globals. #if (platform == tilaunchpad) int ret=0; //ret = setjmp(warmstart);// needs to be here since context from init() would be gone warmstart: if (ret == 0) { coldstart(); // basic hardware setup, clock to TUSB3410, and enable } else if (ret == 2) { dputs("\nalmost BSL only one RTS change\n"); } else if (ret > 2) { // reset released after more than two tst transisitions // We could write a BSL, a nice exercise for a Sunday afternoon. dputs("\nBSL\n"); //call_BSL(); // once you are done uncomment ;-) } else { // we come here after DTR high (release reset) dputs("\nWarmstart\n"); } #endif #if (platform == donbfet) extern void donbfet_reboot(void); void (*reboot_function)(void) = donbfet_reboot; #elif (platform == zigduino) extern void zigduino_reboot(void); void (*reboot_function)(void) = zigduino_reboot; #else void (*reboot_function)(void) = (void *) 0xFFFE; #endif init(); txstring(MONITOR,OK,"http://goodfet.sf.net/"); //txstring(0xab,0xcd,"http://goodfet.sf.net/"); //Command loop. There's no end! while(1){ //Magic 3 app = serial_rx(); // If the app is the reset byte (0x80) increment and loop if (app == RESET){ reset_count++; if (reset_count > 4){ // We could trigger the WDT with either: // WDTCTL = 0; // or // WDTCTL = WDTPW + WDTCNTCL + WDTSSEL + 0x00; // but instead we'll jump to our reboot function pointer (*reboot_function)(); debugstr("Rebooting not supported on this platform."); } continue; }else { reset_count = 0; } verb = serial_rx(); len = rxword(); //Read data, looking for buffer overflow. if(len <= CMDDATALEN){ for(i = 0; i < len; i++) cmddata[i] = serial_rx(); handle(app,verb,len); }else { //Listen to the blaberring. for(i = 0; i < len; i++) serial_rx(); //Reply with an error. debugstr("Buffer length exceeded."); txdata(MONITOR,NOK,0); } } }
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; 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 { LEDTest8(); checkKeys(); LEDTest6(); checkKeys(); LEDTest3(); checkKeys(); LEDTest4(); checkKeys(); LEDTest2(); checkKeys(); LEDTest5(); checkKeys(); LEDTest7(); checkKeys(); LEDTest1(); } checkKeys(); } }