static void usbshell_task (void *pvParameters) { static portCHAR buf[128], c, *p = buf; shell_print (PROMPT); for (;;) { if (!vUSBRecvByte (&c, sizeof (c), 100)) continue; if (c == '\n' || c == '\r') { *p = '\0'; parse_cmd (buf); p = buf; shell_print (PROMPT); continue; } else if (c < ' ') continue; if (p == buf + sizeof (buf) - 1) { p = buf; *p = '\0'; } /* local echo */ vUSBSendByte (c); *p++ = c; } }
static void serial_task(void *handle) { int i; (void) handle; portCHAR data; vTasksRunning = TRUE; i = 0; for (;;) { debug_printf("%04i: Hello Task! (%04i bytes free heap memory)\n", i++, xPortGetFreeHeapSize()); GPIOSetValue(LED_PORT, LED_BIT, LED_ON); vTaskDelay(10 / portTICK_RATE_MS); GPIOSetValue(LED_PORT, LED_BIT, LED_OFF); while (vUSBRecvByte(&data, sizeof(data), 990)) UARTSendChar(data); } }
static void vCmdTask (void *pvParameters) { (void) pvParameters; unsigned int t = 0; portCHAR cByte; portBASE_TYPE len = 0; static char next_command[MAX_CMD_LINE_LENGTH]; for (;;) { if (vUSBRecvByte (&cByte, 1, 100)) { vDebugSendHook (cByte); switch (cByte) { case '\n': case '\r': if (len) { next_command[len] = 0; vCmdProcess (next_command); len = 0; } break; default: next_command[len++] = cByte; } } else if (AT91F_PIO_GetInput (EXT_BUTTON_PIO) & EXT_BUTTON_PIN) { if (t < 30) t++; else { for (t = 0; t < 10; t++) { vTaskDelay (500 / portTICK_RATE_MS); led_set_red (0); vTaskDelay (500 / portTICK_RATE_MS); led_set_red (1); } /* backup reader id */ t = env.e.reader_id; vNetworkResetDefaultSettings (); /* restore reader id */ env.e.reader_id = t; /* store the configuration */ env_store (); /* wait a bit before the reset */ debug_printf ("restoring original settings" " after reset pin triggerd & reboot...\n"); vTaskDelay (1000 / portTICK_RATE_MS); /*force watchdog reset */ while (1); } } else t = 0; } }