void pi_main(void* data) { int numPartitions = 12000; int circleCount = 0; double interval = 0, pi = 0; int i = 0, j = 0; numPartitions = 300; interval = 1.0/(double)numPartitions; for (i = 0; i < numPartitions; i++) { double a = (i + .5)*interval; for (j = 0; j < numPartitions; j++) { double b = (j + .5)*interval; if ((a*a + b*b) <= 1) circleCount++; } } pi = (double)(4*circleCount)/(numPartitions * numPartitions); if(pi > 3.14 && pi < 3.15) { // Correct Value user_led_toggle(*(int *)data); } else { // The LED should stop blinking while(1); } }
void task_input(void * ptr) { static int len = 0; static char buffer[48]; char ch = getchar(); if(ch != 0) { putchar(ch); // Echo back the character // Toggle the LED for fun user_led_toggle(*(int *)ptr); // Ignore the initial whitespace if((len == 0) && (ch == ' ' || ch == '\t' || ch == '\r' || ch == '\n')) { return; // Ignore the characters } if(ch == '\r' || ch == '\n') { buffer[len++] = '\0'; strcpy(input_str, buffer); len = 0; OS_SemPost(&input_ready); return; } buffer[len++] = ch; if((len+1) == sizeof(input_str)) { buffer[len++] = '\0'; strcpy(input_str, buffer); len = 0; OS_SemPost(&input_ready); return; } } }
/////////////////////////////////////////////////////////////////////////////// // _PFM_SetUserLED // The led parameter indicates which LED should be turned ON/OFF/Toggled depending on // the options provided /////////////////////////////////////////////////////////////////////////////// OS_Return _PFM_SetUserLED(LED_Number led, LED_Options options) { OS_Return status = SUCCESS; switch(options) { case LED_ON: user_led_on(led); break; case LED_OFF: user_led_off(led); break; case LED_TOGGLE: user_led_toggle(led); break; default: status = BAD_ARGUMENT; break; } return status; }
void task_3(void * ptr) { user_led_toggle(*(int *)ptr); }
void task_count(void * ptr) { test_counter++; user_led_toggle(*(int *)ptr); }