From 8f3d9fae9a9de68a28c9f2a8d3d9a1c09612abbb Mon Sep 17 00:00:00 2001 From: Petr Ledvina Date: Fri, 9 Oct 2015 13:08:02 +0200 Subject: [PATCH] unify `typedef struct name_s {} name_t;` naming convention --- src/main/blackbox/blackbox.c | 14 +++++++------- src/main/blackbox/blackbox_fielddefs.h | 14 ++++++-------- src/main/common/maths.h | 2 +- src/main/drivers/accgyro_adxl345.h | 2 +- src/main/drivers/adc.h | 4 ++-- src/main/drivers/barometer.h | 2 +- src/main/drivers/barometer_bmp280.c | 2 +- src/main/drivers/bus_i2c_stm32f10x.c | 2 +- src/main/drivers/flash.h | 2 +- src/main/drivers/pwm_mapping.h | 2 +- src/main/drivers/pwm_rx.c | 2 +- src/main/drivers/serial.h | 2 +- src/main/flight/lowpass.h | 2 +- src/main/flight/mixer.h | 12 ++++++------ src/main/io/gps.c | 2 +- src/main/io/gps.h | 2 +- src/test/unit/baro_bmp280_unittest.cc | 2 +- src/test/unit/encoding_unittest.cc | 4 ++-- 18 files changed, 36 insertions(+), 38 deletions(-) diff --git a/src/main/blackbox/blackbox.c b/src/main/blackbox/blackbox.c index e279a06957..1fc6b5a925 100644 --- a/src/main/blackbox/blackbox.c +++ b/src/main/blackbox/blackbox.c @@ -111,7 +111,7 @@ static const char* const blackboxFieldHeaderNames[] = { }; /* All field definition structs should look like this (but with longer arrs): */ -typedef struct blackboxFieldDefinition_t { +typedef struct blackboxFieldDefinition_s { const char *name; // If the field name has a number to be included in square brackets [1] afterwards, set it here, or -1 for no brackets: int8_t fieldNameIndex; @@ -124,7 +124,7 @@ typedef struct blackboxFieldDefinition_t { #define BLACKBOX_SIMPLE_FIELD_HEADER_COUNT (BLACKBOX_DELTA_FIELD_HEADER_COUNT - 2) #define BLACKBOX_CONDITIONAL_FIELD_HEADER_COUNT (BLACKBOX_DELTA_FIELD_HEADER_COUNT - 2) -typedef struct blackboxSimpleFieldDefinition_t { +typedef struct blackboxSimpleFieldDefinition_s { const char *name; int8_t fieldNameIndex; @@ -133,7 +133,7 @@ typedef struct blackboxSimpleFieldDefinition_t { uint8_t encode; } blackboxSimpleFieldDefinition_t; -typedef struct blackboxConditionalFieldDefinition_t { +typedef struct blackboxConditionalFieldDefinition_s { const char *name; int8_t fieldNameIndex; @@ -143,7 +143,7 @@ typedef struct blackboxConditionalFieldDefinition_t { uint8_t condition; // Decide whether this field should appear in the log } blackboxConditionalFieldDefinition_t; -typedef struct blackboxDeltaFieldDefinition_t { +typedef struct blackboxDeltaFieldDefinition_s { const char *name; int8_t fieldNameIndex; @@ -264,7 +264,7 @@ typedef enum BlackboxState { BLACKBOX_STATE_SHUTTING_DOWN } BlackboxState; -typedef struct blackboxMainState_t { +typedef struct blackboxMainState_s { uint32_t time; int32_t axisPID_P[XYZ_AXIS_COUNT], axisPID_I[XYZ_AXIS_COUNT], axisPID_D[XYZ_AXIS_COUNT]; @@ -290,13 +290,13 @@ typedef struct blackboxMainState_t { uint16_t rssi; } blackboxMainState_t; -typedef struct blackboxGpsState_t { +typedef struct blackboxGpsState_s { int32_t GPS_home[2], GPS_coord[2]; uint8_t GPS_numSat; } blackboxGpsState_t; // This data is updated really infrequently: -typedef struct blackboxSlowState_t { +typedef struct blackboxSlowState_s { uint16_t flightModeFlags; uint8_t stateFlags; uint8_t failsafePhase; diff --git a/src/main/blackbox/blackbox_fielddefs.h b/src/main/blackbox/blackbox_fielddefs.h index e3c23f80e5..0bee570f20 100644 --- a/src/main/blackbox/blackbox_fielddefs.h +++ b/src/main/blackbox/blackbox_fielddefs.h @@ -109,40 +109,38 @@ typedef enum FlightLogEvent { FLIGHT_LOG_EVENT_LOG_END = 255 } FlightLogEvent; -typedef struct flightLogEvent_syncBeep_t { +typedef struct flightLogEvent_syncBeep_s { uint32_t time; } flightLogEvent_syncBeep_t; -typedef struct flightLogEvent_inflightAdjustment_t { +typedef struct flightLogEvent_inflightAdjustment_s { uint8_t adjustmentFunction; bool floatFlag; int32_t newValue; float newFloatValue; } flightLogEvent_inflightAdjustment_t; -typedef struct flightLogEvent_loggingResume_t { +typedef struct flightLogEvent_loggingResume_s { uint32_t logIteration; uint32_t currentTime; } flightLogEvent_loggingResume_t; #define FLIGHT_LOG_EVENT_INFLIGHT_ADJUSTMENT_FUNCTION_FLOAT_VALUE_FLAG 128 -typedef struct flightLogEvent_gtuneCycleResult_t { +typedef struct flightLogEvent_gtuneCycleResult_s { uint8_t gtuneAxis; int32_t gtuneGyroAVG; int16_t gtuneNewP; } flightLogEvent_gtuneCycleResult_t; -typedef union flightLogEventData_t -{ +typedef union flightLogEventData_u { flightLogEvent_syncBeep_t syncBeep; flightLogEvent_inflightAdjustment_t inflightAdjustment; flightLogEvent_loggingResume_t loggingResume; flightLogEvent_gtuneCycleResult_t gtuneCycleResult; } flightLogEventData_t; -typedef struct flightLogEvent_t -{ +typedef struct flightLogEvent_s { FlightLogEvent event; flightLogEventData_t data; } flightLogEvent_t; diff --git a/src/main/common/maths.h b/src/main/common/maths.h index 689d09fc69..e682f0581f 100644 --- a/src/main/common/maths.h +++ b/src/main/common/maths.h @@ -34,7 +34,7 @@ #define MAX(a, b) ((a) > (b) ? (a) : (b)) #define ABS(x) ((x) > 0 ? (x) : -(x)) -typedef struct stdev_t +typedef struct stdev_s { float m_oldM, m_newM, m_oldS, m_newS; int m_n; diff --git a/src/main/drivers/accgyro_adxl345.h b/src/main/drivers/accgyro_adxl345.h index 151302dbaa..654b0e4290 100644 --- a/src/main/drivers/accgyro_adxl345.h +++ b/src/main/drivers/accgyro_adxl345.h @@ -17,7 +17,7 @@ #pragma once -typedef struct drv_adxl345_config_t { +typedef struct drv_adxl345_config_s { bool useFifo; uint16_t dataRate; } drv_adxl345_config_t; diff --git a/src/main/drivers/adc.h b/src/main/drivers/adc.h index f39e2a448f..f090c8fa8d 100644 --- a/src/main/drivers/adc.h +++ b/src/main/drivers/adc.h @@ -27,14 +27,14 @@ typedef enum { #define ADC_CHANNEL_COUNT (ADC_CHANNEL_MAX + 1) -typedef struct adc_config_t { +typedef struct adc_config_s { uint8_t adcChannel; // ADC1_INxx channel number uint8_t dmaIndex; // index into DMA buffer in case of sparse channels bool enabled; uint8_t sampleTime; } adc_config_t; -typedef struct drv_adc_config_t { +typedef struct drv_adc_config_s { bool enableVBat; bool enableRSSI; bool enableCurrentMeter; diff --git a/src/main/drivers/barometer.h b/src/main/drivers/barometer.h index ddc1e7e36e..6d0e1c034b 100644 --- a/src/main/drivers/barometer.h +++ b/src/main/drivers/barometer.h @@ -20,7 +20,7 @@ typedef void (*baroOpFuncPtr)(void); // baro start operation typedef void (*baroCalculateFuncPtr)(int32_t *pressure, int32_t *temperature); // baro calculation (filled params are pressure and temperature) -typedef struct baro_t { +typedef struct baro_s { uint16_t ut_delay; uint16_t up_delay; baroOpFuncPtr start_ut; diff --git a/src/main/drivers/barometer_bmp280.c b/src/main/drivers/barometer_bmp280.c index b72531f3a5..43de7560e1 100644 --- a/src/main/drivers/barometer_bmp280.c +++ b/src/main/drivers/barometer_bmp280.c @@ -72,7 +72,7 @@ #define T_SETUP_PRESSURE_MAX (10) // 10/16 = 0.625 ms -typedef struct bmp280_calib_param_t { +typedef struct bmp280_calib_param_s { uint16_t dig_T1; /* calibration T1 data */ int16_t dig_T2; /* calibration T2 data */ int16_t dig_T3; /* calibration T3 data */ diff --git a/src/main/drivers/bus_i2c_stm32f10x.c b/src/main/drivers/bus_i2c_stm32f10x.c index 026dccf507..38fde8e45c 100644 --- a/src/main/drivers/bus_i2c_stm32f10x.c +++ b/src/main/drivers/bus_i2c_stm32f10x.c @@ -42,7 +42,7 @@ static void i2c_er_handler(void); static void i2c_ev_handler(void); static void i2cUnstick(void); -typedef struct i2cDevice_t { +typedef struct i2cDevice_s { I2C_TypeDef *dev; GPIO_TypeDef *gpio; uint16_t scl; diff --git a/src/main/drivers/flash.h b/src/main/drivers/flash.h index ca046ffbe6..21216825c1 100644 --- a/src/main/drivers/flash.h +++ b/src/main/drivers/flash.h @@ -19,7 +19,7 @@ #include -typedef struct flashGeometry_t { +typedef struct flashGeometry_s { uint16_t sectors; // Count of the number of erasable blocks on the device uint16_t pagesPerSector; diff --git a/src/main/drivers/pwm_mapping.h b/src/main/drivers/pwm_mapping.h index be663abfa0..73f5f61ba8 100644 --- a/src/main/drivers/pwm_mapping.h +++ b/src/main/drivers/pwm_mapping.h @@ -44,7 +44,7 @@ typedef struct sonarGPIOConfig_s { uint16_t echoPin; } sonarGPIOConfig_t; -typedef struct drv_pwm_config_t { +typedef struct drv_pwm_config_s { bool useParallelPWM; bool usePPM; bool useSerialRx; diff --git a/src/main/drivers/pwm_rx.c b/src/main/drivers/pwm_rx.c index 90dd28a0ba..b87fecd11c 100644 --- a/src/main/drivers/pwm_rx.c +++ b/src/main/drivers/pwm_rx.c @@ -83,7 +83,7 @@ static uint8_t ppmFrameCount = 0; static uint8_t lastPPMFrameCount = 0; static uint8_t ppmCountShift = 0; -typedef struct ppmDevice { +typedef struct ppmDevice_s { uint8_t pulseIndex; uint32_t previousTime; uint32_t currentTime; diff --git a/src/main/drivers/serial.h b/src/main/drivers/serial.h index d197991f77..7c1e87d988 100644 --- a/src/main/drivers/serial.h +++ b/src/main/drivers/serial.h @@ -36,7 +36,7 @@ typedef enum portOptions_t { typedef void (*serialReceiveCallbackPtr)(uint16_t data); // used by serial drivers to return frames to app -typedef struct serialPort { +typedef struct serialPort_s { const struct serialPortVTable *vTable; diff --git a/src/main/flight/lowpass.h b/src/main/flight/lowpass.h index bbd20f4b93..f1b57a315e 100644 --- a/src/main/flight/lowpass.h +++ b/src/main/flight/lowpass.h @@ -21,7 +21,7 @@ #define LOWPASS_NUM_COEF 3 #define LPF_ROUND(x) (x < 0 ? (x - 0.5f) : (x + 0.5f)) -typedef struct lowpass_t { +typedef struct lowpass_s { bool init; int16_t freq; // Normalized freq in 1/1000ths float bf[LOWPASS_NUM_COEF]; diff --git a/src/main/flight/mixer.h b/src/main/flight/mixer.h index 07f31c4cff..ca3bb7d1e0 100644 --- a/src/main/flight/mixer.h +++ b/src/main/flight/mixer.h @@ -54,7 +54,7 @@ typedef enum mixerMode } mixerMode_e; // Custom mixer data per motor -typedef struct motorMixer_t { +typedef struct motorMixer_s { float throttle; float roll; float pitch; @@ -62,7 +62,7 @@ typedef struct motorMixer_t { } motorMixer_t; // Custom mixer configuration -typedef struct mixer_t { +typedef struct mixer_s { uint8_t motorCount; uint8_t useServo; const motorMixer_t *motor; @@ -86,7 +86,7 @@ typedef struct flight3DConfig_s { uint16_t deadband3d_throttle; // default throttle deadband from MIDRC } flight3DConfig_t; -typedef struct airplaneConfig_t { +typedef struct airplaneConfig_s { int8_t fixedwing_althold_dir; // +1 or -1 for pitch/althold gain. later check if need more than just sign } airplaneConfig_t; @@ -150,7 +150,7 @@ typedef enum { #define SERVO_FLAPPERONS_MIN SERVO_FLAPPERON_1 #define SERVO_FLAPPERONS_MAX SERVO_FLAPPERON_2 -typedef struct servoMixer_t { +typedef struct servoMixer_s { uint8_t targetChannel; // servo that receives the output of the rule uint8_t inputSource; // input channel for this rule int8_t rate; // range [-125;+125] ; can be used to adjust a rate 0-125% and a direction @@ -165,12 +165,12 @@ typedef struct servoMixer_t { #define MAX_SERVO_BOXES 3 // Custom mixer configuration -typedef struct mixerRules_t { +typedef struct mixerRules_s { uint8_t servoRuleCount; const servoMixer_t *rule; } mixerRules_t; -typedef struct servoParam_t { +typedef struct servoParam_s { int16_t min; // servo min int16_t max; // servo max int16_t middle; // servo middle diff --git a/src/main/io/gps.c b/src/main/io/gps.c index c5ebe3b991..0a02f39c67 100755 --- a/src/main/io/gps.c +++ b/src/main/io/gps.c @@ -99,7 +99,7 @@ static gpsConfig_t *gpsConfig; static serialConfig_t *serialConfig; static serialPort_t *gpsPort; -typedef struct gpsInitData_t { +typedef struct gpsInitData_s { uint8_t index; uint8_t baudrateIndex; // see baudRate_e const char *ubx; diff --git a/src/main/io/gps.h b/src/main/io/gps.h index ee90f09b23..cdb9f66f6f 100644 --- a/src/main/io/gps.h +++ b/src/main/io/gps.h @@ -81,7 +81,7 @@ typedef enum { #define GPS_MESSAGE_STATE_ENTRY_COUNT (GPS_MESSAGE_STATE_MAX + 1) -typedef struct gpsData_t { +typedef struct gpsData_s { uint8_t state; // GPS thread state. Used for detecting cable disconnects and configuring attached devices uint8_t baudrateIndex; // index into auto-detecting or current baudrate uint32_t errors; // gps error counter - crc error/lost of data/sync etc.. diff --git a/src/test/unit/baro_bmp280_unittest.cc b/src/test/unit/baro_bmp280_unittest.cc index 737f8278a6..e937dc494b 100644 --- a/src/test/unit/baro_bmp280_unittest.cc +++ b/src/test/unit/baro_bmp280_unittest.cc @@ -22,7 +22,7 @@ extern "C" { extern uint32_t bmp280_up; extern uint32_t bmp280_ut; -typedef struct bmp280_calib_param_t { +typedef struct bmp280_calib_param_s { uint16_t dig_T1; /* calibration T1 data */ int16_t dig_T2; /* calibration T2 data */ int16_t dig_T3; /* calibration T3 data */ diff --git a/src/test/unit/encoding_unittest.cc b/src/test/unit/encoding_unittest.cc index bf2c70b916..6e7cb29d5a 100644 --- a/src/test/unit/encoding_unittest.cc +++ b/src/test/unit/encoding_unittest.cc @@ -23,12 +23,12 @@ extern "C" { #include "unittest_macros.h" #include "gtest/gtest.h" -typedef struct zigzagEncodingExpectation_t { +typedef struct zigzagEncodingExpectation_s { int32_t input; uint32_t expected; } zigzagEncodingExpectation_t; -typedef struct floatToIntEncodingExpectation_t { +typedef struct floatToIntEncodingExpectation_s { float input; uint32_t expected; } floatToIntEncodingExpectation_t;