void usbToUartService() { uint8 signals; // Data while(usbComRxAvailable() && uart1TxAvailable()) { uart1TxSendByte(usbComRxReceiveByte()); } while(uart1RxAvailable() && usbComTxAvailable()) { usbComTxSendByte(uart1RxReceiveByte()); } // Control lines controlled by computer. P1_0 = !(usbComRxControlSignals() & ACM_CONTROL_LINE_DTR); P1_1 = !(usbComRxControlSignals() & ACM_CONTROL_LINE_RTS); P1DIR |= (1<<0) | (1<<1); // Control lines controlled by device. signals = 0; if (!P1_2){ signals |= ACM_SERIAL_STATE_TX_CARRIER; } // TX Carrier = DSR if (!P1_3){ signals |= ACM_SERIAL_STATE_RX_CARRIER; } // RX Carrier = CD usbComTxControlSignals(signals); }
void uartToRadioService() { // Data while(uart1RxAvailable() && radioComTxAvailable()) { radioComTxSendByte(uart1RxReceiveByte()); } while(radioComRxAvailable() && uart1TxAvailable()) { uart1TxSendByte(radioComRxReceiveByte()); } // Control Signals. ioTxSignals(radioComRxControlSignals()); radioComTxControlSignals(ioRxSignals()); }
void radioToUart1Service() { adcReport XDATA * rxPacket; // Check if there is a radio packet to report and space in the // USB TX buffers to report it. if ((rxPacket = (adcReport XDATA *)radioQueueRxCurrentPacket()) && uart1TxAvailable() >= 64) { // We received a packet from a Wixel, presumably one running // the wireless_adc_tx app. Format it nicely and send it to // the USB host (PC). uint8 i; printf("%02X-%02X-%02X-%02X,%12lu,%4d,%4d,%4d, ", rxPacket->serialNumber[3], //Ausgabe der Sender Seriennummer rxPacket->serialNumber[2], rxPacket->serialNumber[1], rxPacket->serialNumber[0], getMs(), // Millisekunden 32bit rxPacket->length, // Wie viele Pakete wurden empfangen rxPacket->rssi/2 - 71, // RSSI dBm rxPacket->quality & 0x7F // LQI Bitfehlerrate ); // CRC // 1 CRC Pass, 0 CRC Fail putchar((rxPacket->quality & 0x80) ? '1' : '0'); //Ausgabe der ADC Werte for(i = 0; i < 6; i++) { printf(",%5u", rxPacket->readings[i]); } //Am Ende der Ausgabe Umbruch senden putchar('\r'); putchar('\n'); radioQueueRxDoneWithPacket(); } }
void usbToUartService() { uint8 signals; // Data while(usbComRxAvailable() && uart1TxAvailable()) { uart1TxSendByte(usbComRxReceiveByte()); } while(uart1RxAvailable() && usbComTxAvailable()) { usbComTxSendByte(uart1RxReceiveByte()); } ioTxSignals(usbComRxControlSignals()); // Need to switch bits 0 and 1 so that DTR pairs up with DSR. signals = ioRxSignals(); usbComTxControlSignals( ((signals & 1) ? 2 : 0) | ((signals & 2) ? 1 : 0)); // TODO: report framing, parity, and overrun errors to the USB host here }