mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-02-20 10:54:14 +01:00
OP-1464 uncrustify
This commit is contained in:
parent
22b2317732
commit
c0c5cd3d16
@ -445,22 +445,29 @@ uint32_t hwsettings_gpsspeed_enum_to_baud(uint8_t baud)
|
||||
{
|
||||
switch (baud) {
|
||||
case HWSETTINGS_GPSSPEED_2400:
|
||||
return(2400);
|
||||
return 2400;
|
||||
|
||||
case HWSETTINGS_GPSSPEED_4800:
|
||||
return(4800);
|
||||
return 4800;
|
||||
|
||||
default:
|
||||
case HWSETTINGS_GPSSPEED_9600:
|
||||
return(9600);
|
||||
return 9600;
|
||||
|
||||
case HWSETTINGS_GPSSPEED_19200:
|
||||
return(19200);
|
||||
return 19200;
|
||||
|
||||
case HWSETTINGS_GPSSPEED_38400:
|
||||
return(38400);
|
||||
return 38400;
|
||||
|
||||
case HWSETTINGS_GPSSPEED_57600:
|
||||
return(57600);
|
||||
return 57600;
|
||||
|
||||
case HWSETTINGS_GPSSPEED_115200:
|
||||
return(115200);
|
||||
return 115200;
|
||||
|
||||
case HWSETTINGS_GPSSPEED_230400:
|
||||
return(230400);
|
||||
return 230400;
|
||||
}
|
||||
}
|
||||
|
||||
@ -468,7 +475,7 @@ uint32_t hwsettings_gpsspeed_enum_to_baud(uint8_t baud)
|
||||
// having already set the GPS's baud rate with a serial command, set the local Revo port baud rate
|
||||
void gps_set_fc_baud_from_arg(uint8_t baud)
|
||||
{
|
||||
static uint8_t previous_baud=255;
|
||||
static uint8_t previous_baud = 255;
|
||||
static uint8_t mutex; // = 0
|
||||
|
||||
// do we need this?
|
||||
@ -499,7 +506,7 @@ void gps_set_fc_baud_from_arg(uint8_t baud)
|
||||
static void updateHwSettings(UAVObjEvent __attribute__((unused)) *ev)
|
||||
{
|
||||
#if defined(PIOS_INCLUDE_GPS_UBX_PARSER) && !defined(PIOS_GPS_MINIMAL)
|
||||
static uint32_t previousGpsPort=0xf0f0f0f0; // = doesn't match gpsport
|
||||
static uint32_t previousGpsPort = 0xf0f0f0f0; // = doesn't match gpsport
|
||||
#endif
|
||||
// if GPS (UBX or NMEA) is enabled at all
|
||||
if (gpsPort && gpsEnabled) {
|
||||
@ -510,7 +517,7 @@ static void updateHwSettings(UAVObjEvent __attribute__((unused)) *ev)
|
||||
if (ev == NULL
|
||||
|| previousGpsPort != gpsPort
|
||||
|| gpsSettings.UbxAutoConfig == GPSSETTINGS_UBXAUTOCONFIG_DISABLED
|
||||
|| gpsSettings.DataProtocol != GPSSETTINGS_DATAPROTOCOL_UBX)
|
||||
|| gpsSettings.DataProtocol != GPSSETTINGS_DATAPROTOCOL_UBX)
|
||||
#endif
|
||||
{
|
||||
uint8_t speed;
|
||||
@ -555,15 +562,15 @@ void updateGpsSettings(__attribute__((unused)) UAVObjEvent *ev)
|
||||
// setting it up completely means that if we switch from initial NMEA to UBX or disabled to enabled, that it will start normally
|
||||
newconfig.UbxAutoConfig = gpsSettings.UbxAutoConfig;
|
||||
newconfig.navRate = gpsSettings.UbxRate;
|
||||
newconfig.dynamicModel = gpsSettings.UbxDynamicModel == GPSSETTINGS_UBXDYNAMICMODEL_PORTABLE ? UBX_DYNMODEL_PORTABLE :
|
||||
gpsSettings.UbxDynamicModel == GPSSETTINGS_UBXDYNAMICMODEL_STATIONARY ? UBX_DYNMODEL_STATIONARY :
|
||||
gpsSettings.UbxDynamicModel == GPSSETTINGS_UBXDYNAMICMODEL_PEDESTRIAN ? UBX_DYNMODEL_PEDESTRIAN :
|
||||
gpsSettings.UbxDynamicModel == GPSSETTINGS_UBXDYNAMICMODEL_AUTOMOTIVE ? UBX_DYNMODEL_AUTOMOTIVE :
|
||||
gpsSettings.UbxDynamicModel == GPSSETTINGS_UBXDYNAMICMODEL_SEA ? UBX_DYNMODEL_SEA :
|
||||
gpsSettings.UbxDynamicModel == GPSSETTINGS_UBXDYNAMICMODEL_AIRBORNE1G ? UBX_DYNMODEL_AIRBORNE1G :
|
||||
gpsSettings.UbxDynamicModel == GPSSETTINGS_UBXDYNAMICMODEL_AIRBORNE2G ? UBX_DYNMODEL_AIRBORNE2G :
|
||||
gpsSettings.UbxDynamicModel == GPSSETTINGS_UBXDYNAMICMODEL_AIRBORNE4G ? UBX_DYNMODEL_AIRBORNE4G :
|
||||
UBX_DYNMODEL_AIRBORNE1G;
|
||||
newconfig.dynamicModel = gpsSettings.UbxDynamicModel == GPSSETTINGS_UBXDYNAMICMODEL_PORTABLE ? UBX_DYNMODEL_PORTABLE :
|
||||
gpsSettings.UbxDynamicModel == GPSSETTINGS_UBXDYNAMICMODEL_STATIONARY ? UBX_DYNMODEL_STATIONARY :
|
||||
gpsSettings.UbxDynamicModel == GPSSETTINGS_UBXDYNAMICMODEL_PEDESTRIAN ? UBX_DYNMODEL_PEDESTRIAN :
|
||||
gpsSettings.UbxDynamicModel == GPSSETTINGS_UBXDYNAMICMODEL_AUTOMOTIVE ? UBX_DYNMODEL_AUTOMOTIVE :
|
||||
gpsSettings.UbxDynamicModel == GPSSETTINGS_UBXDYNAMICMODEL_SEA ? UBX_DYNMODEL_SEA :
|
||||
gpsSettings.UbxDynamicModel == GPSSETTINGS_UBXDYNAMICMODEL_AIRBORNE1G ? UBX_DYNMODEL_AIRBORNE1G :
|
||||
gpsSettings.UbxDynamicModel == GPSSETTINGS_UBXDYNAMICMODEL_AIRBORNE2G ? UBX_DYNMODEL_AIRBORNE2G :
|
||||
gpsSettings.UbxDynamicModel == GPSSETTINGS_UBXDYNAMICMODEL_AIRBORNE4G ? UBX_DYNMODEL_AIRBORNE4G :
|
||||
UBX_DYNMODEL_AIRBORNE1G;
|
||||
|
||||
switch ((GPSSettingsUbxSBASModeOptions)gpsSettings.UbxSBASMode) {
|
||||
case GPSSETTINGS_UBXSBASMODE_RANGINGCORRECTION:
|
||||
@ -600,11 +607,11 @@ void updateGpsSettings(__attribute__((unused)) UAVObjEvent *ev)
|
||||
|
||||
newconfig.SBASChannelsUsed = gpsSettings.UbxSBASChannelsUsed;
|
||||
|
||||
newconfig.SBASSats = gpsSettings.UbxSBASSats == GPSSETTINGS_UBXSBASSATS_WAAS ? UBX_SBAS_SATS_WAAS :
|
||||
newconfig.SBASSats = gpsSettings.UbxSBASSats == GPSSETTINGS_UBXSBASSATS_WAAS ? UBX_SBAS_SATS_WAAS :
|
||||
gpsSettings.UbxSBASSats == GPSSETTINGS_UBXSBASSATS_EGNOS ? UBX_SBAS_SATS_EGNOS :
|
||||
gpsSettings.UbxSBASSats == GPSSETTINGS_UBXSBASSATS_MSAS ? UBX_SBAS_SATS_MSAS :
|
||||
gpsSettings.UbxSBASSats == GPSSETTINGS_UBXSBASSATS_MSAS ? UBX_SBAS_SATS_MSAS :
|
||||
gpsSettings.UbxSBASSats == GPSSETTINGS_UBXSBASSATS_GAGAN ? UBX_SBAS_SATS_GAGAN :
|
||||
gpsSettings.UbxSBASSats == GPSSETTINGS_UBXSBASSATS_SDCM ? UBX_SBAS_SATS_SDCM : UBX_SBAS_SATS_AUTOSCAN;
|
||||
gpsSettings.UbxSBASSats == GPSSETTINGS_UBXSBASSATS_SDCM ? UBX_SBAS_SATS_SDCM : UBX_SBAS_SATS_AUTOSCAN;
|
||||
|
||||
switch (gpsSettings.UbxGNSSMode) {
|
||||
case GPSSETTINGS_UBXGNSSMODE_GPSGLONASS:
|
||||
|
@ -111,7 +111,7 @@ int parse_nmea_stream(uint8_t *rx, uint8_t len, char *gps_rx_buffer, GPSPosition
|
||||
static uint8_t rx_count = 0;
|
||||
static bool start_flag = false;
|
||||
static bool found_cr = false;
|
||||
bool goodParse = false;
|
||||
bool goodParse = false;
|
||||
uint8_t c;
|
||||
int i = 0;
|
||||
|
||||
@ -124,7 +124,7 @@ int parse_nmea_stream(uint8_t *rx, uint8_t len, char *gps_rx_buffer, GPSPosition
|
||||
if (c == '$') { // NMEA identifier found
|
||||
start_flag = false;
|
||||
}
|
||||
if (!start_flag) { // if no NMEA identifier ('$') found yet
|
||||
if (!start_flag) { // if no NMEA identifier ('$') found yet
|
||||
if (c == '$') { // NMEA identifier found
|
||||
start_flag = true;
|
||||
found_cr = false;
|
||||
@ -133,7 +133,7 @@ int parse_nmea_stream(uint8_t *rx, uint8_t len, char *gps_rx_buffer, GPSPosition
|
||||
// find a likely candidate for a NMEA string
|
||||
// skip over some e.g. uBlox packets
|
||||
uint8_t *p;
|
||||
p = memchr(&rx[i], '$', len-i);
|
||||
p = memchr(&rx[i], '$', len - i);
|
||||
if (p) {
|
||||
i += p - &rx[i];
|
||||
} else {
|
||||
|
@ -238,9 +238,9 @@ void gps_ubx_reset_sensor_type()
|
||||
// is this needed?
|
||||
// what happens if two tasks / threads try to do an XyzSet() at the same time?
|
||||
if (__sync_fetch_and_add(&mutex, 1) == 0) {
|
||||
ubxHwVersion = -1;
|
||||
baud_to_try_index -= 1; // undo postincrement and start with the one that was most recently successful
|
||||
sensorType = GPSPOSITIONSENSOR_SENSORTYPE_UNKNOWN;
|
||||
ubxHwVersion = -1;
|
||||
baud_to_try_index -= 1; // undo postincrement and start with the one that was most recently successful
|
||||
sensorType = GPSPOSITIONSENSOR_SENSORTYPE_UNKNOWN;
|
||||
GPSPositionSensorSensorTypeSet(&sensorType);
|
||||
// make the sensor type / autobaud code time out immediately to send the request immediately
|
||||
status->lastStepTimestampRaw += 0x8000000UL;
|
||||
@ -279,7 +279,7 @@ static void config_gps_baud(uint16_t *bytes_to_send)
|
||||
// disable current UBX messages for low baud rates
|
||||
status->working_packet.message.payload.cfg_prt.outProtoMask = 1;
|
||||
// Ask GPS to change it's speed
|
||||
status->working_packet.message.payload.cfg_prt.baudRate = hwsettings_gpsspeed_enum_to_baud(hwsettings_baud);
|
||||
status->working_packet.message.payload.cfg_prt.baudRate = hwsettings_gpsspeed_enum_to_baud(hwsettings_baud);
|
||||
*bytes_to_send = prepare_packet((UBXSentPacket_t *)&status->working_packet, UBX_CLASS_CFG, UBX_ID_CFG_PRT, sizeof(ubx_cfg_prt_t));
|
||||
}
|
||||
|
||||
@ -429,7 +429,7 @@ static void configure(uint16_t *bytes_to_send)
|
||||
// Skip and fall through to next step
|
||||
status->lastConfigSent++;
|
||||
}
|
||||
// in the else case we must fall through because we must send something each time because successful send is tested externally
|
||||
// in the else case we must fall through because we must send something each time because successful send is tested externally
|
||||
|
||||
case LAST_CONFIG_SENT_START + 3:
|
||||
config_sbas(bytes_to_send);
|
||||
@ -480,12 +480,12 @@ static void setGpsSettings()
|
||||
|
||||
#if 0
|
||||
// get the "in memory" version to a local buffer
|
||||
GPSSettingsGet((void *) &status->gpsSettings);
|
||||
GPSSettingsGet((void *)&status->gpsSettings);
|
||||
// load the permanent version into memory
|
||||
UAVObjLoad(GPSSettingsHandle(), 0);
|
||||
#endif
|
||||
// change the in memory version of the field we want to change
|
||||
GPSSettingsUbxAutoConfigSet((GPSSettingsUbxAutoConfigOptions *) &status->currentSettings.UbxAutoConfig);
|
||||
GPSSettingsUbxAutoConfigSet((GPSSettingsUbxAutoConfigOptions *)&status->currentSettings.UbxAutoConfig);
|
||||
// save the in memory version to permanent
|
||||
UAVObjSave(GPSSettingsHandle(), 0);
|
||||
#if 0
|
||||
@ -494,10 +494,10 @@ static void setGpsSettings()
|
||||
// try casting it correctly and it says:
|
||||
// expected 'struct GPSSettingsData *' but argument is of type 'struct GPSSettingsData *'
|
||||
// probably a volatile or align issue
|
||||
GPSSettingsSet((void *) &status->gpsSettings); // set the "in memory" version back into use
|
||||
GPSSettingsSet((void *)&status->gpsSettings); // set the "in memory" version back into use
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
#endif /* if defined(AUTOBAUD_CONFIGURE_STORE_AND_DISABLE) */
|
||||
|
||||
|
||||
// 9600 baud and lower are not usable, and are best left at factory default
|
||||
@ -537,8 +537,8 @@ void gps_ubx_autoconfig_run(char * *buffer, uint16_t *bytes_to_send)
|
||||
// and the fact we are here says that ubxHwVersion has not been set (it is set externally)
|
||||
// so this try at this baud rate has failed
|
||||
// if we get here
|
||||
// select the next baud rate, skipping ahead if new baud rate is HwSettings.GPSSpeed
|
||||
// set Revo baud rate to current++ value (immediate change so we can send right after that) and send the MON_VER request
|
||||
// select the next baud rate, skipping ahead if new baud rate is HwSettings.GPSSpeed
|
||||
// set Revo baud rate to current++ value (immediate change so we can send right after that) and send the MON_VER request
|
||||
// baud rate search order are most likely matches first
|
||||
|
||||
// if AutoBaud or higher, do AutoBaud
|
||||
@ -559,7 +559,7 @@ void gps_ubx_autoconfig_run(char * *buffer, uint16_t *bytes_to_send)
|
||||
// get the next baud rate to try from the table, but skip over the value of HwSettings.GPSSpeed
|
||||
do {
|
||||
// index is inited to be out of bounds, which is interpreted as "currently defined baud rate" (= HwSettings.GPSSpeed)
|
||||
if (baud_to_try_index >= sizeof(baud_array)/sizeof(baud_array[0])) {
|
||||
if (baud_to_try_index >= sizeof(baud_array) / sizeof(baud_array[0])) {
|
||||
HwSettingsGPSSpeedGet(&hwsettings_baud);
|
||||
baud_to_try = hwsettings_baud;
|
||||
baud_to_try_index = 0;
|
||||
@ -567,7 +567,7 @@ void gps_ubx_autoconfig_run(char * *buffer, uint16_t *bytes_to_send)
|
||||
} else {
|
||||
baud_to_try = baud_array[baud_to_try_index++];
|
||||
}
|
||||
// skip HwSettings.GPSSpeed when you run across it in the list
|
||||
// skip HwSettings.GPSSpeed when you run across it in the list
|
||||
} while (baud_to_try == hwsettings_baud);
|
||||
// set the FC (Revo) baud rate
|
||||
gps_set_fc_baud_from_arg(baud_to_try);
|
||||
@ -598,9 +598,9 @@ void gps_ubx_autoconfig_run(char * *buffer, uint16_t *bytes_to_send)
|
||||
// we should look for the GPS version again (user may plug in a different GPS and then do autoconfig again)
|
||||
// zero retries for the next state that needs it (INIT_STEP_SAVE)
|
||||
set_current_step_if_untouched(INIT_STEP_SEND_MON_VER);
|
||||
// fall through to next state
|
||||
// we can do that if we choose because we haven't sent any data in this state
|
||||
// break;
|
||||
// fall through to next state
|
||||
// we can do that if we choose because we haven't sent any data in this state
|
||||
// break;
|
||||
|
||||
case INIT_STEP_SEND_MON_VER:
|
||||
build_request((UBXSentPacket_t *)&status->working_packet, UBX_CLASS_MON, UBX_ID_MON_VER, bytes_to_send);
|
||||
@ -618,9 +618,9 @@ void gps_ubx_autoconfig_run(char * *buffer, uint16_t *bytes_to_send)
|
||||
}
|
||||
// Continue with next configuration option
|
||||
set_current_step_if_untouched(INIT_STEP_RESET_GPS);
|
||||
// fall through to next state
|
||||
// we can do that if we choose because we haven't sent any data in this state
|
||||
// break;
|
||||
// fall through to next state
|
||||
// we can do that if we choose because we haven't sent any data in this state
|
||||
// break;
|
||||
|
||||
// if here, we have just verified that the baud rates are in sync (again)
|
||||
case INIT_STEP_RESET_GPS:
|
||||
@ -682,12 +682,12 @@ void gps_ubx_autoconfig_run(char * *buffer, uint16_t *bytes_to_send)
|
||||
// set the Revo GPS port to 9600 baud to match the reset to factory default that has already been done
|
||||
gps_set_fc_baud_from_arg(HWSETTINGS_GPSSPEED_9600);
|
||||
}
|
||||
// at most, we just set Revo baud and that doesn't send any data
|
||||
// fall through to next state
|
||||
// we can do that if we choose because we haven't sent any data in this state
|
||||
// set_current_step_if_untouched(INIT_STEP_GPS_BAUD);
|
||||
// allow it enter the next state immmediately by not setting status->lastStepTimestampRaw = PIOS_DELAY_GetRaw();
|
||||
// break;
|
||||
// at most, we just set Revo baud and that doesn't send any data
|
||||
// fall through to next state
|
||||
// we can do that if we choose because we haven't sent any data in this state
|
||||
// set_current_step_if_untouched(INIT_STEP_GPS_BAUD);
|
||||
// allow it enter the next state immmediately by not setting status->lastStepTimestampRaw = PIOS_DELAY_GetRaw();
|
||||
// break;
|
||||
|
||||
// Revo and GPS are both at 9600 baud
|
||||
case INIT_STEP_GPS_BAUD:
|
||||
@ -818,7 +818,7 @@ void gps_ubx_autoconfig_run(char * *buffer, uint16_t *bytes_to_send)
|
||||
// fall through to next state
|
||||
// we can do that if we choose because we haven't sent any data in this state
|
||||
set_current_step_if_untouched(INIT_STEP_PRE_DONE);
|
||||
// break;
|
||||
// break;
|
||||
|
||||
// the autoconfig has completed normally
|
||||
case INIT_STEP_PRE_DONE:
|
||||
|
@ -663,7 +663,6 @@ void PIOS_Board_Init(void)
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
|
||||
} /* hwsettings_rm_flexiport */
|
||||
|
||||
|
||||
|
@ -179,11 +179,11 @@ void VehicleConfigurationHelper::applyHardwareConfiguration()
|
||||
|
||||
switch (m_configSource->getGpsType()) {
|
||||
case VehicleConfigurationSource::GPS_NMEA:
|
||||
gpsData.DataProtocol = GPSSettings::DATAPROTOCOL_NMEA;
|
||||
gpsData.DataProtocol = GPSSettings::DATAPROTOCOL_NMEA;
|
||||
gpsData.UbxAutoConfig = GPSSettings::UBXAUTOCONFIG_DISABLED;
|
||||
break;
|
||||
case VehicleConfigurationSource::GPS_UBX:
|
||||
gpsData.DataProtocol = GPSSettings::DATAPROTOCOL_UBX;
|
||||
gpsData.DataProtocol = GPSSettings::DATAPROTOCOL_UBX;
|
||||
gpsData.UbxAutoConfig = GPSSettings::UBXAUTOCONFIG_AUTOBAUDANDCONFIGURE;
|
||||
break;
|
||||
case VehicleConfigurationSource::GPS_PLATINUM:
|
||||
|
Loading…
x
Reference in New Issue
Block a user