void APP_Tasks ( void ) { /* Check the application's current state. */ switch ( appData.state ) { /* Application's initial state. */ case APP_STATE_INIT: { bool appInitialized = true; if (appInitialized) { // appData.state = APP_STATE_SERVICE_TASKS; appData.state = APP_STATE_RX; // change state to USART receive } break; } // case APP_STATE_SERVICE_TASKS: // { // // break; // } /* TODO: implement your application state machine.*/ case APP_STATE_RX: // USART receive state { // if byte received in USART instance pointed to by myUSARTHandle (USART1 in this case) if (!DRV_USART_ReceiverBufferIsEmpty(myUSARTHandle)) { appData.rx_byte = DRV_USART_ReadByte(myUSARTHandle); // read received byte appData.tx_byte = appData.rx_byte + 1; // modifying received byte confirms it was received appData.state = APP_STATE_TX; // change state to TX } break; } case APP_STATE_TX: // USART transmit state { // make sure the transmit buffer is not full before trying to write byte if(!(DRV_USART_TRANSFER_STATUS_TRANSMIT_FULL & DRV_USART_TransferStatus(myUSARTHandle)) ) { DRV_USART_WriteByte(myUSARTHandle, appData.tx_byte); // send modified byte appData.state = APP_STATE_RX; // change state to RX and wait for next received byte } } /* The default state should never be executed. */ default: { /* TODO: Handle error in application's state machine. */ break; } } }