Esempio n. 1
0
void gpsTask(void *unused)
{
    gpsData.serial = serialOpen(USART1, 9600);
    gpsData.mode = MODE_NMEA;   // NMEA

    while (1) {
        CoTickDelay(25);

        while (uartAvailable(gpsData.serial)) {
            switch (gpsData.mode) {
            case MODE_NMEA:    // NMEA
                gpsData.validFrames += gpsNewFrameNMEA(uartRead(gpsData.serial));
                break;

            case MODE_UBX:     // UBX
                gpsData.validFrames += gpsNewFrameUBLOX(uartRead(gpsData.serial));
                break;

            case MODE_MTK:     // MTK
                break;

            case MODE_PASSTHROUGH:     // GPS -> UART bridge
                // TODO
                // usbSerialWrite(uartRead(gpsData.serial));
                break;
            }
        }
    }
}
Esempio n. 2
0
bool gpsNewFrame(uint8_t c)
{
    switch (gpsConfig()->provider) {
        case GPS_NMEA:          // NMEA
            return gpsNewFrameNMEA(c);
        case GPS_UBLOX:         // UBX binary
            return gpsNewFrameUBLOX(c);
    }

    return false;
}
Esempio n. 3
0
static bool gpsNewFrame(uint8_t c)
{
    switch (mcfg.gps_type) {
        case GPS_NMEA:          // NMEA
        case GPS_MTK_NMEA:      // MTK in NMEA mode
            return gpsNewFrameNMEA(c);
        case GPS_UBLOX:         // UBX binary
            return gpsNewFrameUBLOX(c);
        case GPS_MTK_BINARY:    // MTK in BINARY mode (TODO)
            return false;
    }

    return false;
}
Esempio n. 4
0
static bool gpsReceiveData(void)
{
    bool hasNewData = false;

    if (gpsState.gpsPort) {
        while (serialRxBytesWaiting(gpsState.gpsPort)) {
            uint8_t newChar = serialRead(gpsState.gpsPort);
            if (gpsNewFrameNMEA(newChar)) {
                gpsSol.flags.gpsHeartbeat = !gpsSol.flags.gpsHeartbeat;
                gpsSol.flags.validVelNE = 0;
                gpsSol.flags.validVelD = 0;
                hasNewData = true;
            }
        }
    }

    return hasNewData;
}