static void hottSendTelemetryData(void) { if (!hottIsSending) { hottIsSending = true; // FIXME temorary workaround for HoTT not working on Hardware serial ports due to hardware/softserial serial port initialisation differences if ((portConfig->identifier == SERIAL_PORT_UART1) || (portConfig->identifier == SERIAL_PORT_UART2) || (portConfig->identifier == SERIAL_PORT_UART3)) workAroundForHottTelemetryOnUsart(hottPort, MODE_TX); else serialSetMode(hottPort, MODE_TX); hottMsgCrc = 0; return; } if (hottMsgRemainingBytesToSendCount == 0) { hottMsg = NULL; hottIsSending = false; // FIXME temorary workaround for HoTT not working on Hardware serial ports due to hardware/softserial serial port initialisation differences if ((portConfig->identifier == SERIAL_PORT_UART1) || (portConfig->identifier == SERIAL_PORT_UART2) || (portConfig->identifier == SERIAL_PORT_UART3)) workAroundForHottTelemetryOnUsart(hottPort, MODE_RX); else serialSetMode(hottPort, MODE_RX); flushHottRxBuffer(); return; } --hottMsgRemainingBytesToSendCount; if(hottMsgRemainingBytesToSendCount == 0) { hottSerialWrite(hottMsgCrc++); return; } hottMsgCrc += *hottMsg; hottSerialWrite(*hottMsg++); }
static void hottSendTelemetryData(void) { if (!hottIsSending) { hottIsSending = true; serialSetMode(hottPort, MODE_TX); hottMsgCrc = 0; return; } if (hottMsgRemainingBytesToSendCount == 0) { hottMsg = NULL; hottIsSending = false; serialSetMode(hottPort, MODE_RX); flushHottRxBuffer(); return; } --hottMsgRemainingBytesToSendCount; if(hottMsgRemainingBytesToSendCount == 0) { hottSerialWrite(hottMsgCrc++); return; } hottMsgCrc += *hottMsg; hottSerialWrite(*hottMsg++); }
void gpsEnablePassthrough(serialPort_t *gpsPassthroughPort) { waitForSerialPortToFinishTransmitting(gpsState.gpsPort); waitForSerialPortToFinishTransmitting(gpsPassthroughPort); if(!(gpsState.gpsPort->mode & MODE_TX)) serialSetMode(gpsState.gpsPort, gpsState.gpsPort->mode | MODE_TX); LED0_OFF; LED1_OFF; char c; while(1) { if (serialRxBytesWaiting(gpsState.gpsPort)) { LED0_ON; c = serialRead(gpsState.gpsPort); serialWrite(gpsPassthroughPort, c); LED0_OFF; } if (serialRxBytesWaiting(gpsPassthroughPort)) { LED1_ON; c = serialRead(gpsPassthroughPort); serialWrite(gpsState.gpsPort, c); LED1_OFF; } } }
void freeFrSkyTelemetryPort(void) { // FIXME only need to reset the port if the port is shared serialSetMode(frskyPort, previousPortMode); serialSetBaudRate(frskyPort, previousBaudRate); endSerialPortFunction(frskyPort, FUNCTION_TELEMETRY); }
void gpsEnablePassthrough(serialPort_t *gpsPassthroughPort) { waitForSerialPortToFinishTransmitting(gpsPort); waitForSerialPortToFinishTransmitting(gpsPassthroughPort); if(!(gpsPort->mode & MODE_TX)) serialSetMode(gpsPort, gpsPort->mode | MODE_TX); #ifdef DISPLAY if (feature(FEATURE_DISPLAY)) { displayShowFixedPage(PAGE_GPS); } #endif serialPassthrough(gpsPort, gpsPassthroughPort, &gpsHandlePassthrough, NULL); }
void configureFrSkyTelemetryPort(void) { frskyPort = findOpenSerialPort(FUNCTION_TELEMETRY); if (frskyPort) { previousPortMode = frskyPort->mode; previousBaudRate = frskyPort->baudRate; //waitForSerialPortToFinishTransmitting(frskyPort); // FIXME locks up the system serialSetBaudRate(frskyPort, FRSKY_BAUDRATE); serialSetMode(frskyPort, FRSKY_INITIAL_PORT_MODE); beginSerialPortFunction(frskyPort, FUNCTION_TELEMETRY); } else { frskyPort = openSerialPort(FUNCTION_TELEMETRY, NULL, FRSKY_BAUDRATE, FRSKY_INITIAL_PORT_MODE, telemetryConfig->telemetry_inversion); // FIXME only need these values to reset the port if the port is shared previousPortMode = frskyPort->mode; previousBaudRate = frskyPort->baudRate; } }
void gpsEnablePassthrough(serialPort_t *gpsPassthroughPort) { waitForSerialPortToFinishTransmitting(gpsPort); waitForSerialPortToFinishTransmitting(gpsPassthroughPort); if(!(gpsPort->mode & MODE_TX)) serialSetMode(gpsPort, gpsPort->mode | MODE_TX); LED0_OFF; LED1_OFF; #ifdef DISPLAY if (feature(FEATURE_DISPLAY)) { displayShowFixedPage(PAGE_GPS); } #endif char c; while(1) { if (serialRxBytesWaiting(gpsPort)) { LED0_ON; c = serialRead(gpsPort); gpsNewData(c); serialWrite(gpsPassthroughPort, c); LED0_OFF; } if (serialRxBytesWaiting(gpsPassthroughPort)) { LED1_ON; c = serialRead(gpsPassthroughPort); serialWrite(gpsPort, c); LED1_OFF; } #ifdef DISPLAY if (feature(FEATURE_DISPLAY)) { updateDisplay(); } #endif } }
serialPort_t *openSerialPort( serialPortIdentifier_e identifier, serialPortFunction_e function, serialReceiveCallbackPtr callback, uint32_t baudRate, portMode_t mode, portOptions_t options) { #if (!defined(USE_VCP) && !defined(USE_UART1) && !defined(USE_UART2) && !defined(USE_UART3) && !defined(USE_UART4) && !defined(USE_UART5) && !defined(USE_SOFTSERIAL1) && !defined(USE_SOFTSERIAL1)) UNUSED(callback); UNUSED(baudRate); UNUSED(mode); UNUSED(options); #endif serialPortUsage_t *serialPortUsage = findSerialPortUsageByIdentifier(identifier); if (!serialPortUsage || serialPortUsage->function != FUNCTION_NONE) { // not available / already in use return NULL; } serialPort_t *serialPort = NULL; switch(identifier) { #ifdef USE_VCP case SERIAL_PORT_USB_VCP: serialPort = usbVcpOpen(); break; #endif #ifdef USE_UART1 case SERIAL_PORT_UART1: serialPort = uartOpen(USART1, callback, baudRate, mode, options); break; #endif #ifdef USE_UART2 case SERIAL_PORT_UART2: serialPort = uartOpen(USART2, callback, baudRate, mode, options); break; #endif #ifdef USE_UART3 case SERIAL_PORT_UART3: serialPort = uartOpen(USART3, callback, baudRate, mode, options); break; #endif #ifdef USE_UART4 case SERIAL_PORT_UART4: serialPort = uartOpen(UART4, callback, baudRate, mode, options); break; #endif #ifdef USE_UART5 case SERIAL_PORT_UART5: serialPort = uartOpen(UART5, callback, baudRate, mode, options); break; #endif #ifdef USE_SOFTSERIAL1 case SERIAL_PORT_SOFTSERIAL1: serialPort = openSoftSerial(SOFTSERIAL1, callback, baudRate, options); serialSetMode(serialPort, mode); break; #endif #ifdef USE_SOFTSERIAL2 case SERIAL_PORT_SOFTSERIAL2: serialPort = openSoftSerial(SOFTSERIAL2, callback, baudRate, options); serialSetMode(serialPort, mode); break; #endif default: break; } if (!serialPort) { return NULL; } serialPort->identifier = identifier; serialPortUsage->function = function; serialPortUsage->serialPort = serialPort; return serialPort; }
serialPort_t *openSerialPort( serialPortIdentifier_e identifier, serialPortFunction_e function, serialReceiveCallbackPtr callback, uint32_t baudRate, portMode_t mode, serialInversion_e inversion) { serialPortUsage_t *serialPortUsage = findSerialPortUsageByIdentifier(identifier); if (serialPortUsage->function != FUNCTION_NONE) { // already in use return NULL; } serialPort_t *serialPort = NULL; switch(identifier) { #ifdef USE_VCP case SERIAL_PORT_USB_VCP: serialPort = usbVcpOpen(); break; #endif #ifdef USE_USART1 case SERIAL_PORT_USART1: serialPort = uartOpen(USART1, callback, baudRate, mode, inversion); break; #endif #ifdef USE_USART2 case SERIAL_PORT_USART2: serialPort = uartOpen(USART2, callback, baudRate, mode, inversion); break; #endif #ifdef USE_USART3 case SERIAL_PORT_USART3: serialPort = uartOpen(USART3, callback, baudRate, mode, inversion); break; #endif #ifdef USE_SOFTSERIAL1 case SERIAL_PORT_SOFTSERIAL1: serialPort = openSoftSerial(SOFTSERIAL1, callback, baudRate, inversion); serialSetMode(serialPort, mode); break; #endif #ifdef USE_SOFTSERIAL2 case SERIAL_PORT_SOFTSERIAL2: serialPort = openSoftSerial(SOFTSERIAL2, callback, baudRate, inversion); serialSetMode(serialPort, mode); break; #endif default: break; } if (!serialPort) { return NULL; } serialPort->identifier = identifier; serialPortUsage->function = function; serialPortUsage->serialPort = serialPort; return serialPort; }