mirror of
https://gitee.com/xiaohuolufeihua/bizhang_-obav.git
synced 2026-05-21 01:12:11 +00:00
deprecate df_bmp280_wrapper and replace with in tree bmp280
- deprecate DriverFramework bmp280 driver (df_bmp280_wrapper) - update beaglebone blue and snapdragon flight eagle boards to use in tree bmp280 - update posix (really just linux) and qurt I2C wrappers - tested on beaglebone blue
This commit is contained in:
@@ -44,7 +44,6 @@ px4_add_board(
|
||||
LABEL default
|
||||
#TESTING
|
||||
TOOLCHAIN arm-linux-gnueabihf
|
||||
|
||||
DRIVERS
|
||||
#barometer # all available barometer drivers
|
||||
batt_smbus
|
||||
@@ -53,17 +52,14 @@ px4_add_board(
|
||||
distance_sensor # all available distance sensor drivers
|
||||
gps
|
||||
#imu # all available imu drivers
|
||||
lights/rgbled
|
||||
#lights/rgbled
|
||||
linux_sbus
|
||||
#magnetometer # all available magnetometer drivers
|
||||
pwm_out_sim
|
||||
qshell/posix
|
||||
#telemetry # all available telemetry drivers
|
||||
|
||||
MODULES
|
||||
muorb/krait
|
||||
muorb/test
|
||||
|
||||
airspeed_selector
|
||||
attitude_estimator_q
|
||||
camera_feedback
|
||||
commander
|
||||
@@ -72,7 +68,6 @@ px4_add_board(
|
||||
events
|
||||
fw_att_control
|
||||
fw_pos_control_l1
|
||||
rover_pos_control
|
||||
land_detector
|
||||
landing_target_estimator
|
||||
load_mon
|
||||
@@ -80,17 +75,19 @@ px4_add_board(
|
||||
logger
|
||||
mavlink
|
||||
mc_att_control
|
||||
mc_rate_control
|
||||
mc_pos_control
|
||||
mc_rate_control
|
||||
#micrortps_bridge
|
||||
muorb/krait
|
||||
muorb/test
|
||||
navigator
|
||||
rc_update
|
||||
rover_pos_control
|
||||
sensors
|
||||
#sih
|
||||
simulator
|
||||
vmount
|
||||
vtol_att_control
|
||||
airspeed_selector
|
||||
|
||||
SYSTEMCMDS
|
||||
#bl_update
|
||||
#config
|
||||
@@ -100,6 +97,7 @@ px4_add_board(
|
||||
led_control
|
||||
mixer
|
||||
motor_ramp
|
||||
motor_test
|
||||
#mtd
|
||||
#nshterm
|
||||
param
|
||||
@@ -114,12 +112,14 @@ px4_add_board(
|
||||
tune_control
|
||||
ver
|
||||
work_queue
|
||||
|
||||
EXAMPLES
|
||||
#bottle_drop # OBC challenge
|
||||
#fixedwing_control # Tutorial code from https://px4.io/dev/example_fixedwing_control
|
||||
#hello
|
||||
#hwtest # Hardware test
|
||||
#matlab_csv_serial
|
||||
#px4_mavlink_debug # Tutorial code from http://dev.px4.io/en/debug/debug_values.html
|
||||
#px4_simple_app # Tutorial code from http://dev.px4.io/en/apps/hello_sky.html
|
||||
#rover_steering_control # Rover example app
|
||||
#uuv_example_app
|
||||
)
|
||||
|
||||
@@ -43,46 +43,48 @@ px4_add_board(
|
||||
VENDOR atlflight
|
||||
MODEL eagle
|
||||
LABEL qurt-default
|
||||
|
||||
DRIVERS
|
||||
barometer/bmp280
|
||||
gps
|
||||
imu/mpu9250
|
||||
magnetometer/hmc5883
|
||||
spektrum_rc
|
||||
qshell/qurt
|
||||
snapdragon_pwm_out
|
||||
|
||||
spektrum_rc
|
||||
DF_DRIVERS
|
||||
mpu9250
|
||||
bmp280
|
||||
hmc5883
|
||||
trone
|
||||
isl29501
|
||||
ltc2946
|
||||
|
||||
mpu9250
|
||||
trone
|
||||
MODULES
|
||||
muorb/adsp
|
||||
|
||||
airspeed_selector
|
||||
attitude_estimator_q
|
||||
commander
|
||||
ekf2
|
||||
fw_att_control
|
||||
fw_pos_control_l1
|
||||
rover_pos_control
|
||||
land_detector
|
||||
landing_target_estimator
|
||||
local_position_estimator
|
||||
mc_att_control
|
||||
mc_rate_control
|
||||
mc_pos_control
|
||||
mc_rate_control
|
||||
muorb/adsp
|
||||
rc_update
|
||||
rover_pos_control
|
||||
sensors
|
||||
#sih
|
||||
vmount
|
||||
vtol_att_control
|
||||
airspeed_selector
|
||||
|
||||
SYSTEMCMDS
|
||||
led_control
|
||||
mixer
|
||||
#motor_ramp
|
||||
motor_test
|
||||
param
|
||||
perf
|
||||
#pwm
|
||||
#topic_listener
|
||||
ver
|
||||
work_queue
|
||||
)
|
||||
|
||||
@@ -32,5 +32,6 @@
|
||||
############################################################################
|
||||
|
||||
add_library(drivers_board
|
||||
sitl_led.c
|
||||
board_config.h
|
||||
init.c
|
||||
)
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
/**
|
||||
* @file board_config.h
|
||||
*
|
||||
* SITL internal definitions
|
||||
* EAGLE internal definitions
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
@@ -45,17 +45,17 @@
|
||||
#define BOARD_HAS_NO_RESET
|
||||
#define BOARD_HAS_NO_BOOTLOADER
|
||||
|
||||
#define BOARD_NUMBER_BRICKS 0
|
||||
|
||||
/*
|
||||
* I2C busses
|
||||
*/
|
||||
#define PX4_I2C_BUS_ESC 1
|
||||
#define PX4_SIM_BUS_TEST 2
|
||||
#define PX4_I2C_BUS_EXPANSION 3
|
||||
#define PX4_I2C_BUS_LED 3
|
||||
#define PX4_I2C_BUS_EXPANSION1 2 // I2C2: J9 / GPS
|
||||
#define PX4_I2C_BUS_EXPANSION 3 // I2C3: J14 / Power
|
||||
#define PX4_I2C_BUS_EXPANSION2 9 // I2C9: J15 / Radio Receiver / Sensors
|
||||
|
||||
#define PX4_NUMBER_I2C_BUSES 3
|
||||
|
||||
#define PX4_I2C_OBDEV_BMP280 0x76
|
||||
|
||||
// SPI
|
||||
#define PX4_SPI_BUS_SENSORS 1
|
||||
#define PX4_SPIDEV_MPU PX4_MK_SPI_SEL(PX4_SPI_BUS_SENSORS, 1)
|
||||
|
||||
0
boards/atlflight/eagle/src/init.c
Normal file
0
boards/atlflight/eagle/src/init.c
Normal file
@@ -1,82 +0,0 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* Copyright (c) 2013 PX4 Development Team. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name PX4 nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/**
|
||||
* @file sitl_led.c
|
||||
*
|
||||
* sitl LED backend.
|
||||
*/
|
||||
|
||||
#include <px4_platform_common/px4_config.h>
|
||||
#include <px4_platform_common/log.h>
|
||||
#include <stdbool.h>
|
||||
#include <systemlib/px4_macros.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
extern void led_init(void);
|
||||
extern void led_on(int led);
|
||||
extern void led_off(int led);
|
||||
extern void led_toggle(int led);
|
||||
__END_DECLS
|
||||
|
||||
static bool _led_state[] = { false, false, false, false };
|
||||
|
||||
__EXPORT void led_init()
|
||||
{
|
||||
PX4_DEBUG("LED_INIT");
|
||||
}
|
||||
|
||||
__EXPORT void led_on(int led)
|
||||
{
|
||||
if ((unsigned int)led < arraySize(_led_state)) {
|
||||
PX4_DEBUG("LED%d_ON", led);
|
||||
_led_state[led] = true;
|
||||
}
|
||||
}
|
||||
|
||||
__EXPORT void led_off(int led)
|
||||
{
|
||||
if ((unsigned int)led < arraySize(_led_state)) {
|
||||
PX4_DEBUG("LED%d_OFF", led);
|
||||
_led_state[led] = false;
|
||||
}
|
||||
}
|
||||
|
||||
__EXPORT void led_toggle(int led)
|
||||
{
|
||||
if ((unsigned int)led < arraySize(_led_state)) {
|
||||
_led_state[led] = !_led_state[led];
|
||||
PX4_DEBUG("LED%d_TOGGLE: %s", led, _led_state[led] ? "ON" : "OFF");
|
||||
|
||||
}
|
||||
}
|
||||
@@ -42,9 +42,8 @@ px4_add_board(
|
||||
VENDOR atlflight
|
||||
MODEL excelsior
|
||||
LABEL default
|
||||
TESTING
|
||||
#TESTING
|
||||
TOOLCHAIN arm-oemllib32-linux-gnueabi
|
||||
|
||||
DRIVERS
|
||||
#barometer # all available barometer drivers
|
||||
batt_smbus
|
||||
@@ -53,17 +52,14 @@ px4_add_board(
|
||||
distance_sensor # all available distance sensor drivers
|
||||
gps
|
||||
#imu # all available imu drivers
|
||||
lights/rgbled
|
||||
#lights/rgbled
|
||||
linux_sbus
|
||||
#magnetometer # all available magnetometer drivers
|
||||
pwm_out_sim
|
||||
qshell/posix
|
||||
#telemetry # all available telemetry drivers
|
||||
|
||||
MODULES
|
||||
muorb/krait
|
||||
muorb/test
|
||||
|
||||
airspeed_selector
|
||||
attitude_estimator_q
|
||||
camera_feedback
|
||||
commander
|
||||
@@ -72,7 +68,6 @@ px4_add_board(
|
||||
events
|
||||
fw_att_control
|
||||
fw_pos_control_l1
|
||||
rover_pos_control
|
||||
land_detector
|
||||
landing_target_estimator
|
||||
load_mon
|
||||
@@ -80,17 +75,19 @@ px4_add_board(
|
||||
logger
|
||||
mavlink
|
||||
mc_att_control
|
||||
mc_rate_control
|
||||
mc_pos_control
|
||||
mc_rate_control
|
||||
#micrortps_bridge
|
||||
muorb/krait
|
||||
muorb/test
|
||||
navigator
|
||||
rc_update
|
||||
rover_pos_control
|
||||
sensors
|
||||
sih
|
||||
#sih
|
||||
simulator
|
||||
vmount
|
||||
vtol_att_control
|
||||
airspeed_selector
|
||||
|
||||
SYSTEMCMDS
|
||||
#bl_update
|
||||
#config
|
||||
@@ -100,6 +97,7 @@ px4_add_board(
|
||||
led_control
|
||||
mixer
|
||||
motor_ramp
|
||||
motor_test
|
||||
#mtd
|
||||
#nshterm
|
||||
param
|
||||
@@ -108,19 +106,20 @@ px4_add_board(
|
||||
reboot
|
||||
sd_bench
|
||||
shutdown
|
||||
tests # tests and test runner
|
||||
#tests # tests and test runner
|
||||
top
|
||||
topic_listener
|
||||
tune_control
|
||||
ver
|
||||
work_queue
|
||||
|
||||
EXAMPLES
|
||||
bottle_drop # OBC challenge
|
||||
fixedwing_control # Tutorial code from https://px4.io/dev/example_fixedwing_control
|
||||
hello
|
||||
#bottle_drop # OBC challenge
|
||||
#fixedwing_control # Tutorial code from https://px4.io/dev/example_fixedwing_control
|
||||
#hello
|
||||
#hwtest # Hardware test
|
||||
px4_mavlink_debug # Tutorial code from http://dev.px4.io/en/debug/debug_values.html
|
||||
px4_simple_app # Tutorial code from http://dev.px4.io/en/apps/hello_sky.html
|
||||
rover_steering_control # Rover example app
|
||||
#matlab_csv_serial
|
||||
#px4_mavlink_debug # Tutorial code from http://dev.px4.io/en/debug/debug_values.html
|
||||
#px4_simple_app # Tutorial code from http://dev.px4.io/en/apps/hello_sky.html
|
||||
#rover_steering_control # Rover example app
|
||||
#uuv_example_app
|
||||
)
|
||||
|
||||
@@ -43,45 +43,48 @@ px4_add_board(
|
||||
VENDOR atlflight
|
||||
MODEL excelsior
|
||||
LABEL qurt-default
|
||||
|
||||
DRIVERS
|
||||
barometer/bmp280
|
||||
gps
|
||||
imu/mpu9250
|
||||
spektrum_rc
|
||||
magnetometer/hmc5883
|
||||
qshell/qurt
|
||||
snapdragon_pwm_out
|
||||
|
||||
spektrum_rc
|
||||
DF_DRIVERS
|
||||
mpu9250
|
||||
bmp280
|
||||
hmc5883
|
||||
trone
|
||||
isl29501
|
||||
ltc2946
|
||||
|
||||
mpu9250
|
||||
trone
|
||||
MODULES
|
||||
muorb/adsp
|
||||
|
||||
airspeed_selector
|
||||
attitude_estimator_q
|
||||
commander
|
||||
ekf2
|
||||
fw_att_control
|
||||
fw_pos_control_l1
|
||||
rover_pos_control
|
||||
land_detector
|
||||
landing_target_estimator
|
||||
local_position_estimator
|
||||
mc_att_control
|
||||
mc_rate_control
|
||||
mc_pos_control
|
||||
mc_rate_control
|
||||
muorb/adsp
|
||||
rc_update
|
||||
rover_pos_control
|
||||
sensors
|
||||
sih
|
||||
vmount
|
||||
vtol_att_control
|
||||
airspeed_selector
|
||||
|
||||
SYSTEMCMDS
|
||||
led_control
|
||||
mixer
|
||||
#motor_ramp
|
||||
motor_test
|
||||
param
|
||||
perf
|
||||
#pwm
|
||||
#topic_listener
|
||||
ver
|
||||
work_queue
|
||||
)
|
||||
|
||||
@@ -31,5 +31,7 @@
|
||||
#
|
||||
############################################################################
|
||||
|
||||
px4_add_library(drivers__ledsim led.cpp)
|
||||
target_link_libraries(drivers__ledsim PRIVATE drivers__led)
|
||||
add_library(drivers_board
|
||||
board_config.h
|
||||
init.c
|
||||
)
|
||||
@@ -39,9 +39,26 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#define BOARD_BATTERY1_V_DIV (10.177939394f)
|
||||
#define BOARD_BATTERY1_A_PER_V (15.391030303f)
|
||||
#define BOARD_OVERRIDE_UUID "EAGLEID000000000" // must be of length 16
|
||||
#define PX4_SOC_ARCH_ID PX4_SOC_ARCH_ID_EAGLE
|
||||
|
||||
#define BOARD_HAS_NO_RESET
|
||||
|
||||
#define BOARD_HAS_NO_BOOTLOADER
|
||||
|
||||
/*
|
||||
* I2C busses
|
||||
*/
|
||||
#define PX4_I2C_BUS_EXPANSION1 2 // I2C2: J9 / GPS
|
||||
#define PX4_I2C_BUS_EXPANSION 3 // I2C3: J14 / Power
|
||||
#define PX4_I2C_BUS_EXPANSION2 9 // I2C9: J15 / Radio Receiver / Sensors
|
||||
|
||||
#define PX4_NUMBER_I2C_BUSES 3
|
||||
|
||||
#define PX4_I2C_OBDEV_BMP280 0x76
|
||||
|
||||
// SPI
|
||||
#define PX4_SPI_BUS_SENSORS 1
|
||||
#define PX4_SPIDEV_MPU PX4_MK_SPI_SEL(PX4_SPI_BUS_SENSORS, 1)
|
||||
|
||||
#include <system_config.h>
|
||||
#include <px4_platform_common/board_common.h>
|
||||
|
||||
0
boards/atlflight/excelsior/src/init.c
Normal file
0
boards/atlflight/excelsior/src/init.c
Normal file
@@ -25,7 +25,6 @@ px4_add_board(
|
||||
pwm_out_sim
|
||||
#telemetry # all available telemetry drivers
|
||||
DF_DRIVERS # NOTE: DriverFramework is migrating to intree PX4 drivers
|
||||
bmp280
|
||||
mpu9250
|
||||
MODULES
|
||||
airspeed_selector
|
||||
|
||||
@@ -23,7 +23,6 @@ px4_add_board(
|
||||
pwm_out_sim
|
||||
#telemetry # all available telemetry drivers
|
||||
DF_DRIVERS # NOTE: DriverFramework is migrating to intree PX4 drivers
|
||||
bmp280
|
||||
mpu9250
|
||||
MODULES
|
||||
airspeed_selector
|
||||
|
||||
@@ -60,8 +60,13 @@
|
||||
/*
|
||||
* I2C busses
|
||||
*/
|
||||
#define PX4_I2C_BUS_EXPANSION 1
|
||||
#define PX4_NUMBER_I2C_BUSES 1
|
||||
#define PX4_I2C_BUS_EXPANSION 1 // i2c-1: pins P9 17,18
|
||||
#define PX4_I2C_BUS_ONBOARD 2 // i2c-2: pins P9 19,20 - bmp280, mpu9250
|
||||
|
||||
#define PX4_NUMBER_I2C_BUSES 2
|
||||
|
||||
#define PX4_I2C_OBDEV_MPU9250 0x68
|
||||
#define PX4_I2C_OBDEV_BMP280 0x76
|
||||
|
||||
#include <system_config.h>
|
||||
#include <px4_platform_common/board_common.h>
|
||||
@@ -82,8 +87,6 @@ void rc_cleaning(void);
|
||||
#define rc_i2c_unlock_bus rc_i2c_release_bus
|
||||
#define rc_i2c_get_lock rc_i2c_get_in_use_state
|
||||
|
||||
#define rc_bmp_init rc_initialize_barometer
|
||||
|
||||
#define rc_adc_read_raw rc_adc_raw
|
||||
|
||||
#define rc_servo_send_pulse_us rc_send_servo_pulse_us
|
||||
@@ -94,25 +97,6 @@ void rc_cleaning(void);
|
||||
#define rc_filter_prefill_outputs rc_prefill_filter_outputs
|
||||
#define rc_filter_butterworth_lowpass rc_butterworth_lowpass
|
||||
|
||||
/**
|
||||
* struct to hold the data retreived during one read of the barometer.
|
||||
*/
|
||||
typedef struct rc_bmp_data_t {
|
||||
float temp_c; ///< temperature in degrees celcius
|
||||
float alt_m; ///< altitude in meters
|
||||
float pressure_pa; ///< current pressure in pascals
|
||||
} rc_bmp_data_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
int rc_bmp_read(rc_bmp_data_t *data);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#endif // BOARD_CONFIG_H
|
||||
|
||||
@@ -138,17 +138,3 @@ void rc_cleaning(void)
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
#ifdef __RC_V0_3
|
||||
int rc_bmp_read(rc_bmp_data_t *data)
|
||||
{
|
||||
int rtn = rc_read_barometer();
|
||||
|
||||
data->temp_c = rc_bmp_get_temperature();
|
||||
data->alt_m = rc_bmp_get_altitude_m();
|
||||
data->pressure_pa = rc_bmp_get_pressure_pa();
|
||||
|
||||
return rtn;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -110,7 +110,6 @@ endif()
|
||||
if ("${PX4_BOARD}" MATCHES "beaglebone_blue")
|
||||
target_link_libraries(px4 PRIVATE robotics_cape)
|
||||
add_dependencies(df_driver_framework librobotcontrol)
|
||||
add_dependencies(df_bmp280 librobotcontrol)
|
||||
add_dependencies(df_mpu9250 librobotcontrol)
|
||||
|
||||
elseif ("${PX4_BOARD}" MATCHES "sitl")
|
||||
|
||||
@@ -304,7 +304,6 @@ function(px4_os_add_flags)
|
||||
# For DriverFramework
|
||||
-D__DF_LINUX
|
||||
-D__DF_BBBLUE
|
||||
-D__DF_BBBLUE_USE_RC_BMP280_IMP # optional
|
||||
|
||||
-DRC_AUTOPILOT_EXT # Enable extensions in Robotics Cape Library, TODO: remove
|
||||
)
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
/*
|
||||
* I2C busses
|
||||
*/
|
||||
#define PX4_I2C_BUS_ESC 1
|
||||
#define PX4_I2C_BUS_EXPANSION 3
|
||||
#define PX4_I2C_BUS_LED 3
|
||||
|
||||
#define BOARD_OVERRIDE_UUID "SYSTEMID0000 " // must be of length 16
|
||||
#define PX4_SOC_ARCH_ID PX4_SOC_ARCH_ID_QURT
|
||||
|
||||
#define BOARD_HAS_NO_RESET
|
||||
#define BOARD_HAS_NO_BOOTLOADER
|
||||
|
||||
#include <px4_platform_common/board_common.h>
|
||||
@@ -51,7 +51,7 @@ param set BAT_V_DIV 11.0
|
||||
|
||||
dataman start
|
||||
|
||||
df_bmp280_wrapper start -D /dev/i2c-2
|
||||
bmp280 -I start
|
||||
|
||||
df_mpu9250_wrapper start
|
||||
# options: -R rotation
|
||||
|
||||
@@ -51,7 +51,7 @@ param set BAT_V_DIV 11.0
|
||||
|
||||
dataman start
|
||||
|
||||
df_bmp280_wrapper start -D /dev/i2c-2
|
||||
bmp280 -I start
|
||||
|
||||
df_mpu9250_wrapper start
|
||||
# options: -R rotation
|
||||
|
||||
@@ -25,7 +25,7 @@ param set UART_ESC_MOTOR3 1
|
||||
param set UART_ESC_MOTOR4 3
|
||||
sleep 1
|
||||
df_mpu9250_wrapper start
|
||||
df_bmp280_wrapper start
|
||||
bmp280 start
|
||||
gps start -d /dev/tty-4
|
||||
rc_update start
|
||||
sensors start
|
||||
|
||||
@@ -25,7 +25,7 @@ param set UART_ESC_MOTOR3 1
|
||||
param set UART_ESC_MOTOR4 3
|
||||
sleep 1
|
||||
df_mpu9250_wrapper start
|
||||
df_bmp280_wrapper start
|
||||
bmp280 start
|
||||
gps start -d /dev/tty-4
|
||||
rc_update start
|
||||
sensors start
|
||||
|
||||
@@ -7,7 +7,7 @@ param set MAV_TYPE 2
|
||||
sleep 1
|
||||
df_hmc5883_wrapper start
|
||||
df_mpu9250_wrapper start_without_mag
|
||||
df_bmp280_wrapper start
|
||||
bmp280 start
|
||||
df_trone_wrapper start
|
||||
#df_ltc2946_wrapper start # (currently not working on all boards...)
|
||||
#df_isl29501_wrapper start
|
||||
|
||||
@@ -172,7 +172,7 @@ fi
|
||||
|
||||
|
||||
qshell df_mpu9250_wrapper start
|
||||
qshell df_bmp280_wrapper start
|
||||
qshell bmp280 start
|
||||
qshell rc_update start
|
||||
qshell sensors start
|
||||
|
||||
|
||||
@@ -73,7 +73,7 @@ param set UART_ESC_MOTOR3 1
|
||||
param set UART_ESC_MOTOR4 3
|
||||
sleep 1
|
||||
df_mpu9250_wrapper start
|
||||
df_bmp280_wrapper start
|
||||
bmp280 start
|
||||
rc_update start
|
||||
sensors start
|
||||
commander start
|
||||
|
||||
@@ -1,45 +0,0 @@
|
||||
############################################################################
|
||||
#
|
||||
# Copyright (c) 2016 PX4 Development Team. All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in
|
||||
# the documentation and/or other materials provided with the
|
||||
# distribution.
|
||||
# 3. Neither the name PX4 nor the names of its contributors may be
|
||||
# used to endorse or promote products derived from this software
|
||||
# without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
############################################################################
|
||||
|
||||
include_directories(../../../lib/DriverFramework/drivers)
|
||||
|
||||
px4_add_module(
|
||||
MODULE platforms__posix__drivers__df_bmp280_wrapper
|
||||
MAIN df_bmp280_wrapper
|
||||
SRCS
|
||||
df_bmp280_wrapper.cpp
|
||||
DEPENDS
|
||||
git_driverframework
|
||||
df_driver_framework
|
||||
df_bmp280
|
||||
)
|
||||
@@ -1,300 +0,0 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* Copyright (c) 2016 PX4 Development Team. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name PX4 nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/**
|
||||
* @file df_bmp280_wrapper.cpp
|
||||
* Lightweight driver to access the BMP280 of the DriverFramework.
|
||||
*
|
||||
* @author Julian Oes <julian@oes.ch>
|
||||
*/
|
||||
|
||||
#include <px4_platform_common/px4_config.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
#include <unistd.h>
|
||||
#include <px4_platform_common/getopt.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <perf/perf_counter.h>
|
||||
#include <systemlib/err.h>
|
||||
|
||||
#include <drivers/drv_hrt.h>
|
||||
#include <drivers/drv_baro.h>
|
||||
|
||||
#include <board_config.h>
|
||||
//#include <mathlib/math/filter/LowPassFilter2p.hpp>
|
||||
|
||||
#include <bmp280/BMP280.hpp>
|
||||
#include <DevMgr.hpp>
|
||||
|
||||
|
||||
extern "C" { __EXPORT int df_bmp280_wrapper_main(int argc, char *argv[]); }
|
||||
|
||||
using namespace DriverFramework;
|
||||
|
||||
|
||||
class DfBmp280Wrapper : public BMP280
|
||||
{
|
||||
public:
|
||||
DfBmp280Wrapper();
|
||||
~DfBmp280Wrapper();
|
||||
|
||||
|
||||
/**
|
||||
* Start automatic measurement.
|
||||
*
|
||||
* @return 0 on success
|
||||
*/
|
||||
int start();
|
||||
|
||||
/**
|
||||
* Stop automatic measurement.
|
||||
*
|
||||
* @return 0 on success
|
||||
*/
|
||||
int stop();
|
||||
|
||||
private:
|
||||
int _publish(struct baro_sensor_data &data);
|
||||
|
||||
orb_advert_t _baro_topic;
|
||||
|
||||
int _baro_orb_class_instance;
|
||||
|
||||
perf_counter_t _baro_sample_perf;
|
||||
|
||||
};
|
||||
|
||||
DfBmp280Wrapper::DfBmp280Wrapper() :
|
||||
BMP280(BARO_DEVICE_PATH),
|
||||
_baro_topic(nullptr),
|
||||
_baro_orb_class_instance(-1),
|
||||
_baro_sample_perf(perf_alloc(PC_ELAPSED, "df_baro_read"))
|
||||
{
|
||||
}
|
||||
|
||||
DfBmp280Wrapper::~DfBmp280Wrapper()
|
||||
{
|
||||
perf_free(_baro_sample_perf);
|
||||
}
|
||||
|
||||
int DfBmp280Wrapper::start()
|
||||
{
|
||||
/* Init device and start sensor. */
|
||||
int ret = init();
|
||||
|
||||
if (ret != 0) {
|
||||
PX4_ERR("BMP280 init fail: %d", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = BMP280::start();
|
||||
|
||||
if (ret != 0) {
|
||||
PX4_ERR("BMP280 start fail: %d", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
#if defined(__DF_BBBLUE)
|
||||
PX4_INFO("BMP280 started");
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int DfBmp280Wrapper::stop()
|
||||
{
|
||||
/* Stop sensor. */
|
||||
int ret = BMP280::stop();
|
||||
|
||||
if (ret != 0) {
|
||||
PX4_ERR("BMP280 stop fail: %d", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int DfBmp280Wrapper::_publish(struct baro_sensor_data &data)
|
||||
{
|
||||
perf_begin(_baro_sample_perf);
|
||||
|
||||
sensor_baro_s baro_report = {};
|
||||
baro_report.timestamp = hrt_absolute_time();
|
||||
baro_report.error_count = data.error_counter;
|
||||
|
||||
baro_report.pressure = data.pressure_pa / 100.0f; // to mbar
|
||||
baro_report.temperature = data.temperature_c;
|
||||
|
||||
// TODO: when is this ever blocked?
|
||||
if (!(m_pub_blocked)) {
|
||||
|
||||
if (_baro_topic == nullptr) {
|
||||
_baro_topic = orb_advertise_multi(ORB_ID(sensor_baro), &baro_report,
|
||||
&_baro_orb_class_instance, ORB_PRIO_DEFAULT);
|
||||
|
||||
} else {
|
||||
orb_publish(ORB_ID(sensor_baro), _baro_topic, &baro_report);
|
||||
}
|
||||
}
|
||||
|
||||
perf_end(_baro_sample_perf);
|
||||
|
||||
return 0;
|
||||
};
|
||||
|
||||
|
||||
namespace df_bmp280_wrapper
|
||||
{
|
||||
|
||||
DfBmp280Wrapper *g_dev = nullptr;
|
||||
|
||||
int start(/* enum Rotation rotation */);
|
||||
int stop();
|
||||
int info();
|
||||
void usage();
|
||||
|
||||
int start(/*enum Rotation rotation*/)
|
||||
{
|
||||
g_dev = new DfBmp280Wrapper(/*rotation*/);
|
||||
|
||||
if (g_dev == nullptr) {
|
||||
PX4_ERR("failed instantiating DfBmp280Wrapper object");
|
||||
return -1;
|
||||
}
|
||||
|
||||
int ret = g_dev->start();
|
||||
|
||||
if (ret != 0) {
|
||||
PX4_ERR("DfBmp280Wrapper start failed");
|
||||
return ret;
|
||||
}
|
||||
|
||||
// Open the IMU sensor
|
||||
DevHandle h;
|
||||
DevMgr::getHandle(BARO_DEVICE_PATH, h);
|
||||
|
||||
if (!h.isValid()) {
|
||||
DF_LOG_INFO("Error: unable to obtain a valid handle for the receiver at: %s (%d)",
|
||||
BARO_DEVICE_PATH, h.getError());
|
||||
return -1;
|
||||
}
|
||||
|
||||
DevMgr::releaseHandle(h);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int stop()
|
||||
{
|
||||
if (g_dev == nullptr) {
|
||||
PX4_ERR("driver not running");
|
||||
return 1;
|
||||
}
|
||||
|
||||
int ret = g_dev->stop();
|
||||
|
||||
if (ret != 0) {
|
||||
PX4_ERR("driver could not be stopped");
|
||||
return ret;
|
||||
}
|
||||
|
||||
delete g_dev;
|
||||
g_dev = nullptr;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Print a little info about the driver.
|
||||
*/
|
||||
int
|
||||
info()
|
||||
{
|
||||
if (g_dev == nullptr) {
|
||||
PX4_ERR("driver not running");
|
||||
return 1;
|
||||
}
|
||||
|
||||
PX4_DEBUG("state @ %p", g_dev);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
usage()
|
||||
{
|
||||
PX4_WARN("Usage: df_bmp280_wrapper 'start', 'info', 'stop'");
|
||||
}
|
||||
|
||||
} // namespace df_bmp280_wrapper
|
||||
|
||||
|
||||
int
|
||||
df_bmp280_wrapper_main(int argc, char *argv[])
|
||||
{
|
||||
int ret = 0;
|
||||
int myoptind = 1;
|
||||
|
||||
if (argc <= 1) {
|
||||
df_bmp280_wrapper::usage();
|
||||
return 1;
|
||||
}
|
||||
|
||||
const char *verb = argv[myoptind];
|
||||
|
||||
|
||||
if (!strcmp(verb, "start")) {
|
||||
ret = df_bmp280_wrapper::start();
|
||||
}
|
||||
|
||||
else if (!strcmp(verb, "stop")) {
|
||||
ret = df_bmp280_wrapper::stop();
|
||||
}
|
||||
|
||||
else if (!strcmp(verb, "info")) {
|
||||
ret = df_bmp280_wrapper::info();
|
||||
}
|
||||
|
||||
else {
|
||||
df_bmp280_wrapper::usage();
|
||||
return 1;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* Copyright (c) 2012-2017 PX4 Development Team. All rights reserved.
|
||||
* Copyright (c) 2012-2020 PX4 Development Team. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
@@ -62,17 +62,20 @@
|
||||
#define DRV_MAG_DEVTYPE_QMC5883 0x08
|
||||
#define DRV_MAG_DEVTYPE_AK09916 0x09
|
||||
#define DRV_DEVTYPE_ICM20948 0x0A
|
||||
|
||||
#define DRV_ACC_DEVTYPE_LSM303D 0x11
|
||||
#define DRV_ACC_DEVTYPE_BMA180 0x12
|
||||
#define DRV_ACC_DEVTYPE_MPU6000 0x13
|
||||
#define DRV_ACC_DEVTYPE_ACCELSIM 0x14
|
||||
#define DRV_ACC_DEVTYPE_MPU9250 0x16
|
||||
#define DRV_ACC_DEVTYPE_BMI160 0x17
|
||||
|
||||
#define DRV_GYR_DEVTYPE_MPU6000 0x21
|
||||
#define DRV_GYR_DEVTYPE_L3GD20 0x22
|
||||
#define DRV_GYR_DEVTYPE_GYROSIM 0x23
|
||||
#define DRV_GYR_DEVTYPE_MPU9250 0x24
|
||||
#define DRV_GYR_DEVTYPE_BMI160 0x25
|
||||
|
||||
#define DRV_RNG_DEVTYPE_MB12XX 0x31
|
||||
#define DRV_RNG_DEVTYPE_LL40LS 0x32
|
||||
#define DRV_ACC_DEVTYPE_MPU6050 0x33
|
||||
@@ -92,12 +95,13 @@
|
||||
#define DRV_ACC_DEVTYPE_BMI055 0x41
|
||||
#define DRV_GYR_DEVTYPE_BMI055 0x42
|
||||
#define DRV_MAG_DEVTYPE_BMM150 0x43
|
||||
#define DRV_BARO_DEVTYPE_BMP285 0x44
|
||||
|
||||
#define DRV_DIFF_PRESS_DEVTYPE_ETS3 0x45
|
||||
#define DRV_DIFF_PRESS_DEVTYPE_MS4525 0x46
|
||||
#define DRV_DIFF_PRESS_DEVTYPE_MS5525 0x47
|
||||
#define DRV_DIFF_PRESS_DEVTYPE_SDP31 0x48
|
||||
#define DRV_DIFF_PRESS_DEVTYPE_SDP32 0x49
|
||||
|
||||
#define DRV_DIFF_PRESS_DEVTYPE_SDP33 0x50
|
||||
#define DRV_BARO_DEVTYPE_MPL3115A2 0x51
|
||||
#define DRV_ACC_DEVTYPE_FXOS8701C 0x52
|
||||
@@ -108,6 +112,7 @@
|
||||
#define DRV_GYR_DEVTYPE_ADIS16448 0x57
|
||||
#define DRV_BARO_DEVTYPE_LPS22HB 0x58
|
||||
#define DRV_ACC_DEVTYPE_ADIS16477 0x59
|
||||
|
||||
#define DRV_GYR_DEVTYPE_ADIS16477 0x60
|
||||
#define DRV_ACC_DEVTYPE_LSM303AGR 0x61
|
||||
#define DRV_MAG_DEVTYPE_LSM303AGR 0x62
|
||||
|
||||
@@ -487,9 +487,6 @@ start(int argc, char *argv[])
|
||||
while (1) {
|
||||
const int busses_to_try[] = {
|
||||
PX4_I2C_BUS_EXPANSION,
|
||||
#ifdef PX4_I2C_BUS_ESC
|
||||
PX4_I2C_BUS_ESC,
|
||||
#endif
|
||||
#ifdef PX4_I2C_BUS_ONBOARD
|
||||
PX4_I2C_BUS_ONBOARD,
|
||||
#endif
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* Copyright (c) 2012-2015 PX4 Development Team. All rights reserved.
|
||||
* Copyright (c) 2012-2020 PX4 Development Team. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
@@ -32,7 +32,7 @@
|
||||
****************************************************************************/
|
||||
|
||||
/**
|
||||
* @file i2c.cpp
|
||||
* @file I2C.cpp
|
||||
*
|
||||
* Base class for devices attached via the I2C bus.
|
||||
*
|
||||
@@ -42,6 +42,8 @@
|
||||
|
||||
#include "I2C.hpp"
|
||||
|
||||
#include <nuttx/i2c/i2c_master.h>
|
||||
|
||||
namespace device
|
||||
{
|
||||
/*
|
||||
@@ -169,19 +171,19 @@ out:
|
||||
int
|
||||
I2C::transfer(const uint8_t *send, const unsigned send_len, uint8_t *recv, const unsigned recv_len)
|
||||
{
|
||||
px4_i2c_msg_t msgv[2];
|
||||
unsigned msgs;
|
||||
int ret = PX4_ERROR;
|
||||
unsigned retry_count = 0;
|
||||
|
||||
if (_dev == nullptr) {
|
||||
PX4_ERR("I2C device not opened");
|
||||
return 1;
|
||||
return PX4_ERROR;
|
||||
}
|
||||
|
||||
do {
|
||||
DEVICE_DEBUG("transfer out %p/%u in %p/%u", send, send_len, recv, recv_len);
|
||||
msgs = 0;
|
||||
|
||||
px4_i2c_msg_t msgv[2] {};
|
||||
unsigned msgs = 0;
|
||||
|
||||
if (send_len > 0) {
|
||||
msgv[msgs].frequency = _bus_clocks[get_device_bus() - 1];
|
||||
@@ -205,10 +207,15 @@ I2C::transfer(const uint8_t *send, const unsigned send_len, uint8_t *recv, const
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
ret = I2C_TRANSFER(_dev, &msgv[0], msgs);
|
||||
int ret_transfer = I2C_TRANSFER(_dev, &msgv[0], msgs);
|
||||
|
||||
/* success */
|
||||
if (ret == PX4_OK) {
|
||||
if (ret_transfer != 0) {
|
||||
DEVICE_DEBUG("I2C transfer failed, result %d", ret_transfer);
|
||||
ret = PX4_ERROR;
|
||||
|
||||
} else {
|
||||
// success
|
||||
ret = PX4_OK;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* Copyright (c) 2012-2019 PX4 Development Team. All rights reserved.
|
||||
* Copyright (c) 2016-2020 PX4 Development Team. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
@@ -32,7 +32,7 @@
|
||||
****************************************************************************/
|
||||
|
||||
/**
|
||||
* @file i2c.cpp
|
||||
* @file I2C.cpp
|
||||
*
|
||||
* Base class for devices attached via the I2C bus.
|
||||
*
|
||||
@@ -109,6 +109,7 @@ out:
|
||||
|
||||
if ((ret != OK) && !(_fd < 0)) {
|
||||
::close(_fd);
|
||||
_fd = -1;
|
||||
}
|
||||
|
||||
return ret;
|
||||
@@ -117,19 +118,19 @@ out:
|
||||
int
|
||||
I2C::transfer(const uint8_t *send, const unsigned send_len, uint8_t *recv, const unsigned recv_len)
|
||||
{
|
||||
struct i2c_msg msgv[2];
|
||||
unsigned msgs;
|
||||
int ret = PX4_ERROR;
|
||||
unsigned retry_count = 0;
|
||||
|
||||
if (_fd < 0) {
|
||||
PX4_ERR("I2C device not opened");
|
||||
return 1;
|
||||
return PX4_ERROR;
|
||||
}
|
||||
|
||||
do {
|
||||
DEVICE_DEBUG("transfer out %p/%u in %p/%u", send, send_len, recv, recv_len);
|
||||
msgs = 0;
|
||||
|
||||
unsigned msgs = 0;
|
||||
struct i2c_msg msgv[2] {};
|
||||
|
||||
if (send_len > 0) {
|
||||
msgv[msgs].addr = get_device_address();
|
||||
@@ -151,24 +152,19 @@ I2C::transfer(const uint8_t *send, const unsigned send_len, uint8_t *recv, const
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
struct i2c_rdwr_ioctl_data packets;
|
||||
|
||||
i2c_rdwr_ioctl_data packets{};
|
||||
packets.msgs = msgv;
|
||||
|
||||
packets.nmsgs = msgs;
|
||||
|
||||
ret = ::ioctl(_fd, I2C_RDWR, (unsigned long)&packets);
|
||||
int ret_ioctl = ::ioctl(_fd, I2C_RDWR, (unsigned long)&packets);
|
||||
|
||||
if (ret == -1) {
|
||||
if (ret_ioctl == -1) {
|
||||
DEVICE_DEBUG("I2C transfer failed");
|
||||
ret = PX4_ERROR;
|
||||
|
||||
} else {
|
||||
// success
|
||||
ret = PX4_OK;
|
||||
}
|
||||
|
||||
/* success */
|
||||
if (ret == PX4_OK) {
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* Copyright (C) 2012 PX4 Development Team. All rights reserved.
|
||||
* Copyright (C) 2016-2020 PX4 Development Team. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
@@ -32,7 +32,7 @@
|
||||
****************************************************************************/
|
||||
|
||||
/**
|
||||
* @file i2c.h
|
||||
* @file I2C.hpp
|
||||
*
|
||||
* Base class for devices connected via I2C.
|
||||
*/
|
||||
@@ -44,11 +44,6 @@
|
||||
|
||||
#include <px4_platform_common/i2c.h>
|
||||
|
||||
#ifdef __PX4_LINUX
|
||||
#include <linux/i2c.h>
|
||||
#include <linux/i2c-dev.h>
|
||||
#endif
|
||||
|
||||
namespace device __EXPORT
|
||||
{
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* Copyright (c) 2012-2015 PX4 Development Team. All rights reserved.
|
||||
* Copyright (c) 2016-2020 PX4 Development Team. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
@@ -32,7 +32,7 @@
|
||||
****************************************************************************/
|
||||
|
||||
/**
|
||||
* @file i2c.cpp
|
||||
* @file I2C.cpp
|
||||
*
|
||||
* Base class for devices attached via the I2C bus.
|
||||
*
|
||||
@@ -42,13 +42,14 @@
|
||||
|
||||
#include "I2C.hpp"
|
||||
|
||||
#include "dev_fs_lib_i2c.h"
|
||||
#include <dev_fs_lib_i2c.h>
|
||||
|
||||
namespace device
|
||||
{
|
||||
|
||||
I2C::I2C(const char *name, const char *devname, const int bus, const uint16_t address, const uint32_t frequency) :
|
||||
CDev(name, devname)
|
||||
CDev(name, devname),
|
||||
_frequency(frequency)
|
||||
{
|
||||
DEVICE_DEBUG("I2C::I2C name = %s devname = %s", name, devname);
|
||||
// fill in _device_id fields for a I2C device
|
||||
@@ -70,26 +71,43 @@ I2C::~I2C()
|
||||
int
|
||||
I2C::init()
|
||||
{
|
||||
// Assume the driver set the desired bus frequency. There is no standard
|
||||
// way to set it from user space.
|
||||
|
||||
// do base class init, which will create device node, etc
|
||||
int ret = CDev::init();
|
||||
|
||||
if (ret != PX4_OK) {
|
||||
DEVICE_DEBUG("CDev::init failed");
|
||||
return ret;
|
||||
}
|
||||
int ret = PX4_ERROR;
|
||||
|
||||
// Open the actual I2C device
|
||||
char dev_path[16];
|
||||
char dev_path[16] {};
|
||||
snprintf(dev_path, sizeof(dev_path), "/dev/iic-%i", get_device_bus());
|
||||
_fd = ::open(dev_path, O_RDWR);
|
||||
|
||||
if (_fd < 0) {
|
||||
PX4_ERR("could not open %s", dev_path);
|
||||
px4_errno = errno;
|
||||
return PX4_ERROR;
|
||||
DEVICE_DEBUG("failed to init I2C");
|
||||
ret = -ENOENT;
|
||||
goto out;
|
||||
}
|
||||
|
||||
// call the probe function to check whether the device is present
|
||||
ret = probe();
|
||||
|
||||
if (ret != OK) {
|
||||
DEVICE_DEBUG("probe failed");
|
||||
goto out;
|
||||
}
|
||||
|
||||
// do base class init, which will create device node, etc
|
||||
ret = CDev::init();
|
||||
|
||||
if (ret != OK) {
|
||||
DEVICE_DEBUG("cdev init failed");
|
||||
goto out;
|
||||
}
|
||||
|
||||
// tell the world where we are
|
||||
DEVICE_LOG("on I2C bus %d at 0x%02x", get_device_bus(), get_device_address());
|
||||
|
||||
out:
|
||||
|
||||
if ((ret != OK) && !(_fd < 0)) {
|
||||
::close(_fd);
|
||||
_fd = -1;
|
||||
}
|
||||
|
||||
return ret;
|
||||
@@ -98,6 +116,28 @@ I2C::init()
|
||||
int
|
||||
I2C::transfer(const uint8_t *send, const unsigned send_len, uint8_t *recv, const unsigned recv_len)
|
||||
{
|
||||
int ret = PX4_ERROR;
|
||||
unsigned retry_count = 0;
|
||||
|
||||
if (_fd < 0) {
|
||||
PX4_ERR("I2C device not opened");
|
||||
return PX4_ERROR;
|
||||
}
|
||||
|
||||
do {
|
||||
DEVICE_DEBUG("transfer out %p/%u in %p/%u", send, send_len, recv, recv_len);
|
||||
|
||||
dspal_i2c_ioctl_slave_config slave_config{};
|
||||
slave_config.slave_address = get_device_address();
|
||||
slave_config.bus_frequency_in_khz = _frequency / 1000;
|
||||
slave_config.byte_transer_timeout_in_usecs = 10000; // 10 ms
|
||||
int ret_config = ::ioctl(_fd, I2C_IOCTL_SLAVE, &slave_config);
|
||||
|
||||
if (ret_config < 0) {
|
||||
DEVICE_DEBUG("Could not set slave config, result: %d", ret_config);
|
||||
}
|
||||
|
||||
|
||||
dspal_i2c_ioctl_combined_write_read ioctl_write_read{};
|
||||
|
||||
ioctl_write_read.write_buf = (uint8_t *)send;
|
||||
@@ -107,12 +147,19 @@ I2C::transfer(const uint8_t *send, const unsigned send_len, uint8_t *recv, const
|
||||
|
||||
int bytes_read = ::ioctl(_fd, I2C_IOCTL_RDWR, &ioctl_write_read);
|
||||
|
||||
if (bytes_read != (ssize_t)recv_len) {
|
||||
PX4_ERR("read register reports a read of %d bytes, but attempted to read %d bytes", bytes_read, recv_len);
|
||||
return -1;
|
||||
if (bytes_read != (int)recv_len) {
|
||||
DEVICE_DEBUG("I2C transfer failed, bytes read %d", bytes_read);
|
||||
ret = PX4_ERROR;
|
||||
|
||||
} else {
|
||||
// success
|
||||
ret = PX4_OK;
|
||||
break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
} while (retry_count++ < _retries);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
} // namespace device
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* Copyright (C) 2012 PX4 Development Team. All rights reserved.
|
||||
* Copyright (C) 2016-2020 PX4 Development Team. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
@@ -32,7 +32,7 @@
|
||||
****************************************************************************/
|
||||
|
||||
/**
|
||||
* @file i2c.h
|
||||
* @file I2C.hpp
|
||||
*
|
||||
* Base class for devices connected via I2C.
|
||||
*/
|
||||
@@ -44,11 +44,6 @@
|
||||
|
||||
#include <px4_platform_common/i2c.h>
|
||||
|
||||
#ifdef __PX4_LINUX
|
||||
#include <linux/i2c.h>
|
||||
#include <linux/i2c-dev.h>
|
||||
#endif
|
||||
|
||||
namespace device __EXPORT
|
||||
{
|
||||
|
||||
@@ -109,6 +104,7 @@ protected:
|
||||
virtual bool external() const override { return px4_i2c_bus_external(_device_id.devid_s.bus); }
|
||||
|
||||
private:
|
||||
uint32_t _frequency{0};
|
||||
int _fd{-1};
|
||||
|
||||
};
|
||||
|
||||
@@ -53,8 +53,6 @@ if (NOT ${PX4_PLATFORM} STREQUAL "qurt")
|
||||
simulator_mavlink.cpp)
|
||||
endif()
|
||||
|
||||
add_subdirectory(ledsim)
|
||||
|
||||
px4_add_module(
|
||||
MODULE modules__simulator
|
||||
MAIN simulator
|
||||
@@ -70,7 +68,6 @@ px4_add_module(
|
||||
git_mavlink_v2
|
||||
battery
|
||||
conversion
|
||||
drivers__ledsim
|
||||
git_ecl
|
||||
ecl_geo
|
||||
drivers_accelerometer
|
||||
|
||||
@@ -1,135 +0,0 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* Copyright (c) 2013 PX4 Development Team. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name PX4 nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/**
|
||||
* @file led.cpp
|
||||
*
|
||||
* LED driver.
|
||||
*/
|
||||
|
||||
#include <px4_platform_common/px4_config.h>
|
||||
#include <drivers/drv_board_led.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "VirtDevObj.hpp"
|
||||
|
||||
using namespace DriverFramework;
|
||||
|
||||
/*
|
||||
* Ideally we'd be able to get these from up_internal.h,
|
||||
* but since we want to be able to disable the NuttX use
|
||||
* of leds for system indication at will and there is no
|
||||
* separate switch, we need to build independent of the
|
||||
* CONFIG_ARCH_LEDS configuration switch.
|
||||
*/
|
||||
__BEGIN_DECLS
|
||||
extern void led_init();
|
||||
extern void led_on(int led);
|
||||
extern void led_off(int led);
|
||||
extern void led_toggle(int led);
|
||||
__END_DECLS
|
||||
|
||||
class LED : public VirtDevObj
|
||||
{
|
||||
public:
|
||||
LED();
|
||||
~LED() override = default;
|
||||
|
||||
int init() override;
|
||||
int devIOCTL(unsigned long cmd, unsigned long arg) override;
|
||||
|
||||
protected:
|
||||
void _measure() override {}
|
||||
};
|
||||
|
||||
LED::LED() :
|
||||
VirtDevObj("led", "/dev/ledsim", LED_BASE_DEVICE_PATH, 0)
|
||||
{
|
||||
// force immediate init/device registration
|
||||
init();
|
||||
}
|
||||
|
||||
int
|
||||
LED::init()
|
||||
{
|
||||
int ret = VirtDevObj::init();
|
||||
|
||||
if (ret == 0) {
|
||||
led_init();
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int
|
||||
LED::devIOCTL(unsigned long cmd, unsigned long arg)
|
||||
{
|
||||
int result = OK;
|
||||
|
||||
switch (cmd) {
|
||||
case LED_ON:
|
||||
led_on(arg);
|
||||
break;
|
||||
|
||||
case LED_OFF:
|
||||
led_off(arg);
|
||||
break;
|
||||
|
||||
case LED_TOGGLE:
|
||||
led_toggle(arg);
|
||||
break;
|
||||
|
||||
|
||||
default:
|
||||
result = VirtDevObj::devIOCTL(cmd, arg);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
namespace
|
||||
{
|
||||
LED *gLED;
|
||||
}
|
||||
|
||||
void
|
||||
drv_led_start(void)
|
||||
{
|
||||
if (gLED == nullptr) {
|
||||
gLED = new LED;
|
||||
|
||||
if (gLED != nullptr) {
|
||||
gLED->init();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -86,8 +86,6 @@ int Simulator::start(int argc, char *argv[])
|
||||
_instance = new Simulator();
|
||||
|
||||
if (_instance) {
|
||||
drv_led_start();
|
||||
|
||||
if (argc == 4 && strcmp(argv[2], "-u") == 0) {
|
||||
_instance->set_ip(InternetProtocol::UDP);
|
||||
_instance->set_port(atoi(argv[3]));
|
||||
|
||||
Reference in New Issue
Block a user