/** * @brief The main task for the UART1 channel * @param pvParameters: * @retval None */ void uart1Task(void *pvParameters) { /* Mutex semaphore to manage when it's ok to send and receive new data */ xSemaphore = xSemaphoreCreateMutex(); /* Mutex semaphore for accessing the settings for this channel */ xSettingsSemaphore = xSemaphoreCreateMutex(); /* Create software timers */ prvBuffer1ClearTimer = xTimerCreate("Buf1ClearUart1", 10, pdFALSE, 0, prvBuffer1ClearTimerCallback); prvBuffer2ClearTimer = xTimerCreate("Buf2ClearUart1", 10, pdFALSE, 0, prvBuffer2ClearTimerCallback); /* Initialize hardware */ prvHardwareInit(); /* Wait to make sure the SPI FLASH is initialized */ while (SPI_FLASH_Initialized() == false) { vTaskDelay(100 / portTICK_PERIOD_MS); } /* Try to read the settings from SPI FLASH */ prvReadSettingsFromSpiFlash(); /* * TODO: Figure out a good way to allow saved data in SPI FLASH to be read next time we wake up so that we * don't have to do a clear every time we start up the device. */ uart1Clear(); // uint8_t* data = "UART1 Debug! "; uint8_t* data = "Prevas Student Embedded Awards 2014 - "; /* The parameter in vTaskDelayUntil is the absolute time * in ticks at which you want to be woken calculated as * an increment from the time you were last woken. */ TickType_t xNextWakeTime; /* Initialize xNextWakeTime - this only needs to be done once. */ xNextWakeTime = xTaskGetTickCount(); prvDoneInitializing = true; while (1) { vTaskDelayUntil(&xNextWakeTime, 1000 / portTICK_PERIOD_MS); /* Transmit debug data if that mode is active */ if (prvCurrentSettings.connection == UARTConnection_Connected && prvCurrentSettings.mode == UARTMode_DebugTX) uart1Transmit(data, strlen(data)); } /* Something has gone wrong */ error: while (1); }
/** * @brief Callback a generic UART clear button * @param Event: The event that caused the callback * @param ButtonId: The button ID that the event happened on * @retval None */ void lcdGenericUartClearButtonCallback(GUITouchEvent Event, uint32_t ButtonId) { /* TODO: BUG, something goes wrong if you clear while a lot of data is being received at the same time */ if (Event == GUITouchEvent_Up) { bool channelWasReset = false; switch (ButtonId) { case GUIButtonId_Uart1Clear: uart1Clear(); GUITextBox_ClearDisplayedDataInBuffer(GUITextBoxId_Uart1Main); GUITextBox_SetAddressesTo(GUITextBoxId_Uart1Main, FLASH_ADR_UART1_DATA); channelWasReset = true; break; case GUIButtonId_Uart2Clear: uart2Clear(); GUITextBox_ClearDisplayedDataInBuffer(GUITextBoxId_Uart2Main); GUITextBox_SetAddressesTo(GUITextBoxId_Uart2Main, FLASH_ADR_UART2_DATA); channelWasReset = true; break; case GUIButtonId_Rs232Clear: rs232Clear(); GUITextBox_ClearDisplayedDataInBuffer(GUITextBoxId_Rs232Main); GUITextBox_SetAddressesTo(GUITextBoxId_Rs232Main, FLASH_ADR_RS232_DATA); channelWasReset = true; break; default: break; } // /* If a channel was reset we should save the settings so that the correct addresses are saved */ // if (channelWasReset) // { // guiSaveSettingsButtonCallback(GUITouchEvent_Up, ButtonId); // } } }