mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-04-14 10:07:39 +08:00
Fixing code style
This commit is contained in:
parent
f09b60ad9e
commit
62b4d2de0d
@ -95,9 +95,9 @@ __BEGIN_DECLS
|
||||
|
||||
/* SPI Bus 1 Internal Sensors */
|
||||
|
||||
#define GPIO_SPI_CS_MPU9250 (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_2MHz|GPIO_OUTPUT_SET|GPIO_PORTC|GPIO_PIN2)
|
||||
#define GPIO_SPI_CS_LIS3MDL (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_2MHz|GPIO_OUTPUT_SET|GPIO_PORTE|GPIO_PIN15)
|
||||
#define GPIO_SPI_CS_MS5611 (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_2MHz|GPIO_OUTPUT_SET|GPIO_PORTD|GPIO_PIN7)
|
||||
#define GPIO_SPI_CS_MPU9250 (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_2MHz|GPIO_OUTPUT_SET|GPIO_PORTC|GPIO_PIN2)
|
||||
#define GPIO_SPI_CS_LIS3MDL (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_2MHz|GPIO_OUTPUT_SET|GPIO_PORTE|GPIO_PIN15)
|
||||
#define GPIO_SPI_CS_MS5611 (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_2MHz|GPIO_OUTPUT_SET|GPIO_PORTD|GPIO_PIN7)
|
||||
#define GPIO_SPI_CS_ICM_20608_G (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_2MHz|GPIO_OUTPUT_SET|GPIO_PORTC|GPIO_PIN15)
|
||||
#define GPIO_SPI_CS_TEMPCAL_EEPROM (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_2MHz|GPIO_OUTPUT_SET|GPIO_PORTH|GPIO_PIN5)
|
||||
|
||||
@ -134,10 +134,10 @@ __BEGIN_DECLS
|
||||
|
||||
#define _PIN_OFF(def) (((def) & (GPIO_PORT_MASK | GPIO_PIN_MASK)) | (GPIO_INPUT|GPIO_PULLDOWN|GPIO_SPEED_2MHz))
|
||||
|
||||
#define GPIO_SPI_CS_OFF_MPU9250 _PIN_OFF(GPIO_SPI_CS_MPU9250)
|
||||
#define GPIO_SPI_CS_OFF_LIS3MDL _PIN_OFF(GPIO_SPI_CS_LIS3MDL)
|
||||
#define GPIO_SPI_CS_OFF_MS5611 _PIN_OFF(GPIO_SPI_CS_MS5611)
|
||||
#define GPIO_SPI_CS_OFF_ICM_20608_G _PIN_OFF(GPIO_SPI_CS_ICM_20608_G)
|
||||
#define GPIO_SPI_CS_OFF_MPU9250 _PIN_OFF(GPIO_SPI_CS_MPU9250)
|
||||
#define GPIO_SPI_CS_OFF_LIS3MDL _PIN_OFF(GPIO_SPI_CS_LIS3MDL)
|
||||
#define GPIO_SPI_CS_OFF_MS5611 _PIN_OFF(GPIO_SPI_CS_MS5611)
|
||||
#define GPIO_SPI_CS_OFF_ICM_20608_G _PIN_OFF(GPIO_SPI_CS_ICM_20608_G)
|
||||
#define GPIO_SPI_CS_OFF_TEMPCAL_EEPROM _PIN_OFF(GPIO_SPI_CS_OFF_TEMPCAL_EEPROM)
|
||||
|
||||
#define GPIO_DRDY_OFF_MPU9250 _PIN_OFF(GPIO_DRDY_MPU9250)
|
||||
@ -170,7 +170,7 @@ __BEGIN_DECLS
|
||||
#define PX4_SPIDEV_BMA 9
|
||||
#define PX4_SPIDEV_EXT0 10
|
||||
#define PX4_SPIDEV_EXT1 11
|
||||
#define PX4_SPIDEV_EEPROM 12
|
||||
#define PX4_SPIDEV_EEPROM 12
|
||||
|
||||
|
||||
/* I2C busses */
|
||||
@ -194,12 +194,12 @@ __BEGIN_DECLS
|
||||
#define ADC_CHANNELS (1 << 2) | (1 << 3) | (1 << 4) | (1 << 10) | (1 << 11) | (1 << 12) | (1 << 13) | (1 << 14)
|
||||
|
||||
// ADC defines to be used in sensors.cpp to read from a particular channel
|
||||
#define ADC_BATTERY_VOLTAGE_CHANNEL 2
|
||||
#define ADC_BATTERY_CURRENT_CHANNEL 3
|
||||
#define ADC_5V_RAIL_SENSE 4
|
||||
#define ADC_BATTERY_VOLTAGE_CHANNEL 2
|
||||
#define ADC_BATTERY_CURRENT_CHANNEL 3
|
||||
#define ADC_5V_RAIL_SENSE 4
|
||||
#define ADC_BATTERY2_VOLTAGE_CHANNEL 11
|
||||
#define ADC_BATTERY2_CURRENT_CHANNEL 13
|
||||
//#define ADC_RC_RSSI_CHANNEL 11
|
||||
//#define ADC_RC_RSSI_CHANNEL 11
|
||||
|
||||
/* Define Battery 1 Voltage Divider and A per V
|
||||
*/
|
||||
@ -239,13 +239,13 @@ __BEGIN_DECLS
|
||||
#define GPIO_VDD_5V_PERIPH_EN (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_2MHz|GPIO_OUTPUT_CLEAR|GPIO_PORTG|GPIO_PIN10)
|
||||
#define GPIO_VDD_5V_PERIPH_OC (GPIO_INPUT|GPIO_PULLUP|GPIO_PORTG|GPIO_PIN4)
|
||||
#define GPIO_VDD_5V_HIPOWER_OC (GPIO_INPUT|GPIO_PULLUP|GPIO_PORTF|GPIO_PIN3)
|
||||
#define GPIO_VBUS_VALID (GPIO_INPUT|GPIO_PULLUP|GPIO_PORTC|GPIO_PIN0)
|
||||
#define GPIO_VBUS_VALID (GPIO_INPUT|GPIO_PULLUP|GPIO_PORTC|GPIO_PIN0)
|
||||
|
||||
/* Tone alarm output */
|
||||
#define TONE_ALARM_TIMER 2 /* timer 2 */
|
||||
#define TONE_ALARM_CHANNEL 1 /* channel 1 */
|
||||
#define TONE_ALARM_TIMER 2 /* timer 2 */
|
||||
#define TONE_ALARM_CHANNEL 1 /* channel 1 */
|
||||
#define GPIO_TONE_ALARM_IDLE (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_2MHz|GPIO_OUTPUT_CLEAR|GPIO_PORTA|GPIO_PIN15)
|
||||
#define GPIO_TONE_ALARM (GPIO_ALT|GPIO_AF1|GPIO_SPEED_2MHz|GPIO_PUSHPULL|GPIO_PORTA|GPIO_PIN15)
|
||||
#define GPIO_TONE_ALARM (GPIO_ALT|GPIO_AF1|GPIO_SPEED_2MHz|GPIO_PUSHPULL|GPIO_PORTA|GPIO_PIN15)
|
||||
|
||||
/* PWM
|
||||
*
|
||||
@ -293,7 +293,7 @@ __BEGIN_DECLS
|
||||
|
||||
/* PWM input driver. Use FMU AUX5 pins attached to timer4 channel 2 */
|
||||
#define PWMIN_TIMER 4
|
||||
#define PWMIN_TIMER_CHANNEL 2
|
||||
#define PWMIN_TIMER_CHANNEL 2
|
||||
#define GPIO_PWM_IN GPIO_TIM4_CH2IN_2
|
||||
|
||||
#define GPIO_RSSI_IN (GPIO_INPUT|GPIO_PULLUP|GPIO_PORTC|GPIO_PIN1)
|
||||
@ -309,7 +309,7 @@ __BEGIN_DECLS
|
||||
|
||||
/* Power switch controls ******************************************************/
|
||||
|
||||
#define POWER_SPEKTRUM(_s) px4_arch_gpiowrite(GPIO_SPEKTRUM_PWR_EN, (1-_s))
|
||||
#define POWER_SPEKTRUM(_s) px4_arch_gpiowrite(GPIO_SPEKTRUM_PWR_EN, (1-_s))
|
||||
#define SPEKTRUM_RX_AS_UART() px4_arch_configgpio(GPIO_USART1_RX)
|
||||
|
||||
// FMUv4-pro has a separate GPIO for serial RC output
|
||||
|
||||
@ -131,7 +131,7 @@ __END_DECLS
|
||||
__EXPORT void board_peripheral_reset(int ms)
|
||||
{
|
||||
/* set the peripheral and sensor rails off */
|
||||
stm32_gpiowrite(GPIO_VDD_3V3_PERIPH_EN, 0);
|
||||
stm32_gpiowrite(GPIO_VDD_3V3_PERIPH_EN, 0);
|
||||
stm32_gpiowrite(GPIO_VDD_3V3_SENSORS_EN, 0);
|
||||
stm32_gpiowrite(GPIO_VDD_5V_PERIPH_EN, 1);
|
||||
|
||||
@ -174,16 +174,16 @@ stm32_boardinitialize(void)
|
||||
stm32_configgpio(GPIO_ADC1_IN3); /* BATT_CURRENT_SENS */
|
||||
stm32_configgpio(GPIO_ADC1_IN4); /* VDD_5V_SENS */
|
||||
stm32_configgpio(GPIO_ADC1_IN11); /* BATT2_VOLTAGE_SENS */
|
||||
stm32_configgpio(GPIO_ADC1_IN13); /* BATT2_CURRENT_SENS */
|
||||
stm32_configgpio(GPIO_ADC1_IN13); /* BATT2_CURRENT_SENS */
|
||||
|
||||
/* configure power supply control/sense pins */
|
||||
stm32_configgpio(GPIO_VDD_3V3_PERIPH_EN);
|
||||
stm32_configgpio(GPIO_VDD_3V3_SENSORS_EN);
|
||||
stm32_configgpio(GPIO_VDD_5V_PERIPH_EN);
|
||||
|
||||
|
||||
stm32_configgpio(GPIO_VDD_BRICK_VALID);
|
||||
stm32_configgpio(GPIO_VDD_BRICK2_VALID);
|
||||
|
||||
|
||||
stm32_configgpio(GPIO_VDD_5V_PERIPH_OC);
|
||||
stm32_configgpio(GPIO_VDD_5V_HIPOWER_OC);
|
||||
stm32_configgpio(GPIO_VBUS_VALID);
|
||||
|
||||
@ -135,7 +135,7 @@ __EXPORT void stm32_spi1select(FAR struct spi_dev_s *dev, enum spi_dev_e devid,
|
||||
stm32_gpiowrite(GPIO_SPI_CS_ICM_20608_G, 1);
|
||||
stm32_gpiowrite(GPIO_SPI_CS_TEMPCAL_EEPROM, 1);
|
||||
break;
|
||||
|
||||
|
||||
case PX4_SPIDEV_EEPROM:
|
||||
/* Making sure the other peripherals are not selected */
|
||||
stm32_gpiowrite(GPIO_SPI_CS_MPU9250, 1);
|
||||
@ -143,7 +143,7 @@ __EXPORT void stm32_spi1select(FAR struct spi_dev_s *dev, enum spi_dev_e devid,
|
||||
stm32_gpiowrite(GPIO_SPI_CS_MS5611, 1);
|
||||
stm32_gpiowrite(GPIO_SPI_CS_ICM_20608_G, 1);
|
||||
stm32_gpiowrite(GPIO_SPI_CS_TEMPCAL_EEPROM, !selected);
|
||||
break;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
@ -225,7 +225,7 @@ __EXPORT void board_spi_reset(int ms)
|
||||
stm32_gpiowrite(GPIO_SPI_CS_OFF_MS5611, 0);
|
||||
stm32_gpiowrite(GPIO_SPI_CS_OFF_ICM_20608_G, 0);
|
||||
stm32_gpiowrite(GPIO_SPI_CS_TEMPCAL_EEPROM, 0);
|
||||
|
||||
|
||||
stm32_configgpio(GPIO_SPI1_SCK_OFF);
|
||||
stm32_configgpio(GPIO_SPI1_MISO_OFF);
|
||||
stm32_configgpio(GPIO_SPI1_MOSI_OFF);
|
||||
|
||||
@ -132,7 +132,7 @@ public:
|
||||
* Stop the automatic measurement state machine.
|
||||
*/
|
||||
void stop();
|
||||
|
||||
|
||||
/**
|
||||
* Diagnostics - print some basic information about the driver.
|
||||
*/
|
||||
@ -814,8 +814,8 @@ LIS3MDL::cycle()
|
||||
{
|
||||
if (_measure_ticks == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* collection phase? */
|
||||
if (_collect_phase) {
|
||||
|
||||
@ -853,7 +853,7 @@ LIS3MDL::cycle()
|
||||
|
||||
/* next phase is collection */
|
||||
_collect_phase = true;
|
||||
|
||||
|
||||
if (_measure_ticks > 0) {
|
||||
/* schedule a fresh cycle call when the measurement is done */
|
||||
work_queue(HPWORK,
|
||||
@ -861,7 +861,7 @@ LIS3MDL::cycle()
|
||||
(worker_t)&LIS3MDL::cycle_trampoline,
|
||||
this,
|
||||
USEC2TICK(LIS3MDL_CONVERSION_INTERVAL));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
@ -951,8 +951,8 @@ LIS3MDL::collect()
|
||||
|
||||
/* the LIS3MDL mag on Pixhawk Pro by Drotek has x pointing towards,
|
||||
* y pointing to the right, and z down, therefore no switch needed,
|
||||
* it is better to have no artificial rotation inside the
|
||||
* driver and then use the startup script with -R command with the
|
||||
* it is better to have no artificial rotation inside the
|
||||
* driver and then use the startup script with -R command with the
|
||||
* real rotation between the sensor and body frame */
|
||||
xraw_f = report.x;
|
||||
yraw_f = report.y;
|
||||
@ -1029,7 +1029,7 @@ int LIS3MDL::calibrate(struct file *filp, unsigned enable)
|
||||
}
|
||||
|
||||
usleep(20000);
|
||||
|
||||
|
||||
// discard 10 samples to let the sensor settle
|
||||
for (uint8_t i = 0; i < 10; i++) {
|
||||
struct pollfd fds;
|
||||
@ -1079,14 +1079,14 @@ int LIS3MDL::calibrate(struct file *filp, unsigned enable)
|
||||
|
||||
sum_non_excited[0] += report.x;
|
||||
sum_non_excited[1] += report.y;
|
||||
sum_non_excited[2] += report.z;
|
||||
sum_non_excited[2] += report.z;
|
||||
}
|
||||
|
||||
|
||||
sum_non_excited[0] /= 10.0f;
|
||||
sum_non_excited[1] /= 10.0f;
|
||||
sum_non_excited[2] /= 10.0f;
|
||||
|
||||
|
||||
|
||||
|
||||
if (OK != ioctl(filp, MAGIOCEXSTRAP, 1)) {
|
||||
warnx("FAILED: MAGIOCEXSTRAP 1");
|
||||
ret = 1;
|
||||
@ -1094,7 +1094,7 @@ int LIS3MDL::calibrate(struct file *filp, unsigned enable)
|
||||
}
|
||||
|
||||
usleep(60000);
|
||||
|
||||
|
||||
// discard 10 samples to let the sensor settle
|
||||
for (uint8_t i = 0; i < 10; i++) {
|
||||
struct pollfd fds;
|
||||
@ -1144,20 +1144,19 @@ int LIS3MDL::calibrate(struct file *filp, unsigned enable)
|
||||
|
||||
sum_excited[0] += report.x;
|
||||
sum_excited[1] += report.y;
|
||||
sum_excited[2] += report.z;
|
||||
sum_excited[2] += report.z;
|
||||
}
|
||||
|
||||
|
||||
sum_excited[0] /= 10.0f;
|
||||
sum_excited[1] /= 10.0f;
|
||||
sum_excited[2] /= 10.0f;
|
||||
sum_excited[2] /= 10.0f;
|
||||
|
||||
if (1.0f < fabsf(sum_excited[0] - sum_non_excited[0]) && fabsf(sum_excited[0] - sum_non_excited[0]) < 3.0f &&
|
||||
1.0f < fabsf(sum_excited[1] - sum_non_excited[1]) && fabsf(sum_excited[1] - sum_non_excited[1]) < 3.0f &&
|
||||
0.1f < fabsf(sum_excited[2] - sum_non_excited[2]) && fabsf(sum_excited[2] - sum_non_excited[2]) < 1.0f){
|
||||
ret = OK;
|
||||
}
|
||||
else
|
||||
{
|
||||
1.0f < fabsf(sum_excited[1] - sum_non_excited[1]) && fabsf(sum_excited[1] - sum_non_excited[1]) < 3.0f &&
|
||||
0.1f < fabsf(sum_excited[2] - sum_non_excited[2]) && fabsf(sum_excited[2] - sum_non_excited[2]) < 1.0f) {
|
||||
ret = OK;
|
||||
|
||||
} else {
|
||||
ret = -EIO;
|
||||
goto out;
|
||||
}
|
||||
@ -1171,7 +1170,7 @@ out:
|
||||
if (OK != ::ioctl(fd, MAGIOCSRANGE, 4)) {
|
||||
warnx("FAILED: MAGIOCSRANGE 4 Ga");
|
||||
}
|
||||
|
||||
|
||||
if (OK != ::ioctl(fd, MAGIOCEXSTRAP, 0)) {
|
||||
warnx("FAILED: MAGIOCEXSTRAP 0");
|
||||
}
|
||||
@ -1552,7 +1551,7 @@ test(enum LIS3MDL_BUS busid)
|
||||
/**
|
||||
* Self test check.
|
||||
*
|
||||
* Unlike HMC5883, self test feature cannot be used to calculate
|
||||
* Unlike HMC5883, self test feature cannot be used to calculate
|
||||
* scale.
|
||||
*
|
||||
* SELF TEST OPERATION
|
||||
@ -1561,7 +1560,7 @@ test(enum LIS3MDL_BUS busid)
|
||||
* (bias field) to be measured. To implement self test, the least significant bits
|
||||
* (MS1 and MS0) of configuration register A are changed from 00 to 01 (positive bias).
|
||||
* A few measurements are taken and stored with and without the additional magnetic
|
||||
* field. According to ST datasheet, those values must stay between thresholds in order
|
||||
* field. According to ST datasheet, those values must stay between thresholds in order
|
||||
* to pass the self test.
|
||||
*/
|
||||
int calibrate(enum LIS3MDL_BUS busid)
|
||||
@ -1694,11 +1693,11 @@ lis3mdl_main(int argc, char *argv[])
|
||||
|
||||
/*
|
||||
* Stop the driver.
|
||||
*/
|
||||
*/
|
||||
if (!strcmp(verb, "stop")) {
|
||||
return lis3mdl::stop();
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Test the driver/device.
|
||||
*/
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user