static void taskUARTTXControl(void *pvParameters) { xTaskParameter_t *pxTaskParameter; portTickType xStartTime; /* The parameter points to an xTaskParameters_t structure. */ pxTaskParameter = (xTaskParameter_t *) pvParameters; struct UARTMessage *pxRxedMessage; struct UARTMessage Message2; pxRxedMessage = &Message2; while(1) { //UART handling code if(xUARTQueue != 0) // make sure the task isn't null { //if( uxQueueMessagesWaiting( xUARTQueue ) != 0 ) // see if there are messages waiting //{ if( xQueueReceive( xUARTQueue, ( pxRxedMessage ), portMAX_DELAY ) ) // get the messages { //vUartPutStr(UART2, pxRxedMessage->ucMessage, 50); //void vUartPutStr(UART_MODULE umPortNum, char *pString, int iStrLen); UARTPutString(pxRxedMessage->ucMessage); } // } } } }
void Keyb_Task(void) { char text[320]; uint8_t key = 0; while(1) { if(!OSQueuePend(qKeyboard, &key, 0)) { switch(key) { case LEFT_KEY: // Block LED RGB task UARTPutString(UART0_BASE, "Botão Esquerdo pressionado!\n\r"); OSAvailableMemory(text); UARTPutString(UART0_BASE, text); OSCPULoad(text); UARTPutString(UART0_BASE, text); UARTPutString(UART0_BASE, "\n\r"); break; case RIGHT_KEY: // UnBlock LED RGB task UARTPutString(UART0_BASE, "Botão Direito pressionado!\n\r"); OSUptimeInfo(text); UARTPutString(UART0_BASE, text); UARTPutString(UART0_BASE, "\n\r"); break; case BOTH_KEY: UARTPutString(UART0_BASE, "Ambos os botões pressionados!\n\r"); OSTaskList(text); UARTPutString(UART0_BASE, text); UARTPutString(UART0_BASE, "\n\r"); break; default: break; } } } }
void Terminal(void) { char data; if (OSSemCreate(0,&sUART) != ALLOC_EVENT_OK) { // Oh Oh // Não deveria entrar aqui !!! BlockTask(th6); }; if (OSMutexCreate(&mutexTx,6) != ALLOC_EVENT_OK) { // Oh Oh // Não deveria entrar aqui !!! BlockTask(th6); }; if (OSQueueCreate(64, &qUART) != ALLOC_EVENT_OK) { // Oh Oh // Não deveria entrar aqui !!! BlockTask(th6); }; // // Enable the peripherals used by this example. // The UART itself needs to be enabled, as well as the GPIO port // containing the pins that will be used. // SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0); SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA); // // Configure the GPIO pin muxing for the UART function. // This is only necessary if your part supports GPIO pin function muxing. // Study the data sheet to see which functions are allocated per pin. // TODO: change this to select the port/pin you are using // GPIOPinConfigure(GPIO_PA0_U0RX); GPIOPinConfigure(GPIO_PA1_U0TX); // // Since GPIO A0 and A1 are used for the UART function, they must be // configured for use as a peripheral function (instead of GPIO). // TODO: change this to match the port/pin you are using // GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1); // // Configure the UART for 115,200, 8-N-1 operation. // This function uses SysCtlClockGet() to get the system clock // frequency. This could be also be a variable or hard coded value // instead of a function call. // UARTConfigSetExpClk(UART0_BASE, SysCtlClockGet(), 115200, (UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE | UART_CONFIG_PAR_NONE)); UARTFIFODisable(UART0_BASE); // // Enable the UART interrupt. // ROM_IntEnable(INT_UART0); ROM_UARTIntEnable(UART0_BASE, UART_INT_RX | UART_INT_RT); // // Put a character to show start of example. This will display on the // terminal. // UARTPutString(UART0_BASE, "Iniciou!\n\r\n\r"); while(1) { if(!OSQueuePend(qUART, (INT8U*)&data, 0)) { if (data != 13) { UARTPutChar(UART0_BASE, data); }else { UARTPutString(UART0_BASE, "\n\r"); } } } }