Ejemplo n.º 1
0
gpsEnablePassthroughResult_e gpsEnablePassthrough(void)
{
    if (gpsData.state != GPS_RECEIVING_DATA)
        return GPS_PASSTHROUGH_NO_GPS;

    serialPort_t *gpsPassthroughPort = findOpenSerialPort(FUNCTION_GPS_PASSTHROUGH);
    if (gpsPassthroughPort) {

        waitForSerialPortToFinishTransmitting(gpsPassthroughPort);
        serialSetBaudRate(gpsPassthroughPort, serialConfig->gps_passthrough_baudrate);
    } else {
        gpsPassthroughPort = openSerialPort(FUNCTION_GPS_PASSTHROUGH, NULL, serialConfig->gps_passthrough_baudrate, MODE_RXTX, SERIAL_NOT_INVERTED);
        if (!gpsPassthroughPort) {
            return GPS_PASSTHROUGH_NO_SERIAL_PORT;
        }
    }

    LED0_OFF;
    LED1_OFF;

    while(1) {
        if (serialTotalBytesWaiting(gpsPort)) {
            LED0_ON;
            serialWrite(gpsPassthroughPort, serialRead(gpsPort));
            LED0_OFF;
        }
        if (serialTotalBytesWaiting(gpsPassthroughPort)) {
            LED1_ON;
            serialWrite(gpsPort, serialRead(gpsPassthroughPort));
            LED1_OFF;
        }
    }
    return GPS_PASSTHROUGH_ENABLED;
}
Ejemplo n.º 2
0
void cliInit(serialConfig_t *serialConfig)
{
    cliPort = findOpenSerialPort(FUNCTION_CLI);
    if (!cliPort) {
        cliPort = openSerialPort(FUNCTION_CLI, NULL, serialConfig->cli_baudrate, MODE_RXTX, SERIAL_NOT_INVERTED);
    }

}
Ejemplo n.º 3
0
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;
    }
}