From e6de41855b2ee936117207ddd39f013b373f5be3 Mon Sep 17 00:00:00 2001 From: Rich von Lehe Date: Sat, 11 Apr 2015 15:43:04 -0500 Subject: [PATCH] OP-1740: GetSet use enums: Getting more files to conform to using enums instead of uint8_t... --- flight/libraries/plans.c | 2 +- flight/libraries/sanitycheck.c | 22 +++++++++---------- flight/modules/Airspeed/airspeed.c | 4 ++-- flight/modules/GPS/GPS.c | 6 ++--- flight/modules/Logging/Logging.c | 2 +- flight/modules/ManualControl/manualcontrol.c | 4 ++-- .../ManualControl/pathfollowerhandler.c | 6 ++--- .../modules/ManualControl/stabilizedhandler.c | 14 ++++++------ .../ManualControl/takeofflocationhandler.c | 12 +++++----- flight/modules/PathPlanner/pathplanner.c | 2 +- flight/modules/Stabilization/innerloop.c | 2 +- flight/modules/Stabilization/outerloop.c | 2 +- flight/modules/Telemetry/telemetry.c | 2 +- .../boards/simposix/firmware/pios_board.c | 11 +++++++--- 14 files changed, 48 insertions(+), 43 deletions(-) diff --git a/flight/libraries/plans.c b/flight/libraries/plans.c index 650a0cc78..a2720f463 100644 --- a/flight/libraries/plans.c +++ b/flight/libraries/plans.c @@ -154,7 +154,7 @@ void plan_setup_returnToBase() pathDesired.StartingVelocity = 0.0f; pathDesired.EndingVelocity = 0.0f; - uint8_t ReturnToBaseNextCommand; + FlightModeSettingsReturnToBaseNextCommandOptions ReturnToBaseNextCommand; FlightModeSettingsReturnToBaseNextCommandGet(&ReturnToBaseNextCommand); pathDesired.ModeParameters[PATHDESIRED_MODEPARAMETER_GOTOENDPOINT_NEXTCOMMAND] = (float)ReturnToBaseNextCommand; pathDesired.ModeParameters[PATHDESIRED_MODEPARAMETER_GOTOENDPOINT_UNUSED1] = 0.0f; diff --git a/flight/libraries/sanitycheck.c b/flight/libraries/sanitycheck.c index 7f16cc1c1..8302668f3 100644 --- a/flight/libraries/sanitycheck.c +++ b/flight/libraries/sanitycheck.c @@ -74,7 +74,7 @@ int32_t configuration_check() // Classify navigation capability #ifdef REVOLUTION RevoSettingsInitialize(); - uint8_t revoFusion; + RevoSettingsFusionAlgorithmOptions revoFusion; RevoSettingsFusionAlgorithmGet(&revoFusion); bool navCapableFusion; switch (revoFusion) { @@ -104,8 +104,8 @@ int32_t configuration_check() // For each available flight mode position sanity check the available // modes uint8_t num_modes; - uint8_t modes[FLIGHTMODESETTINGS_FLIGHTMODEPOSITION_NUMELEM]; - uint8_t FlightModeAssistMap[STABILIZATIONSETTINGS_FLIGHTMODEASSISTMAP_NUMELEM]; + FlightModeSettingsFlightModePositionOptions modes[FLIGHTMODESETTINGS_FLIGHTMODEPOSITION_NUMELEM]; + StabilizationSettingsFlightModeAssistMapOptions FlightModeAssistMap[STABILIZATIONSETTINGS_FLIGHTMODEASSISTMAP_NUMELEM]; ManualControlSettingsFlightModeNumberGet(&num_modes); StabilizationSettingsFlightModeAssistMapGet(FlightModeAssistMap); FlightModeSettingsFlightModePositionGet(modes); @@ -208,7 +208,7 @@ int32_t configuration_check() } } - uint8_t checks_disabled; + FlightModeSettingsDisableSanityChecksOptions checks_disabled; FlightModeSettingsDisableSanityChecksGet(&checks_disabled); if (checks_disabled == FLIGHTMODESETTINGS_DISABLESANITYCHECKS_TRUE) { severity = SYSTEMALARMS_ALARM_WARNING; @@ -236,22 +236,22 @@ static bool check_stabilization_settings(int index, bool multirotor, bool copter // Get the different axis modes for this switch position switch (index) { case 1: - FlightModeSettingsStabilization1SettingsArrayGet(modes); + FlightModeSettingsStabilization1SettingsArrayGet((FlightModeSettingsStabilization1SettingsOptions*) modes); break; case 2: - FlightModeSettingsStabilization2SettingsArrayGet(modes); + FlightModeSettingsStabilization2SettingsArrayGet((FlightModeSettingsStabilization2SettingsOptions*) modes); break; case 3: - FlightModeSettingsStabilization3SettingsArrayGet(modes); + FlightModeSettingsStabilization3SettingsArrayGet((FlightModeSettingsStabilization3SettingsOptions*) modes); break; case 4: - FlightModeSettingsStabilization4SettingsArrayGet(modes); + FlightModeSettingsStabilization4SettingsArrayGet((FlightModeSettingsStabilization4SettingsOptions*) modes); break; case 5: - FlightModeSettingsStabilization5SettingsArrayGet(modes); + FlightModeSettingsStabilization5SettingsArrayGet((FlightModeSettingsStabilization5SettingsOptions*) modes); break; case 6: - FlightModeSettingsStabilization6SettingsArrayGet(modes); + FlightModeSettingsStabilization6SettingsArrayGet((FlightModeSettingsStabilization6SettingsOptions*) modes); break; default: return false; @@ -325,7 +325,7 @@ static bool check_stabilization_settings(int index, bool multirotor, bool copter FrameType_t GetCurrentFrameType() { - uint8_t airframe_type; + SystemSettingsAirframeTypeOptions airframe_type; SystemSettingsAirframeTypeGet(&airframe_type); switch ((SystemSettingsAirframeTypeOptions)airframe_type) { diff --git a/flight/modules/Airspeed/airspeed.c b/flight/modules/Airspeed/airspeed.c index d86a692a6..b46ba55db 100644 --- a/flight/modules/Airspeed/airspeed.c +++ b/flight/modules/Airspeed/airspeed.c @@ -98,7 +98,7 @@ int32_t AirspeedInitialize() #else HwSettingsInitialize(); - uint8_t optionalModules[HWSETTINGS_OPTIONALMODULES_NUMELEM]; + HwSettingsOptionalModulesOptions optionalModules[HWSETTINGS_OPTIONALMODULES_NUMELEM]; HwSettingsOptionalModulesArrayGet(optionalModules); @@ -110,7 +110,7 @@ int32_t AirspeedInitialize() } #endif - uint8_t adcRouting[HWSETTINGS_ADCROUTING_NUMELEM]; + HwSettingsADCRoutingOptions adcRouting[HWSETTINGS_ADCROUTING_NUMELEM]; HwSettingsADCRoutingArrayGet(adcRouting); // Determine if the barometric airspeed sensor is routed to an ADC pin diff --git a/flight/modules/GPS/GPS.c b/flight/modules/GPS/GPS.c index 460f6fdc1..d9a080256 100644 --- a/flight/modules/GPS/GPS.c +++ b/flight/modules/GPS/GPS.c @@ -153,7 +153,7 @@ int32_t GPSStart(void) int32_t GPSInitialize(void) { gpsPort = PIOS_COM_GPS; - uint8_t gpsProtocol; + GPSSettingsDataProtocolOptions gpsProtocol; #ifdef MODULE_GPS_BUILTIN gpsEnabled = true; @@ -338,7 +338,7 @@ static void gpsTask(__attribute__((unused)) void *parameters) (gpsSettings.DataProtocol == GPSSETTINGS_DATAPROTOCOL_UBX && gpspositionsensor.AutoConfigStatus == GPSPOSITIONSENSOR_AUTOCONFIGSTATUS_ERROR)) { // we have not received any valid GPS sentences for a while. // either the GPS is not plugged in or a hardware problem or the GPS has locked up. - uint8_t status = GPSPOSITIONSENSOR_STATUS_NOGPS; + GPSPositionSensorStatusOptions status = GPSPOSITIONSENSOR_STATUS_NOGPS; GPSPositionSensorStatusSet(&status); AlarmsSet(SYSTEMALARMS_ALARM_GPS, SYSTEMALARMS_ALARM_ERROR); } else { @@ -439,7 +439,7 @@ static void updateHwSettings() { if (gpsPort) { // Retrieve settings - uint8_t speed; + HwSettingsGPSSpeedOptions speed; HwSettingsGPSSpeedGet(&speed); // Set port speed diff --git a/flight/modules/Logging/Logging.c b/flight/modules/Logging/Logging.c index bc0733186..7529420d2 100644 --- a/flight/modules/Logging/Logging.c +++ b/flight/modules/Logging/Logging.c @@ -134,7 +134,7 @@ static void ControlUpdatedCb(__attribute__((unused)) UAVObjEvent *ev) } DebugLogEntrySet(entry); } else if (control.Operation == DEBUGLOGCONTROL_OPERATION_FORMATFLASH) { - uint8_t armed; + FlightStatusArmedOptions armed; FlightStatusArmedGet(&armed); if (armed == FLIGHTSTATUS_ARMED_DISARMED) { PIOS_DEBUGLOG_Format(); diff --git a/flight/modules/ManualControl/manualcontrol.c b/flight/modules/ManualControl/manualcontrol.c index 70b872296..b90a09ccf 100644 --- a/flight/modules/ManualControl/manualcontrol.c +++ b/flight/modules/ManualControl/manualcontrol.c @@ -182,7 +182,7 @@ static void SettingsUpdatedCb(__attribute__((unused)) UAVObjEvent *ev) { frameType = GetCurrentFrameType(); #ifndef PIOS_EXCLUDE_ADVANCED_FEATURES - uint8_t TreatCustomCraftAs; + VtolPathFollowerSettingsTreatCustomCraftAsOptions TreatCustomCraftAs; VtolPathFollowerSettingsTreatCustomCraftAsGet(&TreatCustomCraftAs); @@ -485,7 +485,7 @@ static uint8_t isAssistedFlightMode(uint8_t position, uint8_t flightMode, Flight { uint8_t flightModeAssistOption = STABILIZATIONSETTINGS_FLIGHTMODEASSISTMAP_NONE; uint8_t isAssistedFlag = FLIGHTSTATUS_FLIGHTMODEASSIST_NONE; - uint8_t FlightModeAssistMap[STABILIZATIONSETTINGS_FLIGHTMODEASSISTMAP_NUMELEM]; + StabilizationSettingsFlightModeAssistMapOptions FlightModeAssistMap[STABILIZATIONSETTINGS_FLIGHTMODEASSISTMAP_NUMELEM]; StabilizationSettingsFlightModeAssistMapGet(FlightModeAssistMap); if (position < STABILIZATIONSETTINGS_FLIGHTMODEASSISTMAP_NUMELEM) { diff --git a/flight/modules/ManualControl/pathfollowerhandler.c b/flight/modules/ManualControl/pathfollowerhandler.c index 1a0818b68..972366268 100644 --- a/flight/modules/ManualControl/pathfollowerhandler.c +++ b/flight/modules/ManualControl/pathfollowerhandler.c @@ -55,9 +55,9 @@ void pathFollowerHandler(bool newinit) plan_initialize(); } - uint8_t flightMode; - uint8_t assistedControlFlightMode; - uint8_t flightModeAssist; + FlightStatusFlightModeOptions flightMode; + FlightStatusAssistedControlStateOptions assistedControlFlightMode; + FlightStatusFlightModeAssistOptions flightModeAssist; FlightStatusFlightModeGet(&flightMode); FlightStatusFlightModeAssistGet(&flightModeAssist); FlightStatusAssistedControlStateGet(&assistedControlFlightMode); diff --git a/flight/modules/ManualControl/stabilizedhandler.c b/flight/modules/ManualControl/stabilizedhandler.c index 4621a7171..0a523d3f6 100644 --- a/flight/modules/ManualControl/stabilizedhandler.c +++ b/flight/modules/ManualControl/stabilizedhandler.c @@ -96,27 +96,27 @@ void stabilizedHandler(bool newinit) switch (flightStatus.FlightMode) { case FLIGHTSTATUS_FLIGHTMODE_STABILIZED1: - stab_settings = FlightModeSettingsStabilization1SettingsToArray(settings.Stabilization1Settings); + stab_settings = (uint8_t*) FlightModeSettingsStabilization1SettingsToArray(settings.Stabilization1Settings); break; case FLIGHTSTATUS_FLIGHTMODE_STABILIZED2: - stab_settings = FlightModeSettingsStabilization2SettingsToArray(settings.Stabilization2Settings); + stab_settings = (uint8_t*) FlightModeSettingsStabilization2SettingsToArray(settings.Stabilization2Settings); break; case FLIGHTSTATUS_FLIGHTMODE_STABILIZED3: - stab_settings = FlightModeSettingsStabilization3SettingsToArray(settings.Stabilization3Settings); + stab_settings = (uint8_t*) FlightModeSettingsStabilization3SettingsToArray(settings.Stabilization3Settings); break; case FLIGHTSTATUS_FLIGHTMODE_STABILIZED4: - stab_settings = FlightModeSettingsStabilization4SettingsToArray(settings.Stabilization4Settings); + stab_settings = (uint8_t*) FlightModeSettingsStabilization4SettingsToArray(settings.Stabilization4Settings); break; case FLIGHTSTATUS_FLIGHTMODE_STABILIZED5: - stab_settings = FlightModeSettingsStabilization5SettingsToArray(settings.Stabilization5Settings); + stab_settings = (uint8_t*) FlightModeSettingsStabilization5SettingsToArray(settings.Stabilization5Settings); break; case FLIGHTSTATUS_FLIGHTMODE_STABILIZED6: - stab_settings = FlightModeSettingsStabilization6SettingsToArray(settings.Stabilization6Settings); + stab_settings = (uint8_t*) FlightModeSettingsStabilization6SettingsToArray(settings.Stabilization6Settings); break; default: // Major error, this should not occur because only enter this block when one of these is true AlarmsSet(SYSTEMALARMS_ALARM_MANUALCONTROL, SYSTEMALARMS_ALARM_CRITICAL); - stab_settings = FlightModeSettingsStabilization1SettingsToArray(settings.Stabilization1Settings); + stab_settings = (uint8_t*) FlightModeSettingsStabilization1SettingsToArray(settings.Stabilization1Settings); return; } diff --git a/flight/modules/ManualControl/takeofflocationhandler.c b/flight/modules/ManualControl/takeofflocationhandler.c index 42a10777d..93332f2b1 100644 --- a/flight/modules/ManualControl/takeofflocationhandler.c +++ b/flight/modules/ManualControl/takeofflocationhandler.c @@ -42,8 +42,8 @@ void takeOffLocationHandlerInit() { TakeOffLocationInitialize(); // check whether there is a preset/valid takeoff location - uint8_t mode; - uint8_t status; + TakeOffLocationModeOptions mode; + TakeOffLocationStatusOptions status; TakeOffLocationModeGet(&mode); TakeOffLocationStatusGet(&status); // preset with invalid location will actually behave like FirstTakeoff @@ -61,8 +61,8 @@ void takeOffLocationHandlerInit() */ void takeOffLocationHandler() { - uint8_t armed; - uint8_t status; + FlightStatusArmedOptions armed; + TakeOffLocationStatusOptions status; FlightStatusArmedGet(&armed); @@ -77,7 +77,7 @@ void takeOffLocationHandler() case FLIGHTSTATUS_ARMED_ARMING: case FLIGHTSTATUS_ARMED_ARMED: if (!locationSet || status != TAKEOFFLOCATION_STATUS_VALID) { - uint8_t mode; + TakeOffLocationModeOptions mode; TakeOffLocationModeGet(&mode); if ((mode != TAKEOFFLOCATION_MODE_PRESET) || (status == TAKEOFFLOCATION_STATUS_INVALID)) { @@ -91,7 +91,7 @@ void takeOffLocationHandler() case FLIGHTSTATUS_ARMED_DISARMED: // unset if location is to be acquired at each arming if (locationSet) { - uint8_t mode; + TakeOffLocationModeOptions mode; TakeOffLocationModeGet(&mode); if (mode == TAKEOFFLOCATION_MODE_ARMINGLOCATION) { locationSet = false; diff --git a/flight/modules/PathPlanner/pathplanner.c b/flight/modules/PathPlanner/pathplanner.c index ab6442391..7e3c92bba 100644 --- a/flight/modules/PathPlanner/pathplanner.c +++ b/flight/modules/PathPlanner/pathplanner.c @@ -138,7 +138,7 @@ MODULE_INITCALL(PathPlannerInitialize, PathPlannerStart); static void SettingsUpdatedCb(__attribute__((unused)) UAVObjEvent *ev) { - uint8_t TreatCustomCraftAs; + VtolPathFollowerSettingsTreatCustomCraftAsOptions TreatCustomCraftAs; VtolPathFollowerSettingsTreatCustomCraftAsGet(&TreatCustomCraftAs); diff --git a/flight/modules/Stabilization/innerloop.c b/flight/modules/Stabilization/innerloop.c index 2ed1ae57b..b772b0602 100644 --- a/flight/modules/Stabilization/innerloop.c +++ b/flight/modules/Stabilization/innerloop.c @@ -334,7 +334,7 @@ static void stabilizationInnerloopTask() } { - uint8_t armed; + FlightStatusArmedOptions armed; FlightStatusArmedGet(&armed); float throttleDesired; ManualControlCommandThrottleGet(&throttleDesired); diff --git a/flight/modules/Stabilization/outerloop.c b/flight/modules/Stabilization/outerloop.c index 995003208..b4ea4e73f 100644 --- a/flight/modules/Stabilization/outerloop.c +++ b/flight/modules/Stabilization/outerloop.c @@ -264,7 +264,7 @@ static void stabilizationOuterloopTask() RateDesiredSet(&rateDesired); { - uint8_t armed; + FlightStatusArmedOptions armed; FlightStatusArmedGet(&armed); float throttleDesired; ManualControlCommandThrottleGet(&throttleDesired); diff --git a/flight/modules/Telemetry/telemetry.c b/flight/modules/Telemetry/telemetry.c index 86d565891..0cddc68ed 100644 --- a/flight/modules/Telemetry/telemetry.c +++ b/flight/modules/Telemetry/telemetry.c @@ -685,7 +685,7 @@ static void updateSettings() { if (telemetryPort) { // Retrieve settings - uint8_t speed; + HwSettingsTelemetrySpeedOptions speed; HwSettingsTelemetrySpeedGet(&speed); // Set port speed diff --git a/flight/targets/boards/simposix/firmware/pios_board.c b/flight/targets/boards/simposix/firmware/pios_board.c index 781833d32..19799d2d4 100644 --- a/flight/targets/boards/simposix/firmware/pios_board.c +++ b/flight/targets/boards/simposix/firmware/pios_board.c @@ -152,7 +152,7 @@ void PIOS_Board_Init(void) /* Configure IO ports */ /* Configure Telemetry port */ - uint8_t hwsettings_rv_telemetryport; + HwSettingsRV_TelemetryPortOptions hwsettings_rv_telemetryport; HwSettingsRV_TelemetryPortGet(&hwsettings_rv_telemetryport); switch (hwsettings_rv_telemetryport) { @@ -164,10 +164,12 @@ void PIOS_Board_Init(void) case HWSETTINGS_RV_TELEMETRYPORT_COMAUX: PIOS_Board_configure_com(&pios_udp_telem_cfg, PIOS_COM_AUX_RX_BUF_LEN, PIOS_COM_AUX_TX_BUF_LEN, &pios_udp_com_driver, &pios_com_aux_id); break; + default: + break; } /* hwsettings_rv_telemetryport */ /* Configure GPS port */ - uint8_t hwsettings_rv_gpsport; + HwSettingsRV_GPSPortOptions hwsettings_rv_gpsport; HwSettingsRV_GPSPortGet(&hwsettings_rv_gpsport); switch (hwsettings_rv_gpsport) { case HWSETTINGS_RV_GPSPORT_DISABLED: @@ -184,10 +186,12 @@ void PIOS_Board_Init(void) case HWSETTINGS_RV_GPSPORT_COMAUX: PIOS_Board_configure_com(&pios_udp_gps_cfg, PIOS_COM_AUX_RX_BUF_LEN, PIOS_COM_AUX_TX_BUF_LEN, &pios_udp_com_driver, &pios_com_aux_id); break; + default: + break; } /* hwsettings_rv_gpsport */ /* Configure AUXPort */ - uint8_t hwsettings_rv_auxport; + HwSettingsRV_AuxPortOptions hwsettings_rv_auxport; HwSettingsRV_AuxPortGet(&hwsettings_rv_auxport); switch (hwsettings_rv_auxport) { @@ -201,6 +205,7 @@ void PIOS_Board_Init(void) case HWSETTINGS_RV_AUXPORT_COMAUX: PIOS_Board_configure_com(&pios_udp_aux_cfg, PIOS_COM_AUX_RX_BUF_LEN, PIOS_COM_AUX_TX_BUF_LEN, &pios_udp_com_driver, &pios_com_aux_id); break; + default: break; } /* hwsettings_rv_auxport */ }