//====================================== // Receive a message from a message port //====================================== void ReceiveMessage(struct MessagePort *MP, struct Message *Msg) { struct Message *temp; while (MP->msgQueue == 0) { MP->waitingProc = currentTask; currentTask->waiting = 0x80; BlockTask(currentTask); SWTASKS; } asm("cli"); temp = MP->msgQueue; MP->msgQueue = temp->nextMessage; temp->nextMessage = 0; asm("sti"); memcpy((char *)Msg, (char *)temp, sizeof(struct Message)); DeallocMem(temp); }
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"); } } } }