diff --git a/CMakeLists.txt b/CMakeLists.txt index 1446279e150d..a3071a9455fb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -347,6 +347,17 @@ else() px4_find_python_module(jinja2 REQUIRED) endif() +#============================================================================= +# get chip and chip manufacturer +# +px4_os_determine_build_chip() +if(NOT PX4_CHIP_MANUFACTURER) + message(FATAL_ERROR "px4_os_determine_build_chip() needs to set PX4_CHIP_MANUFACTURER") +endif() +if(NOT PX4_CHIP) + message(FATAL_ERROR "px4_os_determine_build_chip() needs to set PX4_CHIP") +endif() + #============================================================================= # build flags # @@ -451,7 +462,8 @@ add_library(parameters_interface INTERFACE) include(px4_add_library) add_subdirectory(src/lib EXCLUDE_FROM_ALL) -add_subdirectory(src/platforms EXCLUDE_FROM_ALL) +add_subdirectory(platforms/${PX4_PLATFORM}/src/px4) +add_subdirectory(platforms EXCLUDE_FROM_ALL) add_subdirectory(src/modules/uORB EXCLUDE_FROM_ALL) # TODO: platform layer add_subdirectory(src/drivers/boards EXCLUDE_FROM_ALL) diff --git a/boards/airmind/mindpx-v2/default.cmake b/boards/airmind/mindpx-v2/default.cmake index 82d7eeb9eea5..d01596976619 100644 --- a/boards/airmind/mindpx-v2/default.cmake +++ b/boards/airmind/mindpx-v2/default.cmake @@ -15,6 +15,7 @@ px4_add_board( TEL2:/dev/ttyS2 DRIVERS + adc barometer # all available barometer drivers batt_smbus camera_trigger @@ -40,9 +41,6 @@ px4_add_board( pwm_out_sim px4fmu rc_input - stm32 - stm32/adc - stm32/tone_alarm tap_esc telemetry # all available telemetry drivers test_ppm diff --git a/boards/airmind/mindpx-v2/src/timer_config.c b/boards/airmind/mindpx-v2/src/timer_config.c index c93957177e84..6f9b6fee53ac 100644 --- a/boards/airmind/mindpx-v2/src/timer_config.c +++ b/boards/airmind/mindpx-v2/src/timer_config.c @@ -46,7 +46,7 @@ #include #include -#include +#include #include "board_config.h" diff --git a/boards/auav/esc35-v1/default.cmake b/boards/auav/esc35-v1/default.cmake index a5ce12d19682..2c36fae924ad 100644 --- a/boards/auav/esc35-v1/default.cmake +++ b/boards/auav/esc35-v1/default.cmake @@ -45,7 +45,6 @@ px4_add_board( DRIVERS bootloaders - stm32 uavcanesc MODULES diff --git a/boards/auav/x21/default.cmake b/boards/auav/x21/default.cmake index caa3130eb0a5..1c2fc5836bcc 100644 --- a/boards/auav/x21/default.cmake +++ b/boards/auav/x21/default.cmake @@ -16,6 +16,7 @@ px4_add_board( TEL2:/dev/ttyS2 DRIVERS + adc barometer # all available barometer drivers batt_smbus camera_capture @@ -46,9 +47,6 @@ px4_add_board( px4fmu px4io roboclaw - stm32 - stm32/adc - stm32/tone_alarm tap_esc telemetry # all available telemetry drivers test_ppm diff --git a/boards/auav/x21/src/timer_config.c b/boards/auav/x21/src/timer_config.c index 66f375b0a665..6350d7c5e0df 100644 --- a/boards/auav/x21/src/timer_config.c +++ b/boards/auav/x21/src/timer_config.c @@ -46,7 +46,7 @@ #include #include -#include +#include #include "board_config.h" diff --git a/boards/av/x-v1/default.cmake b/boards/av/x-v1/default.cmake index 243d3f3367dc..e17bd74707c5 100644 --- a/boards/av/x-v1/default.cmake +++ b/boards/av/x-v1/default.cmake @@ -18,6 +18,7 @@ px4_add_board( TEL4:/dev/ttyS3 DRIVERS + adc barometer # all available barometer drivers batt_smbus camera_capture @@ -47,9 +48,6 @@ px4_add_board( px4fmu rc_input #roboclaw - stm32 - stm32/adc - #stm32/tone_alarm tap_esc telemetry # all available telemetry drivers test_ppm diff --git a/boards/av/x-v1/src/timer_config.c b/boards/av/x-v1/src/timer_config.c index 50018efeacf2..110e51274789 100644 --- a/boards/av/x-v1/src/timer_config.c +++ b/boards/av/x-v1/src/timer_config.c @@ -46,7 +46,7 @@ #include #include -#include +#include #include "board_config.h" diff --git a/boards/bitcraze/crazyflie/default.cmake b/boards/bitcraze/crazyflie/default.cmake index 95b422b433b7..73a9a8cf1550 100644 --- a/boards/bitcraze/crazyflie/default.cmake +++ b/boards/bitcraze/crazyflie/default.cmake @@ -14,7 +14,6 @@ px4_add_board( imu/mpu9250 optical_flow/pmw3901 px4fmu - stm32 MODULES attitude_estimator_q diff --git a/boards/bitcraze/crazyflie/src/timer_config.c b/boards/bitcraze/crazyflie/src/timer_config.c index feedf26c7bbb..510ca6f5c687 100644 --- a/boards/bitcraze/crazyflie/src/timer_config.c +++ b/boards/bitcraze/crazyflie/src/timer_config.c @@ -48,7 +48,7 @@ #include "board_config.h" #include -#include +#include /* IO Timers normally free-run at 1MHz diff --git a/boards/holybro/kakutef7/default.cmake b/boards/holybro/kakutef7/default.cmake index 393316ea0706..2548c0aa7164 100644 --- a/boards/holybro/kakutef7/default.cmake +++ b/boards/holybro/kakutef7/default.cmake @@ -17,6 +17,7 @@ px4_add_board( # /dev/ttyS5: UART7 (ESC telemetry) DRIVERS + adc barometer/bmp280 gps imu/mpu6000 @@ -25,9 +26,6 @@ px4_add_board( pwm_out_sim px4fmu rc_input - stm32 - stm32/adc - stm32/tone_alarm telemetry tone_alarm osd diff --git a/boards/holybro/kakutef7/src/timer_config.c b/boards/holybro/kakutef7/src/timer_config.c index cb5827af77ee..325d6a160890 100644 --- a/boards/holybro/kakutef7/src/timer_config.c +++ b/boards/holybro/kakutef7/src/timer_config.c @@ -46,7 +46,7 @@ #include #include -#include +#include #include "board_config.h" diff --git a/boards/intel/aerofc-v1/default.cmake b/boards/intel/aerofc-v1/default.cmake index 21c0fdffa95b..bb38e3727e23 100644 --- a/boards/intel/aerofc-v1/default.cmake +++ b/boards/intel/aerofc-v1/default.cmake @@ -27,7 +27,6 @@ px4_add_board( pwm_out_sim px4fmu rc_input - stm32 tap_esc #telemetry # all available telemetry drivers #uavcan diff --git a/boards/intel/aerofc-v1/rtps.cmake b/boards/intel/aerofc-v1/rtps.cmake index 0310c2bc1f62..b78db8514386 100644 --- a/boards/intel/aerofc-v1/rtps.cmake +++ b/boards/intel/aerofc-v1/rtps.cmake @@ -30,7 +30,6 @@ px4_add_board( pwm_out_sim px4fmu rc_input - stm32 tap_esc #telemetry # all available telemetry drivers #uavcan diff --git a/boards/intel/aerofc-v1/src/timer_config.c b/boards/intel/aerofc-v1/src/timer_config.c index b9385b2fbeef..887e5013e97f 100644 --- a/boards/intel/aerofc-v1/src/timer_config.c +++ b/boards/intel/aerofc-v1/src/timer_config.c @@ -47,7 +47,7 @@ #include #include -#include +#include #include "board_config.h" diff --git a/boards/mro/ctrl-zero-f7/default.cmake b/boards/mro/ctrl-zero-f7/default.cmake index 26dfedb27c6e..933aac5ab6c9 100644 --- a/boards/mro/ctrl-zero-f7/default.cmake +++ b/boards/mro/ctrl-zero-f7/default.cmake @@ -19,6 +19,7 @@ px4_add_board( #FRSKY:/dev/ttyS5 DRIVERS + adc #barometer # all available barometer drivers #barometer/dps310 batt_smbus @@ -49,9 +50,6 @@ px4_add_board( rc_input roboclaw safety_button - stm32 - stm32/adc - stm32/tone_alarm tap_esc telemetry # all available telemetry drivers test_ppm diff --git a/boards/mro/ctrl-zero-f7/src/timer_config.c b/boards/mro/ctrl-zero-f7/src/timer_config.c index f092ef9ee10c..bc6a90aed925 100644 --- a/boards/mro/ctrl-zero-f7/src/timer_config.c +++ b/boards/mro/ctrl-zero-f7/src/timer_config.c @@ -46,7 +46,7 @@ #include #include -#include +#include #include "board_config.h" diff --git a/boards/nxp/fmuk66-v3/default.cmake b/boards/nxp/fmuk66-v3/default.cmake index 247087e45566..fce85d888982 100644 --- a/boards/nxp/fmuk66-v3/default.cmake +++ b/boards/nxp/fmuk66-v3/default.cmake @@ -15,6 +15,7 @@ px4_add_board( TEL2:/dev/ttyS1 DRIVERS + adc barometer # all available barometer drivers barometer/mpl3115a2 batt_smbus @@ -30,9 +31,6 @@ px4_add_board( imu/mpu6000 imu/mpu9250 irlock - kinetis - kinetis/adc - kinetis/tone_alarm lights/blinkm lights/oreoled lights/rgbled diff --git a/boards/nxp/fmuk66-v3/src/timer_config.c b/boards/nxp/fmuk66-v3/src/timer_config.c index 3d61c2041e74..67eac5cd51e7 100644 --- a/boards/nxp/fmuk66-v3/src/timer_config.c +++ b/boards/nxp/fmuk66-v3/src/timer_config.c @@ -47,7 +47,7 @@ #include "chip/kinetis_ftm.h" #include -#include +#include #include "board_config.h" diff --git a/boards/omnibus/f4sd/default.cmake b/boards/omnibus/f4sd/default.cmake index c65758e92909..2da984ed7daa 100644 --- a/boards/omnibus/f4sd/default.cmake +++ b/boards/omnibus/f4sd/default.cmake @@ -12,6 +12,7 @@ px4_add_board( URT6:/dev/ttyS2 DRIVERS + adc #barometer # all available barometer drivers barometer/bmp280 #batt_smbus @@ -35,9 +36,6 @@ px4_add_board( #pwm_out_sim px4fmu rc_input - stm32 - stm32/adc - #stm32/tone_alarm #tap_esc #telemetry # all available telemetry drivers telemetry/frsky_telemetry diff --git a/boards/omnibus/f4sd/src/timer_config.c b/boards/omnibus/f4sd/src/timer_config.c index 23783b9b7a0a..615a728522a3 100644 --- a/boards/omnibus/f4sd/src/timer_config.c +++ b/boards/omnibus/f4sd/src/timer_config.c @@ -46,7 +46,7 @@ #include #include -#include +#include #include "board_config.h" diff --git a/boards/px4/cannode-v1/default.cmake b/boards/px4/cannode-v1/default.cmake index 4a08ac97b9b8..8075713e59be 100644 --- a/boards/px4/cannode-v1/default.cmake +++ b/boards/px4/cannode-v1/default.cmake @@ -43,7 +43,6 @@ px4_add_board( DRIVERS bootloaders - stm32 uavcannode MODULES diff --git a/boards/px4/esc-v1/default.cmake b/boards/px4/esc-v1/default.cmake index a466be1648c3..394441bed090 100644 --- a/boards/px4/esc-v1/default.cmake +++ b/boards/px4/esc-v1/default.cmake @@ -45,7 +45,6 @@ px4_add_board( DRIVERS bootloaders - stm32 uavcanesc MODULES diff --git a/boards/px4/fmu-v2/default.cmake b/boards/px4/fmu-v2/default.cmake index b218dcb38f78..f2ba1df675e8 100644 --- a/boards/px4/fmu-v2/default.cmake +++ b/boards/px4/fmu-v2/default.cmake @@ -20,6 +20,7 @@ px4_add_board( TEL4:/dev/ttyS6 DRIVERS + adc #barometer # all available barometer drivers barometer/ms5611 #batt_smbus @@ -55,9 +56,6 @@ px4_add_board( px4fmu px4io #roboclaw - stm32 - stm32/adc - stm32/tone_alarm #tap_esc #telemetry # all available telemetry drivers #test_ppm diff --git a/boards/px4/fmu-v2/fixedwing.cmake b/boards/px4/fmu-v2/fixedwing.cmake index 5af5a9db9a07..49cebe8e351e 100644 --- a/boards/px4/fmu-v2/fixedwing.cmake +++ b/boards/px4/fmu-v2/fixedwing.cmake @@ -18,6 +18,7 @@ px4_add_board( TEL4:/dev/ttyS6 DRIVERS + adc #barometer # all available barometer drivers barometer/ms5611 batt_smbus @@ -35,9 +36,6 @@ px4_add_board( magnetometer/hmc5883 px4fmu px4io - stm32 - stm32/adc - stm32/tone_alarm #telemetry # all available telemetry drivers telemetry/iridiumsbd tone_alarm diff --git a/boards/px4/fmu-v2/lpe.cmake b/boards/px4/fmu-v2/lpe.cmake index 3100902268a3..8c1a55379f80 100644 --- a/boards/px4/fmu-v2/lpe.cmake +++ b/boards/px4/fmu-v2/lpe.cmake @@ -19,6 +19,7 @@ px4_add_board( TEL4:/dev/ttyS6 DRIVERS + adc #barometer # all available barometer drivers barometer/ms5611 #batt_smbus @@ -51,9 +52,6 @@ px4_add_board( pwm_out_sim px4fmu px4io - stm32 - stm32/adc - stm32/tone_alarm #tap_esc #telemetry # all available telemetry drivers #test_ppm diff --git a/boards/px4/fmu-v2/multicopter.cmake b/boards/px4/fmu-v2/multicopter.cmake index 4fb16fdf4ca5..0ddefaed1a89 100644 --- a/boards/px4/fmu-v2/multicopter.cmake +++ b/boards/px4/fmu-v2/multicopter.cmake @@ -19,6 +19,7 @@ px4_add_board( TEL4:/dev/ttyS6 DRIVERS + adc barometer/ms5611 #batt_smbus camera_capture @@ -35,9 +36,6 @@ px4_add_board( optical_flow/px4flow px4fmu px4io - stm32 - stm32/adc - stm32/tone_alarm tone_alarm MODULES diff --git a/boards/px4/fmu-v2/rover.cmake b/boards/px4/fmu-v2/rover.cmake index 36290de0cff4..a355c5bd195d 100644 --- a/boards/px4/fmu-v2/rover.cmake +++ b/boards/px4/fmu-v2/rover.cmake @@ -16,6 +16,7 @@ px4_add_board( TEL4:/dev/ttyS6 DRIVERS + adc barometer/ms5611 batt_smbus camera_capture @@ -31,9 +32,6 @@ px4_add_board( optical_flow/px4flow px4fmu px4io - stm32 - stm32/adc - stm32/tone_alarm tone_alarm MODULES diff --git a/boards/px4/fmu-v2/src/timer_config.c b/boards/px4/fmu-v2/src/timer_config.c index 5adc4260dbc1..492400eb26ae 100644 --- a/boards/px4/fmu-v2/src/timer_config.c +++ b/boards/px4/fmu-v2/src/timer_config.c @@ -46,7 +46,7 @@ #include #include -#include +#include #include "board_config.h" diff --git a/boards/px4/fmu-v2/test.cmake b/boards/px4/fmu-v2/test.cmake index 39b89893c827..0a0258a9cca3 100644 --- a/boards/px4/fmu-v2/test.cmake +++ b/boards/px4/fmu-v2/test.cmake @@ -18,6 +18,7 @@ px4_add_board( TEL4:/dev/ttyS3 DRIVERS + adc #barometer # all available barometer drivers barometer/ms5611 #batt_smbus @@ -51,9 +52,6 @@ px4_add_board( #pwm_out_sim px4fmu px4io - stm32 - stm32/adc - stm32/tone_alarm #tap_esc #telemetry # all available telemetry drivers #test_ppm diff --git a/boards/px4/fmu-v3/default.cmake b/boards/px4/fmu-v3/default.cmake index 05e87e5e9670..b8590f6da9db 100644 --- a/boards/px4/fmu-v3/default.cmake +++ b/boards/px4/fmu-v3/default.cmake @@ -20,6 +20,7 @@ px4_add_board( TEL4:/dev/ttyS6 DRIVERS + adc barometer # all available barometer drivers batt_smbus camera_capture @@ -54,9 +55,6 @@ px4_add_board( px4fmu px4io roboclaw - stm32 - stm32/adc - stm32/tone_alarm tap_esc telemetry # all available telemetry drivers test_ppm diff --git a/boards/px4/fmu-v3/rtps.cmake b/boards/px4/fmu-v3/rtps.cmake index c08515a2985f..a1e90322f75b 100644 --- a/boards/px4/fmu-v3/rtps.cmake +++ b/boards/px4/fmu-v3/rtps.cmake @@ -20,6 +20,7 @@ px4_add_board( TEL4:/dev/ttyS3 DRIVERS + adc barometer # all available barometer drivers batt_smbus camera_capture @@ -53,9 +54,6 @@ px4_add_board( px4fmu px4io roboclaw - stm32 - stm32/adc - stm32/tone_alarm tap_esc telemetry # all available telemetry drivers test_ppm diff --git a/boards/px4/fmu-v3/src/timer_config.c b/boards/px4/fmu-v3/src/timer_config.c index 5adc4260dbc1..492400eb26ae 100644 --- a/boards/px4/fmu-v3/src/timer_config.c +++ b/boards/px4/fmu-v3/src/timer_config.c @@ -46,7 +46,7 @@ #include #include -#include +#include #include "board_config.h" diff --git a/boards/px4/fmu-v3/stackcheck.cmake b/boards/px4/fmu-v3/stackcheck.cmake index 4ff91eb9b0ca..46cb455a8702 100644 --- a/boards/px4/fmu-v3/stackcheck.cmake +++ b/boards/px4/fmu-v3/stackcheck.cmake @@ -20,6 +20,7 @@ px4_add_board( TEL4:/dev/ttyS3 DRIVERS + adc barometer # all available barometer drivers batt_smbus camera_capture @@ -53,9 +54,6 @@ px4_add_board( px4fmu px4io roboclaw - stm32 - stm32/adc - stm32/tone_alarm tap_esc telemetry # all available telemetry drivers test_ppm diff --git a/boards/px4/fmu-v4/default.cmake b/boards/px4/fmu-v4/default.cmake index 04cbea663d7d..af57e810a7d2 100644 --- a/boards/px4/fmu-v4/default.cmake +++ b/boards/px4/fmu-v4/default.cmake @@ -16,6 +16,7 @@ px4_add_board( TEL2:/dev/ttyS2 DRIVERS + adc barometer # all available barometer drivers batt_smbus camera_capture @@ -39,9 +40,6 @@ px4_add_board( px4fmu rc_input safety_button - stm32 - stm32/adc - stm32/tone_alarm tap_esc telemetry # all available telemetry drivers test_ppm diff --git a/boards/px4/fmu-v4/rtps.cmake b/boards/px4/fmu-v4/rtps.cmake index b9c596854035..a8d36810d091 100644 --- a/boards/px4/fmu-v4/rtps.cmake +++ b/boards/px4/fmu-v4/rtps.cmake @@ -16,6 +16,7 @@ px4_add_board( TEL2:/dev/ttyS2 DRIVERS + adc barometer # all available barometer drivers batt_smbus camera_capture @@ -41,9 +42,6 @@ px4_add_board( px4fmu rc_input safety_button - stm32 - stm32/adc - stm32/tone_alarm tap_esc telemetry # all available telemetry drivers test_ppm diff --git a/boards/px4/fmu-v4/src/timer_config.c b/boards/px4/fmu-v4/src/timer_config.c index 25363fd72336..57cd33ec7c25 100644 --- a/boards/px4/fmu-v4/src/timer_config.c +++ b/boards/px4/fmu-v4/src/timer_config.c @@ -46,7 +46,7 @@ #include #include -#include +#include #include "board_config.h" diff --git a/boards/px4/fmu-v4/stackcheck.cmake b/boards/px4/fmu-v4/stackcheck.cmake index 0427e928d54c..8b7180837cfd 100644 --- a/boards/px4/fmu-v4/stackcheck.cmake +++ b/boards/px4/fmu-v4/stackcheck.cmake @@ -16,6 +16,7 @@ px4_add_board( TEL2:/dev/ttyS2 DRIVERS + adc barometer # all available barometer drivers batt_smbus camera_capture @@ -39,9 +40,6 @@ px4_add_board( px4fmu rc_input safety_button - stm32 - stm32/adc - stm32/tone_alarm tap_esc telemetry # all available telemetry drivers test_ppm diff --git a/boards/px4/fmu-v4pro/default.cmake b/boards/px4/fmu-v4pro/default.cmake index e229eb12d690..a46b74cc4886 100644 --- a/boards/px4/fmu-v4pro/default.cmake +++ b/boards/px4/fmu-v4pro/default.cmake @@ -19,6 +19,7 @@ px4_add_board( TEL4:/dev/ttyS6 DRIVERS + adc barometer # all available barometer drivers batt_smbus camera_capture @@ -52,9 +53,6 @@ px4_add_board( px4fmu px4io roboclaw - stm32 - stm32/adc - stm32/tone_alarm tap_esc telemetry # all available telemetry drivers test_ppm diff --git a/boards/px4/fmu-v4pro/rtps.cmake b/boards/px4/fmu-v4pro/rtps.cmake index 0de0625ea61a..ee11cf861907 100644 --- a/boards/px4/fmu-v4pro/rtps.cmake +++ b/boards/px4/fmu-v4pro/rtps.cmake @@ -19,6 +19,7 @@ px4_add_board( TEL4:/dev/ttyS6 DRIVERS + adc barometer # all available barometer drivers batt_smbus camera_trigger @@ -51,9 +52,6 @@ px4_add_board( px4fmu px4io roboclaw - stm32 - stm32/adc - stm32/tone_alarm tap_esc telemetry # all available telemetry drivers test_ppm diff --git a/boards/px4/fmu-v4pro/src/timer_config.c b/boards/px4/fmu-v4pro/src/timer_config.c index c2a778b793de..9947d27daffb 100644 --- a/boards/px4/fmu-v4pro/src/timer_config.c +++ b/boards/px4/fmu-v4pro/src/timer_config.c @@ -46,7 +46,7 @@ #include #include -#include +#include #include "board_config.h" diff --git a/boards/px4/fmu-v5/critmonitor.cmake b/boards/px4/fmu-v5/critmonitor.cmake index 5bb06eee4f4f..93ab6b4b60d7 100644 --- a/boards/px4/fmu-v5/critmonitor.cmake +++ b/boards/px4/fmu-v5/critmonitor.cmake @@ -18,6 +18,7 @@ px4_add_board( TEL4:/dev/ttyS3 DRIVERS + adc barometer # all available barometer drivers batt_smbus camera_capture @@ -53,9 +54,6 @@ px4_add_board( rc_input roboclaw safety_button - stm32 - stm32/adc - stm32/tone_alarm tap_esc telemetry # all available telemetry drivers test_ppm diff --git a/boards/px4/fmu-v5/default.cmake b/boards/px4/fmu-v5/default.cmake index 97b9c79586e5..d87af728011e 100644 --- a/boards/px4/fmu-v5/default.cmake +++ b/boards/px4/fmu-v5/default.cmake @@ -18,6 +18,7 @@ px4_add_board( TEL4:/dev/ttyS3 DRIVERS + adc barometer # all available barometer drivers batt_smbus camera_capture @@ -53,9 +54,6 @@ px4_add_board( rc_input roboclaw safety_button - stm32 - stm32/adc - stm32/tone_alarm tap_esc telemetry # all available telemetry drivers test_ppm diff --git a/boards/px4/fmu-v5/fixedwing.cmake b/boards/px4/fmu-v5/fixedwing.cmake index 7f5fb493f0b1..d4a134f48ea5 100644 --- a/boards/px4/fmu-v5/fixedwing.cmake +++ b/boards/px4/fmu-v5/fixedwing.cmake @@ -17,6 +17,7 @@ px4_add_board( TEL4:/dev/ttyS3 DRIVERS + adc barometer # all available barometer drivers batt_smbus camera_capture @@ -37,9 +38,6 @@ px4_add_board( px4io rc_input safety_button - stm32 - stm32/adc - stm32/tone_alarm telemetry # all available telemetry drivers tone_alarm uavcan diff --git a/boards/px4/fmu-v5/irqmonitor.cmake b/boards/px4/fmu-v5/irqmonitor.cmake index 664d493931fd..0edf3e6db31b 100644 --- a/boards/px4/fmu-v5/irqmonitor.cmake +++ b/boards/px4/fmu-v5/irqmonitor.cmake @@ -18,6 +18,7 @@ px4_add_board( TEL4:/dev/ttyS3 DRIVERS + adc barometer # all available barometer drivers batt_smbus camera_capture @@ -53,9 +54,6 @@ px4_add_board( rc_input roboclaw safety_button - stm32 - stm32/adc - stm32/tone_alarm tap_esc telemetry # all available telemetry drivers test_ppm diff --git a/boards/px4/fmu-v5/multicopter.cmake b/boards/px4/fmu-v5/multicopter.cmake index 6b0bce74ce15..e043e919687d 100644 --- a/boards/px4/fmu-v5/multicopter.cmake +++ b/boards/px4/fmu-v5/multicopter.cmake @@ -18,6 +18,7 @@ px4_add_board( TEL4:/dev/ttyS3 DRIVERS + adc barometer # all available barometer drivers batt_smbus camera_capture @@ -41,9 +42,6 @@ px4_add_board( rc_input roboclaw safety_button - stm32 - stm32/adc - stm32/tone_alarm tap_esc telemetry # all available telemetry drivers tone_alarm diff --git a/boards/px4/fmu-v5/rover.cmake b/boards/px4/fmu-v5/rover.cmake index f72467f4e771..a0645d1bf6b9 100644 --- a/boards/px4/fmu-v5/rover.cmake +++ b/boards/px4/fmu-v5/rover.cmake @@ -17,6 +17,7 @@ px4_add_board( TEL4:/dev/ttyS3 DRIVERS + adc barometer # all available barometer drivers batt_smbus camera_capture @@ -41,9 +42,6 @@ px4_add_board( rc_input roboclaw safety_button - stm32 - stm32/adc - stm32/tone_alarm telemetry # all available telemetry drivers tone_alarm uavcan diff --git a/boards/px4/fmu-v5/rtps.cmake b/boards/px4/fmu-v5/rtps.cmake index 6f337e4c3635..a9e3f2b286f5 100644 --- a/boards/px4/fmu-v5/rtps.cmake +++ b/boards/px4/fmu-v5/rtps.cmake @@ -18,6 +18,7 @@ px4_add_board( TEL4:/dev/ttyS3 DRIVERS + adc barometer # all available barometer drivers batt_smbus camera_capture @@ -51,9 +52,6 @@ px4_add_board( rc_input roboclaw safety_button - stm32 - stm32/adc - stm32/tone_alarm tap_esc telemetry # all available telemetry drivers test_ppm diff --git a/boards/px4/fmu-v5/src/timer_config.c b/boards/px4/fmu-v5/src/timer_config.c index bf4db8f412aa..42a838eef23c 100644 --- a/boards/px4/fmu-v5/src/timer_config.c +++ b/boards/px4/fmu-v5/src/timer_config.c @@ -46,7 +46,7 @@ #include #include -#include +#include #include "board_config.h" diff --git a/boards/px4/fmu-v5/stackcheck.cmake b/boards/px4/fmu-v5/stackcheck.cmake index 1335d2b86312..01aa59128fbd 100644 --- a/boards/px4/fmu-v5/stackcheck.cmake +++ b/boards/px4/fmu-v5/stackcheck.cmake @@ -18,6 +18,7 @@ px4_add_board( TEL4:/dev/ttyS3 DRIVERS + adc barometer # all available barometer drivers batt_smbus camera_capture @@ -51,9 +52,6 @@ px4_add_board( rc_input roboclaw safety_button - stm32 - stm32/adc - stm32/tone_alarm tap_esc telemetry # all available telemetry drivers test_ppm diff --git a/boards/px4/fmu-v5x/default.cmake b/boards/px4/fmu-v5x/default.cmake index 3bab45afd245..86297b21eebf 100644 --- a/boards/px4/fmu-v5x/default.cmake +++ b/boards/px4/fmu-v5x/default.cmake @@ -19,6 +19,7 @@ px4_add_board( GPS2:/dev/ttyS0 DRIVERS + adc barometer # all available barometer drivers batt_smbus camera_capture @@ -53,9 +54,6 @@ px4_add_board( rc_input roboclaw safety_button - stm32 - stm32/adc - stm32/tone_alarm tap_esc telemetry # all available telemetry drivers test_ppm diff --git a/boards/px4/fmu-v5x/fixedwing.cmake b/boards/px4/fmu-v5x/fixedwing.cmake index 436f509c8da3..1609bf73119d 100644 --- a/boards/px4/fmu-v5x/fixedwing.cmake +++ b/boards/px4/fmu-v5x/fixedwing.cmake @@ -18,6 +18,7 @@ px4_add_board( GPS2:/dev/ttyS0 DRIVERS + adc barometer # all available barometer drivers batt_smbus camera_capture @@ -47,9 +48,6 @@ px4_add_board( px4io rc_input safety_button - stm32 - stm32/adc - stm32/tone_alarm telemetry # all available telemetry drivers tone_alarm uavcan diff --git a/boards/px4/fmu-v5x/multicopter.cmake b/boards/px4/fmu-v5x/multicopter.cmake index 46fdec308e90..3607bd0918eb 100644 --- a/boards/px4/fmu-v5x/multicopter.cmake +++ b/boards/px4/fmu-v5x/multicopter.cmake @@ -19,6 +19,7 @@ px4_add_board( GPS2:/dev/ttyS0 DRIVERS + adc barometer # all available barometer drivers batt_smbus camera_capture @@ -48,9 +49,6 @@ px4_add_board( rc_input roboclaw safety_button - stm32 - stm32/adc - stm32/tone_alarm tap_esc telemetry # all available telemetry drivers tone_alarm diff --git a/boards/px4/fmu-v5x/rover.cmake b/boards/px4/fmu-v5x/rover.cmake index dd6a4186c6f9..f620b4a7027c 100644 --- a/boards/px4/fmu-v5x/rover.cmake +++ b/boards/px4/fmu-v5x/rover.cmake @@ -18,6 +18,7 @@ px4_add_board( GPS2:/dev/ttyS0 DRIVERS + adc barometer # all available barometer drivers batt_smbus camera_capture @@ -51,9 +52,6 @@ px4_add_board( rc_input roboclaw safety_button - stm32 - stm32/adc - stm32/tone_alarm telemetry # all available telemetry drivers tone_alarm uavcan diff --git a/boards/px4/fmu-v5x/rtps.cmake b/boards/px4/fmu-v5x/rtps.cmake index f69c8bdc2edf..381b1c1b890c 100644 --- a/boards/px4/fmu-v5x/rtps.cmake +++ b/boards/px4/fmu-v5x/rtps.cmake @@ -19,6 +19,7 @@ px4_add_board( GPS2:/dev/ttyS0 DRIVERS + adc barometer # all available barometer drivers batt_smbus camera_capture @@ -53,9 +54,6 @@ px4_add_board( rc_input roboclaw safety_button - stm32 - stm32/adc - stm32/tone_alarm tap_esc telemetry # all available telemetry drivers test_ppm diff --git a/boards/px4/fmu-v5x/src/timer_config.c b/boards/px4/fmu-v5x/src/timer_config.c index 6d70c8686a98..51f07bbf73c1 100644 --- a/boards/px4/fmu-v5x/src/timer_config.c +++ b/boards/px4/fmu-v5x/src/timer_config.c @@ -46,7 +46,7 @@ #include #include -#include +#include #include "board_config.h" diff --git a/boards/px4/fmu-v5x/stackcheck.cmake b/boards/px4/fmu-v5x/stackcheck.cmake index 8264d38d8d94..5c0b5bc7ccd3 100644 --- a/boards/px4/fmu-v5x/stackcheck.cmake +++ b/boards/px4/fmu-v5x/stackcheck.cmake @@ -19,6 +19,7 @@ px4_add_board( GPS2:/dev/ttyS0 DRIVERS + adc barometer # all available barometer drivers batt_smbus camera_capture @@ -53,9 +54,6 @@ px4_add_board( rc_input roboclaw safety_button - stm32 - stm32/adc - stm32/tone_alarm tap_esc telemetry # all available telemetry drivers test_ppm diff --git a/boards/px4/io-v2/default.cmake b/boards/px4/io-v2/default.cmake index 0dbbf93cfe72..d1144c1bd494 100644 --- a/boards/px4/io-v2/default.cmake +++ b/boards/px4/io-v2/default.cmake @@ -6,7 +6,6 @@ px4_add_board( TOOLCHAIN arm-none-eabi ARCHITECTURE cortex-m3 DRIVERS - stm32 MODULES px4iofirmware ) diff --git a/boards/px4/io-v2/src/timer_config.c b/boards/px4/io-v2/src/timer_config.c index 7d75d4c5b18c..72968008aac7 100644 --- a/boards/px4/io-v2/src/timer_config.c +++ b/boards/px4/io-v2/src/timer_config.c @@ -42,7 +42,7 @@ #include #include -#include +#include #include diff --git a/boards/px4/sitl/default.cmake b/boards/px4/sitl/default.cmake index ed04be10104b..ed7aa3f81e02 100644 --- a/boards/px4/sitl/default.cmake +++ b/boards/px4/sitl/default.cmake @@ -17,7 +17,6 @@ px4_add_board( #magnetometer # all available magnetometer drivers pwm_out_sim #telemetry # all available telemetry drivers - sim/tone_alarm tone_alarm #uavcan diff --git a/boards/px4/sitl/rtps.cmake b/boards/px4/sitl/rtps.cmake index 0832820bcc66..e5437c565d19 100644 --- a/boards/px4/sitl/rtps.cmake +++ b/boards/px4/sitl/rtps.cmake @@ -17,7 +17,6 @@ px4_add_board( #magnetometer # all available magnetometer drivers pwm_out_sim #telemetry # all available telemetry drivers - sim/tone_alarm tone_alarm #uavcan diff --git a/boards/px4/sitl/test.cmake b/boards/px4/sitl/test.cmake index 3fc12e87556d..bb66117394a2 100644 --- a/boards/px4/sitl/test.cmake +++ b/boards/px4/sitl/test.cmake @@ -17,7 +17,6 @@ px4_add_board( #magnetometer # all available magnetometer drivers pwm_out_sim #telemetry # all available telemetry drivers - sim/tone_alarm tone_alarm #uavcan diff --git a/boards/thiemar/s2740vc-v1/default.cmake b/boards/thiemar/s2740vc-v1/default.cmake index 045206334a64..4c2fa67db98a 100644 --- a/boards/thiemar/s2740vc-v1/default.cmake +++ b/boards/thiemar/s2740vc-v1/default.cmake @@ -36,7 +36,6 @@ px4_add_board( DRIVERS bootloaders - stm32 #uavcannode MODULES diff --git a/boards/thiemar/s2740vc-v1/src/CMakeLists.txt b/boards/thiemar/s2740vc-v1/src/CMakeLists.txt index 1f19644ff933..20a1df3f1c12 100644 --- a/boards/thiemar/s2740vc-v1/src/CMakeLists.txt +++ b/boards/thiemar/s2740vc-v1/src/CMakeLists.txt @@ -41,6 +41,6 @@ add_library(drivers_board ) target_link_libraries(drivers_board - PRIVATE - drivers_arch + PRIVATE + px4_layer ) diff --git a/boards/uvify/core/default.cmake b/boards/uvify/core/default.cmake index 6b50d55c88bc..6df30e332d74 100644 --- a/boards/uvify/core/default.cmake +++ b/boards/uvify/core/default.cmake @@ -16,6 +16,7 @@ px4_add_board( TEL2:/dev/ttyS2 DRIVERS + adc #barometer # all available barometer drivers barometer/ms5611 batt_smbus @@ -45,9 +46,6 @@ px4_add_board( pwm_out_sim px4fmu rc_input - stm32 - stm32/adc - stm32/tone_alarm #tap_esc telemetry # all available telemetry drivers #test_ppm diff --git a/boards/uvify/core/src/timer_config.c b/boards/uvify/core/src/timer_config.c index 0d9ff0898c03..f56750432494 100644 --- a/boards/uvify/core/src/timer_config.c +++ b/boards/uvify/core/src/timer_config.c @@ -46,7 +46,7 @@ #include #include -#include +#include #include "board_config.h" diff --git a/cmake/px4_add_board.cmake b/cmake/px4_add_board.cmake index 80d9435034df..0c35b1cb6cc6 100644 --- a/cmake/px4_add_board.cmake +++ b/cmake/px4_add_board.cmake @@ -183,6 +183,9 @@ function(px4_add_board) set(PX4_PLATFORM ${PLATFORM} CACHE STRING "PX4 board OS" FORCE) list(APPEND CMAKE_MODULE_PATH ${PX4_SOURCE_DIR}/platforms/${PX4_PLATFORM}/cmake) + # platform-specific include path + include_directories(${PX4_SOURCE_DIR}/platforms/${PX4_PLATFORM}/src/px4/common/include) + if(ARCHITECTURE) set(CMAKE_SYSTEM_PROCESSOR ${ARCHITECTURE} CACHE INTERNAL "system processor" FORCE) endif() @@ -261,8 +264,8 @@ function(px4_add_board) foreach(driver ${DF_DRIVERS}) list(APPEND config_df_driver_list ${driver}) - if(EXISTS "${PX4_SOURCE_DIR}/src/platforms/posix/drivers/df_${driver}_wrapper") - list(APPEND config_module_list platforms/posix/drivers/df_${driver}_wrapper) + if(EXISTS "${PX4_SOURCE_DIR}/src/drivers/driver_framework_wrapper/df_${driver}_wrapper") + list(APPEND config_module_list drivers/driver_framework_wrapper/df_${driver}_wrapper) endif() endforeach() set(config_df_driver_list ${config_df_driver_list} PARENT_SCOPE) diff --git a/cmake/px4_add_common_flags.cmake b/cmake/px4_add_common_flags.cmake index 032503da388b..a13f6ce47ad1 100644 --- a/cmake/px4_add_common_flags.cmake +++ b/cmake/px4_add_common_flags.cmake @@ -174,6 +174,9 @@ function(px4_add_common_flags) ${PX4_BINARY_DIR}/src/lib ${PX4_BINARY_DIR}/src/modules + ${PX4_SOURCE_DIR}/platforms/${PX4_PLATFORM}/src/px4/${PX4_CHIP_MANUFACTURER}/${PX4_CHIP}/include + ${PX4_SOURCE_DIR}/platforms/${PX4_PLATFORM}/src/px4/common/include + ${PX4_SOURCE_DIR}/platforms/common/include ${PX4_SOURCE_DIR}/src ${PX4_SOURCE_DIR}/src/include ${PX4_SOURCE_DIR}/src/lib @@ -181,7 +184,6 @@ function(px4_add_common_flags) ${PX4_SOURCE_DIR}/src/lib/matrix ${PX4_SOURCE_DIR}/src/modules ${PX4_SOURCE_DIR}/src/platforms - ${PX4_SOURCE_DIR}/src/platforms/common ) add_definitions( diff --git a/cmake/px4_add_library.cmake b/cmake/px4_add_library.cmake index a7290fd4823b..2a6377c71a2d 100644 --- a/cmake/px4_add_library.cmake +++ b/cmake/px4_add_library.cmake @@ -40,7 +40,7 @@ include(px4_base) # Like add_library but with PX4 platform dependencies # function(px4_add_library target) - add_library(${target} ${ARGN}) + add_library(${target} EXCLUDE_FROM_ALL ${ARGN}) target_compile_definitions(${target} PRIVATE MODULE_NAME="${target}") diff --git a/platforms/nuttx/src/CMakeLists.txt b/platforms/CMakeLists.txt similarity index 94% rename from platforms/nuttx/src/CMakeLists.txt rename to platforms/CMakeLists.txt index 602b1b710744..cca36ff6c781 100644 --- a/platforms/nuttx/src/CMakeLists.txt +++ b/platforms/CMakeLists.txt @@ -1,6 +1,6 @@ ############################################################################ # -# Copyright (c) 2017 PX4 Development Team. All rights reserved. +# Copyright (c) 2019 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 @@ -31,4 +31,6 @@ # ############################################################################ -add_subdirectory(px4_layer) +add_subdirectory(common) + + diff --git a/src/platforms/common/CMakeLists.txt b/platforms/common/CMakeLists.txt similarity index 100% rename from src/platforms/common/CMakeLists.txt rename to platforms/common/CMakeLists.txt diff --git a/src/platforms/apps.cpp.in b/platforms/common/apps.cpp.in similarity index 100% rename from src/platforms/apps.cpp.in rename to platforms/common/apps.cpp.in diff --git a/src/platforms/apps.h.in b/platforms/common/apps.h.in similarity index 100% rename from src/platforms/apps.h.in rename to platforms/common/apps.h.in diff --git a/src/platforms/empty.c b/platforms/common/empty.c similarity index 100% rename from src/platforms/empty.c rename to platforms/common/empty.c diff --git a/src/platforms/common/px4_work_queue/ScheduledWorkItem.hpp b/platforms/common/include/px4_platform_common/px4_work_queue/ScheduledWorkItem.hpp similarity index 100% rename from src/platforms/common/px4_work_queue/ScheduledWorkItem.hpp rename to platforms/common/include/px4_platform_common/px4_work_queue/ScheduledWorkItem.hpp diff --git a/src/platforms/common/px4_work_queue/WorkItem.hpp b/platforms/common/include/px4_platform_common/px4_work_queue/WorkItem.hpp similarity index 100% rename from src/platforms/common/px4_work_queue/WorkItem.hpp rename to platforms/common/include/px4_platform_common/px4_work_queue/WorkItem.hpp diff --git a/src/platforms/common/px4_work_queue/WorkQueue.hpp b/platforms/common/include/px4_platform_common/px4_work_queue/WorkQueue.hpp similarity index 100% rename from src/platforms/common/px4_work_queue/WorkQueue.hpp rename to platforms/common/include/px4_platform_common/px4_work_queue/WorkQueue.hpp diff --git a/src/platforms/common/px4_work_queue/WorkQueueManager.hpp b/platforms/common/include/px4_platform_common/px4_work_queue/WorkQueueManager.hpp similarity index 100% rename from src/platforms/common/px4_work_queue/WorkQueueManager.hpp rename to platforms/common/include/px4_platform_common/px4_work_queue/WorkQueueManager.hpp diff --git a/src/platforms/common/module.cpp b/platforms/common/module.cpp similarity index 100% rename from src/platforms/common/module.cpp rename to platforms/common/module.cpp diff --git a/src/platforms/common/px4_cli.cpp b/platforms/common/px4_cli.cpp similarity index 100% rename from src/platforms/common/px4_cli.cpp rename to platforms/common/px4_cli.cpp diff --git a/src/platforms/common/px4_getopt.c b/platforms/common/px4_getopt.c similarity index 100% rename from src/platforms/common/px4_getopt.c rename to platforms/common/px4_getopt.c diff --git a/src/platforms/common/px4_log.c b/platforms/common/px4_log.c similarity index 100% rename from src/platforms/common/px4_log.c rename to platforms/common/px4_log.c diff --git a/src/platforms/common/px4_work_queue/CMakeLists.txt b/platforms/common/px4_work_queue/CMakeLists.txt similarity index 100% rename from src/platforms/common/px4_work_queue/CMakeLists.txt rename to platforms/common/px4_work_queue/CMakeLists.txt diff --git a/src/platforms/common/px4_work_queue/ScheduledWorkItem.cpp b/platforms/common/px4_work_queue/ScheduledWorkItem.cpp similarity index 97% rename from src/platforms/common/px4_work_queue/ScheduledWorkItem.cpp rename to platforms/common/px4_work_queue/ScheduledWorkItem.cpp index d729e241340f..72c45598a77d 100644 --- a/src/platforms/common/px4_work_queue/ScheduledWorkItem.cpp +++ b/platforms/common/px4_work_queue/ScheduledWorkItem.cpp @@ -31,7 +31,7 @@ * ****************************************************************************/ -#include "ScheduledWorkItem.hpp" +#include namespace px4 { diff --git a/src/platforms/common/px4_work_queue/WorkItem.cpp b/platforms/common/px4_work_queue/WorkItem.cpp similarity index 92% rename from src/platforms/common/px4_work_queue/WorkItem.cpp rename to platforms/common/px4_work_queue/WorkItem.cpp index cbf8541b20fb..865df26e50af 100644 --- a/src/platforms/common/px4_work_queue/WorkItem.cpp +++ b/platforms/common/px4_work_queue/WorkItem.cpp @@ -31,10 +31,10 @@ * ****************************************************************************/ -#include "WorkItem.hpp" +#include -#include "WorkQueue.hpp" -#include "WorkQueueManager.hpp" +#include +#include #include #include diff --git a/src/platforms/common/px4_work_queue/WorkQueue.cpp b/platforms/common/px4_work_queue/WorkQueue.cpp similarity index 96% rename from src/platforms/common/px4_work_queue/WorkQueue.cpp rename to platforms/common/px4_work_queue/WorkQueue.cpp index e9fd51be4d42..41641bae180b 100644 --- a/src/platforms/common/px4_work_queue/WorkQueue.cpp +++ b/platforms/common/px4_work_queue/WorkQueue.cpp @@ -31,8 +31,8 @@ * ****************************************************************************/ -#include "WorkQueue.hpp" -#include "WorkItem.hpp" +#include +#include #include diff --git a/src/platforms/common/px4_work_queue/WorkQueueManager.cpp b/platforms/common/px4_work_queue/WorkQueueManager.cpp similarity index 98% rename from src/platforms/common/px4_work_queue/WorkQueueManager.cpp rename to platforms/common/px4_work_queue/WorkQueueManager.cpp index f9d092396f60..db111a7dc8cb 100644 --- a/src/platforms/common/px4_work_queue/WorkQueueManager.cpp +++ b/platforms/common/px4_work_queue/WorkQueueManager.cpp @@ -31,9 +31,9 @@ * ****************************************************************************/ -#include "WorkQueueManager.hpp" +#include -#include "WorkQueue.hpp" +#include #include #include diff --git a/src/platforms/common/px4_work_queue/test/CMakeLists.txt b/platforms/common/px4_work_queue/test/CMakeLists.txt similarity index 100% rename from src/platforms/common/px4_work_queue/test/CMakeLists.txt rename to platforms/common/px4_work_queue/test/CMakeLists.txt diff --git a/src/platforms/common/px4_work_queue/test/wqueue_main.cpp b/platforms/common/px4_work_queue/test/wqueue_main.cpp similarity index 98% rename from src/platforms/common/px4_work_queue/test/wqueue_main.cpp rename to platforms/common/px4_work_queue/test/wqueue_main.cpp index aeb95c622b8b..e2106b9294de 100644 --- a/src/platforms/common/px4_work_queue/test/wqueue_main.cpp +++ b/platforms/common/px4_work_queue/test/wqueue_main.cpp @@ -35,8 +35,8 @@ #include "wqueue_scheduled_test.h" #include -#include #include +#include #include int PX4_MAIN(int argc, char **argv) diff --git a/src/platforms/common/px4_work_queue/test/wqueue_scheduled_test.cpp b/platforms/common/px4_work_queue/test/wqueue_scheduled_test.cpp similarity index 100% rename from src/platforms/common/px4_work_queue/test/wqueue_scheduled_test.cpp rename to platforms/common/px4_work_queue/test/wqueue_scheduled_test.cpp diff --git a/src/platforms/common/px4_work_queue/test/wqueue_scheduled_test.h b/platforms/common/px4_work_queue/test/wqueue_scheduled_test.h similarity index 96% rename from src/platforms/common/px4_work_queue/test/wqueue_scheduled_test.h rename to platforms/common/px4_work_queue/test/wqueue_scheduled_test.h index 538267003325..52ba1c98b25b 100644 --- a/src/platforms/common/px4_work_queue/test/wqueue_scheduled_test.h +++ b/platforms/common/px4_work_queue/test/wqueue_scheduled_test.h @@ -34,7 +34,7 @@ #pragma once #include -#include +#include #include using namespace px4; diff --git a/src/platforms/common/px4_work_queue/test/wqueue_start.cpp b/platforms/common/px4_work_queue/test/wqueue_start.cpp similarity index 100% rename from src/platforms/common/px4_work_queue/test/wqueue_start.cpp rename to platforms/common/px4_work_queue/test/wqueue_start.cpp diff --git a/src/platforms/common/px4_work_queue/test/wqueue_test.cpp b/platforms/common/px4_work_queue/test/wqueue_test.cpp similarity index 100% rename from src/platforms/common/px4_work_queue/test/wqueue_test.cpp rename to platforms/common/px4_work_queue/test/wqueue_test.cpp diff --git a/src/platforms/common/px4_work_queue/test/wqueue_test.h b/platforms/common/px4_work_queue/test/wqueue_test.h similarity index 97% rename from src/platforms/common/px4_work_queue/test/wqueue_test.h rename to platforms/common/px4_work_queue/test/wqueue_test.h index 4935901b7435..573fea900749 100644 --- a/src/platforms/common/px4_work_queue/test/wqueue_test.h +++ b/platforms/common/px4_work_queue/test/wqueue_test.h @@ -34,7 +34,7 @@ #pragma once #include -#include +#include #include using namespace px4; diff --git a/src/platforms/common/shutdown.cpp b/platforms/common/shutdown.cpp similarity index 100% rename from src/platforms/common/shutdown.cpp rename to platforms/common/shutdown.cpp diff --git a/src/platforms/common/work_queue/CMakeLists.txt b/platforms/common/work_queue/CMakeLists.txt similarity index 100% rename from src/platforms/common/work_queue/CMakeLists.txt rename to platforms/common/work_queue/CMakeLists.txt diff --git a/src/platforms/common/work_queue/dq_addlast.c b/platforms/common/work_queue/dq_addlast.c similarity index 100% rename from src/platforms/common/work_queue/dq_addlast.c rename to platforms/common/work_queue/dq_addlast.c diff --git a/src/platforms/common/work_queue/dq_rem.c b/platforms/common/work_queue/dq_rem.c similarity index 100% rename from src/platforms/common/work_queue/dq_rem.c rename to platforms/common/work_queue/dq_rem.c diff --git a/src/platforms/common/work_queue/dq_remfirst.c b/platforms/common/work_queue/dq_remfirst.c similarity index 100% rename from src/platforms/common/work_queue/dq_remfirst.c rename to platforms/common/work_queue/dq_remfirst.c diff --git a/src/platforms/common/work_queue/hrt_queue.c b/platforms/common/work_queue/hrt_queue.c similarity index 100% rename from src/platforms/common/work_queue/hrt_queue.c rename to platforms/common/work_queue/hrt_queue.c diff --git a/src/platforms/common/work_queue/hrt_thread.c b/platforms/common/work_queue/hrt_thread.c similarity index 100% rename from src/platforms/common/work_queue/hrt_thread.c rename to platforms/common/work_queue/hrt_thread.c diff --git a/src/platforms/common/work_queue/hrt_work_cancel.c b/platforms/common/work_queue/hrt_work_cancel.c similarity index 100% rename from src/platforms/common/work_queue/hrt_work_cancel.c rename to platforms/common/work_queue/hrt_work_cancel.c diff --git a/src/platforms/common/work_queue/queue.c b/platforms/common/work_queue/queue.c similarity index 100% rename from src/platforms/common/work_queue/queue.c rename to platforms/common/work_queue/queue.c diff --git a/src/platforms/common/work_queue/sq_addafter.c b/platforms/common/work_queue/sq_addafter.c similarity index 100% rename from src/platforms/common/work_queue/sq_addafter.c rename to platforms/common/work_queue/sq_addafter.c diff --git a/src/platforms/common/work_queue/sq_addlast.c b/platforms/common/work_queue/sq_addlast.c similarity index 100% rename from src/platforms/common/work_queue/sq_addlast.c rename to platforms/common/work_queue/sq_addlast.c diff --git a/src/platforms/common/work_queue/sq_remfirst.c b/platforms/common/work_queue/sq_remfirst.c similarity index 100% rename from src/platforms/common/work_queue/sq_remfirst.c rename to platforms/common/work_queue/sq_remfirst.c diff --git a/src/platforms/common/work_queue/work_cancel.c b/platforms/common/work_queue/work_cancel.c similarity index 100% rename from src/platforms/common/work_queue/work_cancel.c rename to platforms/common/work_queue/work_cancel.c diff --git a/src/platforms/common/work_queue/work_lock.c b/platforms/common/work_queue/work_lock.c similarity index 100% rename from src/platforms/common/work_queue/work_lock.c rename to platforms/common/work_queue/work_lock.c diff --git a/src/platforms/common/work_queue/work_lock.h b/platforms/common/work_queue/work_lock.h similarity index 100% rename from src/platforms/common/work_queue/work_lock.h rename to platforms/common/work_queue/work_lock.h diff --git a/src/platforms/common/work_queue/work_queue.c b/platforms/common/work_queue/work_queue.c similarity index 100% rename from src/platforms/common/work_queue/work_queue.c rename to platforms/common/work_queue/work_queue.c diff --git a/src/platforms/common/work_queue/work_thread.c b/platforms/common/work_queue/work_thread.c similarity index 100% rename from src/platforms/common/work_queue/work_thread.c rename to platforms/common/work_queue/work_thread.c diff --git a/src/platforms/common/work_queue/wqueue_test/CMakeLists.txt b/platforms/common/work_queue/wqueue_test/CMakeLists.txt similarity index 100% rename from src/platforms/common/work_queue/wqueue_test/CMakeLists.txt rename to platforms/common/work_queue/wqueue_test/CMakeLists.txt diff --git a/src/platforms/common/work_queue/wqueue_test/wqueue_main.cpp b/platforms/common/work_queue/wqueue_test/wqueue_main.cpp similarity index 98% rename from src/platforms/common/work_queue/wqueue_test/wqueue_main.cpp rename to platforms/common/work_queue/wqueue_test/wqueue_main.cpp index 9f693c62a922..fb222df24c68 100644 --- a/src/platforms/common/work_queue/wqueue_test/wqueue_main.cpp +++ b/platforms/common/work_queue/wqueue_test/wqueue_main.cpp @@ -40,7 +40,6 @@ #include "wqueue_test.h" #include -#include #include #include diff --git a/src/platforms/common/work_queue/wqueue_test/wqueue_start_posix.cpp b/platforms/common/work_queue/wqueue_test/wqueue_start_posix.cpp similarity index 100% rename from src/platforms/common/work_queue/wqueue_test/wqueue_start_posix.cpp rename to platforms/common/work_queue/wqueue_test/wqueue_start_posix.cpp diff --git a/src/platforms/common/work_queue/wqueue_test/wqueue_test.cpp b/platforms/common/work_queue/wqueue_test/wqueue_test.cpp similarity index 100% rename from src/platforms/common/work_queue/wqueue_test/wqueue_test.cpp rename to platforms/common/work_queue/wqueue_test/wqueue_test.cpp diff --git a/src/platforms/common/work_queue/wqueue_test/wqueue_test.h b/platforms/common/work_queue/wqueue_test/wqueue_test.h similarity index 100% rename from src/platforms/common/work_queue/wqueue_test/wqueue_test.h rename to platforms/common/work_queue/wqueue_test/wqueue_test.h diff --git a/platforms/nuttx/CMakeLists.txt b/platforms/nuttx/CMakeLists.txt index fb6b630d24b2..ecc186b1d1d5 100644 --- a/platforms/nuttx/CMakeLists.txt +++ b/platforms/nuttx/CMakeLists.txt @@ -36,9 +36,7 @@ include(cygwin_cygpath) set(NUTTX_DIR ${PX4_BINARY_DIR}/NuttX/nuttx) set(NUTTX_APPS_DIR ${PX4_BINARY_DIR}/NuttX/apps) -add_subdirectory(src) - -add_executable(px4 ${PX4_SOURCE_DIR}/src/platforms/empty.c) +add_executable(px4 ${PX4_SOURCE_DIR}/platforms/common/empty.c) set(FW_NAME ${PX4_BOARD_VENDOR}_${PX4_BOARD_MODEL}_${PX4_BOARD_LABEL}.elf) set_target_properties(px4 PROPERTIES OUTPUT_NAME ${FW_NAME}) add_dependencies(px4 git_nuttx nuttx_build) @@ -76,9 +74,9 @@ CYGPATH(PX4_BINARY_DIR PX4_BINARY_DIR_CYG) target_link_libraries(nuttx_arch INTERFACE drivers_board - drivers_arch drivers_boards_common drivers_boards_common_arch + arch_hrt ) target_link_libraries(nuttx_c INTERFACE nuttx_drivers) diff --git a/platforms/nuttx/cmake/px4_impl_os.cmake b/platforms/nuttx/cmake/px4_impl_os.cmake index 3c9b27ef58e0..7c98a88b4d24 100644 --- a/platforms/nuttx/cmake/px4_impl_os.cmake +++ b/platforms/nuttx/cmake/px4_impl_os.cmake @@ -38,6 +38,7 @@ # Required OS Interface Functions # # * px4_os_add_flags +# * px4_os_determine_build_chip # * px4_os_prebuild_targets # @@ -84,6 +85,41 @@ function(px4_os_add_flags) endfunction() +#============================================================================= +# +# px4_os_determine_build_chip +# +# Sets PX4_CHIP and PX4_CHIP_MANUFACTURER. +# +# Usage: +# px4_os_determine_build_chip() +# +function(px4_os_determine_build_chip) + + # determine chip and chip manufacturer based on NuttX config + if (CONFIG_STM32_STM32F10XX) + set(CHIP_MANUFACTURER "stm") + set(CHIP "stm32f1") + elseif(CONFIG_STM32_STM32F30XX) + set(CHIP_MANUFACTURER "stm") + set(CHIP "stm32f3") + elseif(CONFIG_STM32_STM32F4XXX) + set(CHIP_MANUFACTURER "stm") + set(CHIP "stm32f4") + elseif(CONFIG_ARCH_CHIP_STM32F7) + set(CHIP_MANUFACTURER "stm") + set(CHIP "stm32f7") + elseif(CONFIG_ARCH_CHIP_MK66FN2M0VMD18) + set(CHIP_MANUFACTURER "nxp") + set(CHIP "k66") + else() + message(FATAL_ERROR "Could not determine chip architecture from NuttX config. You may have to add it.") + endif() + + set(PX4_CHIP ${CHIP} CACHE STRING "PX4 Chip" FORCE) + set(PX4_CHIP_MANUFACTURER ${CHIP_MANUFACTURER} CACHE STRING "PX4 Chip Manufacturer" FORCE) +endfunction() + #============================================================================= # # px4_os_prebuild_targets diff --git a/src/platforms/CMakeLists.txt b/platforms/nuttx/src/px4/CMakeLists.txt similarity index 92% rename from src/platforms/CMakeLists.txt rename to platforms/nuttx/src/px4/CMakeLists.txt index 272e4d66bd71..929788b587e2 100644 --- a/src/platforms/CMakeLists.txt +++ b/platforms/nuttx/src/px4/CMakeLists.txt @@ -33,7 +33,5 @@ add_subdirectory(common) -if (${PX4_PLATFORM} STREQUAL "posix" AND BUILD_TESTING) - add_subdirectory(posix/test_stubs) - add_subdirectory(posix/gtest_runner) -endif() +add_subdirectory(${PX4_CHIP_MANUFACTURER}) + diff --git a/platforms/nuttx/src/px4_layer/CMakeLists.txt b/platforms/nuttx/src/px4/common/CMakeLists.txt similarity index 96% rename from platforms/nuttx/src/px4_layer/CMakeLists.txt rename to platforms/nuttx/src/px4/common/CMakeLists.txt index 8d5e50dbaed4..967dd6e46785 100644 --- a/platforms/nuttx/src/px4_layer/CMakeLists.txt +++ b/platforms/nuttx/src/px4/common/CMakeLists.txt @@ -48,6 +48,6 @@ if (NOT ${PX4_BOARD} MATCHES "px4_io") px4_work_queue ) else() - add_library(px4_layer ${PX4_SOURCE_DIR}/src/platforms/empty.c) + add_library(px4_layer ${PX4_SOURCE_DIR}/platforms/common/empty.c) endif() add_dependencies(px4_layer prebuild_targets) diff --git a/platforms/nuttx/src/px4_layer/console_buffer.cpp b/platforms/nuttx/src/px4/common/console_buffer.cpp similarity index 100% rename from platforms/nuttx/src/px4_layer/console_buffer.cpp rename to platforms/nuttx/src/px4/common/console_buffer.cpp diff --git a/platforms/nuttx/src/px4/common/include/px4_platform/adc.h b/platforms/nuttx/src/px4/common/include/px4_platform/adc.h new file mode 100644 index 000000000000..d7f6e85a5b94 --- /dev/null +++ b/platforms/nuttx/src/px4/common/include/px4_platform/adc.h @@ -0,0 +1,40 @@ +/**************************************************************************** + * + * Copyright (c) 2019 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. + * + ****************************************************************************/ +#pragma once + +#if SYSTEM_ADC_BASE == HW_REV_VER_ADC_BASE +# define SYSTEM_ADC_COUNT 1 +#else +# define SYSTEM_ADC_COUNT 2 +#endif + diff --git a/platforms/nuttx/src/px4/common/include/px4_platform/micro_hal.h b/platforms/nuttx/src/px4/common/include/px4_platform/micro_hal.h new file mode 100644 index 000000000000..8bf62a5f8dbd --- /dev/null +++ b/platforms/nuttx/src/px4/common/include/px4_platform/micro_hal.h @@ -0,0 +1,56 @@ +/**************************************************************************** + * + * Copyright (c) 2019 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. + * + ****************************************************************************/ +#pragma once + + +__BEGIN_DECLS +#include +#include + +/* For historical reasons (NuttX STM32 numbering) PX4 bus numbering is 1 based + * All PX4 code, including, board code is written to assuming 1 based numbering. + * The following macros are used to allow the board config to define the bus + * numbers in terms of the NuttX driver numbering. 1,2,3 for one based numbering + * schemes or 0,1,2 for zero based schemes. + */ + +#define PX4_BUS_NUMBER_TO_PX4(x) ((x)+PX4_BUS_OFFSET) /* Use to define Zero based to match Nuttx Driver but provide 1 based to PX4 */ +#define PX4_BUS_NUMBER_FROM_PX4(x) ((x)-PX4_BUS_OFFSET) /* Use to map PX4 1 based to NuttX driver 0 based */ + +#define px4_enter_critical_section() enter_critical_section() +#define px4_leave_critical_section(flags) leave_critical_section(flags) + +#include + +__END_DECLS + diff --git a/platforms/nuttx/src/px4_layer/px4_init.cpp b/platforms/nuttx/src/px4/common/px4_init.cpp similarity index 98% rename from platforms/nuttx/src/px4_layer/px4_init.cpp rename to platforms/nuttx/src/px4/common/px4_init.cpp index 466fcc4afd85..7748f7b94c6a 100644 --- a/platforms/nuttx/src/px4_layer/px4_init.cpp +++ b/platforms/nuttx/src/px4/common/px4_init.cpp @@ -38,7 +38,7 @@ #include #include #include -#include +#include #include #include diff --git a/platforms/nuttx/src/px4_layer/px4_nuttx_impl.cpp b/platforms/nuttx/src/px4/common/px4_nuttx_impl.cpp similarity index 95% rename from platforms/nuttx/src/px4_layer/px4_nuttx_impl.cpp rename to platforms/nuttx/src/px4/common/px4_nuttx_impl.cpp index e760cee5e9b9..30780b11d70f 100644 --- a/platforms/nuttx/src/px4_layer/px4_nuttx_impl.cpp +++ b/platforms/nuttx/src/px4/common/px4_nuttx_impl.cpp @@ -38,7 +38,6 @@ */ #include -#include #include namespace px4 @@ -49,9 +48,4 @@ void init(int argc, char *argv[], const char *process_name) printf("process: %s\n", process_name); } -uint64_t get_time_micros() -{ - return hrt_absolute_time(); -} - } diff --git a/platforms/nuttx/src/px4_layer/px4_nuttx_tasks.c b/platforms/nuttx/src/px4/common/px4_nuttx_tasks.c similarity index 100% rename from platforms/nuttx/src/px4_layer/px4_nuttx_tasks.c rename to platforms/nuttx/src/px4/common/px4_nuttx_tasks.c diff --git a/src/drivers/stm32/adc/CMakeLists.txt b/platforms/nuttx/src/px4/nxp/CMakeLists.txt similarity index 92% rename from src/drivers/stm32/adc/CMakeLists.txt rename to platforms/nuttx/src/px4/nxp/CMakeLists.txt index 46f8f429de00..ec489bf559c3 100644 --- a/src/drivers/stm32/adc/CMakeLists.txt +++ b/platforms/nuttx/src/px4/nxp/CMakeLists.txt @@ -1,6 +1,6 @@ ############################################################################ # -# Copyright (c) 2015 PX4 Development Team. All rights reserved. +# Copyright (c) 2019 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 @@ -31,9 +31,6 @@ # ############################################################################ -px4_add_module( - MODULE drivers__adc - MAIN adc - SRCS - adc.cpp - ) + +add_subdirectory(${PX4_CHIP}) + diff --git a/platforms/posix/src/CMakeLists.txt b/platforms/nuttx/src/px4/nxp/k66/CMakeLists.txt similarity index 85% rename from platforms/posix/src/CMakeLists.txt rename to platforms/nuttx/src/px4/nxp/k66/CMakeLists.txt index c46e436e8e7b..7f95fdb519c8 100644 --- a/platforms/posix/src/CMakeLists.txt +++ b/platforms/nuttx/src/px4/nxp/k66/CMakeLists.txt @@ -1,6 +1,6 @@ ############################################################################ # -# Copyright (c) 2017 PX4 Development Team. All rights reserved. +# Copyright (c) 2019 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,11 @@ ############################################################################ -add_subdirectory(px4_daemon) -add_subdirectory(px4_layer) +add_subdirectory(../kinetis/adc adc) +add_subdirectory(../kinetis/led_pwm led_pwm) +add_subdirectory(../kinetis/hrt hrt) +add_subdirectory(../kinetis/io_pins io_pins) +add_subdirectory(../kinetis/tone_alarm tone_alarm) + + -add_subdirectory(lockstep_scheduler) diff --git a/platforms/nuttx/src/px4/nxp/k66/include/px4_arch/adc.h b/platforms/nuttx/src/px4/nxp/k66/include/px4_arch/adc.h new file mode 100644 index 000000000000..743deaed331c --- /dev/null +++ b/platforms/nuttx/src/px4/nxp/k66/include/px4_arch/adc.h @@ -0,0 +1,36 @@ +/**************************************************************************** + * + * Copyright (c) 2019 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. + * + ****************************************************************************/ +#pragma once + +#include "../../../kinetis/include/px4_arch/adc.h" + diff --git a/src/drivers/kinetis/drv_pwm_servo.h b/platforms/nuttx/src/px4/nxp/k66/include/px4_arch/io_timer.h similarity index 90% rename from src/drivers/kinetis/drv_pwm_servo.h rename to platforms/nuttx/src/px4/nxp/k66/include/px4_arch/io_timer.h index e3477183d2ab..11661f853a71 100644 --- a/src/drivers/kinetis/drv_pwm_servo.h +++ b/platforms/nuttx/src/px4/nxp/k66/include/px4_arch/io_timer.h @@ -1,6 +1,6 @@ /**************************************************************************** * - * Copyright (C) 2012 PX4 Development Team. All rights reserved. + * Copyright (c) 2019 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 @@ -30,13 +30,8 @@ * POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************/ +#pragma once -/** - * @file drv_pwm_servo.h - * - * stm32-specific PWM output data. - */ -#pragma once +#include "../../../kinetis/include/px4_arch/io_timer.h" -#include diff --git a/platforms/nuttx/src/px4/nxp/k66/include/px4_arch/micro_hal.h b/platforms/nuttx/src/px4/nxp/k66/include/px4_arch/micro_hal.h new file mode 100644 index 000000000000..33930f5235db --- /dev/null +++ b/platforms/nuttx/src/px4/nxp/k66/include/px4_arch/micro_hal.h @@ -0,0 +1,112 @@ +/**************************************************************************** + * + * Copyright (c) 2019 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. + * + ****************************************************************************/ +#pragma once + + +#include + +__BEGIN_DECLS + +#define PX4_SOC_ARCH_ID PX4_SOC_ARCH_ID_KINETISK66 + +// Fixme: using ?? +#define PX4_BBSRAM_SIZE 2048 +#define PX4_BBSRAM_GETDESC_IOCTL 0 +#define PX4_NUMBER_I2C_BUSES KINETIS_NI2C + +#define GPIO_OUTPUT_SET GPIO_OUTPUT_ONE +#define GPIO_OUTPUT_CLEAR GPIO_OUTPUT_ZERO + +#include +#include +#include +#include + +/* Kinetis defines the 128 bit UUID as + * init32_t[4] that can be read as words + * init32_t[0] PX4_CPU_UUID_ADDRESS[0] bits 127:96 (offset 0) + * init32_t[1] PX4_CPU_UUID_ADDRESS[1] bits 95:64 (offset 4) + * init32_t[2] PX4_CPU_UUID_ADDRESS[1] bits 63:32 (offset 8) + * init32_t[3] PX4_CPU_UUID_ADDRESS[3] bits 31:0 (offset C) + * + * PX4 uses the words in bigendian order MSB to LSB + * word [0] [1] [2] [3] + * bits 127:96 95-64 63-32, 31-00, + */ +#define PX4_CPU_UUID_BYTE_LENGTH KINETIS_UID_SIZE +#define PX4_CPU_UUID_WORD32_LENGTH (PX4_CPU_UUID_BYTE_LENGTH/sizeof(uint32_t)) + +/* The mfguid will be an array of bytes with + * MSD @ index 0 - LSD @ index PX4_CPU_MFGUID_BYTE_LENGTH-1 + * + * It will be converted to a string with the MSD on left and LSD on the right most position. + */ +#define PX4_CPU_MFGUID_BYTE_LENGTH PX4_CPU_UUID_BYTE_LENGTH + +/* define common formating across all commands */ + +#define PX4_CPU_UUID_WORD32_FORMAT "%08x" +#define PX4_CPU_UUID_WORD32_SEPARATOR ":" + +#define PX4_CPU_UUID_WORD32_UNIQUE_H 3 /* Least significant digits change the most */ +#define PX4_CPU_UUID_WORD32_UNIQUE_M 2 /* Middle High significant digits */ +#define PX4_CPU_UUID_WORD32_UNIQUE_L 1 /* Middle Low significant digits */ +#define PX4_CPU_UUID_WORD32_UNIQUE_N 0 /* Most significant digits change the least */ + +/* Separator nnn:nnn:nnnn 2 char per byte term */ +#define PX4_CPU_UUID_WORD32_FORMAT_SIZE (PX4_CPU_UUID_WORD32_LENGTH-1+(2*PX4_CPU_UUID_BYTE_LENGTH)+1) +#define PX4_CPU_MFGUID_FORMAT_SIZE ((2*PX4_CPU_MFGUID_BYTE_LENGTH)+1) + +#define kinetis_bbsram_savepanic(fileno, context, length) (0) // todo:Not implemented yet + +#define px4_savepanic(fileno, context, length) kinetis_bbsram_savepanic(fileno, context, length) + +/* bus_num is zero based on kinetis and must be translated from the legacy one based */ + +#define PX4_BUS_OFFSET 1 /* Kinetis buses are 0 based and adjustment is needed */ + +#define px4_spibus_initialize(bus_num_1based) kinetis_spibus_initialize(PX4_BUS_NUMBER_FROM_PX4(bus_num_1based)) + +#define px4_i2cbus_initialize(bus_num_1based) kinetis_i2cbus_initialize(PX4_BUS_NUMBER_FROM_PX4(bus_num_1based)) +#define px4_i2cbus_uninitialize(pdev) kinetis_i2cbus_uninitialize(pdev) + +#define px4_arch_configgpio(pinset) kinetis_pinconfig(pinset) +#define px4_arch_unconfiggpio(pinset) +#define px4_arch_gpioread(pinset) kinetis_gpioread(pinset) +#define px4_arch_gpiowrite(pinset, value) kinetis_gpiowrite(pinset, value) + +/* kinetis_gpiosetevent is not implemented and will need to be added */ + +#define px4_arch_gpiosetevent(pinset,r,f,e,fp,a) kinetis_gpiosetevent(pinset,r,f,e,fp,a) + +__END_DECLS diff --git a/src/lib/drivers/tone_alarm/CMakeLists.txt b/platforms/nuttx/src/px4/nxp/kinetis/adc/CMakeLists.txt similarity index 97% rename from src/lib/drivers/tone_alarm/CMakeLists.txt rename to platforms/nuttx/src/px4/nxp/kinetis/adc/CMakeLists.txt index 53b343a25e7e..d2487d05bf2c 100644 --- a/src/lib/drivers/tone_alarm/CMakeLists.txt +++ b/platforms/nuttx/src/px4/nxp/kinetis/adc/CMakeLists.txt @@ -31,4 +31,6 @@ # ############################################################################ -# ToneAlarmInterface Library - Intentionally Blank +px4_add_library(arch_adc + adc.cpp +) diff --git a/platforms/nuttx/src/px4/nxp/kinetis/adc/adc.cpp b/platforms/nuttx/src/px4/nxp/kinetis/adc/adc.cpp new file mode 100644 index 000000000000..78a650ec937c --- /dev/null +++ b/platforms/nuttx/src/px4/nxp/kinetis/adc/adc.cpp @@ -0,0 +1,183 @@ +/**************************************************************************** + * + * Copyright (C) 2019 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 +#include +#include +#include + +#include +#include +#include +#include + + +#define _REG(_addr) (*(volatile uint32_t *)(_addr)) + +/* ADC register accessors */ + +#define REG(a, _reg) _REG(KINETIS_ADC##a##_BASE + (_reg)) + +#define rSC1A(adc) REG(adc, KINETIS_ADC_SC1A_OFFSET) /* ADC status and control registers 1 */ +#define rSC1B(adc) REG(adc, KINETIS_ADC_SC1B_OFFSET) /* ADC status and control registers 1 */ +#define rCFG1(adc) REG(adc, KINETIS_ADC_CFG1_OFFSET) /* ADC configuration register 1 */ +#define rCFG2(adc) REG(adc, KINETIS_ADC_CFG2_OFFSET) /* Configuration register 2 */ +#define rRA(adc) REG(adc, KINETIS_ADC_RA_OFFSET) /* ADC data result register */ +#define rRB(adc) REG(adc, KINETIS_ADC_RB_OFFSET) /* ADC data result register */ +#define rCV1(adc) REG(adc, KINETIS_ADC_CV1_OFFSET) /* Compare value registers */ +#define rCV2(adc) REG(adc, KINETIS_ADC_CV2_OFFSET) /* Compare value registers */ +#define rSC2(adc) REG(adc, KINETIS_ADC_SC2_OFFSET) /* Status and control register 2 */ +#define rSC3(adc) REG(adc, KINETIS_ADC_SC3_OFFSET) /* Status and control register 3 */ +#define rOFS(adc) REG(adc, KINETIS_ADC_OFS_OFFSET) /* ADC offset correction register */ +#define rPG(adc) REG(adc, KINETIS_ADC_PG_OFFSET) /* ADC plus-side gain register */ +#define rMG(adc) REG(adc, KINETIS_ADC_MG_OFFSET) /* ADC minus-side gain register */ +#define rCLPD(adc) REG(adc, KINETIS_ADC_CLPD_OFFSET) /* ADC plus-side general calibration value register */ +#define rCLPS(adc) REG(adc, KINETIS_ADC_CLPS_OFFSET) /* ADC plus-side general calibration value register */ +#define rCLP4(adc) REG(adc, KINETIS_ADC_CLP4_OFFSET) /* ADC plus-side general calibration value register */ +#define rCLP3(adc) REG(adc, KINETIS_ADC_CLP3_OFFSET) /* ADC plus-side general calibration value register */ +#define rCLP2(adc) REG(adc, KINETIS_ADC_CLP2_OFFSET) /* ADC plus-side general calibration value register */ +#define rCLP1(adc) REG(adc, KINETIS_ADC_CLP1_OFFSET) /* ADC plus-side general calibration value register */ +#define rCLP0(adc) REG(adc, KINETIS_ADC_CLP0_OFFSET) /* ADC plus-side general calibration value register */ +#define rCLMD(adc) REG(adc, KINETIS_ADC_CLMD_OFFSET) /* ADC minus-side general calibration value register */ +#define rCLMS(adc) REG(adc, KINETIS_ADC_CLMS_OFFSET) /* ADC minus-side general calibration value register */ +#define rCLM4(adc) REG(adc, KINETIS_ADC_CLM4_OFFSET) /* ADC minus-side general calibration value register */ +#define rCLM3(adc) REG(adc, KINETIS_ADC_CLM3_OFFSET) /* ADC minus-side general calibration value register */ +#define rCLM2(adc) REG(adc, KINETIS_ADC_CLM2_OFFSET) /* ADC minus-side general calibration value register */ +#define rCLM1(adc) REG(adc, KINETIS_ADC_CLM1_OFFSET) /* ADC minus-side general calibration value register */ +#define rCLM0(adc) REG(adc, KINETIS_ADC_CLM0_OFFSET) /* ADC minus-side general calibration value register */ + +int px4_arch_adc_init(uint32_t base_address) +{ + /* Input is Buss Clock 56 Mhz We will use /8 for 7 Mhz */ + + irqstate_t flags = px4_enter_critical_section(); + + _REG(KINETIS_SIM_SCGC3) |= SIM_SCGC3_ADC1; + rCFG1(1) = ADC_CFG1_ADICLK_BUSCLK | ADC_CFG1_MODE_1213BIT | ADC_CFG1_ADIV_DIV8; + rCFG2(1) = 0; + rSC2(1) = ADC_SC2_REFSEL_DEFAULT; + + px4_leave_critical_section(flags); + + /* Clear the CALF and begin the calibration */ + + rSC3(1) = ADC_SC3_CAL | ADC_SC3_CALF; + + while ((rSC1A(1) & ADC_SC1_COCO) == 0) { + usleep(100); + + if (rSC3(1) & ADC_SC3_CALF) { + return -1; + } + } + + /* dummy read to clear COCO of calibration */ + + int32_t r = rRA(1); + + /* Check the state of CALF at the end of calibration */ + + if (rSC3(1) & ADC_SC3_CALF) { + return -1; + } + + /* Calculate the calibration values for single ended positive */ + + r = rCLP0(1) + rCLP1(1) + rCLP2(1) + rCLP3(1) + rCLP4(1) + rCLPS(1) ; + r = 0x8000U | (r >> 1U); + rPG(1) = r; + + /* Calculate the calibration values for double ended Negitive */ + + r = rCLM0(1) + rCLM1(1) + rCLM2(1) + rCLM3(1) + rCLM4(1) + rCLMS(1) ; + r = 0x8000U | (r >> 1U); + rMG(1) = r; + + /* kick off a sample and wait for it to complete */ + hrt_abstime now = hrt_absolute_time(); + + rSC1A(1) = ADC_SC1_ADCH(ADC_SC1_ADCH_TEMP); + + while (!(rSC1A(1) & ADC_SC1_COCO)) { + + /* don't wait for more than 500us, since that means something broke - should reset here if we see this */ + if ((hrt_absolute_time() - now) > 500) { + return -1; + } + } + + return 0; +} + +void px4_arch_adc_uninit(uint32_t base_address) +{ + irqstate_t flags = px4_enter_critical_section(); + _REG(KINETIS_SIM_SCGC3) &= ~SIM_SCGC3_ADC1; + px4_leave_critical_section(flags); +} + +uint16_t px4_arch_adc_sample(uint32_t base_address, unsigned channel) +{ + irqstate_t flags = px4_enter_critical_section(); + + /* clear any previous COCC */ + rRA(1); + + /* run a single conversion right now - should take about 35 cycles (5 microseconds) max */ + rSC1A(1) = ADC_SC1_ADCH(channel); + + /* wait for the conversion to complete */ + const hrt_abstime now = hrt_absolute_time(); + + while (!(rSC1A(1) & ADC_SC1_COCO)) { + + /* don't wait for more than 10us, since that means something broke - should reset here if we see this */ + if ((hrt_absolute_time() - now) > 10) { + px4_leave_critical_section(flags); + return 0xffff; + } + } + + /* read the result and clear EOC */ + uint16_t result = rRA(1); + + px4_leave_critical_section(flags); + + return result; +} + +uint32_t px4_arch_adc_temp_sensor_mask() +{ + return 1 << (ADC_SC1_ADCH_TEMP >> ADC_SC1_ADCH_SHIFT); +} + diff --git a/platforms/nuttx/src/px4/nxp/kinetis/hrt/CMakeLists.txt b/platforms/nuttx/src/px4/nxp/kinetis/hrt/CMakeLists.txt new file mode 100644 index 000000000000..ebd97f8a42fa --- /dev/null +++ b/platforms/nuttx/src/px4/nxp/kinetis/hrt/CMakeLists.txt @@ -0,0 +1,38 @@ +############################################################################ +# +# Copyright (c) 2015-2019 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. +# +############################################################################ + +px4_add_library(arch_hrt + hrt.c +) +target_compile_options(arch_hrt PRIVATE -Wno-cast-align) # TODO: fix and enable + diff --git a/src/drivers/kinetis/drv_hrt.c b/platforms/nuttx/src/px4/nxp/kinetis/hrt/hrt.c similarity index 100% rename from src/drivers/kinetis/drv_hrt.c rename to platforms/nuttx/src/px4/nxp/kinetis/hrt/hrt.c diff --git a/src/drivers/stm32/drv_pwm_servo.h b/platforms/nuttx/src/px4/nxp/kinetis/include/px4_arch/adc.h similarity index 90% rename from src/drivers/stm32/drv_pwm_servo.h rename to platforms/nuttx/src/px4/nxp/kinetis/include/px4_arch/adc.h index ecd42687f6c3..400305ebd21b 100644 --- a/src/drivers/stm32/drv_pwm_servo.h +++ b/platforms/nuttx/src/px4/nxp/kinetis/include/px4_arch/adc.h @@ -1,6 +1,6 @@ /**************************************************************************** * - * Copyright (C) 2012 PX4 Development Team. All rights reserved. + * Copyright (c) 2019 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 @@ -30,14 +30,12 @@ * POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************/ +#pragma once -/** - * @file drv_pwm_servo.h - * - * stm32-specific PWM output data. - */ +#include -#pragma once +#define SYSTEM_ADC_BASE 0 // not used on kinetis + +#include -#include diff --git a/src/drivers/kinetis/drv_io_timer.h b/platforms/nuttx/src/px4/nxp/kinetis/include/px4_arch/io_timer.h similarity index 100% rename from src/drivers/kinetis/drv_io_timer.h rename to platforms/nuttx/src/px4/nxp/kinetis/include/px4_arch/io_timer.h diff --git a/platforms/nuttx/src/px4/nxp/kinetis/io_pins/CMakeLists.txt b/platforms/nuttx/src/px4/nxp/kinetis/io_pins/CMakeLists.txt new file mode 100644 index 000000000000..401bf06ef5dd --- /dev/null +++ b/platforms/nuttx/src/px4/nxp/kinetis/io_pins/CMakeLists.txt @@ -0,0 +1,39 @@ +############################################################################ +# +# Copyright (c) 2015-2019 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. +# +############################################################################ + +px4_add_library(arch_io_pins + io_timer.c + pwm_servo.c + pwm_trigger.c + input_capture.c +) diff --git a/src/drivers/kinetis/drv_input_capture.c b/platforms/nuttx/src/px4/nxp/kinetis/io_pins/input_capture.c similarity index 99% rename from src/drivers/kinetis/drv_input_capture.c rename to platforms/nuttx/src/px4/nxp/kinetis/io_pins/input_capture.c index c44138118d85..ed3bdeaff08c 100644 --- a/src/drivers/kinetis/drv_input_capture.c +++ b/platforms/nuttx/src/px4/nxp/kinetis/io_pins/input_capture.c @@ -72,9 +72,7 @@ #include #include -#include "drv_io_timer.h" - -#include "drv_input_capture.h" +#include #include #include "chip/kinetis_sim.h" diff --git a/src/drivers/kinetis/drv_io_timer.c b/platforms/nuttx/src/px4/nxp/kinetis/io_pins/io_timer.c similarity index 99% rename from src/drivers/kinetis/drv_io_timer.c rename to platforms/nuttx/src/px4/nxp/kinetis/io_pins/io_timer.c index 4aaa8bb095d5..7ba1ce7fd477 100644 --- a/src/drivers/kinetis/drv_io_timer.c +++ b/platforms/nuttx/src/px4/nxp/kinetis/io_pins/io_timer.c @@ -56,7 +56,7 @@ #include #include -#include "drv_io_timer.h" +#include #include #include "chip/kinetis_sim.h" diff --git a/src/drivers/kinetis/drv_pwm_servo.c b/platforms/nuttx/src/px4/nxp/kinetis/io_pins/pwm_servo.c similarity index 98% rename from src/drivers/kinetis/drv_pwm_servo.c rename to platforms/nuttx/src/px4/nxp/kinetis/io_pins/pwm_servo.c index be1ab4050d73..908b71225c52 100644 --- a/src/drivers/kinetis/drv_pwm_servo.c +++ b/platforms/nuttx/src/px4/nxp/kinetis/io_pins/pwm_servo.c @@ -58,8 +58,7 @@ #include #include -#include "drv_io_timer.h" -#include "drv_pwm_servo.h" +#include #include diff --git a/src/drivers/kinetis/drv_pwm_trigger.c b/platforms/nuttx/src/px4/nxp/kinetis/io_pins/pwm_trigger.c similarity index 98% rename from src/drivers/kinetis/drv_pwm_trigger.c rename to platforms/nuttx/src/px4/nxp/kinetis/io_pins/pwm_trigger.c index 722e32d47450..6c5bc0e92e01 100644 --- a/src/drivers/kinetis/drv_pwm_trigger.c +++ b/platforms/nuttx/src/px4/nxp/kinetis/io_pins/pwm_trigger.c @@ -54,8 +54,7 @@ #include #include -#include "drv_io_timer.h" -#include "drv_pwm_trigger.h" +#include int up_pwm_trigger_set(unsigned channel, uint16_t value) { diff --git a/platforms/nuttx/src/px4/nxp/kinetis/led_pwm/CMakeLists.txt b/platforms/nuttx/src/px4/nxp/kinetis/led_pwm/CMakeLists.txt new file mode 100644 index 000000000000..1b1504352612 --- /dev/null +++ b/platforms/nuttx/src/px4/nxp/kinetis/led_pwm/CMakeLists.txt @@ -0,0 +1,36 @@ +############################################################################ +# +# Copyright (c) 2015-2019 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. +# +############################################################################ + +px4_add_library(arch_led_pwm + led_pwm.cpp +) diff --git a/src/drivers/kinetis/drv_led_pwm.cpp b/platforms/nuttx/src/px4/nxp/kinetis/led_pwm/led_pwm.cpp similarity index 99% rename from src/drivers/kinetis/drv_led_pwm.cpp rename to platforms/nuttx/src/px4/nxp/kinetis/led_pwm/led_pwm.cpp index b11ca0e4580f..8450d87d72fa 100644 --- a/src/drivers/kinetis/drv_led_pwm.cpp +++ b/platforms/nuttx/src/px4/nxp/kinetis/led_pwm/led_pwm.cpp @@ -56,7 +56,7 @@ #include #include -#include "drv_io_timer.h" +#include #include #include "chip/kinetis_sim.h" diff --git a/src/drivers/stm32/tone_alarm/CMakeLists.txt b/platforms/nuttx/src/px4/nxp/kinetis/tone_alarm/CMakeLists.txt similarity index 97% rename from src/drivers/stm32/tone_alarm/CMakeLists.txt rename to platforms/nuttx/src/px4/nxp/kinetis/tone_alarm/CMakeLists.txt index 5251d3910a7a..a2d2f8144bcc 100644 --- a/src/drivers/stm32/tone_alarm/CMakeLists.txt +++ b/platforms/nuttx/src/px4/nxp/kinetis/tone_alarm/CMakeLists.txt @@ -31,6 +31,6 @@ # ############################################################################ -px4_add_library(tone_alarm_interface +px4_add_library(arch_tone_alarm ToneAlarmInterface.cpp ) diff --git a/src/drivers/kinetis/tone_alarm/ToneAlarmInterface.cpp b/platforms/nuttx/src/px4/nxp/kinetis/tone_alarm/ToneAlarmInterface.cpp similarity index 97% rename from src/drivers/kinetis/tone_alarm/ToneAlarmInterface.cpp rename to platforms/nuttx/src/px4/nxp/kinetis/tone_alarm/ToneAlarmInterface.cpp index e7f36bd2ab54..a96180a429ea 100644 --- a/src/drivers/kinetis/tone_alarm/ToneAlarmInterface.cpp +++ b/platforms/nuttx/src/px4/nxp/kinetis/tone_alarm/ToneAlarmInterface.cpp @@ -39,7 +39,7 @@ #include "kinetis_tpm.h" #include -#include +#include #include #include @@ -115,7 +115,9 @@ # define rCNSC CAT3(rC, TONE_ALARM_CHANNEL, SC) /* Channel Status and Control Register used by Tone alarm */ # define STATUS CAT3(TPM_STATUS_CH, TONE_ALARM_CHANNEL, F) /* Capture and Compare Status Register used by Tone alarm */ -void ToneAlarmInterface::init() +namespace ToneAlarmInterface +{ +void init() { #ifdef GPIO_TONE_ALARM_NEG px4_arch_configgpio(GPIO_TONE_ALARM_NEG); @@ -157,7 +159,7 @@ void ToneAlarmInterface::init() rMOD = 0; // Default the timer to a modulo value of 1; playing notes will change this. } -void ToneAlarmInterface::start_note(unsigned frequency) +void start_note(unsigned frequency) { // Calculate the signal switching period. // (Signal switching period is one half of the frequency period). @@ -174,7 +176,7 @@ void ToneAlarmInterface::start_note(unsigned frequency) px4_arch_configgpio(GPIO_TONE_ALARM); } -void ToneAlarmInterface::stop_note() +void stop_note() { // Stop the current note. rSC &= ~TPM_SC_CMOD_MASK; @@ -182,3 +184,5 @@ void ToneAlarmInterface::stop_note() // Ensure the GPIO is not driving the speaker. px4_arch_configgpio(GPIO_TONE_ALARM_IDLE); } + +} /* namespace ToneAlarmInterface */ diff --git a/platforms/nuttx/src/px4/stm/CMakeLists.txt b/platforms/nuttx/src/px4/stm/CMakeLists.txt new file mode 100644 index 000000000000..ec489bf559c3 --- /dev/null +++ b/platforms/nuttx/src/px4/stm/CMakeLists.txt @@ -0,0 +1,36 @@ +############################################################################ +# +# Copyright (c) 2019 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. +# +############################################################################ + + +add_subdirectory(${PX4_CHIP}) + diff --git a/platforms/nuttx/src/px4/stm/stm32_common/adc/CMakeLists.txt b/platforms/nuttx/src/px4/stm/stm32_common/adc/CMakeLists.txt new file mode 100644 index 000000000000..d2487d05bf2c --- /dev/null +++ b/platforms/nuttx/src/px4/stm/stm32_common/adc/CMakeLists.txt @@ -0,0 +1,36 @@ +############################################################################ +# +# Copyright (c) 2015-2019 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. +# +############################################################################ + +px4_add_library(arch_adc + adc.cpp +) diff --git a/platforms/nuttx/src/px4/stm/stm32_common/adc/adc.cpp b/platforms/nuttx/src/px4/stm/stm32_common/adc/adc.cpp new file mode 100644 index 000000000000..6661c27c1c66 --- /dev/null +++ b/platforms/nuttx/src/px4/stm/stm32_common/adc/adc.cpp @@ -0,0 +1,230 @@ +/**************************************************************************** + * + * Copyright (C) 2019 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 +#include +#include +#include + +#include +#include + +/* + * Register accessors. + * For now, no reason not to just use ADC1. + */ +#define REG(base, _reg) (*(volatile uint32_t *)((base) + (_reg))) + +#define rSR(base) REG((base), STM32_ADC_SR_OFFSET) +#define rCR1(base) REG((base), STM32_ADC_CR1_OFFSET) +#define rCR2(base) REG((base), STM32_ADC_CR2_OFFSET) +#define rSMPR1(base) REG((base), STM32_ADC_SMPR1_OFFSET) +#define rSMPR2(base) REG((base), STM32_ADC_SMPR2_OFFSET) +#define rJOFR1(base) REG((base), STM32_ADC_JOFR1_OFFSET) +#define rJOFR2(base) REG((base), STM32_ADC_JOFR2_OFFSET) +#define rJOFR3(base) REG((base), STM32_ADC_JOFR3_OFFSET) +#define rJOFR4(base) REG((base), STM32_ADC_JOFR4_OFFSET) +#define rHTR(base) REG((base), STM32_ADC_HTR_OFFSET) +#define rLTR(base) REG((base), STM32_ADC_LTR_OFFSET) +#define rSQR1(base) REG((base), STM32_ADC_SQR1_OFFSET) +#define rSQR2(base) REG((base), STM32_ADC_SQR2_OFFSET) +#define rSQR3(base) REG((base), STM32_ADC_SQR3_OFFSET) +#define rJSQR(base) REG((base), STM32_ADC_JSQR_OFFSET) +#define rJDR1(base) REG((base), STM32_ADC_JDR1_OFFSET) +#define rJDR2(base) REG((base), STM32_ADC_JDR2_OFFSET) +#define rJDR3(base) REG((base), STM32_ADC_JDR3_OFFSET) +#define rJDR4(base) REG((base), STM32_ADC_JDR4_OFFSET) +#define rDR(base) REG((base), STM32_ADC_DR_OFFSET) + + + +#ifdef STM32_ADC_CCR +# define rCCR(base) REG((base), STM32_ADC_CCR_OFFSET) + +/* Assuming VDC 2.4 - 3.6 */ + +#define ADC_MAX_FADC 36000000 + +# if STM32_PCLK2_FREQUENCY/2 <= ADC_MAX_FADC +# define ADC_CCR_ADCPRE_DIV ADC_CCR_ADCPRE_DIV2 +# elif STM32_PCLK2_FREQUENCY/4 <= ADC_MAX_FADC +# define ADC_CCR_ADCPRE_DIV ADC_CCR_ADCPRE_DIV4 +# elif STM32_PCLK2_FREQUENCY/6 <= ADC_MAX_FADC +# define ADC_CCR_ADCPRE_DIV ADC_CCR_ADCPRE_DIV6 +# elif STM32_PCLK2_FREQUENCY/8 <= ADC_MAX_FADC +# define ADC_CCR_ADCPRE_DIV ADC_CCR_ADCPRE_DIV8 +# else +# error "ADC PCLK2 too high - no divisor found " +# endif +#endif + + +int px4_arch_adc_init(uint32_t base_address) +{ + /* Perform ADC init once per ADC */ + + static uint32_t once[SYSTEM_ADC_COUNT] {}; + + uint32_t *free = nullptr; + + for (uint32_t i = 0; i < SYSTEM_ADC_COUNT; i++) { + if (once[i] == base_address) { + + /* This one was done already */ + + return OK; + } + + /* Use first free slot */ + + if (free == nullptr && once[i] == 0) { + free = &once[i]; + } + } + + if (free == nullptr) { + + /* ADC misconfigured SYSTEM_ADC_COUNT too small */; + + PANIC(); + } + + *free = base_address; + + /* do calibration if supported */ +#ifdef ADC_CR2_CAL + rCR2(base_address) |= ADC_CR2_CAL; + px4_usleep(100); + + if (rCR2(base_address) & ADC_CR2_CAL) { + return -1; + } + +#endif + + /* arbitrarily configure all channels for 55 cycle sample time */ + rSMPR1(base_address) = 0b00000011011011011011011011011011; + rSMPR2(base_address) = 0b00011011011011011011011011011011; + + /* XXX for F2/4, might want to select 12-bit mode? */ + rCR1(base_address) = 0; + + /* enable the temperature sensor / Vrefint channel if supported*/ + rCR2(base_address) = +#ifdef ADC_CR2_TSVREFE + /* enable the temperature sensor in CR2 */ + ADC_CR2_TSVREFE | +#endif + 0; + + /* Soc have CCR */ +#ifdef STM32_ADC_CCR +# ifdef ADC_CCR_TSVREFE + /* enable temperature sensor in CCR */ + rCCR(base_address) = ADC_CCR_TSVREFE | ADC_CCR_ADCPRE_DIV; +# else + rCCR(base_address) = ADC_CCR_ADCPRE_DIV; +# endif +#endif + + /* configure for a single-channel sequence */ + rSQR1(base_address) = 0; + rSQR2(base_address) = 0; + rSQR3(base_address) = 0; /* will be updated with the channel each tick */ + + /* power-cycle the ADC and turn it on */ + rCR2(base_address) &= ~ADC_CR2_ADON; + px4_usleep(10); + rCR2(base_address) |= ADC_CR2_ADON; + px4_usleep(10); + rCR2(base_address) |= ADC_CR2_ADON; + px4_usleep(10); + + /* kick off a sample and wait for it to complete */ + hrt_abstime now = hrt_absolute_time(); + rCR2(base_address) |= ADC_CR2_SWSTART; + + while (!(rSR(base_address) & ADC_SR_EOC)) { + + /* don't wait for more than 500us, since that means something broke - should reset here if we see this */ + if ((hrt_absolute_time() - now) > 500) { + return -1; + } + } + + return 0; +} + +void px4_arch_adc_uninit(uint32_t base_address) +{ + // nothing to do +} + +uint16_t px4_arch_adc_sample(uint32_t base_address, unsigned channel) +{ + irqstate_t flags = px4_enter_critical_section(); + + /* clear any previous EOC */ + if (rSR(base_address) & ADC_SR_EOC) { + rSR(base_address) &= ~ADC_SR_EOC; + } + + /* run a single conversion right now - should take about 60 cycles (a few microseconds) max */ + rSQR3(base_address) = channel; + rCR2(base_address) |= ADC_CR2_SWSTART; + + /* wait for the conversion to complete */ + const hrt_abstime now = hrt_absolute_time(); + + while (!(rSR(base_address) & ADC_SR_EOC)) { + + /* don't wait for more than 50us, since that means something broke - should reset here if we see this */ + if ((hrt_absolute_time() - now) > 50) { + px4_leave_critical_section(flags); + return 0xffff; + } + } + + /* read the result and clear EOC */ + uint16_t result = rDR(base_address); + + px4_leave_critical_section(flags); + + return result; +} + +uint32_t px4_arch_adc_temp_sensor_mask() +{ + return 1 << 16; +} + diff --git a/platforms/nuttx/src/px4/stm/stm32_common/hrt/CMakeLists.txt b/platforms/nuttx/src/px4/stm/stm32_common/hrt/CMakeLists.txt new file mode 100644 index 000000000000..ebd97f8a42fa --- /dev/null +++ b/platforms/nuttx/src/px4/stm/stm32_common/hrt/CMakeLists.txt @@ -0,0 +1,38 @@ +############################################################################ +# +# Copyright (c) 2015-2019 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. +# +############################################################################ + +px4_add_library(arch_hrt + hrt.c +) +target_compile_options(arch_hrt PRIVATE -Wno-cast-align) # TODO: fix and enable + diff --git a/src/drivers/stm32/drv_hrt.c b/platforms/nuttx/src/px4/stm/stm32_common/hrt/hrt.c similarity index 100% rename from src/drivers/stm32/drv_hrt.c rename to platforms/nuttx/src/px4/stm/stm32_common/hrt/hrt.c diff --git a/src/platforms/px4_middleware.h b/platforms/nuttx/src/px4/stm/stm32_common/include/px4_arch/adc.h similarity index 71% rename from src/platforms/px4_middleware.h rename to platforms/nuttx/src/px4/stm/stm32_common/include/px4_arch/adc.h index 393074848799..17ff58304537 100644 --- a/src/platforms/px4_middleware.h +++ b/platforms/nuttx/src/px4/stm/stm32_common/include/px4_arch/adc.h @@ -1,6 +1,6 @@ /**************************************************************************** * - * Copyright (c) 2014 PX4 Development Team. All rights reserved. + * Copyright (c) 2019 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 @@ -30,38 +30,28 @@ * POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************/ - -/** - * @file px4_middleware.h - * - * PX4 generic middleware wrapper - */ - #pragma once -#include -#include +#include -namespace px4 -{ -__EXPORT void init(int argc, char *argv[], const char *process_name); +/* Historically PX4 used one ADC1 With FMUvnX this has changes. + * These defines maintain compatibility while allowing the + * new boards to override the ADC used from HW VER/REV and + * the system one. + * + * Depending on HW configuration (VER/REV POP options) hardware detection + * may or may NOT initialize a given ADC. SYSTEM_ADC_COUNT is used to size the + * singleton array to ensure this is only done once per ADC. + */ -__EXPORT uint64_t get_time_micros(); +#if !defined(HW_REV_VER_ADC_BASE) +# define HW_REV_VER_ADC_BASE STM32_ADC1_BASE +#endif -#if defined(__PX4_NUTTX) -extern bool task_should_exit; -/** - * Returns true if the app/task should continue to run - */ -__EXPORT inline bool ok() { return !task_should_exit; } -#elif defined(__PX4_QURT) -// FIXME - usleep not supported by DSPAL -inline void usleep(uint64_t sleep_interval) { } -#else -/** - * Linux needs to have globally unique checks for thread/task status - */ +#if !defined(SYSTEM_ADC_BASE) +# define SYSTEM_ADC_BASE STM32_ADC1_BASE #endif -} // namespace px4 +#include + diff --git a/src/drivers/stm32/drv_io_timer.h b/platforms/nuttx/src/px4/stm/stm32_common/include/px4_arch/io_timer.h similarity index 100% rename from src/drivers/stm32/drv_io_timer.h rename to platforms/nuttx/src/px4/stm/stm32_common/include/px4_arch/io_timer.h diff --git a/platforms/nuttx/src/px4/stm/stm32_common/include/px4_arch/micro_hal.h b/platforms/nuttx/src/px4/stm/stm32_common/include/px4_arch/micro_hal.h new file mode 100644 index 000000000000..6b1bb58216cf --- /dev/null +++ b/platforms/nuttx/src/px4/stm/stm32_common/include/px4_arch/micro_hal.h @@ -0,0 +1,105 @@ +/**************************************************************************** + * + * Copyright (c) 2019 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. + * + ****************************************************************************/ +#pragma once + +#include + +__BEGIN_DECLS + +#include +#include +#include + +/* STM32/32F7 defines the 96 bit UUID as + * init32_t[3] that can be read as bytes/half-words/words + * init32_t[0] PX4_CPU_UUID_ADDRESS[0] bits 31:0 (offset 0) + * init32_t[1] PX4_CPU_UUID_ADDRESS[1] bits 63:32 (offset 4) + * init32_t[2] PX4_CPU_UUID_ADDRESS[3] bits 96:64 (offset 8) + * + * The original PX4 stm32 (legacy) based implementation **displayed** the + * UUID as: ABCD EFGH IJKL + * Where: + * A was bit 31 and D was bit 0 + * E was bit 63 and H was bit 32 + * I was bit 95 and L was bit 64 + * + * Since the string was used by some manufactures to identify the units + * it must be preserved. + * + * For new targets moving forward we will use + * IJKL EFGH ABCD + */ +#define PX4_CPU_UUID_BYTE_LENGTH 12 +#define PX4_CPU_UUID_WORD32_LENGTH (PX4_CPU_UUID_BYTE_LENGTH/sizeof(uint32_t)) + +/* The mfguid will be an array of bytes with + * MSD @ index 0 - LSD @ index PX4_CPU_MFGUID_BYTE_LENGTH-1 + * + * It will be converted to a string with the MSD on left and LSD on the right most position. + */ +#define PX4_CPU_MFGUID_BYTE_LENGTH PX4_CPU_UUID_BYTE_LENGTH + +/* By not defining PX4_CPU_UUID_CORRECT_CORRELATION the following maintains the legacy incorrect order + * used for selection of significant digits of the UUID in the PX4 code base. + * This is done to avoid the ripple effects changing the IDs used on STM32 base platforms + */ +#if defined(PX4_CPU_UUID_CORRECT_CORRELATION) +# define PX4_CPU_UUID_WORD32_UNIQUE_H 0 /* Least significant digits change the most */ +# define PX4_CPU_UUID_WORD32_UNIQUE_M 1 /* Middle significant digits */ +# define PX4_CPU_UUID_WORD32_UNIQUE_L 2 /* Most significant digits change the least */ +#else +/* Legacy incorrect ordering */ +# define PX4_CPU_UUID_WORD32_UNIQUE_H 2 /* Most significant digits change the least */ +# define PX4_CPU_UUID_WORD32_UNIQUE_M 1 /* Middle significant digits */ +# define PX4_CPU_UUID_WORD32_UNIQUE_L 0 /* Least significant digits change the most */ +#endif + +/* Separator nnn:nnn:nnnn 2 char per byte term */ +#define PX4_CPU_UUID_WORD32_FORMAT_SIZE (PX4_CPU_UUID_WORD32_LENGTH-1+(2*PX4_CPU_UUID_BYTE_LENGTH)+1) +#define PX4_CPU_MFGUID_FORMAT_SIZE ((2*PX4_CPU_MFGUID_BYTE_LENGTH)+1) + +#define px4_savepanic(fileno, context, length) stm32_bbsram_savepanic(fileno, context, length) + +#define PX4_BUS_OFFSET 0 /* STM buses are 1 based no adjustment needed */ +#define px4_spibus_initialize(bus_num_1based) stm32_spibus_initialize(bus_num_1based) + +#define px4_i2cbus_initialize(bus_num_1based) stm32_i2cbus_initialize(bus_num_1based) +#define px4_i2cbus_uninitialize(pdev) stm32_i2cbus_uninitialize(pdev) + +#define px4_arch_configgpio(pinset) stm32_configgpio(pinset) +#define px4_arch_unconfiggpio(pinset) stm32_unconfiggpio(pinset) +#define px4_arch_gpioread(pinset) stm32_gpioread(pinset) +#define px4_arch_gpiowrite(pinset, value) stm32_gpiowrite(pinset, value) +#define px4_arch_gpiosetevent(pinset,r,f,e,fp,a) stm32_gpiosetevent(pinset,r,f,e,fp,a) + +__END_DECLS diff --git a/src/drivers/px4io/px4io_serial.h b/platforms/nuttx/src/px4/stm/stm32_common/include/px4_arch/px4io_serial.h similarity index 65% rename from src/drivers/px4io/px4io_serial.h rename to platforms/nuttx/src/px4/stm/stm32_common/include/px4_arch/px4io_serial.h index 8e17606da68e..f8888f402419 100644 --- a/src/drivers/px4io/px4io_serial.h +++ b/platforms/nuttx/src/px4/stm/stm32_common/include/px4_arch/px4io_serial.h @@ -32,32 +32,18 @@ ****************************************************************************/ /** - * @file px4io_driver.h + * @file px4io_serial.h * - * Interface for PX4IO + * Serial Interface definition for PX4IO */ #pragma once -/* XXX trim includes */ +#include #include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include #include -#include - #include #include @@ -117,87 +103,17 @@ class PX4IO_serial : public device::Device PX4IO_serial &operator = (const PX4IO_serial &); }; -#if defined(CONFIG_STM32_STM32F10XX) || defined(CONFIG_STM32_STM32F4XXX) -/** XXX use F4 implementation for F1 as well. **/ - -#define PX4IO_INTERFACE_CLASS PX4IO_serial_f4 -#define PX4IO_INTERFACE_F4 - -class PX4IO_serial_f4 : public PX4IO_serial -{ -public: - PX4IO_serial_f4(); - ~PX4IO_serial_f4(); - - virtual int init(); - virtual int ioctl(unsigned operation, unsigned &arg); - -protected: - /** - * Start the transaction with IO and wait for it to complete. - */ - int _bus_exchange(IOPacket *_packet); - -private: - DMA_HANDLE _tx_dma; - DMA_HANDLE _rx_dma; - - IOPacket *_current_packet; - - /** saved DMA status */ - static const unsigned _dma_status_inactive = 0x80000000; // low bits overlap DMA_STATUS_* values - static const unsigned _dma_status_waiting = 0x00000000; - volatile unsigned _rx_dma_status; - - /** client-waiting lock/signal */ - px4_sem_t _completion_semaphore; - - /** - * DMA completion handler. - */ - static void _dma_callback(DMA_HANDLE handle, uint8_t status, void *arg); - void _do_rx_dma_callback(unsigned status); - - /** - * Serial interrupt handler. - */ - static int _interrupt(int vector, void *context, void *arg); - void _do_interrupt(); - - /** - * Cancel any DMA in progress with an error. - */ - void _abort_dma(); - - /** - * Performance counters. - */ - perf_counter_t _pc_dmasetup; - perf_counter_t _pc_dmaerrs; - - /* do not allow top copying this class */ - PX4IO_serial_f4(PX4IO_serial_f4 &); - PX4IO_serial_f4 &operator = (const PX4IO_serial_f4 &); - - /** - * IO Buffer storage - */ - static IOPacket _io_buffer_storage; // XXX static to ensure DMA-able memory -}; - -#elif defined(CONFIG_ARCH_CHIP_STM32F7) - -#define PX4IO_INTERFACE_CLASS PX4IO_serial_f7 -#define PX4IO_INTERFACE_F7 #include -class PX4IO_serial_f7 : public PX4IO_serial +class ArchPX4IOSerial : public PX4IO_serial { public: - PX4IO_serial_f7(); - ~PX4IO_serial_f7(); + ArchPX4IOSerial(); + ArchPX4IOSerial(ArchPX4IOSerial &) = delete; + ArchPX4IOSerial &operator = (const ArchPX4IOSerial &) = delete; + ~ArchPX4IOSerial(); virtual int init(); virtual int ioctl(unsigned operation, unsigned &arg); @@ -245,16 +161,9 @@ class PX4IO_serial_f7 : public PX4IO_serial perf_counter_t _pc_dmasetup; perf_counter_t _pc_dmaerrs; - /* do not allow top copying this class */ - PX4IO_serial_f7(PX4IO_serial_f7 &); - PX4IO_serial_f7 &operator = (const PX4IO_serial_f7 &); - /** * IO Buffer storage */ - static uint8_t _io_buffer_storage[] __attribute__((aligned(ARMV7M_DCACHE_LINESIZE))); + static uint8_t _io_buffer_storage[] __attribute__((aligned(PX4IO_SERIAL_BUF_ALIGN))); }; -#else -#error "Interface not implemented for this chip" -#endif diff --git a/platforms/nuttx/src/px4/stm/stm32_common/io_pins/CMakeLists.txt b/platforms/nuttx/src/px4/stm/stm32_common/io_pins/CMakeLists.txt new file mode 100644 index 000000000000..401bf06ef5dd --- /dev/null +++ b/platforms/nuttx/src/px4/stm/stm32_common/io_pins/CMakeLists.txt @@ -0,0 +1,39 @@ +############################################################################ +# +# Copyright (c) 2015-2019 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. +# +############################################################################ + +px4_add_library(arch_io_pins + io_timer.c + pwm_servo.c + pwm_trigger.c + input_capture.c +) diff --git a/src/drivers/stm32/drv_input_capture.c b/platforms/nuttx/src/px4/stm/stm32_common/io_pins/input_capture.c similarity index 99% rename from src/drivers/stm32/drv_input_capture.c rename to platforms/nuttx/src/px4/stm/stm32_common/io_pins/input_capture.c index c7505087b1b6..a1eb6a9743a0 100644 --- a/src/drivers/stm32/drv_input_capture.c +++ b/platforms/nuttx/src/px4/stm/stm32_common/io_pins/input_capture.c @@ -72,9 +72,7 @@ #include #include -#include "drv_io_timer.h" - -#include "drv_input_capture.h" +#include #include #include diff --git a/src/drivers/stm32/drv_io_timer.c b/platforms/nuttx/src/px4/stm/stm32_common/io_pins/io_timer.c similarity index 99% rename from src/drivers/stm32/drv_io_timer.c rename to platforms/nuttx/src/px4/stm/stm32_common/io_pins/io_timer.c index 4f654e8a6762..7a11dec0adbc 100644 --- a/src/drivers/stm32/drv_io_timer.c +++ b/platforms/nuttx/src/px4/stm/stm32_common/io_pins/io_timer.c @@ -58,7 +58,7 @@ #include #include -#include "drv_io_timer.h" +#include #include #include diff --git a/src/drivers/stm32/drv_pwm_servo.c b/platforms/nuttx/src/px4/stm/stm32_common/io_pins/pwm_servo.c similarity index 98% rename from src/drivers/stm32/drv_pwm_servo.c rename to platforms/nuttx/src/px4/stm/stm32_common/io_pins/pwm_servo.c index b75772ebc418..9121ea488b14 100644 --- a/src/drivers/stm32/drv_pwm_servo.c +++ b/platforms/nuttx/src/px4/stm/stm32_common/io_pins/pwm_servo.c @@ -58,8 +58,7 @@ #include #include -#include "drv_io_timer.h" -#include "drv_pwm_servo.h" +#include #include diff --git a/src/drivers/stm32/drv_pwm_trigger.c b/platforms/nuttx/src/px4/stm/stm32_common/io_pins/pwm_trigger.c similarity index 98% rename from src/drivers/stm32/drv_pwm_trigger.c rename to platforms/nuttx/src/px4/stm/stm32_common/io_pins/pwm_trigger.c index 86f38acf3964..477206d25fe0 100644 --- a/src/drivers/stm32/drv_pwm_trigger.c +++ b/platforms/nuttx/src/px4/stm/stm32_common/io_pins/pwm_trigger.c @@ -54,8 +54,7 @@ #include #include -#include "drv_io_timer.h" -#include "drv_pwm_trigger.h" +#include #include diff --git a/platforms/nuttx/src/px4/stm/stm32_common/led_pwm/CMakeLists.txt b/platforms/nuttx/src/px4/stm/stm32_common/led_pwm/CMakeLists.txt new file mode 100644 index 000000000000..1b1504352612 --- /dev/null +++ b/platforms/nuttx/src/px4/stm/stm32_common/led_pwm/CMakeLists.txt @@ -0,0 +1,36 @@ +############################################################################ +# +# Copyright (c) 2015-2019 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. +# +############################################################################ + +px4_add_library(arch_led_pwm + led_pwm.cpp +) diff --git a/src/drivers/stm32/drv_led_pwm.cpp b/platforms/nuttx/src/px4/stm/stm32_common/led_pwm/led_pwm.cpp similarity index 99% rename from src/drivers/stm32/drv_led_pwm.cpp rename to platforms/nuttx/src/px4/stm/stm32_common/led_pwm/led_pwm.cpp index c9eafb239171..46cfceeb478a 100644 --- a/src/drivers/stm32/drv_led_pwm.cpp +++ b/platforms/nuttx/src/px4/stm/stm32_common/led_pwm/led_pwm.cpp @@ -57,7 +57,7 @@ #include #include -#include +#include diff --git a/src/drivers/sim/tone_alarm/CMakeLists.txt b/platforms/nuttx/src/px4/stm/stm32_common/tone_alarm/CMakeLists.txt similarity index 97% rename from src/drivers/sim/tone_alarm/CMakeLists.txt rename to platforms/nuttx/src/px4/stm/stm32_common/tone_alarm/CMakeLists.txt index 5251d3910a7a..a2d2f8144bcc 100644 --- a/src/drivers/sim/tone_alarm/CMakeLists.txt +++ b/platforms/nuttx/src/px4/stm/stm32_common/tone_alarm/CMakeLists.txt @@ -31,6 +31,6 @@ # ############################################################################ -px4_add_library(tone_alarm_interface +px4_add_library(arch_tone_alarm ToneAlarmInterface.cpp ) diff --git a/src/drivers/stm32/tone_alarm/ToneAlarmInterface.cpp b/platforms/nuttx/src/px4/stm/stm32_common/tone_alarm/ToneAlarmInterface.cpp similarity index 100% rename from src/drivers/stm32/tone_alarm/ToneAlarmInterface.cpp rename to platforms/nuttx/src/px4/stm/stm32_common/tone_alarm/ToneAlarmInterface.cpp diff --git a/src/drivers/stm32/tone_alarm/ToneAlarmInterfaceGPIO.cpp b/platforms/nuttx/src/px4/stm/stm32_common/tone_alarm/ToneAlarmInterfaceGPIO.cpp similarity index 91% rename from src/drivers/stm32/tone_alarm/ToneAlarmInterfaceGPIO.cpp rename to platforms/nuttx/src/px4/stm/stm32_common/tone_alarm/ToneAlarmInterfaceGPIO.cpp index c73a51296379..c1d9603e9bb1 100644 --- a/src/drivers/stm32/tone_alarm/ToneAlarmInterfaceGPIO.cpp +++ b/platforms/nuttx/src/px4/stm/stm32_common/tone_alarm/ToneAlarmInterfaceGPIO.cpp @@ -31,23 +31,28 @@ * ****************************************************************************/ -#include +#include #include #include -void ToneAlarmInterface::init() +namespace ToneAlarmInterface +{ + +void init() { // Configure the GPIO to the idle state. px4_arch_configgpio(GPIO_TONE_ALARM_IDLE); } -void ToneAlarmInterface::start_note(unsigned frequency) +void start_note(unsigned frequency) { px4_arch_gpiowrite(GPIO_TONE_ALARM_GPIO, 1); } -void ToneAlarmInterface::stop_note() +void stop_note() { // Stop the current note. px4_arch_gpiowrite(GPIO_TONE_ALARM_GPIO, 0); } + +} /* namespace ToneAlarmInterface */ diff --git a/src/drivers/stm32/tone_alarm/ToneAlarmInterfacePWM.cpp b/platforms/nuttx/src/px4/stm/stm32_common/tone_alarm/ToneAlarmInterfacePWM.cpp similarity index 98% rename from src/drivers/stm32/tone_alarm/ToneAlarmInterfacePWM.cpp rename to platforms/nuttx/src/px4/stm/stm32_common/tone_alarm/ToneAlarmInterfacePWM.cpp index eb72700a0adc..da29ce28f487 100644 --- a/src/drivers/stm32/tone_alarm/ToneAlarmInterfacePWM.cpp +++ b/platforms/nuttx/src/px4/stm/stm32_common/tone_alarm/ToneAlarmInterfacePWM.cpp @@ -32,7 +32,7 @@ ****************************************************************************/ #include -#include +#include #include #include @@ -219,7 +219,10 @@ # define rSR REG(STM32_GTIM_SR_OFFSET) #endif -void ToneAlarmInterface::init() +namespace ToneAlarmInterface +{ + +void init() { #ifdef GPIO_TONE_ALARM_NEG px4_arch_configgpio(GPIO_TONE_ALARM_NEG); @@ -251,7 +254,7 @@ void ToneAlarmInterface::init() rCR1 = GTIM_CR1_CEN; // Ensure the timer is running. } -void ToneAlarmInterface::start_note(unsigned frequency) +void start_note(unsigned frequency) { // Calculate the signal switching period. // (Signal switching period is one half of the frequency period). @@ -276,7 +279,7 @@ void ToneAlarmInterface::start_note(unsigned frequency) px4_arch_configgpio(GPIO_TONE_ALARM); } -void ToneAlarmInterface::stop_note() +void stop_note() { // Stop the current note. rCCER &= ~TONE_CCER; @@ -284,3 +287,5 @@ void ToneAlarmInterface::stop_note() // Ensure the GPIO is not driving the speaker. px4_arch_configgpio(GPIO_TONE_ALARM_IDLE); } + +} /* namespace ToneAlarmInterface */ diff --git a/platforms/nuttx/src/px4/stm/stm32f1/CMakeLists.txt b/platforms/nuttx/src/px4/stm/stm32f1/CMakeLists.txt new file mode 100644 index 000000000000..ead07409b1af --- /dev/null +++ b/platforms/nuttx/src/px4/stm/stm32f1/CMakeLists.txt @@ -0,0 +1,36 @@ +############################################################################ +# +# Copyright (c) 2019 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. +# +############################################################################ + + +add_subdirectory(../stm32_common/io_pins io_pins) +add_subdirectory(../stm32_common/hrt hrt) diff --git a/src/drivers/kinetis/drv_pwm_trigger.h b/platforms/nuttx/src/px4/stm/stm32f1/include/px4_arch/io_timer.h similarity index 90% rename from src/drivers/kinetis/drv_pwm_trigger.h rename to platforms/nuttx/src/px4/stm/stm32f1/include/px4_arch/io_timer.h index e27902f51455..2960835d2ec2 100644 --- a/src/drivers/kinetis/drv_pwm_trigger.h +++ b/platforms/nuttx/src/px4/stm/stm32f1/include/px4_arch/io_timer.h @@ -1,6 +1,6 @@ /**************************************************************************** * - * Copyright (C) 2017 PX4 Development Team. All rights reserved. + * Copyright (c) 2019 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 @@ -30,13 +30,8 @@ * POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************/ +#pragma once -/** - * @file drv_pwm_trigger.h - * - * stm32-specific PWM output data. - */ -#pragma once +#include "../../../stm32_common/include/px4_arch/io_timer.h" -#include diff --git a/platforms/nuttx/src/px4/stm/stm32f1/include/px4_arch/micro_hal.h b/platforms/nuttx/src/px4/stm/stm32f1/include/px4_arch/micro_hal.h new file mode 100644 index 000000000000..2c06c7641c3d --- /dev/null +++ b/platforms/nuttx/src/px4/stm/stm32f1/include/px4_arch/micro_hal.h @@ -0,0 +1,51 @@ +/**************************************************************************** + * + * Copyright (c) 2019 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. + * + ****************************************************************************/ +#pragma once + + +#include "../../../stm32_common/include/px4_arch/micro_hal.h" + +__BEGIN_DECLS + +#include +#define PX4_SOC_ARCH_ID PX4_SOC_ARCH_ID_STM32F4 +#define PX4_FLASH_BASE STM32_FLASH_BASE +#if defined(CONFIG_STM32_STM32F4XXX) +# include +# define PX4_BBSRAM_SIZE STM32_BBSRAM_SIZE +# define PX4_BBSRAM_GETDESC_IOCTL STM32_BBSRAM_GETDESC_IOCTL +#endif +#define PX4_NUMBER_I2C_BUSES STM32_NI2C + +__END_DECLS + diff --git a/src/drivers/stm32/drv_pwm_trigger.h b/platforms/nuttx/src/px4/stm/stm32f1/io_timer.h similarity index 90% rename from src/drivers/stm32/drv_pwm_trigger.h rename to platforms/nuttx/src/px4/stm/stm32f1/io_timer.h index e27902f51455..2960835d2ec2 100644 --- a/src/drivers/stm32/drv_pwm_trigger.h +++ b/platforms/nuttx/src/px4/stm/stm32f1/io_timer.h @@ -1,6 +1,6 @@ /**************************************************************************** * - * Copyright (C) 2017 PX4 Development Team. All rights reserved. + * Copyright (c) 2019 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 @@ -30,13 +30,8 @@ * POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************/ +#pragma once -/** - * @file drv_pwm_trigger.h - * - * stm32-specific PWM output data. - */ -#pragma once +#include "../../../stm32_common/include/px4_arch/io_timer.h" -#include diff --git a/platforms/nuttx/src/px4/stm/stm32f3/CMakeLists.txt b/platforms/nuttx/src/px4/stm/stm32f3/CMakeLists.txt new file mode 100644 index 000000000000..40432707c786 --- /dev/null +++ b/platforms/nuttx/src/px4/stm/stm32f3/CMakeLists.txt @@ -0,0 +1,37 @@ +############################################################################ +# +# Copyright (c) 2019 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. +# +############################################################################ + + +add_subdirectory(../stm32_common/hrt hrt) + + diff --git a/platforms/nuttx/src/px4/stm/stm32f3/include/px4_arch/adc.h b/platforms/nuttx/src/px4/stm/stm32f3/include/px4_arch/adc.h new file mode 100644 index 000000000000..9aa5b0c7aeba --- /dev/null +++ b/platforms/nuttx/src/px4/stm/stm32f3/include/px4_arch/adc.h @@ -0,0 +1,36 @@ +/**************************************************************************** + * + * Copyright (c) 2019 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. + * + ****************************************************************************/ +#pragma once + +#include "../../../stm32_common/include/px4_arch/adc.h" + diff --git a/platforms/nuttx/src/px4/stm/stm32f3/include/px4_arch/io_timer.h b/platforms/nuttx/src/px4/stm/stm32f3/include/px4_arch/io_timer.h new file mode 100644 index 000000000000..2960835d2ec2 --- /dev/null +++ b/platforms/nuttx/src/px4/stm/stm32f3/include/px4_arch/io_timer.h @@ -0,0 +1,37 @@ +/**************************************************************************** + * + * Copyright (c) 2019 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. + * + ****************************************************************************/ +#pragma once + + +#include "../../../stm32_common/include/px4_arch/io_timer.h" + diff --git a/platforms/nuttx/src/px4/stm/stm32f3/include/px4_arch/micro_hal.h b/platforms/nuttx/src/px4/stm/stm32f3/include/px4_arch/micro_hal.h new file mode 100644 index 000000000000..2c06c7641c3d --- /dev/null +++ b/platforms/nuttx/src/px4/stm/stm32f3/include/px4_arch/micro_hal.h @@ -0,0 +1,51 @@ +/**************************************************************************** + * + * Copyright (c) 2019 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. + * + ****************************************************************************/ +#pragma once + + +#include "../../../stm32_common/include/px4_arch/micro_hal.h" + +__BEGIN_DECLS + +#include +#define PX4_SOC_ARCH_ID PX4_SOC_ARCH_ID_STM32F4 +#define PX4_FLASH_BASE STM32_FLASH_BASE +#if defined(CONFIG_STM32_STM32F4XXX) +# include +# define PX4_BBSRAM_SIZE STM32_BBSRAM_SIZE +# define PX4_BBSRAM_GETDESC_IOCTL STM32_BBSRAM_GETDESC_IOCTL +#endif +#define PX4_NUMBER_I2C_BUSES STM32_NI2C + +__END_DECLS + diff --git a/platforms/nuttx/src/px4/stm/stm32f4/CMakeLists.txt b/platforms/nuttx/src/px4/stm/stm32f4/CMakeLists.txt new file mode 100644 index 000000000000..0b5fe399e0b7 --- /dev/null +++ b/platforms/nuttx/src/px4/stm/stm32f4/CMakeLists.txt @@ -0,0 +1,42 @@ +############################################################################ +# +# Copyright (c) 2019 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. +# +############################################################################ + + +add_subdirectory(../stm32_common/adc adc) +add_subdirectory(../stm32_common/hrt hrt) +add_subdirectory(../stm32_common/led_pwm led_pwm) +add_subdirectory(../stm32_common/io_pins io_pins) +add_subdirectory(../stm32_common/tone_alarm tone_alarm) + +add_subdirectory(px4io_serial) + diff --git a/platforms/nuttx/src/px4/stm/stm32f4/include/px4_arch/adc.h b/platforms/nuttx/src/px4/stm/stm32f4/include/px4_arch/adc.h new file mode 100644 index 000000000000..9aa5b0c7aeba --- /dev/null +++ b/platforms/nuttx/src/px4/stm/stm32f4/include/px4_arch/adc.h @@ -0,0 +1,36 @@ +/**************************************************************************** + * + * Copyright (c) 2019 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. + * + ****************************************************************************/ +#pragma once + +#include "../../../stm32_common/include/px4_arch/adc.h" + diff --git a/platforms/nuttx/src/px4/stm/stm32f4/include/px4_arch/io_timer.h b/platforms/nuttx/src/px4/stm/stm32f4/include/px4_arch/io_timer.h new file mode 100644 index 000000000000..2960835d2ec2 --- /dev/null +++ b/platforms/nuttx/src/px4/stm/stm32f4/include/px4_arch/io_timer.h @@ -0,0 +1,37 @@ +/**************************************************************************** + * + * Copyright (c) 2019 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. + * + ****************************************************************************/ +#pragma once + + +#include "../../../stm32_common/include/px4_arch/io_timer.h" + diff --git a/platforms/nuttx/src/px4/stm/stm32f4/include/px4_arch/micro_hal.h b/platforms/nuttx/src/px4/stm/stm32f4/include/px4_arch/micro_hal.h new file mode 100644 index 000000000000..2c06c7641c3d --- /dev/null +++ b/platforms/nuttx/src/px4/stm/stm32f4/include/px4_arch/micro_hal.h @@ -0,0 +1,51 @@ +/**************************************************************************** + * + * Copyright (c) 2019 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. + * + ****************************************************************************/ +#pragma once + + +#include "../../../stm32_common/include/px4_arch/micro_hal.h" + +__BEGIN_DECLS + +#include +#define PX4_SOC_ARCH_ID PX4_SOC_ARCH_ID_STM32F4 +#define PX4_FLASH_BASE STM32_FLASH_BASE +#if defined(CONFIG_STM32_STM32F4XXX) +# include +# define PX4_BBSRAM_SIZE STM32_BBSRAM_SIZE +# define PX4_BBSRAM_GETDESC_IOCTL STM32_BBSRAM_GETDESC_IOCTL +#endif +#define PX4_NUMBER_I2C_BUSES STM32_NI2C + +__END_DECLS + diff --git a/platforms/nuttx/src/px4/stm/stm32f4/include/px4_arch/px4io_serial.h b/platforms/nuttx/src/px4/stm/stm32f4/include/px4_arch/px4io_serial.h new file mode 100644 index 000000000000..77564d2ad09f --- /dev/null +++ b/platforms/nuttx/src/px4/stm/stm32f4/include/px4_arch/px4io_serial.h @@ -0,0 +1,38 @@ +/**************************************************************************** + * + * Copyright (c) 2019 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. + * + ****************************************************************************/ + +#pragma once + +#define PX4IO_SERIAL_BUF_ALIGN 4 +#include "../../../stm32_common/include/px4_arch/px4io_serial.h" + diff --git a/platforms/nuttx/src/px4/stm/stm32f4/px4io_serial/CMakeLists.txt b/platforms/nuttx/src/px4/stm/stm32f4/px4io_serial/CMakeLists.txt new file mode 100644 index 000000000000..df450593b1b8 --- /dev/null +++ b/platforms/nuttx/src/px4/stm/stm32f4/px4io_serial/CMakeLists.txt @@ -0,0 +1,36 @@ +############################################################################ +# +# Copyright (c) 2015-2019 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. +# +############################################################################ + +px4_add_library(arch_px4io_serial + px4io_serial.cpp +) diff --git a/src/drivers/px4io/px4io_serial_f4.cpp b/platforms/nuttx/src/px4/stm/stm32f4/px4io_serial/px4io_serial.cpp similarity index 93% rename from src/drivers/px4io/px4io_serial_f4.cpp rename to platforms/nuttx/src/px4/stm/stm32f4/px4io_serial/px4io_serial.cpp index 8ada27f0a1c2..8b70c62dc473 100644 --- a/src/drivers/px4io/px4io_serial_f4.cpp +++ b/platforms/nuttx/src/px4/stm/stm32f4/px4io_serial/px4io_serial.cpp @@ -32,14 +32,12 @@ ****************************************************************************/ /** - * @file px4io_serial_f4.cpp + * @file px4io_serial.cpp * * Serial interface for PX4IO on STM32F4 */ -#include "px4io_serial.h" - -#ifdef PX4IO_INTERFACE_F4 +#include /* serial register accessors */ #define REG(_x) (*(volatile uint32_t *)(PX4IO_SERIAL_BASE + _x)) @@ -51,9 +49,9 @@ #define rCR3 REG(STM32_USART_CR3_OFFSET) #define rGTPR REG(STM32_USART_GTPR_OFFSET) -IOPacket PX4IO_serial_f4::_io_buffer_storage; +uint8_t ArchPX4IOSerial::_io_buffer_storage[sizeof(IOPacket)]; -PX4IO_serial_f4::PX4IO_serial_f4() : +ArchPX4IOSerial::ArchPX4IOSerial() : _tx_dma(nullptr), _rx_dma(nullptr), _current_packet(nullptr), @@ -69,7 +67,7 @@ PX4IO_serial_f4::PX4IO_serial_f4() : { } -PX4IO_serial_f4::~PX4IO_serial_f4() +ArchPX4IOSerial::~ArchPX4IOSerial() { if (_tx_dma != nullptr) { stm32_dmastop(_tx_dma); @@ -105,12 +103,12 @@ PX4IO_serial_f4::~PX4IO_serial_f4() } int -PX4IO_serial_f4::init() +ArchPX4IOSerial::init() { /* initialize base implementation */ int r; - if ((r = PX4IO_serial::init(&_io_buffer_storage)) != 0) { + if ((r = PX4IO_serial::init((IOPacket *)&_io_buffer_storage[0])) != 0) { return r; } @@ -167,7 +165,7 @@ PX4IO_serial_f4::init() } int -PX4IO_serial_f4::ioctl(unsigned operation, unsigned &arg) +ArchPX4IOSerial::ioctl(unsigned operation, unsigned &arg) { switch (operation) { @@ -232,7 +230,7 @@ PX4IO_serial_f4::ioctl(unsigned operation, unsigned &arg) } int -PX4IO_serial_f4::_bus_exchange(IOPacket *_packet) +ArchPX4IOSerial::_bus_exchange(IOPacket *_packet) { _current_packet = _packet; @@ -351,17 +349,17 @@ PX4IO_serial_f4::_bus_exchange(IOPacket *_packet) } void -PX4IO_serial_f4::_dma_callback(DMA_HANDLE handle, uint8_t status, void *arg) +ArchPX4IOSerial::_dma_callback(DMA_HANDLE handle, uint8_t status, void *arg) { if (arg != nullptr) { - PX4IO_serial_f4 *ps = reinterpret_cast(arg); + ArchPX4IOSerial *ps = reinterpret_cast(arg); ps->_do_rx_dma_callback(status); } } void -PX4IO_serial_f4::_do_rx_dma_callback(unsigned status) +ArchPX4IOSerial::_do_rx_dma_callback(unsigned status) { /* on completion of a reply, wake the waiter */ if (_rx_dma_status == _dma_status_waiting) { @@ -386,10 +384,10 @@ PX4IO_serial_f4::_do_rx_dma_callback(unsigned status) } int -PX4IO_serial_f4::_interrupt(int irq, void *context, void *arg) +ArchPX4IOSerial::_interrupt(int irq, void *context, void *arg) { if (arg != nullptr) { - PX4IO_serial_f4 *instance = reinterpret_cast(arg); + ArchPX4IOSerial *instance = reinterpret_cast(arg); instance->_do_interrupt(); } @@ -398,7 +396,7 @@ PX4IO_serial_f4::_interrupt(int irq, void *context, void *arg) } void -PX4IO_serial_f4::_do_interrupt() +ArchPX4IOSerial::_do_interrupt() { uint32_t sr = rSR; /* get UART status register */ (void)rDR; /* read DR to clear status */ @@ -458,7 +456,7 @@ PX4IO_serial_f4::_do_interrupt() } void -PX4IO_serial_f4::_abort_dma() +ArchPX4IOSerial::_abort_dma() { /* disable UART DMA */ rCR3 &= ~(USART_CR3_DMAT | USART_CR3_DMAR); @@ -471,4 +469,3 @@ PX4IO_serial_f4::_abort_dma() stm32_dmastop(_rx_dma); } -#endif /* PX4IO_INTERFACE_F4 */ diff --git a/platforms/nuttx/src/px4/stm/stm32f7/CMakeLists.txt b/platforms/nuttx/src/px4/stm/stm32f7/CMakeLists.txt new file mode 100644 index 000000000000..0b5fe399e0b7 --- /dev/null +++ b/platforms/nuttx/src/px4/stm/stm32f7/CMakeLists.txt @@ -0,0 +1,42 @@ +############################################################################ +# +# Copyright (c) 2019 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. +# +############################################################################ + + +add_subdirectory(../stm32_common/adc adc) +add_subdirectory(../stm32_common/hrt hrt) +add_subdirectory(../stm32_common/led_pwm led_pwm) +add_subdirectory(../stm32_common/io_pins io_pins) +add_subdirectory(../stm32_common/tone_alarm tone_alarm) + +add_subdirectory(px4io_serial) + diff --git a/platforms/nuttx/src/px4/stm/stm32f7/include/px4_arch/adc.h b/platforms/nuttx/src/px4/stm/stm32f7/include/px4_arch/adc.h new file mode 100644 index 000000000000..9aa5b0c7aeba --- /dev/null +++ b/platforms/nuttx/src/px4/stm/stm32f7/include/px4_arch/adc.h @@ -0,0 +1,36 @@ +/**************************************************************************** + * + * Copyright (c) 2019 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. + * + ****************************************************************************/ +#pragma once + +#include "../../../stm32_common/include/px4_arch/adc.h" + diff --git a/platforms/nuttx/src/px4/stm/stm32f7/include/px4_arch/io_timer.h b/platforms/nuttx/src/px4/stm/stm32f7/include/px4_arch/io_timer.h new file mode 100644 index 000000000000..2960835d2ec2 --- /dev/null +++ b/platforms/nuttx/src/px4/stm/stm32f7/include/px4_arch/io_timer.h @@ -0,0 +1,37 @@ +/**************************************************************************** + * + * Copyright (c) 2019 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. + * + ****************************************************************************/ +#pragma once + + +#include "../../../stm32_common/include/px4_arch/io_timer.h" + diff --git a/platforms/nuttx/src/px4/stm/stm32f7/include/px4_arch/micro_hal.h b/platforms/nuttx/src/px4/stm/stm32f7/include/px4_arch/micro_hal.h new file mode 100644 index 000000000000..af9a59589596 --- /dev/null +++ b/platforms/nuttx/src/px4/stm/stm32f7/include/px4_arch/micro_hal.h @@ -0,0 +1,55 @@ +/**************************************************************************** + * + * Copyright (c) 2019 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. + * + ****************************************************************************/ +#pragma once + + +#include "../../../stm32_common/include/px4_arch/micro_hal.h" + +__BEGIN_DECLS + +#define PX4_SOC_ARCH_ID PX4_SOC_ARCH_ID_STM32F7 +#include +#include +#include //include up_systemreset() which is included on stm32.h +#include +#define PX4_BBSRAM_SIZE STM32F7_BBSRAM_SIZE +#define PX4_BBSRAM_GETDESC_IOCTL STM32F7_BBSRAM_GETDESC_IOCTL +#define PX4_FLASH_BASE 0x08000000 +#define PX4_NUMBER_I2C_BUSES STM32F7_NI2C + +void stm32_flash_lock(void); +void stm32_flash_unlock(void); +int stm32_flash_writeprotect(size_t page, bool enabled); + +__END_DECLS + diff --git a/platforms/nuttx/src/px4/stm/stm32f7/include/px4_arch/px4io_serial.h b/platforms/nuttx/src/px4/stm/stm32f7/include/px4_arch/px4io_serial.h new file mode 100644 index 000000000000..0e78048670cc --- /dev/null +++ b/platforms/nuttx/src/px4/stm/stm32f7/include/px4_arch/px4io_serial.h @@ -0,0 +1,38 @@ +/**************************************************************************** + * + * Copyright (c) 2019 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. + * + ****************************************************************************/ + +#pragma once + +#define PX4IO_SERIAL_BUF_ALIGN ARMV7M_DCACHE_LINESIZE +#include "../../../stm32_common/include/px4_arch/px4io_serial.h" + diff --git a/platforms/nuttx/src/px4/stm/stm32f7/px4io_serial/CMakeLists.txt b/platforms/nuttx/src/px4/stm/stm32f7/px4io_serial/CMakeLists.txt new file mode 100644 index 000000000000..df450593b1b8 --- /dev/null +++ b/platforms/nuttx/src/px4/stm/stm32f7/px4io_serial/CMakeLists.txt @@ -0,0 +1,36 @@ +############################################################################ +# +# Copyright (c) 2015-2019 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. +# +############################################################################ + +px4_add_library(arch_px4io_serial + px4io_serial.cpp +) diff --git a/src/drivers/px4io/px4io_serial_f7.cpp b/platforms/nuttx/src/px4/stm/stm32f7/px4io_serial/px4io_serial.cpp similarity index 94% rename from src/drivers/px4io/px4io_serial_f7.cpp rename to platforms/nuttx/src/px4/stm/stm32f7/px4io_serial/px4io_serial.cpp index bcaa38f471a3..0161736a7ba3 100644 --- a/src/drivers/px4io/px4io_serial_f7.cpp +++ b/platforms/nuttx/src/px4/stm/stm32f7/px4io_serial/px4io_serial.cpp @@ -32,14 +32,12 @@ ****************************************************************************/ /** - * @file px4io_serial_f7.cpp + * @file px4io_serial.cpp * * Serial interface for PX4IO on STM32F7 */ -#include "px4io_serial.h" - -#ifdef PX4IO_INTERFACE_F7 +#include #include "stm32_uart.h" #include @@ -60,9 +58,9 @@ #define DMA_BUFFER_MASK (ARMV7M_DCACHE_LINESIZE - 1) #define DMA_ALIGN_UP(n) (((n) + DMA_BUFFER_MASK) & ~DMA_BUFFER_MASK) -uint8_t PX4IO_serial_f7::_io_buffer_storage[DMA_ALIGN_UP(sizeof(IOPacket))]; +uint8_t ArchPX4IOSerial::_io_buffer_storage[DMA_ALIGN_UP(sizeof(IOPacket))]; -PX4IO_serial_f7::PX4IO_serial_f7() : +ArchPX4IOSerial::ArchPX4IOSerial() : _tx_dma(nullptr), _rx_dma(nullptr), _current_packet(nullptr), @@ -78,7 +76,7 @@ PX4IO_serial_f7::PX4IO_serial_f7() : { } -PX4IO_serial_f7::~PX4IO_serial_f7() +ArchPX4IOSerial::~ArchPX4IOSerial() { if (_tx_dma != nullptr) { stm32_dmastop(_tx_dma); @@ -114,7 +112,7 @@ PX4IO_serial_f7::~PX4IO_serial_f7() } int -PX4IO_serial_f7::init() +ArchPX4IOSerial::init() { /* initialize base implementation */ int r = PX4IO_serial::init((IOPacket *)&_io_buffer_storage[0]); @@ -178,7 +176,7 @@ PX4IO_serial_f7::init() } int -PX4IO_serial_f7::ioctl(unsigned operation, unsigned &arg) +ArchPX4IOSerial::ioctl(unsigned operation, unsigned &arg) { switch (operation) { @@ -243,7 +241,7 @@ PX4IO_serial_f7::ioctl(unsigned operation, unsigned &arg) } int -PX4IO_serial_f7::_bus_exchange(IOPacket *_packet) +ArchPX4IOSerial::_bus_exchange(IOPacket *_packet) { _current_packet = _packet; @@ -369,17 +367,17 @@ PX4IO_serial_f7::_bus_exchange(IOPacket *_packet) } void -PX4IO_serial_f7::_dma_callback(DMA_HANDLE handle, uint8_t status, void *arg) +ArchPX4IOSerial::_dma_callback(DMA_HANDLE handle, uint8_t status, void *arg) { if (arg != nullptr) { - PX4IO_serial_f7 *ps = reinterpret_cast(arg); + ArchPX4IOSerial *ps = reinterpret_cast(arg); ps->_do_rx_dma_callback(status); } } void -PX4IO_serial_f7::_do_rx_dma_callback(unsigned status) +ArchPX4IOSerial::_do_rx_dma_callback(unsigned status) { /* on completion of a reply, wake the waiter */ if (_rx_dma_status == _dma_status_waiting) { @@ -405,10 +403,10 @@ PX4IO_serial_f7::_do_rx_dma_callback(unsigned status) } int -PX4IO_serial_f7::_interrupt(int irq, void *context, void *arg) +ArchPX4IOSerial::_interrupt(int irq, void *context, void *arg) { if (arg != nullptr) { - PX4IO_serial_f7 *instance = reinterpret_cast(arg); + ArchPX4IOSerial *instance = reinterpret_cast(arg); instance->_do_interrupt(); } @@ -417,7 +415,7 @@ PX4IO_serial_f7::_interrupt(int irq, void *context, void *arg) } void -PX4IO_serial_f7::_do_interrupt() +ArchPX4IOSerial::_do_interrupt() { uint32_t sr = rISR; /* get UART status register */ @@ -485,7 +483,7 @@ PX4IO_serial_f7::_do_interrupt() } void -PX4IO_serial_f7::_abort_dma() +ArchPX4IOSerial::_abort_dma() { /* stop DMA */ stm32_dmastop(_tx_dma); @@ -502,4 +500,3 @@ PX4IO_serial_f7::_abort_dma() rICR = rISR & rISR_ERR_FLAGS_MASK; /* clear the flags */ } -#endif /* PX4IO_INTERFACE_F7 */ diff --git a/platforms/posix/CMakeLists.txt b/platforms/posix/CMakeLists.txt index 3ba23f6123ea..131bbb305c4d 100644 --- a/platforms/posix/CMakeLists.txt +++ b/platforms/posix/CMakeLists.txt @@ -1,6 +1,4 @@ -add_subdirectory(src) - include_directories(${CMAKE_CURRENT_BINARY_DIR}) get_property(module_libraries GLOBAL PROPERTY PX4_MODULE_LIBRARIES) @@ -37,7 +35,7 @@ if (("${PX4_BOARD}" MATCHES "atlflight_eagle") OR ("${PX4_BOARD}" MATCHES "atlfl APPS_DEST "/home/linaro" SOURCES px4muorb_stub.c - src/main.cpp + src/px4/common/main.cpp apps.cpp LINK_LIBS -Wl,--start-group @@ -52,7 +50,7 @@ if (("${PX4_BOARD}" MATCHES "atlflight_eagle") OR ("${PX4_BOARD}" MATCHES "atlfl else() add_executable(px4 - src/main.cpp + src/px4/common/main.cpp apps.cpp ) diff --git a/platforms/posix/cmake/px4_impl_os.cmake b/platforms/posix/cmake/px4_impl_os.cmake index da86c70ce878..cbee631e3be5 100644 --- a/platforms/posix/cmake/px4_impl_os.cmake +++ b/platforms/posix/cmake/px4_impl_os.cmake @@ -42,6 +42,7 @@ # Required OS Interface Functions # # * px4_os_add_flags +# * px4_os_determine_build_chip # * px4_os_prebuild_targets # @@ -98,8 +99,8 @@ function(px4_posix_generate_builtin_commands) math(EXPR command_count "${command_count}+1") endif() endforeach() - configure_file(${PX4_SOURCE_DIR}/src/platforms/apps.cpp.in ${OUT}.cpp) - configure_file(${PX4_SOURCE_DIR}/src/platforms/apps.h.in ${OUT}.h) + configure_file(${PX4_SOURCE_DIR}/platforms/common/apps.cpp.in ${OUT}.cpp) + configure_file(${PX4_SOURCE_DIR}/platforms/common/apps.h.in ${OUT}.h) endfunction() @@ -149,7 +150,7 @@ function(px4_posix_generate_alias) ) endif() endforeach() - configure_file(${PX4_SOURCE_DIR}/platforms/posix/src/px4-alias.sh_in ${OUT}) + configure_file(${PX4_SOURCE_DIR}/platforms/posix/src/px4/common/px4-alias.sh_in ${OUT}) endfunction() @@ -325,6 +326,23 @@ function(px4_os_add_flags) endfunction() +#============================================================================= +# +# px4_os_determine_build_chip +# +# Sets PX4_CHIP and PX4_CHIP_MANUFACTURER. +# +# Usage: +# px4_os_determine_build_chip() +# +function(px4_os_determine_build_chip) + + # always use generic chip and chip manufacturer + set(PX4_CHIP "generic" CACHE STRING "PX4 Chip" FORCE) + set(PX4_CHIP_MANUFACTURER "generic" CACHE STRING "PX4 Chip Manufacturer" FORCE) + +endfunction() + #============================================================================= # # px4_os_prebuild_targets diff --git a/platforms/posix/src/px4/CMakeLists.txt b/platforms/posix/src/px4/CMakeLists.txt new file mode 100644 index 000000000000..929788b587e2 --- /dev/null +++ b/platforms/posix/src/px4/CMakeLists.txt @@ -0,0 +1,37 @@ +############################################################################ +# +# Copyright (c) 2019 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. +# +############################################################################ + +add_subdirectory(common) + +add_subdirectory(${PX4_CHIP_MANUFACTURER}) + diff --git a/platforms/posix/src/px4_layer/CMakeLists.txt b/platforms/posix/src/px4/common/CMakeLists.txt similarity index 94% rename from platforms/posix/src/px4_layer/CMakeLists.txt rename to platforms/posix/src/px4/common/CMakeLists.txt index a7024ce972e2..491f56bea62a 100644 --- a/platforms/posix/src/px4_layer/CMakeLists.txt +++ b/platforms/posix/src/px4/common/CMakeLists.txt @@ -31,6 +31,10 @@ # ############################################################################ + +add_subdirectory(px4_daemon) +add_subdirectory(lockstep_scheduler) + set(EXTRA_DEPENDS) if("${CONFIG_SHMEM}" STREQUAL "1") list(APPEND CMAKE_MODULE_PATH "${PX4_SOURCE_DIR}/boards/atlflight/cmake_hexagon") @@ -66,3 +70,10 @@ endif() if (EXTRA_DEPENDS) add_dependencies(px4_layer ${EXTRA_DEPENDS}) endif() + + +if (BUILD_TESTING) + add_subdirectory(test_stubs) + add_subdirectory(gtest_runner) +endif() + diff --git a/platforms/posix/src/px4_layer/drv_hrt.cpp b/platforms/posix/src/px4/common/drv_hrt.cpp similarity index 100% rename from platforms/posix/src/px4_layer/drv_hrt.cpp rename to platforms/posix/src/px4/common/drv_hrt.cpp diff --git a/src/platforms/posix/gtest_runner/CMakeLists.txt b/platforms/posix/src/px4/common/gtest_runner/CMakeLists.txt similarity index 100% rename from src/platforms/posix/gtest_runner/CMakeLists.txt rename to platforms/posix/src/px4/common/gtest_runner/CMakeLists.txt diff --git a/src/platforms/posix/gtest_runner/gtest_functional_main.cpp b/platforms/posix/src/px4/common/gtest_runner/gtest_functional_main.cpp similarity index 100% rename from src/platforms/posix/gtest_runner/gtest_functional_main.cpp rename to platforms/posix/src/px4/common/gtest_runner/gtest_functional_main.cpp diff --git a/platforms/posix/src/px4/common/include/px4_platform/micro_hal.h b/platforms/posix/src/px4/common/include/px4_platform/micro_hal.h new file mode 100644 index 000000000000..a629cda2f956 --- /dev/null +++ b/platforms/posix/src/px4/common/include/px4_platform/micro_hal.h @@ -0,0 +1,36 @@ +/**************************************************************************** + * + * Copyright (c) 2019 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. + * + ****************************************************************************/ +#pragma once + + + diff --git a/platforms/posix/src/px4_layer/lib_crc32.c b/platforms/posix/src/px4/common/lib_crc32.c similarity index 100% rename from platforms/posix/src/px4_layer/lib_crc32.c rename to platforms/posix/src/px4/common/lib_crc32.c diff --git a/platforms/posix/src/lockstep_scheduler/.gitignore b/platforms/posix/src/px4/common/lockstep_scheduler/.gitignore similarity index 100% rename from platforms/posix/src/lockstep_scheduler/.gitignore rename to platforms/posix/src/px4/common/lockstep_scheduler/.gitignore diff --git a/platforms/posix/src/lockstep_scheduler/CMakeLists.txt b/platforms/posix/src/px4/common/lockstep_scheduler/CMakeLists.txt similarity index 100% rename from platforms/posix/src/lockstep_scheduler/CMakeLists.txt rename to platforms/posix/src/px4/common/lockstep_scheduler/CMakeLists.txt diff --git a/platforms/posix/src/lockstep_scheduler/build-and-test.sh b/platforms/posix/src/px4/common/lockstep_scheduler/build-and-test.sh similarity index 100% rename from platforms/posix/src/lockstep_scheduler/build-and-test.sh rename to platforms/posix/src/px4/common/lockstep_scheduler/build-and-test.sh diff --git a/platforms/posix/src/lockstep_scheduler/include/lockstep_scheduler/lockstep_scheduler.h b/platforms/posix/src/px4/common/lockstep_scheduler/include/lockstep_scheduler/lockstep_scheduler.h similarity index 100% rename from platforms/posix/src/lockstep_scheduler/include/lockstep_scheduler/lockstep_scheduler.h rename to platforms/posix/src/px4/common/lockstep_scheduler/include/lockstep_scheduler/lockstep_scheduler.h diff --git a/platforms/posix/src/lockstep_scheduler/src/lockstep_scheduler.cpp b/platforms/posix/src/px4/common/lockstep_scheduler/src/lockstep_scheduler.cpp similarity index 100% rename from platforms/posix/src/lockstep_scheduler/src/lockstep_scheduler.cpp rename to platforms/posix/src/px4/common/lockstep_scheduler/src/lockstep_scheduler.cpp diff --git a/platforms/posix/src/lockstep_scheduler/test/CMakeLists.txt b/platforms/posix/src/px4/common/lockstep_scheduler/test/CMakeLists.txt similarity index 100% rename from platforms/posix/src/lockstep_scheduler/test/CMakeLists.txt rename to platforms/posix/src/px4/common/lockstep_scheduler/test/CMakeLists.txt diff --git a/platforms/posix/src/lockstep_scheduler/test/src/lockstep_scheduler_test.cpp b/platforms/posix/src/px4/common/lockstep_scheduler/test/src/lockstep_scheduler_test.cpp similarity index 100% rename from platforms/posix/src/lockstep_scheduler/test/src/lockstep_scheduler_test.cpp rename to platforms/posix/src/px4/common/lockstep_scheduler/test/src/lockstep_scheduler_test.cpp diff --git a/platforms/posix/src/main.cpp b/platforms/posix/src/px4/common/main.cpp similarity index 99% rename from platforms/posix/src/main.cpp rename to platforms/posix/src/px4/common/main.cpp index 21763ae2afa4..016969031a22 100644 --- a/platforms/posix/src/main.cpp +++ b/platforms/posix/src/px4/common/main.cpp @@ -64,14 +64,13 @@ #include #include +#include #include #include #include #include "apps.h" -#include "px4_middleware.h" #include "DriverFramework.hpp" -#include "px4_middleware.h" #include "px4_daemon/client.h" #include "px4_daemon/server.h" #include "px4_daemon/pxh.h" diff --git a/platforms/posix/src/px4-alias.sh_in b/platforms/posix/src/px4/common/px4-alias.sh_in similarity index 100% rename from platforms/posix/src/px4-alias.sh_in rename to platforms/posix/src/px4/common/px4-alias.sh_in diff --git a/platforms/posix/src/px4_daemon/CMakeLists.txt b/platforms/posix/src/px4/common/px4_daemon/CMakeLists.txt similarity index 100% rename from platforms/posix/src/px4_daemon/CMakeLists.txt rename to platforms/posix/src/px4/common/px4_daemon/CMakeLists.txt diff --git a/platforms/posix/src/px4_daemon/client.cpp b/platforms/posix/src/px4/common/px4_daemon/client.cpp similarity index 100% rename from platforms/posix/src/px4_daemon/client.cpp rename to platforms/posix/src/px4/common/px4_daemon/client.cpp diff --git a/platforms/posix/src/px4_daemon/client.h b/platforms/posix/src/px4/common/px4_daemon/client.h similarity index 100% rename from platforms/posix/src/px4_daemon/client.h rename to platforms/posix/src/px4/common/px4_daemon/client.h diff --git a/platforms/posix/src/px4_daemon/history.cpp b/platforms/posix/src/px4/common/px4_daemon/history.cpp similarity index 100% rename from platforms/posix/src/px4_daemon/history.cpp rename to platforms/posix/src/px4/common/px4_daemon/history.cpp diff --git a/platforms/posix/src/px4_daemon/history.h b/platforms/posix/src/px4/common/px4_daemon/history.h similarity index 100% rename from platforms/posix/src/px4_daemon/history.h rename to platforms/posix/src/px4/common/px4_daemon/history.h diff --git a/platforms/posix/src/px4_daemon/pxh.cpp b/platforms/posix/src/px4/common/px4_daemon/pxh.cpp similarity index 100% rename from platforms/posix/src/px4_daemon/pxh.cpp rename to platforms/posix/src/px4/common/px4_daemon/pxh.cpp diff --git a/platforms/posix/src/px4_daemon/pxh.h b/platforms/posix/src/px4/common/px4_daemon/pxh.h similarity index 100% rename from platforms/posix/src/px4_daemon/pxh.h rename to platforms/posix/src/px4/common/px4_daemon/pxh.h diff --git a/platforms/posix/src/px4_daemon/server.cpp b/platforms/posix/src/px4/common/px4_daemon/server.cpp similarity index 100% rename from platforms/posix/src/px4_daemon/server.cpp rename to platforms/posix/src/px4/common/px4_daemon/server.cpp diff --git a/platforms/posix/src/px4_daemon/server.h b/platforms/posix/src/px4/common/px4_daemon/server.h similarity index 100% rename from platforms/posix/src/px4_daemon/server.h rename to platforms/posix/src/px4/common/px4_daemon/server.h diff --git a/platforms/posix/src/px4_daemon/server_io.cpp b/platforms/posix/src/px4/common/px4_daemon/server_io.cpp similarity index 100% rename from platforms/posix/src/px4_daemon/server_io.cpp rename to platforms/posix/src/px4/common/px4_daemon/server_io.cpp diff --git a/platforms/posix/src/px4_daemon/sock_protocol.cpp b/platforms/posix/src/px4/common/px4_daemon/sock_protocol.cpp similarity index 100% rename from platforms/posix/src/px4_daemon/sock_protocol.cpp rename to platforms/posix/src/px4/common/px4_daemon/sock_protocol.cpp diff --git a/platforms/posix/src/px4_daemon/sock_protocol.h b/platforms/posix/src/px4/common/px4_daemon/sock_protocol.h similarity index 100% rename from platforms/posix/src/px4_daemon/sock_protocol.h rename to platforms/posix/src/px4/common/px4_daemon/sock_protocol.h diff --git a/platforms/qurt/src/px4_layer/px4_init.cpp b/platforms/posix/src/px4/common/px4_init.cpp similarity index 96% rename from platforms/qurt/src/px4_layer/px4_init.cpp rename to platforms/posix/src/px4/common/px4_init.cpp index e162ed15cd1b..73387de35f0e 100644 --- a/platforms/qurt/src/px4_layer/px4_init.cpp +++ b/platforms/posix/src/px4/common/px4_init.cpp @@ -37,7 +37,7 @@ #include #include #include -#include +#include int px4_platform_init(void) { diff --git a/platforms/posix/src/px4_layer/px4_posix_impl.cpp b/platforms/posix/src/px4/common/px4_posix_impl.cpp similarity index 97% rename from platforms/posix/src/px4_layer/px4_posix_impl.cpp rename to platforms/posix/src/px4/common/px4_posix_impl.cpp index 9c1cf6504214..3b31c6169869 100644 --- a/platforms/posix/src/px4_layer/px4_posix_impl.cpp +++ b/platforms/posix/src/px4/common/px4_posix_impl.cpp @@ -38,7 +38,6 @@ */ #include -#include #include #include #include @@ -98,10 +97,5 @@ void init(int argc, char *argv[], const char *app_name) #endif } -uint64_t get_time_micros() -{ - return hrt_absolute_time(); -} - } diff --git a/platforms/posix/src/px4_layer/px4_posix_tasks.cpp b/platforms/posix/src/px4/common/px4_posix_tasks.cpp similarity index 100% rename from platforms/posix/src/px4_layer/px4_posix_tasks.cpp rename to platforms/posix/src/px4/common/px4_posix_tasks.cpp diff --git a/platforms/posix/src/px4_layer/px4_sem.cpp b/platforms/posix/src/px4/common/px4_sem.cpp similarity index 99% rename from platforms/posix/src/px4_layer/px4_sem.cpp rename to platforms/posix/src/px4/common/px4_sem.cpp index e579c9222f64..d303f8e66ce1 100644 --- a/platforms/posix/src/px4_layer/px4_sem.cpp +++ b/platforms/posix/src/px4/common/px4_sem.cpp @@ -38,7 +38,6 @@ */ #include -#include #include #include #include diff --git a/platforms/posix/src/px4_layer/shmem_posix.cpp b/platforms/posix/src/px4/common/shmem_posix.cpp similarity index 100% rename from platforms/posix/src/px4_layer/shmem_posix.cpp rename to platforms/posix/src/px4/common/shmem_posix.cpp diff --git a/src/platforms/posix/test_stubs/CMakeLists.txt b/platforms/posix/src/px4/common/test_stubs/CMakeLists.txt similarity index 100% rename from src/platforms/posix/test_stubs/CMakeLists.txt rename to platforms/posix/src/px4/common/test_stubs/CMakeLists.txt diff --git a/src/platforms/posix/test_stubs/stub_daemon.cpp b/platforms/posix/src/px4/common/test_stubs/stub_daemon.cpp similarity index 100% rename from src/platforms/posix/test_stubs/stub_daemon.cpp rename to platforms/posix/src/px4/common/test_stubs/stub_daemon.cpp diff --git a/src/platforms/posix/test_stubs/stub_daemon.h b/platforms/posix/src/px4/common/test_stubs/stub_daemon.h similarity index 100% rename from src/platforms/posix/test_stubs/stub_daemon.h rename to platforms/posix/src/px4/common/test_stubs/stub_daemon.h diff --git a/src/platforms/posix/test_stubs/stub_devmgr.cpp b/platforms/posix/src/px4/common/test_stubs/stub_devmgr.cpp similarity index 100% rename from src/platforms/posix/test_stubs/stub_devmgr.cpp rename to platforms/posix/src/px4/common/test_stubs/stub_devmgr.cpp diff --git a/src/platforms/posix/test_stubs/stub_devmgr.h b/platforms/posix/src/px4/common/test_stubs/stub_devmgr.h similarity index 100% rename from src/platforms/posix/test_stubs/stub_devmgr.h rename to platforms/posix/src/px4/common/test_stubs/stub_devmgr.h diff --git a/src/platforms/posix/test_stubs/stub_parameter.cpp b/platforms/posix/src/px4/common/test_stubs/stub_parameter.cpp similarity index 100% rename from src/platforms/posix/test_stubs/stub_parameter.cpp rename to platforms/posix/src/px4/common/test_stubs/stub_parameter.cpp diff --git a/src/platforms/posix/test_stubs/stub_parameter.h b/platforms/posix/src/px4/common/test_stubs/stub_parameter.h similarity index 100% rename from src/platforms/posix/test_stubs/stub_parameter.h rename to platforms/posix/src/px4/common/test_stubs/stub_parameter.h diff --git a/platforms/posix/src/px4/generic/CMakeLists.txt b/platforms/posix/src/px4/generic/CMakeLists.txt new file mode 100644 index 000000000000..ec489bf559c3 --- /dev/null +++ b/platforms/posix/src/px4/generic/CMakeLists.txt @@ -0,0 +1,36 @@ +############################################################################ +# +# Copyright (c) 2019 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. +# +############################################################################ + + +add_subdirectory(${PX4_CHIP}) + diff --git a/platforms/posix/src/px4/generic/generic/CMakeLists.txt b/platforms/posix/src/px4/generic/generic/CMakeLists.txt new file mode 100644 index 000000000000..4db79a429f8e --- /dev/null +++ b/platforms/posix/src/px4/generic/generic/CMakeLists.txt @@ -0,0 +1,36 @@ +############################################################################ +# +# Copyright (c) 2019 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. +# +############################################################################ + + +add_subdirectory(tone_alarm) + diff --git a/platforms/posix/src/px4/generic/generic/include/px4_arch/micro_hal.h b/platforms/posix/src/px4/generic/generic/include/px4_arch/micro_hal.h new file mode 100644 index 000000000000..d09b73c687dd --- /dev/null +++ b/platforms/posix/src/px4/generic/generic/include/px4_arch/micro_hal.h @@ -0,0 +1,36 @@ +/**************************************************************************** + * + * Copyright (c) 2019 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. + * + ****************************************************************************/ +#pragma once + +#include + diff --git a/src/drivers/kinetis/tone_alarm/CMakeLists.txt b/platforms/posix/src/px4/generic/generic/tone_alarm/CMakeLists.txt similarity index 97% rename from src/drivers/kinetis/tone_alarm/CMakeLists.txt rename to platforms/posix/src/px4/generic/generic/tone_alarm/CMakeLists.txt index 5251d3910a7a..a2d2f8144bcc 100644 --- a/src/drivers/kinetis/tone_alarm/CMakeLists.txt +++ b/platforms/posix/src/px4/generic/generic/tone_alarm/CMakeLists.txt @@ -31,6 +31,6 @@ # ############################################################################ -px4_add_library(tone_alarm_interface +px4_add_library(arch_tone_alarm ToneAlarmInterface.cpp ) diff --git a/src/drivers/sim/tone_alarm/ToneAlarmInterface.cpp b/platforms/posix/src/px4/generic/generic/tone_alarm/ToneAlarmInterface.cpp similarity index 91% rename from src/drivers/sim/tone_alarm/ToneAlarmInterface.cpp rename to platforms/posix/src/px4/generic/generic/tone_alarm/ToneAlarmInterface.cpp index 7e25fc774f73..c56fb8c45feb 100644 --- a/src/drivers/sim/tone_alarm/ToneAlarmInterface.cpp +++ b/platforms/posix/src/px4/generic/generic/tone_alarm/ToneAlarmInterface.cpp @@ -35,20 +35,26 @@ * @file ToneAlarmInterface.cpp */ -#include +#include #include -void ToneAlarmInterface::init() +namespace ToneAlarmInterface +{ + +void init() { // Nothing to be done in simulation. } -void ToneAlarmInterface::start_note(unsigned frequency) +void start_note(unsigned frequency) { // Nothing to be done in simulation. } -void ToneAlarmInterface::stop_note() +void stop_note() { // Nothing to be done in simulation. } + +} /* namespace ToneAlarmInterface */ + diff --git a/platforms/qurt/CMakeLists.txt b/platforms/qurt/CMakeLists.txt index 3c17462dd7cc..1885d1078f3c 100644 --- a/platforms/qurt/CMakeLists.txt +++ b/platforms/qurt/CMakeLists.txt @@ -5,8 +5,6 @@ include(fastrpc) include(qurt_lib) include(qurt_flags) -add_subdirectory(src) - include_directories(${CMAKE_CURRENT_BINARY_DIR}) get_property(module_libraries GLOBAL PROPERTY PX4_MODULE_LIBRARIES) diff --git a/platforms/qurt/cmake/px4_impl_os.cmake b/platforms/qurt/cmake/px4_impl_os.cmake index 18ecb396f943..94cdb61c23ec 100644 --- a/platforms/qurt/cmake/px4_impl_os.cmake +++ b/platforms/qurt/cmake/px4_impl_os.cmake @@ -45,6 +45,7 @@ # Required OS Inteface Functions # # * px4_os_add_flags +# * px4_os_determine_build_chip # * px4_os_prebuild_targets # @@ -94,8 +95,8 @@ function(px4_qurt_generate_builtin_commands) math(EXPR command_count "${command_count}+1") endif() endforeach() - configure_file(${PX4_SOURCE_DIR}/src/platforms/apps.cpp.in ${OUT}.cpp) - configure_file(${PX4_SOURCE_DIR}/src/platforms/apps.h.in ${OUT}.h) + configure_file(${PX4_SOURCE_DIR}/platforms/common/apps.cpp.in ${OUT}.cpp) + configure_file(${PX4_SOURCE_DIR}/platforms/common/apps.h.in ${OUT}.h) endfunction() #============================================================================= @@ -144,6 +145,23 @@ function(px4_os_add_flags) endfunction() +#============================================================================= +# +# px4_os_determine_build_chip +# +# Sets PX4_CHIP and PX4_CHIP_MANUFACTURER. +# +# Usage: +# px4_os_determine_build_chip() +# +function(px4_os_determine_build_chip) + + # always use generic chip and chip manufacturer + set(PX4_CHIP "generic" CACHE STRING "PX4 Chip" FORCE) + set(PX4_CHIP_MANUFACTURER "generic" CACHE STRING "PX4 Chip Manufacturer" FORCE) + +endfunction() + #============================================================================= # # px4_os_prebuild_targets diff --git a/platforms/qurt/src/px4/CMakeLists.txt b/platforms/qurt/src/px4/CMakeLists.txt new file mode 100644 index 000000000000..929788b587e2 --- /dev/null +++ b/platforms/qurt/src/px4/CMakeLists.txt @@ -0,0 +1,37 @@ +############################################################################ +# +# Copyright (c) 2019 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. +# +############################################################################ + +add_subdirectory(common) + +add_subdirectory(${PX4_CHIP_MANUFACTURER}) + diff --git a/platforms/qurt/src/px4_layer/CMakeLists.txt b/platforms/qurt/src/px4/common/CMakeLists.txt similarity index 96% rename from platforms/qurt/src/px4_layer/CMakeLists.txt rename to platforms/qurt/src/px4/common/CMakeLists.txt index 892a6e668474..1e168c411015 100644 --- a/platforms/qurt/src/px4_layer/CMakeLists.txt +++ b/platforms/qurt/src/px4/common/CMakeLists.txt @@ -40,7 +40,7 @@ set(QURT_LAYER_SRCS px4_qurt_impl.cpp px4_qurt_tasks.cpp lib_crc32.c - ../../../posix/src/px4_layer/drv_hrt.cpp + ${PX4_SOURCE_DIR}/platforms/posix/src/px4/common/drv_hrt.cpp qurt_stubs.c main.cpp shmem_qurt.cpp @@ -49,8 +49,8 @@ set(QURT_LAYER_SRCS if ("${QURT_ENABLE_STUBS}" STREQUAL "1") list(APPEND QURT_LAYER_SRCS - ../stubs/stubs_posix.c - ../stubs/stubs_qurt.c + stubs/posix.c + stubs/qurt.c ) endif() diff --git a/platforms/qurt/src/px4_layer/commands_hil.c b/platforms/qurt/src/px4/common/commands_hil.c similarity index 100% rename from platforms/qurt/src/px4_layer/commands_hil.c rename to platforms/qurt/src/px4/common/commands_hil.c diff --git a/platforms/qurt/src/px4_layer/get_commands.h b/platforms/qurt/src/px4/common/get_commands.h similarity index 100% rename from platforms/qurt/src/px4_layer/get_commands.h rename to platforms/qurt/src/px4/common/get_commands.h diff --git a/platforms/qurt/src/px4/common/include/px4_platform/micro_hal.h b/platforms/qurt/src/px4/common/include/px4_platform/micro_hal.h new file mode 100644 index 000000000000..d09b73c687dd --- /dev/null +++ b/platforms/qurt/src/px4/common/include/px4_platform/micro_hal.h @@ -0,0 +1,36 @@ +/**************************************************************************** + * + * Copyright (c) 2019 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. + * + ****************************************************************************/ +#pragma once + +#include + diff --git a/platforms/qurt/src/px4_layer/lib_crc32.c b/platforms/qurt/src/px4/common/lib_crc32.c similarity index 100% rename from platforms/qurt/src/px4_layer/lib_crc32.c rename to platforms/qurt/src/px4/common/lib_crc32.c diff --git a/platforms/qurt/src/px4_layer/main.cpp b/platforms/qurt/src/px4/common/main.cpp similarity index 99% rename from platforms/qurt/src/px4_layer/main.cpp rename to platforms/qurt/src/px4/common/main.cpp index 2fe6b57aac50..8f2aac9323ea 100644 --- a/platforms/qurt/src/px4_layer/main.cpp +++ b/platforms/qurt/src/px4/common/main.cpp @@ -38,10 +38,10 @@ * @author Julian Oes */ -#include #include #include #include +#include #include #include #include diff --git a/platforms/posix/src/px4_layer/px4_init.cpp b/platforms/qurt/src/px4/common/px4_init.cpp similarity index 96% rename from platforms/posix/src/px4_layer/px4_init.cpp rename to platforms/qurt/src/px4/common/px4_init.cpp index e162ed15cd1b..73387de35f0e 100644 --- a/platforms/posix/src/px4_layer/px4_init.cpp +++ b/platforms/qurt/src/px4/common/px4_init.cpp @@ -37,7 +37,7 @@ #include #include #include -#include +#include int px4_platform_init(void) { diff --git a/platforms/qurt/src/px4_layer/px4_qurt_impl.cpp b/platforms/qurt/src/px4/common/px4_qurt_impl.cpp similarity index 99% rename from platforms/qurt/src/px4_layer/px4_qurt_impl.cpp rename to platforms/qurt/src/px4/common/px4_qurt_impl.cpp index 699f0c9ee506..41e5c6556690 100644 --- a/platforms/qurt/src/px4_layer/px4_qurt_impl.cpp +++ b/platforms/qurt/src/px4/common/px4_qurt_impl.cpp @@ -39,7 +39,6 @@ #include #include -#include #include #include #include diff --git a/platforms/qurt/src/px4_layer/px4_qurt_tasks.cpp b/platforms/qurt/src/px4/common/px4_qurt_tasks.cpp similarity index 100% rename from platforms/qurt/src/px4_layer/px4_qurt_tasks.cpp rename to platforms/qurt/src/px4/common/px4_qurt_tasks.cpp diff --git a/platforms/qurt/src/px4_layer/qurt_stubs.c b/platforms/qurt/src/px4/common/qurt_stubs.c similarity index 100% rename from platforms/qurt/src/px4_layer/qurt_stubs.c rename to platforms/qurt/src/px4/common/qurt_stubs.c diff --git a/platforms/qurt/src/px4_layer/shmem_qurt.cpp b/platforms/qurt/src/px4/common/shmem_qurt.cpp similarity index 100% rename from platforms/qurt/src/px4_layer/shmem_qurt.cpp rename to platforms/qurt/src/px4/common/shmem_qurt.cpp diff --git a/src/platforms/qurt/stubs/stubs_posix.c b/platforms/qurt/src/px4/common/stubs/posix.c similarity index 100% rename from src/platforms/qurt/stubs/stubs_posix.c rename to platforms/qurt/src/px4/common/stubs/posix.c diff --git a/src/platforms/qurt/stubs/stubs_qurt.c b/platforms/qurt/src/px4/common/stubs/qurt.c similarity index 100% rename from src/platforms/qurt/stubs/stubs_qurt.c rename to platforms/qurt/src/px4/common/stubs/qurt.c diff --git a/platforms/qurt/src/px4/generic/CMakeLists.txt b/platforms/qurt/src/px4/generic/CMakeLists.txt new file mode 100644 index 000000000000..ec489bf559c3 --- /dev/null +++ b/platforms/qurt/src/px4/generic/CMakeLists.txt @@ -0,0 +1,36 @@ +############################################################################ +# +# Copyright (c) 2019 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. +# +############################################################################ + + +add_subdirectory(${PX4_CHIP}) + diff --git a/platforms/qurt/src/CMakeLists.txt b/platforms/qurt/src/px4/generic/generic/CMakeLists.txt similarity index 94% rename from platforms/qurt/src/CMakeLists.txt rename to platforms/qurt/src/px4/generic/generic/CMakeLists.txt index 602b1b710744..c4e98943e42e 100644 --- a/platforms/qurt/src/CMakeLists.txt +++ b/platforms/qurt/src/px4/generic/generic/CMakeLists.txt @@ -1,6 +1,6 @@ ############################################################################ # -# Copyright (c) 2017 PX4 Development Team. All rights reserved. +# Copyright (c) 2019 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 @@ -31,4 +31,5 @@ # ############################################################################ -add_subdirectory(px4_layer) + + diff --git a/platforms/qurt/src/px4/generic/generic/include/px4_arch/micro_hal.h b/platforms/qurt/src/px4/generic/generic/include/px4_arch/micro_hal.h new file mode 100644 index 000000000000..d09b73c687dd --- /dev/null +++ b/platforms/qurt/src/px4/generic/generic/include/px4_arch/micro_hal.h @@ -0,0 +1,36 @@ +/**************************************************************************** + * + * Copyright (c) 2019 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. + * + ****************************************************************************/ +#pragma once + +#include + diff --git a/src/drivers/kinetis/adc/CMakeLists.txt b/src/drivers/adc/CMakeLists.txt similarity index 95% rename from src/drivers/kinetis/adc/CMakeLists.txt rename to src/drivers/adc/CMakeLists.txt index bf0eca22c49f..5e52fbf6dfe7 100644 --- a/src/drivers/kinetis/adc/CMakeLists.txt +++ b/src/drivers/adc/CMakeLists.txt @@ -1,6 +1,6 @@ ############################################################################ # -# Copyright (c) 2016 PX4 Development Team. All rights reserved. +# Copyright (c) 2019 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 @@ -36,4 +36,6 @@ px4_add_module( MAIN adc SRCS adc.cpp + DEPENDS + arch_adc ) diff --git a/src/drivers/stm32/adc/adc.cpp b/src/drivers/adc/adc.cpp similarity index 62% rename from src/drivers/stm32/adc/adc.cpp rename to src/drivers/adc/adc.cpp index da5836f04d84..768d1034bd77 100644 --- a/src/drivers/stm32/adc/adc.cpp +++ b/src/drivers/adc/adc.cpp @@ -34,80 +34,31 @@ /** * @file adc.cpp * - * Driver for the STM32 ADC. + * Driver for an ADC. * - * This is a low-rate driver, designed for sampling things like voltages - * and so forth. It avoids the gross complexity of the NuttX ADC driver. */ -#include -#include - #include #include #include #include +#include #include #include -#include +#include #include #include #include + using namespace time_literals; -#if defined(ADC_CHANNELS) +#ifndef ADC_CHANNELS +#error "board needs to define ADC_CHANNELS to use this driver" +#endif #define ADC_TOTAL_CHANNELS 32 -/* - * Register accessors. - * For now, no reason not to just use ADC1. - */ -#define REG(base, _reg) (*(volatile uint32_t *)((base) + (_reg))) - -#define rSR(base) REG((base), STM32_ADC_SR_OFFSET) -#define rCR1(base) REG((base), STM32_ADC_CR1_OFFSET) -#define rCR2(base) REG((base), STM32_ADC_CR2_OFFSET) -#define rSMPR1(base) REG((base), STM32_ADC_SMPR1_OFFSET) -#define rSMPR2(base) REG((base), STM32_ADC_SMPR2_OFFSET) -#define rJOFR1(base) REG((base), STM32_ADC_JOFR1_OFFSET) -#define rJOFR2(base) REG((base), STM32_ADC_JOFR2_OFFSET) -#define rJOFR3(base) REG((base), STM32_ADC_JOFR3_OFFSET) -#define rJOFR4(base) REG((base), STM32_ADC_JOFR4_OFFSET) -#define rHTR(base) REG((base), STM32_ADC_HTR_OFFSET) -#define rLTR(base) REG((base), STM32_ADC_LTR_OFFSET) -#define rSQR1(base) REG((base), STM32_ADC_SQR1_OFFSET) -#define rSQR2(base) REG((base), STM32_ADC_SQR2_OFFSET) -#define rSQR3(base) REG((base), STM32_ADC_SQR3_OFFSET) -#define rJSQR(base) REG((base), STM32_ADC_JSQR_OFFSET) -#define rJDR1(base) REG((base), STM32_ADC_JDR1_OFFSET) -#define rJDR2(base) REG((base), STM32_ADC_JDR2_OFFSET) -#define rJDR3(base) REG((base), STM32_ADC_JDR3_OFFSET) -#define rJDR4(base) REG((base), STM32_ADC_JDR4_OFFSET) -#define rDR(base) REG((base), STM32_ADC_DR_OFFSET) - - - -#ifdef STM32_ADC_CCR -# define rCCR(base) REG((base), STM32_ADC_CCR_OFFSET) - -/* Assuming VDC 2.4 - 3.6 */ - -#define ADC_MAX_FADC 36000000 - -# if STM32_PCLK2_FREQUENCY/2 <= ADC_MAX_FADC -# define ADC_CCR_ADCPRE_DIV ADC_CCR_ADCPRE_DIV2 -# elif STM32_PCLK2_FREQUENCY/4 <= ADC_MAX_FADC -# define ADC_CCR_ADCPRE_DIV ADC_CCR_ADCPRE_DIV4 -# elif STM32_PCLK2_FREQUENCY/6 <= ADC_MAX_FADC -# define ADC_CCR_ADCPRE_DIV ADC_CCR_ADCPRE_DIV6 -# elif STM32_PCLK2_FREQUENCY/8 <= ADC_MAX_FADC -# define ADC_CCR_ADCPRE_DIV ADC_CCR_ADCPRE_DIV8 -# else -# error "ADC PCLK2 too high - no divisor found " -# endif -#endif class ADC : public cdev::CDev, public px4::ScheduledWorkItem { @@ -131,8 +82,7 @@ class ADC : public cdev::CDev, public px4::ScheduledWorkItem * Sample a single channel and return the measured value. * * @param channel The channel to sample. - * @return The sampled value, or 0xffff if - * sampling failed. + * @return The sampled value, or 0xffff if sampling failed. */ uint16_t sample(unsigned channel); @@ -159,7 +109,7 @@ ADC::ADC(uint32_t base_address, uint32_t channels) : _base_address(base_address) { /* always enable the temperature sensor */ - channels |= 1 << 16; + channels |= px4_arch_adc_temp_sensor_mask(); /* allocate the sample array */ for (unsigned i = 0; i < ADC_TOTAL_CHANNELS; i++) { @@ -195,108 +145,13 @@ ADC::~ADC() } perf_free(_sample_perf); -} - -int board_adc_init(uint32_t base_address) -{ - /* Perform ADC init once per ADC */ - - static uint32_t once[SYSTEM_ADC_COUNT] {}; - - uint32_t *free = nullptr; - - for (uint32_t i = 0; i < SYSTEM_ADC_COUNT; i++) { - if (once[i] == base_address) { - - /* This one was done already */ - - return OK; - } - - /* Use first free slot */ - - if (free == nullptr && once[i] == 0) { - free = &once[i]; - } - } - - if (free == nullptr) { - - /* ADC misconfigured SYSTEM_ADC_COUNT too small */; - - PANIC(); - } - - *free = base_address; - - /* do calibration if supported */ -#ifdef ADC_CR2_CAL - rCR2(base_address) |= ADC_CR2_CAL; - px4_usleep(100); - - if (rCR2(base_address) & ADC_CR2_CAL) { - return -1; - } - -#endif - - /* arbitrarily configure all channels for 55 cycle sample time */ - rSMPR1(base_address) = 0b00000011011011011011011011011011; - rSMPR2(base_address) = 0b00011011011011011011011011011011; - - /* XXX for F2/4, might want to select 12-bit mode? */ - rCR1(base_address) = 0; - - /* enable the temperature sensor / Vrefint channel if supported*/ - rCR2(base_address) = -#ifdef ADC_CR2_TSVREFE - /* enable the temperature sensor in CR2 */ - ADC_CR2_TSVREFE | -#endif - 0; - - /* Soc have CCR */ -#ifdef STM32_ADC_CCR -# ifdef ADC_CCR_TSVREFE - /* enable temperature sensor in CCR */ - rCCR(base_address) = ADC_CCR_TSVREFE | ADC_CCR_ADCPRE_DIV; -# else - rCCR(base_address) = ADC_CCR_ADCPRE_DIV; -# endif -#endif - - /* configure for a single-channel sequence */ - rSQR1(base_address) = 0; - rSQR2(base_address) = 0; - rSQR3(base_address) = 0; /* will be updated with the channel each tick */ - - /* power-cycle the ADC and turn it on */ - rCR2(base_address) &= ~ADC_CR2_ADON; - px4_usleep(10); - rCR2(base_address) |= ADC_CR2_ADON; - px4_usleep(10); - rCR2(base_address) |= ADC_CR2_ADON; - px4_usleep(10); - - /* kick off a sample and wait for it to complete */ - hrt_abstime now = hrt_absolute_time(); - rCR2(base_address) |= ADC_CR2_SWSTART; - - while (!(rSR(base_address) & ADC_SR_EOC)) { - - /* don't wait for more than 500us, since that means something broke - should reset here if we see this */ - if ((hrt_absolute_time() - now) > 500) { - return -1; - } - } - - return OK; + px4_arch_adc_uninit(_base_address); } int ADC::init() { - int rv = board_adc_init(_base_address); + int rv = px4_arch_adc_init(_base_address); if (rv < 0) { PX4_DEBUG("sample timeout"); @@ -468,44 +323,11 @@ ADC::update_system_power(hrt_abstime now) #endif // BOARD_ADC_USB_CONNECTED } -uint16_t board_adc_sample(uint32_t base_address, unsigned channel) -{ - irqstate_t flags = px4_enter_critical_section(); - - /* clear any previous EOC */ - if (rSR(base_address) & ADC_SR_EOC) { - rSR(base_address) &= ~ADC_SR_EOC; - } - - /* run a single conversion right now - should take about 60 cycles (a few microseconds) max */ - rSQR3(base_address) = channel; - rCR2(base_address) |= ADC_CR2_SWSTART; - - /* wait for the conversion to complete */ - const hrt_abstime now = hrt_absolute_time(); - - while (!(rSR(base_address) & ADC_SR_EOC)) { - - /* don't wait for more than 50us, since that means something broke - should reset here if we see this */ - if ((hrt_absolute_time() - now) > 50) { - px4_leave_critical_section(flags); - return 0xffff; - } - } - - /* read the result and clear EOC */ - uint16_t result = rDR(base_address); - - px4_leave_critical_section(flags); - - return result; -} - uint16_t ADC::sample(unsigned channel) { perf_begin(_sample_perf); - uint16_t result = board_adc_sample(_base_address, channel); + uint16_t result = px4_arch_adc_sample(_base_address, channel); if (result == 0xffff) { PX4_ERR("sample timeout"); @@ -562,7 +384,6 @@ int adc_main(int argc, char *argv[]) { if (g_adc == nullptr) { - /* XXX this hardcodes the default channel set for the board in board_config.h - should be configurable */ g_adc = new ADC(SYSTEM_ADC_BASE, ADC_CHANNELS); if (g_adc == nullptr) { @@ -585,4 +406,3 @@ adc_main(int argc, char *argv[]) return 0; } -#endif diff --git a/src/drivers/barometer/bmp280/bmp280.h b/src/drivers/barometer/bmp280/bmp280.h index 5f81383eb15f..4b50887a7315 100644 --- a/src/drivers/barometer/bmp280/bmp280.h +++ b/src/drivers/barometer/bmp280/bmp280.h @@ -50,7 +50,7 @@ #include #include #include -#include +#include #include "board_config.h" diff --git a/src/drivers/barometer/lps22hb/LPS22HB.hpp b/src/drivers/barometer/lps22hb/LPS22HB.hpp index 0eacf0877a6d..f30dbeded96a 100644 --- a/src/drivers/barometer/lps22hb/LPS22HB.hpp +++ b/src/drivers/barometer/lps22hb/LPS22HB.hpp @@ -42,7 +42,7 @@ #include #include #include -#include +#include #include #include diff --git a/src/drivers/barometer/lps25h/lps25h.h b/src/drivers/barometer/lps25h/lps25h.h index fadf2b34189a..bff2db2df212 100644 --- a/src/drivers/barometer/lps25h/lps25h.h +++ b/src/drivers/barometer/lps25h/lps25h.h @@ -49,7 +49,7 @@ #include #include #include -#include +#include #include #include diff --git a/src/drivers/barometer/mpl3115a2/mpl3115a2.h b/src/drivers/barometer/mpl3115a2/mpl3115a2.h index 0a6be7c00657..17de2e4612c9 100644 --- a/src/drivers/barometer/mpl3115a2/mpl3115a2.h +++ b/src/drivers/barometer/mpl3115a2/mpl3115a2.h @@ -68,7 +68,7 @@ #include #include #include -#include +#include #include #include "board_config.h" diff --git a/src/drivers/barometer/ms5611/ms5611.h b/src/drivers/barometer/ms5611/ms5611.h index cc197dc666d9..6079872353cf 100644 --- a/src/drivers/barometer/ms5611/ms5611.h +++ b/src/drivers/barometer/ms5611/ms5611.h @@ -49,7 +49,7 @@ #include #include #include -#include +#include #include #include diff --git a/src/drivers/batt_smbus/batt_smbus.h b/src/drivers/batt_smbus/batt_smbus.h index ed5d864ec2e2..452fe59bb4e0 100644 --- a/src/drivers/batt_smbus/batt_smbus.h +++ b/src/drivers/batt_smbus/batt_smbus.h @@ -49,7 +49,7 @@ #include #include #include -#include +#include #include #include "board_config.h" diff --git a/src/drivers/boards/common/board_common.h b/src/drivers/boards/common/board_common.h index d421688c1722..9dad6e913a67 100644 --- a/src/drivers/boards/common/board_common.h +++ b/src/drivers/boards/common/board_common.h @@ -196,30 +196,6 @@ # error Unsuported BOARD_NUMBER_BRICKS number. #endif -/* Historically PX4 used one ADC1 With FMUvnX this has changes. - * These defines maintain compatibility while allowing the - * new boards to override the ADC used from HW VER/REV and - * the system one. - * - * Depending on HW configuration (VER/REV POP options) hardware detection - * may or may NOT initialize a given ADC. SYSTEM_ADC_COUNT is used to size the - * singleton array to ensure this is only done once per ADC. - */ - -#if !defined(HW_REV_VER_ADC_BASE) -# define HW_REV_VER_ADC_BASE STM32_ADC1_BASE -#endif - -#if !defined(SYSTEM_ADC_BASE) -# define SYSTEM_ADC_BASE STM32_ADC1_BASE -#endif - -#if SYSTEM_ADC_BASE == HW_REV_VER_ADC_BASE -# define SYSTEM_ADC_COUNT 1 -#else -# define SYSTEM_ADC_COUNT 2 -#endif - /* Choose the source for ADC_SCALED_V5_SENSE */ #if defined(ADC_5V_RAIL_SENSE) #define ADC_SCALED_V5_SENSE ADC_5V_RAIL_SENSE diff --git a/src/drivers/boards/common/board_internal_common.h b/src/drivers/boards/common/board_internal_common.h index 4c6a44a07944..f01eabdc8c7f 100644 --- a/src/drivers/boards/common/board_internal_common.h +++ b/src/drivers/boards/common/board_internal_common.h @@ -45,40 +45,6 @@ * Included Files ************************************************************************************/ -/************************************************************************************ - * Name: board_adc_init - * - * Description: - * boards may provide this function to allow complex version-ing. - * - * Input Parameters: - * base_address - base address of the ADC - * - * Returned Value: - * - * OK, or -1 if the function failed. - */ - -__EXPORT int board_adc_init(uint32_t base_address); - -/************************************************************************************ - * Name: board_adc_sample - * - * Description: - * boards provide this function to allow complex version-ing. - * - * Input Parameters: - * base_address - base address of the ADC - * channel - The number of the adc channel to read. - * - * Returned Value: - * The ADC DN read for the channel or 0xffff if there - * is an error reading the channel. - */ - -__EXPORT uint16_t board_adc_sample(uint32_t base_address, unsigned channel); - - /************************************************************************************ * Name: board_gpio_init * diff --git a/src/drivers/boards/common/stm32/board_hw_rev_ver.c b/src/drivers/boards/common/stm32/board_hw_rev_ver.c index 21c2039266e2..d3e83df51a6a 100644 --- a/src/drivers/boards/common/stm32/board_hw_rev_ver.c +++ b/src/drivers/boards/common/stm32/board_hw_rev_ver.c @@ -37,6 +37,8 @@ * Implementation of STM32 based Board Hardware Revision and Version ID API */ +#include +#include #include #include #include "board_config.h" @@ -199,11 +201,11 @@ static int read_id_dn(int *id, uint32_t gpio_drive, uint32_t gpio_sense, int adc /* Yes - Fire up the ADC (it has once control) */ - if (board_adc_init(HW_REV_VER_ADC_BASE) == OK) { + if (px4_arch_adc_init(HW_REV_VER_ADC_BASE) == OK) { /* Read the value */ for (unsigned av = 0; av < samples; av++) { - dn = board_adc_sample(HW_REV_VER_ADC_BASE, adc_channel); + dn = px4_arch_adc_sample(HW_REV_VER_ADC_BASE, adc_channel); if (dn == 0xffff) { break; diff --git a/src/drivers/camera_capture/camera_capture.hpp b/src/drivers/camera_capture/camera_capture.hpp index c8654071169e..977ae47f6ab1 100644 --- a/src/drivers/camera_capture/camera_capture.hpp +++ b/src/drivers/camera_capture/camera_capture.hpp @@ -48,7 +48,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/src/drivers/camera_trigger/camera_trigger.cpp b/src/drivers/camera_trigger/camera_trigger.cpp index 2174e986ef52..7c2d93dd86d3 100644 --- a/src/drivers/camera_trigger/camera_trigger.cpp +++ b/src/drivers/camera_trigger/camera_trigger.cpp @@ -50,7 +50,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/src/drivers/distance_sensor/cm8jl65/cm8jl65.cpp b/src/drivers/distance_sensor/cm8jl65/cm8jl65.cpp index 07aa1c2866ea..d99d29b390f8 100644 --- a/src/drivers/distance_sensor/cm8jl65/cm8jl65.cpp +++ b/src/drivers/distance_sensor/cm8jl65/cm8jl65.cpp @@ -45,7 +45,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/src/drivers/distance_sensor/leddar_one/leddar_one.cpp b/src/drivers/distance_sensor/leddar_one/leddar_one.cpp index 5cfdf1a681b1..0e35de6f5272 100644 --- a/src/drivers/distance_sensor/leddar_one/leddar_one.cpp +++ b/src/drivers/distance_sensor/leddar_one/leddar_one.cpp @@ -32,7 +32,7 @@ ****************************************************************************/ #include -#include +#include #include #include #include diff --git a/src/drivers/distance_sensor/ll40ls/LidarLiteI2C.h b/src/drivers/distance_sensor/ll40ls/LidarLiteI2C.h index 38fcd7afe9dc..8dde2c897a6b 100644 --- a/src/drivers/distance_sensor/ll40ls/LidarLiteI2C.h +++ b/src/drivers/distance_sensor/ll40ls/LidarLiteI2C.h @@ -42,7 +42,7 @@ #include "LidarLite.h" -#include +#include #include diff --git a/src/drivers/distance_sensor/ll40ls/LidarLitePWM.h b/src/drivers/distance_sensor/ll40ls/LidarLitePWM.h index de37f581d3bc..d50c5b54a45e 100644 --- a/src/drivers/distance_sensor/ll40ls/LidarLitePWM.h +++ b/src/drivers/distance_sensor/ll40ls/LidarLitePWM.h @@ -45,7 +45,7 @@ #include "LidarLite.h" -#include +#include #include class LidarLitePWM : public LidarLite, public px4::ScheduledWorkItem diff --git a/src/drivers/distance_sensor/mappydot/MappyDot.cpp b/src/drivers/distance_sensor/mappydot/MappyDot.cpp index c5e858b4ba81..3500908ab0b1 100644 --- a/src/drivers/distance_sensor/mappydot/MappyDot.cpp +++ b/src/drivers/distance_sensor/mappydot/MappyDot.cpp @@ -47,7 +47,7 @@ #include #include #include -#include +#include #include /* MappyDot Registers */ diff --git a/src/drivers/distance_sensor/mb12xx/mb12xx.cpp b/src/drivers/distance_sensor/mb12xx/mb12xx.cpp index cc180c703e5e..3541062eae0c 100644 --- a/src/drivers/distance_sensor/mb12xx/mb12xx.cpp +++ b/src/drivers/distance_sensor/mb12xx/mb12xx.cpp @@ -63,7 +63,7 @@ #include #include #include -#include +#include #include #include diff --git a/src/drivers/distance_sensor/sf0x/sf0x.cpp b/src/drivers/distance_sensor/sf0x/sf0x.cpp index f454ea7cd3a0..817461560bcb 100644 --- a/src/drivers/distance_sensor/sf0x/sf0x.cpp +++ b/src/drivers/distance_sensor/sf0x/sf0x.cpp @@ -41,7 +41,7 @@ #include #include -#include +#include #include #include diff --git a/src/drivers/distance_sensor/sf1xx/sf1xx.cpp b/src/drivers/distance_sensor/sf1xx/sf1xx.cpp index 9ab43c864522..f2d38846a2d7 100644 --- a/src/drivers/distance_sensor/sf1xx/sf1xx.cpp +++ b/src/drivers/distance_sensor/sf1xx/sf1xx.cpp @@ -44,7 +44,7 @@ #include #include #include -#include +#include #include #include diff --git a/src/drivers/distance_sensor/srf02/srf02.cpp b/src/drivers/distance_sensor/srf02/srf02.cpp index b2e653962249..ac0c67982588 100644 --- a/src/drivers/distance_sensor/srf02/srf02.cpp +++ b/src/drivers/distance_sensor/srf02/srf02.cpp @@ -40,7 +40,7 @@ #include #include #include -#include +#include #include #include diff --git a/src/drivers/distance_sensor/teraranger/teraranger.cpp b/src/drivers/distance_sensor/teraranger/teraranger.cpp index 6808ab3f7fce..14851308953f 100644 --- a/src/drivers/distance_sensor/teraranger/teraranger.cpp +++ b/src/drivers/distance_sensor/teraranger/teraranger.cpp @@ -41,7 +41,7 @@ #include #include #include -#include +#include #include #include diff --git a/src/drivers/distance_sensor/tfmini/tfmini.cpp b/src/drivers/distance_sensor/tfmini/tfmini.cpp index f2272efd61a1..c1f48d86a249 100644 --- a/src/drivers/distance_sensor/tfmini/tfmini.cpp +++ b/src/drivers/distance_sensor/tfmini/tfmini.cpp @@ -66,7 +66,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/src/drivers/distance_sensor/ulanding/ulanding.cpp b/src/drivers/distance_sensor/ulanding/ulanding.cpp index 58abd3e2e326..5ba754961383 100644 --- a/src/drivers/distance_sensor/ulanding/ulanding.cpp +++ b/src/drivers/distance_sensor/ulanding/ulanding.cpp @@ -63,7 +63,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/src/drivers/distance_sensor/vl53lxx/vl53lxx.cpp b/src/drivers/distance_sensor/vl53lxx/vl53lxx.cpp index 215b9c9c29b0..f64131583374 100644 --- a/src/drivers/distance_sensor/vl53lxx/vl53lxx.cpp +++ b/src/drivers/distance_sensor/vl53lxx/vl53lxx.cpp @@ -48,7 +48,7 @@ #include #include #include -#include +#include #include /* Configuration Constants */ diff --git a/src/platforms/posix/drivers/df_ak8963_wrapper/CMakeLists.txt b/src/drivers/driver_framework_wrapper/df_ak8963_wrapper/CMakeLists.txt similarity index 96% rename from src/platforms/posix/drivers/df_ak8963_wrapper/CMakeLists.txt rename to src/drivers/driver_framework_wrapper/df_ak8963_wrapper/CMakeLists.txt index 50967ea90f69..dc9db8bd9660 100644 --- a/src/platforms/posix/drivers/df_ak8963_wrapper/CMakeLists.txt +++ b/src/drivers/driver_framework_wrapper/df_ak8963_wrapper/CMakeLists.txt @@ -31,7 +31,7 @@ # ############################################################################ -include_directories(../../../../lib/DriverFramework/drivers) +include_directories(../../../lib/DriverFramework/drivers) px4_add_module( MODULE platforms__posix__drivers__df_ak8963_wrapper diff --git a/src/platforms/posix/drivers/df_ak8963_wrapper/df_ak8963_wrapper.cpp b/src/drivers/driver_framework_wrapper/df_ak8963_wrapper/df_ak8963_wrapper.cpp similarity index 100% rename from src/platforms/posix/drivers/df_ak8963_wrapper/df_ak8963_wrapper.cpp rename to src/drivers/driver_framework_wrapper/df_ak8963_wrapper/df_ak8963_wrapper.cpp diff --git a/src/platforms/posix/drivers/df_bebop_bus_wrapper/CMakeLists.txt b/src/drivers/driver_framework_wrapper/df_bebop_bus_wrapper/CMakeLists.txt similarity index 96% rename from src/platforms/posix/drivers/df_bebop_bus_wrapper/CMakeLists.txt rename to src/drivers/driver_framework_wrapper/df_bebop_bus_wrapper/CMakeLists.txt index 997261971561..bd2fada0eec6 100644 --- a/src/platforms/posix/drivers/df_bebop_bus_wrapper/CMakeLists.txt +++ b/src/drivers/driver_framework_wrapper/df_bebop_bus_wrapper/CMakeLists.txt @@ -31,7 +31,7 @@ # ############################################################################ -include_directories(../../../../lib/DriverFramework/drivers) +include_directories(../../../lib/DriverFramework/drivers) px4_add_module( MODULE platforms__posix__drivers__df_bebop_bus_wrapper diff --git a/src/platforms/posix/drivers/df_bebop_bus_wrapper/df_bebop_bus_wrapper.cpp b/src/drivers/driver_framework_wrapper/df_bebop_bus_wrapper/df_bebop_bus_wrapper.cpp similarity index 100% rename from src/platforms/posix/drivers/df_bebop_bus_wrapper/df_bebop_bus_wrapper.cpp rename to src/drivers/driver_framework_wrapper/df_bebop_bus_wrapper/df_bebop_bus_wrapper.cpp diff --git a/src/platforms/posix/drivers/df_bebop_rangefinder_wrapper/CMakeLists.txt b/src/drivers/driver_framework_wrapper/df_bebop_rangefinder_wrapper/CMakeLists.txt similarity index 96% rename from src/platforms/posix/drivers/df_bebop_rangefinder_wrapper/CMakeLists.txt rename to src/drivers/driver_framework_wrapper/df_bebop_rangefinder_wrapper/CMakeLists.txt index 4ce56a381349..5273142396eb 100644 --- a/src/platforms/posix/drivers/df_bebop_rangefinder_wrapper/CMakeLists.txt +++ b/src/drivers/driver_framework_wrapper/df_bebop_rangefinder_wrapper/CMakeLists.txt @@ -31,7 +31,7 @@ # ############################################################################ -include_directories(../../../../lib/DriverFramework/drivers) +include_directories(../../../lib/DriverFramework/drivers) px4_add_module( MODULE platforms__posix__drivers__df_bebop_rangefinder_wrapper diff --git a/src/platforms/posix/drivers/df_bebop_rangefinder_wrapper/df_bebop_rangefinder_wrapper.cpp b/src/drivers/driver_framework_wrapper/df_bebop_rangefinder_wrapper/df_bebop_rangefinder_wrapper.cpp similarity index 100% rename from src/platforms/posix/drivers/df_bebop_rangefinder_wrapper/df_bebop_rangefinder_wrapper.cpp rename to src/drivers/driver_framework_wrapper/df_bebop_rangefinder_wrapper/df_bebop_rangefinder_wrapper.cpp diff --git a/src/platforms/posix/drivers/df_bmp280_wrapper/CMakeLists.txt b/src/drivers/driver_framework_wrapper/df_bmp280_wrapper/CMakeLists.txt similarity index 96% rename from src/platforms/posix/drivers/df_bmp280_wrapper/CMakeLists.txt rename to src/drivers/driver_framework_wrapper/df_bmp280_wrapper/CMakeLists.txt index de214f461625..b16e02e3cf40 100644 --- a/src/platforms/posix/drivers/df_bmp280_wrapper/CMakeLists.txt +++ b/src/drivers/driver_framework_wrapper/df_bmp280_wrapper/CMakeLists.txt @@ -31,7 +31,7 @@ # ############################################################################ -include_directories(../../../../lib/DriverFramework/drivers) +include_directories(../../../lib/DriverFramework/drivers) px4_add_module( MODULE platforms__posix__drivers__df_bmp280_wrapper diff --git a/src/platforms/posix/drivers/df_bmp280_wrapper/df_bmp280_wrapper.cpp b/src/drivers/driver_framework_wrapper/df_bmp280_wrapper/df_bmp280_wrapper.cpp similarity index 100% rename from src/platforms/posix/drivers/df_bmp280_wrapper/df_bmp280_wrapper.cpp rename to src/drivers/driver_framework_wrapper/df_bmp280_wrapper/df_bmp280_wrapper.cpp diff --git a/src/platforms/posix/drivers/df_hmc5883_wrapper/CMakeLists.txt b/src/drivers/driver_framework_wrapper/df_hmc5883_wrapper/CMakeLists.txt similarity index 96% rename from src/platforms/posix/drivers/df_hmc5883_wrapper/CMakeLists.txt rename to src/drivers/driver_framework_wrapper/df_hmc5883_wrapper/CMakeLists.txt index 03c76ed090aa..b19f4eefc138 100644 --- a/src/platforms/posix/drivers/df_hmc5883_wrapper/CMakeLists.txt +++ b/src/drivers/driver_framework_wrapper/df_hmc5883_wrapper/CMakeLists.txt @@ -31,7 +31,7 @@ # ############################################################################ -include_directories(../../../../lib/DriverFramework/drivers) +include_directories(../../../lib/DriverFramework/drivers) px4_add_module( MODULE platforms__posix__drivers__df_hmc5883_wrapper diff --git a/src/platforms/posix/drivers/df_hmc5883_wrapper/df_hmc5883_wrapper.cpp b/src/drivers/driver_framework_wrapper/df_hmc5883_wrapper/df_hmc5883_wrapper.cpp similarity index 100% rename from src/platforms/posix/drivers/df_hmc5883_wrapper/df_hmc5883_wrapper.cpp rename to src/drivers/driver_framework_wrapper/df_hmc5883_wrapper/df_hmc5883_wrapper.cpp diff --git a/src/platforms/posix/drivers/df_isl29501_wrapper/CMakeLists.txt b/src/drivers/driver_framework_wrapper/df_isl29501_wrapper/CMakeLists.txt similarity index 96% rename from src/platforms/posix/drivers/df_isl29501_wrapper/CMakeLists.txt rename to src/drivers/driver_framework_wrapper/df_isl29501_wrapper/CMakeLists.txt index 373d1db61bf4..b48e85238c13 100644 --- a/src/platforms/posix/drivers/df_isl29501_wrapper/CMakeLists.txt +++ b/src/drivers/driver_framework_wrapper/df_isl29501_wrapper/CMakeLists.txt @@ -31,7 +31,7 @@ # ############################################################################ -include_directories(../../../../lib/DriverFramework/drivers) +include_directories(../../../lib/DriverFramework/drivers) px4_add_module( MODULE platforms__posix__drivers__df_isl29501_wrapper diff --git a/src/platforms/posix/drivers/df_isl29501_wrapper/df_isl29501_wrapper.cpp b/src/drivers/driver_framework_wrapper/df_isl29501_wrapper/df_isl29501_wrapper.cpp similarity index 100% rename from src/platforms/posix/drivers/df_isl29501_wrapper/df_isl29501_wrapper.cpp rename to src/drivers/driver_framework_wrapper/df_isl29501_wrapper/df_isl29501_wrapper.cpp diff --git a/src/platforms/posix/drivers/df_lsm9ds1_wrapper/CMakeLists.txt b/src/drivers/driver_framework_wrapper/df_lsm9ds1_wrapper/CMakeLists.txt similarity index 96% rename from src/platforms/posix/drivers/df_lsm9ds1_wrapper/CMakeLists.txt rename to src/drivers/driver_framework_wrapper/df_lsm9ds1_wrapper/CMakeLists.txt index 732421a2558e..329b4cd21ae9 100644 --- a/src/platforms/posix/drivers/df_lsm9ds1_wrapper/CMakeLists.txt +++ b/src/drivers/driver_framework_wrapper/df_lsm9ds1_wrapper/CMakeLists.txt @@ -31,7 +31,7 @@ # ############################################################################ -include_directories(../../../../lib/DriverFramework/drivers) +include_directories(../../../lib/DriverFramework/drivers) px4_add_module( MODULE platforms__posix__drivers__df_lsm9ds1_wrapper diff --git a/src/platforms/posix/drivers/df_lsm9ds1_wrapper/df_lsm9ds1_wrapper.cpp b/src/drivers/driver_framework_wrapper/df_lsm9ds1_wrapper/df_lsm9ds1_wrapper.cpp similarity index 100% rename from src/platforms/posix/drivers/df_lsm9ds1_wrapper/df_lsm9ds1_wrapper.cpp rename to src/drivers/driver_framework_wrapper/df_lsm9ds1_wrapper/df_lsm9ds1_wrapper.cpp diff --git a/src/platforms/posix/drivers/df_ltc2946_wrapper/CMakeLists.txt b/src/drivers/driver_framework_wrapper/df_ltc2946_wrapper/CMakeLists.txt similarity index 96% rename from src/platforms/posix/drivers/df_ltc2946_wrapper/CMakeLists.txt rename to src/drivers/driver_framework_wrapper/df_ltc2946_wrapper/CMakeLists.txt index 6095aa793ec9..292c8a5aa772 100644 --- a/src/platforms/posix/drivers/df_ltc2946_wrapper/CMakeLists.txt +++ b/src/drivers/driver_framework_wrapper/df_ltc2946_wrapper/CMakeLists.txt @@ -31,7 +31,7 @@ # ############################################################################ -include_directories(../../../../lib/DriverFramework/drivers) +include_directories(../../../lib/DriverFramework/drivers) px4_add_module( MODULE platforms__posix__drivers__df_ltc2946_wrapper diff --git a/src/platforms/posix/drivers/df_ltc2946_wrapper/df_ltc2946_wrapper.cpp b/src/drivers/driver_framework_wrapper/df_ltc2946_wrapper/df_ltc2946_wrapper.cpp similarity index 100% rename from src/platforms/posix/drivers/df_ltc2946_wrapper/df_ltc2946_wrapper.cpp rename to src/drivers/driver_framework_wrapper/df_ltc2946_wrapper/df_ltc2946_wrapper.cpp diff --git a/src/platforms/posix/drivers/df_mpu6050_wrapper/CMakeLists.txt b/src/drivers/driver_framework_wrapper/df_mpu6050_wrapper/CMakeLists.txt similarity index 96% rename from src/platforms/posix/drivers/df_mpu6050_wrapper/CMakeLists.txt rename to src/drivers/driver_framework_wrapper/df_mpu6050_wrapper/CMakeLists.txt index 4147bf78db9d..3ec392d85463 100644 --- a/src/platforms/posix/drivers/df_mpu6050_wrapper/CMakeLists.txt +++ b/src/drivers/driver_framework_wrapper/df_mpu6050_wrapper/CMakeLists.txt @@ -31,7 +31,7 @@ # ############################################################################ -include_directories(../../../../lib/DriverFramework/drivers) +include_directories(../../../lib/DriverFramework/drivers) px4_add_module( MODULE platforms__posix__drivers__df_mpu6050_wrapper diff --git a/src/platforms/posix/drivers/df_mpu6050_wrapper/df_mpu6050_wrapper.cpp b/src/drivers/driver_framework_wrapper/df_mpu6050_wrapper/df_mpu6050_wrapper.cpp similarity index 100% rename from src/platforms/posix/drivers/df_mpu6050_wrapper/df_mpu6050_wrapper.cpp rename to src/drivers/driver_framework_wrapper/df_mpu6050_wrapper/df_mpu6050_wrapper.cpp diff --git a/src/platforms/posix/drivers/df_mpu9250_wrapper/CMakeLists.txt b/src/drivers/driver_framework_wrapper/df_mpu9250_wrapper/CMakeLists.txt similarity index 96% rename from src/platforms/posix/drivers/df_mpu9250_wrapper/CMakeLists.txt rename to src/drivers/driver_framework_wrapper/df_mpu9250_wrapper/CMakeLists.txt index 9f60ac1312e7..f5f87eb75422 100644 --- a/src/platforms/posix/drivers/df_mpu9250_wrapper/CMakeLists.txt +++ b/src/drivers/driver_framework_wrapper/df_mpu9250_wrapper/CMakeLists.txt @@ -31,7 +31,7 @@ # ############################################################################ -include_directories(../../../../lib/DriverFramework/drivers) +include_directories(../../../lib/DriverFramework/drivers) px4_add_module( MODULE platforms__posix__drivers__df_mpu9250_wrapper diff --git a/src/platforms/posix/drivers/df_mpu9250_wrapper/df_mpu9250_wrapper.cpp b/src/drivers/driver_framework_wrapper/df_mpu9250_wrapper/df_mpu9250_wrapper.cpp similarity index 100% rename from src/platforms/posix/drivers/df_mpu9250_wrapper/df_mpu9250_wrapper.cpp rename to src/drivers/driver_framework_wrapper/df_mpu9250_wrapper/df_mpu9250_wrapper.cpp diff --git a/src/platforms/posix/drivers/df_ms5607_wrapper/CMakeLists.txt b/src/drivers/driver_framework_wrapper/df_ms5607_wrapper/CMakeLists.txt similarity index 96% rename from src/platforms/posix/drivers/df_ms5607_wrapper/CMakeLists.txt rename to src/drivers/driver_framework_wrapper/df_ms5607_wrapper/CMakeLists.txt index 9756a6d16435..f0afda81fa0c 100644 --- a/src/platforms/posix/drivers/df_ms5607_wrapper/CMakeLists.txt +++ b/src/drivers/driver_framework_wrapper/df_ms5607_wrapper/CMakeLists.txt @@ -31,7 +31,7 @@ # ############################################################################ -include_directories(../../../../lib/DriverFramework/drivers) +include_directories(../../../lib/DriverFramework/drivers) px4_add_module( MODULE platforms__posix__drivers__df_ms5607_wrapper diff --git a/src/platforms/posix/drivers/df_ms5607_wrapper/df_ms5607_wrapper.cpp b/src/drivers/driver_framework_wrapper/df_ms5607_wrapper/df_ms5607_wrapper.cpp similarity index 100% rename from src/platforms/posix/drivers/df_ms5607_wrapper/df_ms5607_wrapper.cpp rename to src/drivers/driver_framework_wrapper/df_ms5607_wrapper/df_ms5607_wrapper.cpp diff --git a/src/platforms/posix/drivers/df_ms5611_wrapper/CMakeLists.txt b/src/drivers/driver_framework_wrapper/df_ms5611_wrapper/CMakeLists.txt similarity index 96% rename from src/platforms/posix/drivers/df_ms5611_wrapper/CMakeLists.txt rename to src/drivers/driver_framework_wrapper/df_ms5611_wrapper/CMakeLists.txt index d21aa5733cef..e18fd8567973 100644 --- a/src/platforms/posix/drivers/df_ms5611_wrapper/CMakeLists.txt +++ b/src/drivers/driver_framework_wrapper/df_ms5611_wrapper/CMakeLists.txt @@ -31,7 +31,7 @@ # ############################################################################ -include_directories(../../../../lib/DriverFramework/drivers) +include_directories(../../../lib/DriverFramework/drivers) px4_add_module( MODULE platforms__posix__drivers__df_ms5611_wrapper diff --git a/src/platforms/posix/drivers/df_ms5611_wrapper/df_ms5611_wrapper.cpp b/src/drivers/driver_framework_wrapper/df_ms5611_wrapper/df_ms5611_wrapper.cpp similarity index 100% rename from src/platforms/posix/drivers/df_ms5611_wrapper/df_ms5611_wrapper.cpp rename to src/drivers/driver_framework_wrapper/df_ms5611_wrapper/df_ms5611_wrapper.cpp diff --git a/src/platforms/posix/drivers/df_trone_wrapper/CMakeLists.txt b/src/drivers/driver_framework_wrapper/df_trone_wrapper/CMakeLists.txt similarity index 96% rename from src/platforms/posix/drivers/df_trone_wrapper/CMakeLists.txt rename to src/drivers/driver_framework_wrapper/df_trone_wrapper/CMakeLists.txt index 30b9974c0248..2b6d79e8214b 100644 --- a/src/platforms/posix/drivers/df_trone_wrapper/CMakeLists.txt +++ b/src/drivers/driver_framework_wrapper/df_trone_wrapper/CMakeLists.txt @@ -31,7 +31,7 @@ # ############################################################################ -include_directories(../../../../lib/DriverFramework/drivers) +include_directories(../../../lib/DriverFramework/drivers) px4_add_module( MODULE platforms__posix__drivers__df_trone_wrapper diff --git a/src/platforms/posix/drivers/df_trone_wrapper/df_trone_wrapper.cpp b/src/drivers/driver_framework_wrapper/df_trone_wrapper/df_trone_wrapper.cpp similarity index 100% rename from src/platforms/posix/drivers/df_trone_wrapper/df_trone_wrapper.cpp rename to src/drivers/driver_framework_wrapper/df_trone_wrapper/df_trone_wrapper.cpp diff --git a/src/drivers/drv_adc.h b/src/drivers/drv_adc.h index 4fdfa2d6a9e9..3e7e984eafc7 100644 --- a/src/drivers/drv_adc.h +++ b/src/drivers/drv_adc.h @@ -36,8 +36,6 @@ * * ADC driver interface. * - * This defines additional operations over and above the standard NuttX - * ADC API. */ #pragma once @@ -60,6 +58,34 @@ typedef struct __attribute__((packed)) px4_adc_msg_t { #define ADC0_DEVICE_PATH "/dev/adc0" -/* - * ioctl definitions + +__BEGIN_DECLS + +/** + * Initialize ADC hardware + * @param base_address architecture-specific address to specify the ADC + * @return 0 on success, <0 error otherwise + */ +int px4_arch_adc_init(uint32_t base_address); + +/** + * Uninitialize ADC hardware + * @param base_address architecture-specific address to specify the ADC + */ +void px4_arch_adc_uninit(uint32_t base_address); + +/** + * Read a sample from the ADC + * @param base_address architecture-specific address to specify the ADC + * @param channel specify the channel + * @return sample, 0xffff on error */ +uint16_t px4_arch_adc_sample(uint32_t base_address, unsigned channel); + +/** + * Get the temperature sensor channel bitmask + */ +uint32_t px4_arch_adc_temp_sensor_mask(void); + +__END_DECLS + diff --git a/src/drivers/drv_tone_alarm.h b/src/drivers/drv_tone_alarm.h index 7d389cd7fe30..f22d4798422c 100644 --- a/src/drivers/drv_tone_alarm.h +++ b/src/drivers/drv_tone_alarm.h @@ -91,3 +91,23 @@ enum { TONE_HOME_SET, TONE_NUMBER_OF_TUNES }; + +namespace ToneAlarmInterface +{ + +/** + * @brief Activates/configures the hardware registers. + */ +void init(); + +/** + * @brief Starts playing the note. + */ +void start_note(unsigned frequency); + +/** + * @brief Stops playing the current note and makes the player 'safe'. + */ +void stop_note(); + +} // ToneAlarmInterface diff --git a/src/drivers/heater/heater.h b/src/drivers/heater/heater.h index bcc1916f0175..e492d570f6c4 100644 --- a/src/drivers/heater/heater.h +++ b/src/drivers/heater/heater.h @@ -45,7 +45,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/src/drivers/imu/adis16448/ADIS16448.h b/src/drivers/imu/adis16448/ADIS16448.h index e1c01842baee..e5fd10d8e2d1 100644 --- a/src/drivers/imu/adis16448/ADIS16448.h +++ b/src/drivers/imu/adis16448/ADIS16448.h @@ -50,7 +50,7 @@ #include #include #include -#include +#include using namespace time_literals; diff --git a/src/drivers/imu/adis16477/ADIS16477.hpp b/src/drivers/imu/adis16477/ADIS16477.hpp index a5ed6c562bdd..cc7cec9dd67b 100644 --- a/src/drivers/imu/adis16477/ADIS16477.hpp +++ b/src/drivers/imu/adis16477/ADIS16477.hpp @@ -45,7 +45,7 @@ #include #include #include -#include +#include class ADIS16477 : public device::SPI, public px4::ScheduledWorkItem { diff --git a/src/drivers/imu/adis16497/ADIS16497.hpp b/src/drivers/imu/adis16497/ADIS16497.hpp index 8894d9d778b4..7cb0e7fdf595 100644 --- a/src/drivers/imu/adis16497/ADIS16497.hpp +++ b/src/drivers/imu/adis16497/ADIS16497.hpp @@ -45,7 +45,7 @@ #include #include #include -#include +#include // TODO : This is a copy of the NuttX CRC32 table static constexpr uint32_t crc32_tab[] = { diff --git a/src/drivers/imu/bma180/bma180.cpp b/src/drivers/imu/bma180/bma180.cpp index 47dfba02941d..ea63dd20d4ed 100644 --- a/src/drivers/imu/bma180/bma180.cpp +++ b/src/drivers/imu/bma180/bma180.cpp @@ -57,7 +57,7 @@ #include #include #include -#include +#include #include #include @@ -66,7 +66,7 @@ #include #include #include -#include +#include #define ACCEL_DEVICE_PATH "/dev/bma180" diff --git a/src/drivers/imu/bmi055/BMI055.hpp b/src/drivers/imu/bmi055/BMI055.hpp index eb11619b64c9..75e28f683184 100644 --- a/src/drivers/imu/bmi055/BMI055.hpp +++ b/src/drivers/imu/bmi055/BMI055.hpp @@ -37,7 +37,7 @@ #include #include #include -#include +#include #define DIR_READ 0x80 #define DIR_WRITE 0x00 diff --git a/src/drivers/imu/bmi088/BMI088.hpp b/src/drivers/imu/bmi088/BMI088.hpp index d21ea014cfd4..8e3e6a904e68 100644 --- a/src/drivers/imu/bmi088/BMI088.hpp +++ b/src/drivers/imu/bmi088/BMI088.hpp @@ -38,7 +38,7 @@ #include #include #include -#include +#include #define DIR_READ 0x80 #define DIR_WRITE 0x00 diff --git a/src/drivers/imu/bmi160/bmi160.hpp b/src/drivers/imu/bmi160/bmi160.hpp index cad0827a2c4b..473ecc99239f 100644 --- a/src/drivers/imu/bmi160/bmi160.hpp +++ b/src/drivers/imu/bmi160/bmi160.hpp @@ -40,7 +40,7 @@ #include #include #include -#include +#include #include #define DIR_READ 0x80 diff --git a/src/drivers/imu/fxas21002c/FXAS21002C.hpp b/src/drivers/imu/fxas21002c/FXAS21002C.hpp index 997e969b08b3..8b0f0b15eb27 100644 --- a/src/drivers/imu/fxas21002c/FXAS21002C.hpp +++ b/src/drivers/imu/fxas21002c/FXAS21002C.hpp @@ -43,7 +43,7 @@ #include #include #include -#include +#include class FXAS21002C : public device::SPI, public px4::ScheduledWorkItem diff --git a/src/drivers/imu/fxos8701cq/fxos8701cq.cpp b/src/drivers/imu/fxos8701cq/fxos8701cq.cpp index 0d693db3eea2..e626f861f5b8 100644 --- a/src/drivers/imu/fxos8701cq/fxos8701cq.cpp +++ b/src/drivers/imu/fxos8701cq/fxos8701cq.cpp @@ -46,7 +46,7 @@ #include #include #include -#include +#include #include #if !defined(BOARD_HAS_NOISY_FXOS8700_MAG) diff --git a/src/drivers/imu/icm20948/icm20948.h b/src/drivers/imu/icm20948/icm20948.h index 5814083b7938..abeead1d58c8 100644 --- a/src/drivers/imu/icm20948/icm20948.h +++ b/src/drivers/imu/icm20948/icm20948.h @@ -44,7 +44,7 @@ #include #include #include -#include +#include #include diff --git a/src/drivers/imu/l3gd20/l3gd20.cpp b/src/drivers/imu/l3gd20/l3gd20.cpp index 85aeb561d750..6cadddb99694 100644 --- a/src/drivers/imu/l3gd20/l3gd20.cpp +++ b/src/drivers/imu/l3gd20/l3gd20.cpp @@ -44,7 +44,7 @@ #include #include #include -#include +#include #define L3GD20_DEVICE_PATH "/dev/l3gd20" diff --git a/src/drivers/imu/lsm303d/LSM303D.hpp b/src/drivers/imu/lsm303d/LSM303D.hpp index ab9abf39d380..819b162787d5 100644 --- a/src/drivers/imu/lsm303d/LSM303D.hpp +++ b/src/drivers/imu/lsm303d/LSM303D.hpp @@ -41,7 +41,7 @@ #include #include #include -#include +#include #include #include diff --git a/src/drivers/imu/mpu6000/MPU6000.hpp b/src/drivers/imu/mpu6000/MPU6000.hpp index 33817589ece3..a75a1716d16b 100644 --- a/src/drivers/imu/mpu6000/MPU6000.hpp +++ b/src/drivers/imu/mpu6000/MPU6000.hpp @@ -63,7 +63,7 @@ #include #include #include -#include +#include #include #include diff --git a/src/drivers/imu/mpu9250/mpu9250.h b/src/drivers/imu/mpu9250/mpu9250.h index 84e45cbf711c..65fe2bde2828 100644 --- a/src/drivers/imu/mpu9250/mpu9250.h +++ b/src/drivers/imu/mpu9250/mpu9250.h @@ -35,7 +35,7 @@ #include #include #include -#include +#include #include #include diff --git a/src/drivers/irlock/irlock.cpp b/src/drivers/irlock/irlock.cpp index 223b0e010e8a..5aa9f2c35b86 100644 --- a/src/drivers/irlock/irlock.cpp +++ b/src/drivers/irlock/irlock.cpp @@ -46,7 +46,7 @@ #include #include -#include +#include #include #include diff --git a/src/drivers/kinetis/CMakeLists.txt b/src/drivers/kinetis/CMakeLists.txt deleted file mode 100644 index a2fe213eb4d4..000000000000 --- a/src/drivers/kinetis/CMakeLists.txt +++ /dev/null @@ -1,44 +0,0 @@ -############################################################################ -# -# Copyright (c) 2016-2017 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. -# -############################################################################ - -add_library(drivers_arch - drv_hrt.c - drv_io_timer.c - drv_pwm_servo.c - drv_pwm_trigger.c - drv_input_capture.c - drv_led_pwm.cpp -) -add_dependencies(drivers_arch prebuild_targets) -target_link_libraries(drivers_arch PRIVATE drivers_board) -target_compile_options(drivers_arch PRIVATE -Wno-cast-align) # TODO: fix and enable diff --git a/src/drivers/kinetis/adc/adc.cpp b/src/drivers/kinetis/adc/adc.cpp deleted file mode 100644 index 50f307c3c0d9..000000000000 --- a/src/drivers/kinetis/adc/adc.cpp +++ /dev/null @@ -1,507 +0,0 @@ -/**************************************************************************** - * - * Copyright (C) 2016-2019 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 adc.cpp - * - * TODO:This is stubbed out leving the code intact to document the needed - * mechinsm for porting. - * - * Driver for the Kinetis ADC. - * - * This is a low-rate driver, designed for sampling things like voltages - * and so forth. It avoids the gross complexity of the NuttX ADC driver. - */ - -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -using namespace time_literals; - -#if defined(ADC_CHANNELS) - -#define ADC_TOTAL_CHANNELS 32 - -#define _REG(_addr) (*(volatile uint32_t *)(_addr)) - -/* ADC register accessors */ - -#define REG(a, _reg) _REG(KINETIS_ADC##a##_BASE + (_reg)) - -#define rSC1A(adc) REG(adc, KINETIS_ADC_SC1A_OFFSET) /* ADC status and control registers 1 */ -#define rSC1B(adc) REG(adc, KINETIS_ADC_SC1B_OFFSET) /* ADC status and control registers 1 */ -#define rCFG1(adc) REG(adc, KINETIS_ADC_CFG1_OFFSET) /* ADC configuration register 1 */ -#define rCFG2(adc) REG(adc, KINETIS_ADC_CFG2_OFFSET) /* Configuration register 2 */ -#define rRA(adc) REG(adc, KINETIS_ADC_RA_OFFSET) /* ADC data result register */ -#define rRB(adc) REG(adc, KINETIS_ADC_RB_OFFSET) /* ADC data result register */ -#define rCV1(adc) REG(adc, KINETIS_ADC_CV1_OFFSET) /* Compare value registers */ -#define rCV2(adc) REG(adc, KINETIS_ADC_CV2_OFFSET) /* Compare value registers */ -#define rSC2(adc) REG(adc, KINETIS_ADC_SC2_OFFSET) /* Status and control register 2 */ -#define rSC3(adc) REG(adc, KINETIS_ADC_SC3_OFFSET) /* Status and control register 3 */ -#define rOFS(adc) REG(adc, KINETIS_ADC_OFS_OFFSET) /* ADC offset correction register */ -#define rPG(adc) REG(adc, KINETIS_ADC_PG_OFFSET) /* ADC plus-side gain register */ -#define rMG(adc) REG(adc, KINETIS_ADC_MG_OFFSET) /* ADC minus-side gain register */ -#define rCLPD(adc) REG(adc, KINETIS_ADC_CLPD_OFFSET) /* ADC plus-side general calibration value register */ -#define rCLPS(adc) REG(adc, KINETIS_ADC_CLPS_OFFSET) /* ADC plus-side general calibration value register */ -#define rCLP4(adc) REG(adc, KINETIS_ADC_CLP4_OFFSET) /* ADC plus-side general calibration value register */ -#define rCLP3(adc) REG(adc, KINETIS_ADC_CLP3_OFFSET) /* ADC plus-side general calibration value register */ -#define rCLP2(adc) REG(adc, KINETIS_ADC_CLP2_OFFSET) /* ADC plus-side general calibration value register */ -#define rCLP1(adc) REG(adc, KINETIS_ADC_CLP1_OFFSET) /* ADC plus-side general calibration value register */ -#define rCLP0(adc) REG(adc, KINETIS_ADC_CLP0_OFFSET) /* ADC plus-side general calibration value register */ -#define rCLMD(adc) REG(adc, KINETIS_ADC_CLMD_OFFSET) /* ADC minus-side general calibration value register */ -#define rCLMS(adc) REG(adc, KINETIS_ADC_CLMS_OFFSET) /* ADC minus-side general calibration value register */ -#define rCLM4(adc) REG(adc, KINETIS_ADC_CLM4_OFFSET) /* ADC minus-side general calibration value register */ -#define rCLM3(adc) REG(adc, KINETIS_ADC_CLM3_OFFSET) /* ADC minus-side general calibration value register */ -#define rCLM2(adc) REG(adc, KINETIS_ADC_CLM2_OFFSET) /* ADC minus-side general calibration value register */ -#define rCLM1(adc) REG(adc, KINETIS_ADC_CLM1_OFFSET) /* ADC minus-side general calibration value register */ -#define rCLM0(adc) REG(adc, KINETIS_ADC_CLM0_OFFSET) /* ADC minus-side general calibration value register */ - -class ADC : public cdev::CDev, public px4::ScheduledWorkItem -{ -public: - ADC(uint32_t channels); - ~ADC(); - - virtual int init(); - - virtual int ioctl(file *filp, int cmd, unsigned long arg); - virtual ssize_t read(file *filp, char *buffer, size_t len); - -protected: - virtual int open_first(struct file *filp); - virtual int close_last(struct file *filp); - -private: - void Run() override; - - /** - * Sample a single channel and return the measured value. - * - * @param channel The channel to sample. - * @return The sampled value, or 0xffff if - * sampling failed. - */ - uint16_t sample(unsigned channel); - - void update_adc_report(hrt_abstime now); - void update_system_power(hrt_abstime now); - - - static const hrt_abstime kINTERVAL{10_ms}; /**< 100Hz base rate */ - - perf_counter_t _sample_perf; - - unsigned _channel_count{0}; - px4_adc_msg_t *_samples{nullptr}; /**< sample buffer */ - - uORB::Publication _to_adc_report{ORB_ID(adc_report)}; - uORB::Publication _to_system_power{ORB_ID(system_power)}; -}; - -ADC::ADC(uint32_t channels) : - CDev(ADC0_DEVICE_PATH), - ScheduledWorkItem(px4::wq_configurations::hp_default), - _sample_perf(perf_alloc(PC_ELAPSED, "adc_samples")) -{ - /* always enable the temperature sensor */ - channels |= 1 << (ADC_SC1_ADCH_TEMP >> ADC_SC1_ADCH_SHIFT); - - /* allocate the sample array */ - for (unsigned i = 0; i < ADC_TOTAL_CHANNELS; i++) { - if (channels & (1 << i)) { - _channel_count++; - } - } - - if (_channel_count > PX4_MAX_ADC_CHANNELS) { - PX4_ERR("PX4_MAX_ADC_CHANNELS is too small:is %d needed:%d", PX4_MAX_ADC_CHANNELS, _channel_count); - } - - _samples = new px4_adc_msg_t[_channel_count]; - - /* prefill the channel numbers in the sample array */ - if (_samples != nullptr) { - unsigned index = 0; - - for (unsigned i = 0; i < ADC_TOTAL_CHANNELS; i++) { - if (channels & (1 << i)) { - _samples[index].am_channel = i; - _samples[index].am_data = 0; - index++; - } - } - } -} - -ADC::~ADC() -{ - if (_samples != nullptr) { - delete _samples; - } - - irqstate_t flags = px4_enter_critical_section(); - _REG(KINETIS_SIM_SCGC3) &= ~SIM_SCGC3_ADC1; - px4_leave_critical_section(flags); - - perf_free(_sample_perf); -} - -int board_adc_init() -{ - /* Input is Buss Clock 56 Mhz We will use /8 for 7 Mhz */ - - irqstate_t flags = px4_enter_critical_section(); - - _REG(KINETIS_SIM_SCGC3) |= SIM_SCGC3_ADC1; - rCFG1(1) = ADC_CFG1_ADICLK_BUSCLK | ADC_CFG1_MODE_1213BIT | ADC_CFG1_ADIV_DIV8; - rCFG2(1) = 0; - rSC2(1) = ADC_SC2_REFSEL_DEFAULT; - - px4_leave_critical_section(flags); - - /* Clear the CALF and begin the calibration */ - - rSC3(1) = ADC_SC3_CAL | ADC_SC3_CALF; - - while ((rSC1A(1) & ADC_SC1_COCO) == 0) { - usleep(100); - - if (rSC3(1) & ADC_SC3_CALF) { - return -1; - } - } - - /* dummy read to clear COCO of calibration */ - - int32_t r = rRA(1); - - /* Check the state of CALF at the end of calibration */ - - if (rSC3(1) & ADC_SC3_CALF) { - return -1; - } - - /* Calculate the calibration values for single ended positive */ - - r = rCLP0(1) + rCLP1(1) + rCLP2(1) + rCLP3(1) + rCLP4(1) + rCLPS(1) ; - r = 0x8000U | (r >> 1U); - rPG(1) = r; - - /* Calculate the calibration values for double ended Negitive */ - - r = rCLM0(1) + rCLM1(1) + rCLM2(1) + rCLM3(1) + rCLM4(1) + rCLMS(1) ; - r = 0x8000U | (r >> 1U); - rMG(1) = r; - - /* kick off a sample and wait for it to complete */ - hrt_abstime now = hrt_absolute_time(); - - rSC1A(1) = ADC_SC1_ADCH(ADC_SC1_ADCH_TEMP); - - while (!(rSC1A(1) & ADC_SC1_COCO)) { - - /* don't wait for more than 500us, since that means something broke - should reset here if we see this */ - if ((hrt_absolute_time() - now) > 500) { - return -1; - } - } - - return OK; -} - -int -ADC::init() -{ - int rv = board_adc_init(); - - if (rv < 0) { - PX4_DEBUG("sample timeout"); - return rv; - } - - /* create the device node */ - return CDev::init(); -} - -int -ADC::ioctl(file *filp, int cmd, unsigned long arg) -{ - return -ENOTTY; -} - -ssize_t -ADC::read(file *filp, char *buffer, size_t len) -{ - const size_t maxsize = sizeof(px4_adc_msg_t) * _channel_count; - - if (len > maxsize) { - len = maxsize; - } - - /* block interrupts while copying samples to avoid racing with an update */ - irqstate_t flags = px4_enter_critical_section(); - memcpy(buffer, _samples, len); - px4_leave_critical_section(flags); - - return len; -} - -int -ADC::open_first(struct file *filp) -{ - /* get fresh data */ - Run(); - - /* and schedule regular updates */ - ScheduleOnInterval(kINTERVAL, kINTERVAL); - - return 0; -} - -int -ADC::close_last(struct file *filp) -{ - ScheduleClear(); - - return 0; -} - -void -ADC::Run() -{ - hrt_abstime now = hrt_absolute_time(); - - /* scan the channel set and sample each */ - for (unsigned i = 0; i < _channel_count; i++) { - _samples[i].am_data = sample(_samples[i].am_channel); - } - - update_adc_report(now); - update_system_power(now); -} - -void -ADC::update_adc_report(hrt_abstime now) -{ - adc_report_s adc = {}; - adc.timestamp = now; - - unsigned max_num = _channel_count; - - if (max_num > (sizeof(adc.channel_id) / sizeof(adc.channel_id[0]))) { - max_num = (sizeof(adc.channel_id) / sizeof(adc.channel_id[0])); - } - - for (unsigned i = 0; i < max_num; i++) { - adc.channel_id[i] = _samples[i].am_channel; - adc.channel_value[i] = _samples[i].am_data * 3.3f / 4096.0f; - } - - _to_adc_report.publish(adc); -} - -void -ADC::update_system_power(hrt_abstime now) -{ -#if defined (BOARD_ADC_USB_CONNECTED) - system_power_s system_power {}; - system_power.timestamp = now; - -#if defined(ADC_5V_RAIL_SENSE) - - for (unsigned i = 0; i < _channel_count; i++) { - - if (_samples[i].am_channel == ADC_5V_RAIL_SENSE) { - // it is 2:1 scaled - system_power.voltage5v_v = _samples[i].am_data * (6.6f / 4096.0f); - } - } - -#endif - - /* Note once the board_config.h provides BOARD_ADC_USB_CONNECTED, - * It must provide the true logic GPIO BOARD_ADC_xxxx macros. - */ - // these are not ADC related, but it is convenient to - // publish these to the same topic - - system_power.usb_connected = BOARD_ADC_USB_CONNECTED; - /* If provided used the Valid signal from HW*/ -#if defined(BOARD_ADC_USB_VALID) - system_power.usb_valid = BOARD_ADC_USB_VALID; -#else - /* If not provided then use connected */ - system_power.usb_valid = system_power.usb_connected; -#endif - - system_power.brick_valid = BOARD_ADC_BRICK_VALID; - system_power.servo_valid = BOARD_ADC_SERVO_VALID; - - // OC pins are active low - system_power.periph_5v_oc = BOARD_ADC_PERIPH_5V_OC; - system_power.hipower_5v_oc = BOARD_ADC_HIPOWER_5V_OC; - - /* lazily publish */ - _to_system_power.publish(system_power); - -#endif // BOARD_ADC_USB_CONNECTED -} - -uint16_t board_adc_sample(unsigned channel) -{ - irqstate_t flags = px4_enter_critical_section(); - - /* clear any previous COCC */ - rRA(1); - - /* run a single conversion right now - should take about 35 cycles (5 microseconds) max */ - rSC1A(1) = ADC_SC1_ADCH(channel); - - /* wait for the conversion to complete */ - const hrt_abstime now = hrt_absolute_time(); - - while (!(rSC1A(1) & ADC_SC1_COCO)) { - - /* don't wait for more than 10us, since that means something broke - should reset here if we see this */ - if ((hrt_absolute_time() - now) > 10) { - px4_leave_critical_section(flags); - return 0xffff; - } - } - - /* read the result and clear EOC */ - uint16_t result = rRA(1); - - px4_leave_critical_section(flags); - - return result; -} - -uint16_t -ADC::sample(unsigned channel) -{ - perf_begin(_sample_perf); - uint16_t result = board_adc_sample(channel); - - if (result == 0xffff) { - PX4_ERR("sample timeout"); - } - - perf_end(_sample_perf); - return result; -} - -/* - * Driver 'main' command. - */ -extern "C" __EXPORT int adc_main(int argc, char *argv[]); - -namespace -{ -ADC *g_adc{nullptr}; - -int -test(void) -{ - - int fd = open(ADC0_DEVICE_PATH, O_RDONLY); - - if (fd < 0) { - PX4_ERR("can't open ADC device %d", errno); - return 1; - } - - for (unsigned i = 0; i < 50; i++) { - px4_adc_msg_t data[ADC_TOTAL_CHANNELS]; - ssize_t count = read(fd, data, sizeof(data)); - - if (count < 0) { - PX4_ERR("read error"); - return 1; - } - - unsigned channels = count / sizeof(data[0]); - - for (unsigned j = 0; j < channels; j++) { - printf("%d: %u ", data[j].am_channel, data[j].am_data); - } - - printf("\n"); - px4_usleep(500000); - } - - return 0; -} -} - -int -adc_main(int argc, char *argv[]) -{ - if (g_adc == nullptr) { - /* XXX this hardcodes the default channel set for the board in board_config.h - should be configurable */ - g_adc = new ADC(ADC_CHANNELS); - - if (g_adc == nullptr) { - PX4_ERR("couldn't allocate the ADC driver"); - return 1; - } - - if (g_adc->init() != OK) { - delete g_adc; - PX4_ERR("ADC init failed"); - return 1; - } - } - - if (argc > 1) { - if (!strcmp(argv[1], "test")) { - return test(); - } - } - - return 0; -} -#endif diff --git a/src/drivers/kinetis/drv_input_capture.h b/src/drivers/kinetis/drv_input_capture.h deleted file mode 100644 index 968ce831efaf..000000000000 --- a/src/drivers/kinetis/drv_input_capture.h +++ /dev/null @@ -1,42 +0,0 @@ -/**************************************************************************** - * - * Copyright (C) 2012-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 drv_input_capture.h - * - * stm32-specific input capture data. - */ - -#pragma once - -#include diff --git a/src/drivers/lights/blinkm/blinkm.cpp b/src/drivers/lights/blinkm/blinkm.cpp index 94329bb5251c..27f28f344d0f 100644 --- a/src/drivers/lights/blinkm/blinkm.cpp +++ b/src/drivers/lights/blinkm/blinkm.cpp @@ -99,7 +99,7 @@ #include #include -#include +#include #include #include #include diff --git a/src/drivers/lights/oreoled/oreoled.cpp b/src/drivers/lights/oreoled/oreoled.cpp index 0b546cc88c64..a41b4826c265 100644 --- a/src/drivers/lights/oreoled/oreoled.cpp +++ b/src/drivers/lights/oreoled/oreoled.cpp @@ -47,7 +47,7 @@ #include #include #include -#include +#include #include #define OREOLED_NUM_LEDS 4 ///< maximum number of LEDs the oreo led driver can support diff --git a/src/drivers/lights/pca8574/pca8574.cpp b/src/drivers/lights/pca8574/pca8574.cpp index 944cb6de45e3..bf5f8db3440a 100644 --- a/src/drivers/lights/pca8574/pca8574.cpp +++ b/src/drivers/lights/pca8574/pca8574.cpp @@ -46,7 +46,7 @@ #include #include #include -#include +#include #include diff --git a/src/drivers/lights/rgbled/rgbled.cpp b/src/drivers/lights/rgbled/rgbled.cpp index 073eed08d763..a15a584326f9 100644 --- a/src/drivers/lights/rgbled/rgbled.cpp +++ b/src/drivers/lights/rgbled/rgbled.cpp @@ -45,7 +45,7 @@ #include #include #include -#include +#include #include #include diff --git a/src/drivers/lights/rgbled_ncp5623c/rgbled_ncp5623c.cpp b/src/drivers/lights/rgbled_ncp5623c/rgbled_ncp5623c.cpp index 3dd2726ce669..a794902ed532 100755 --- a/src/drivers/lights/rgbled_ncp5623c/rgbled_ncp5623c.cpp +++ b/src/drivers/lights/rgbled_ncp5623c/rgbled_ncp5623c.cpp @@ -44,7 +44,7 @@ #include #include #include -#include +#include #include #include diff --git a/src/drivers/lights/rgbled_pwm/CMakeLists.txt b/src/drivers/lights/rgbled_pwm/CMakeLists.txt index dc85022c7932..959864f3a88e 100644 --- a/src/drivers/lights/rgbled_pwm/CMakeLists.txt +++ b/src/drivers/lights/rgbled_pwm/CMakeLists.txt @@ -40,4 +40,6 @@ px4_add_module( rgbled_pwm.cpp DEPENDS led - ) \ No newline at end of file + arch_io_pins + arch_led_pwm + ) diff --git a/src/drivers/lights/rgbled_pwm/rgbled_pwm.cpp b/src/drivers/lights/rgbled_pwm/rgbled_pwm.cpp index f50490bd3596..f49e569d58c7 100644 --- a/src/drivers/lights/rgbled_pwm/rgbled_pwm.cpp +++ b/src/drivers/lights/rgbled_pwm/rgbled_pwm.cpp @@ -44,7 +44,7 @@ #include #include #include -#include +#include class RGBLED_PWM : public device::CDev, public px4::ScheduledWorkItem { diff --git a/src/drivers/linux_sbus/linux_sbus.h b/src/drivers/linux_sbus/linux_sbus.h index be51d1db0828..e03a849fd417 100644 --- a/src/drivers/linux_sbus/linux_sbus.h +++ b/src/drivers/linux_sbus/linux_sbus.h @@ -48,7 +48,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/src/drivers/magnetometer/ak09916/ak09916.hpp b/src/drivers/magnetometer/ak09916/ak09916.hpp index 5e6f15dc657b..d42ff990985f 100644 --- a/src/drivers/magnetometer/ak09916/ak09916.hpp +++ b/src/drivers/magnetometer/ak09916/ak09916.hpp @@ -39,7 +39,7 @@ #include #include #include -#include +#include #include #define AK09916_DEVICE_PATH_MAG "/dev/ak09916_i2c_int" diff --git a/src/drivers/magnetometer/bmm150/bmm150.hpp b/src/drivers/magnetometer/bmm150/bmm150.hpp index 78411ae804a1..f9e1fe3d5877 100644 --- a/src/drivers/magnetometer/bmm150/bmm150.hpp +++ b/src/drivers/magnetometer/bmm150/bmm150.hpp @@ -20,7 +20,7 @@ #include #include -#include +#include #include #include diff --git a/src/drivers/magnetometer/hmc5883/hmc5883.cpp b/src/drivers/magnetometer/hmc5883/hmc5883.cpp index f4ef237427ef..1a6e51211e39 100644 --- a/src/drivers/magnetometer/hmc5883/hmc5883.cpp +++ b/src/drivers/magnetometer/hmc5883/hmc5883.cpp @@ -57,7 +57,7 @@ #include #include -#include +#include #include #include diff --git a/src/drivers/magnetometer/ist8310/ist8310.cpp b/src/drivers/magnetometer/ist8310/ist8310.cpp index ddad228ea322..852a59437f4a 100644 --- a/src/drivers/magnetometer/ist8310/ist8310.cpp +++ b/src/drivers/magnetometer/ist8310/ist8310.cpp @@ -76,7 +76,7 @@ #include #include -#include +#include /* * IST8310 internal constants and data structures. diff --git a/src/drivers/magnetometer/lis3mdl/lis3mdl.h b/src/drivers/magnetometer/lis3mdl/lis3mdl.h index c00ebb9943a2..a77e3e85ad45 100644 --- a/src/drivers/magnetometer/lis3mdl/lis3mdl.h +++ b/src/drivers/magnetometer/lis3mdl/lis3mdl.h @@ -48,7 +48,7 @@ #include #include -#include +#include #include #include diff --git a/src/drivers/magnetometer/lsm303agr/LSM303AGR.hpp b/src/drivers/magnetometer/lsm303agr/LSM303AGR.hpp index fcf96ce2aac9..6342c098ad94 100644 --- a/src/drivers/magnetometer/lsm303agr/LSM303AGR.hpp +++ b/src/drivers/magnetometer/lsm303agr/LSM303AGR.hpp @@ -42,7 +42,7 @@ #include #include #include -#include +#include #include // Register mapping diff --git a/src/drivers/magnetometer/qmc5883/qmc5883.cpp b/src/drivers/magnetometer/qmc5883/qmc5883.cpp index 42864a3d2acc..6e3665e87e24 100644 --- a/src/drivers/magnetometer/qmc5883/qmc5883.cpp +++ b/src/drivers/magnetometer/qmc5883/qmc5883.cpp @@ -56,7 +56,7 @@ #include #include -#include +#include #include #include diff --git a/src/drivers/magnetometer/rm3100/rm3100.h b/src/drivers/magnetometer/rm3100/rm3100.h index 1d7ffc24adda..83492e143336 100644 --- a/src/drivers/magnetometer/rm3100/rm3100.h +++ b/src/drivers/magnetometer/rm3100/rm3100.h @@ -52,7 +52,7 @@ #include #include -#include +#include /** * RM3100 internal constants and data structures. diff --git a/src/drivers/optical_flow/paw3902/PAW3902.hpp b/src/drivers/optical_flow/paw3902/PAW3902.hpp index 59d692d2a188..8dd56eb11b9c 100644 --- a/src/drivers/optical_flow/paw3902/PAW3902.hpp +++ b/src/drivers/optical_flow/paw3902/PAW3902.hpp @@ -44,7 +44,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/src/drivers/optical_flow/pmw3901/pmw3901.cpp b/src/drivers/optical_flow/pmw3901/pmw3901.cpp index ed2e8caff717..ca5aa31a9246 100644 --- a/src/drivers/optical_flow/pmw3901/pmw3901.cpp +++ b/src/drivers/optical_flow/pmw3901/pmw3901.cpp @@ -41,7 +41,7 @@ #include #include #include -#include +#include #include diff --git a/src/drivers/optical_flow/px4flow/px4flow.cpp b/src/drivers/optical_flow/px4flow/px4flow.cpp index 789b2b5c0485..e65f69465fb7 100644 --- a/src/drivers/optical_flow/px4flow/px4flow.cpp +++ b/src/drivers/optical_flow/px4flow/px4flow.cpp @@ -49,7 +49,7 @@ #include #include #include -#include +#include #include #include diff --git a/src/drivers/osd/atxxxx/atxxxx.h b/src/drivers/osd/atxxxx/atxxxx.h index 4b6edb950c0c..9af6e441b996 100644 --- a/src/drivers/osd/atxxxx/atxxxx.h +++ b/src/drivers/osd/atxxxx/atxxxx.h @@ -46,7 +46,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/src/drivers/pca9685/pca9685.cpp b/src/drivers/pca9685/pca9685.cpp index adaa6733c04c..6b3ef7307eb9 100644 --- a/src/drivers/pca9685/pca9685.cpp +++ b/src/drivers/pca9685/pca9685.cpp @@ -63,7 +63,7 @@ #include #include -#include +#include #include #include diff --git a/src/drivers/power_monitor/ina226/ina226.cpp b/src/drivers/power_monitor/ina226/ina226.cpp index 034b7ed8a244..b1e740abee6b 100644 --- a/src/drivers/power_monitor/ina226/ina226.cpp +++ b/src/drivers/power_monitor/ina226/ina226.cpp @@ -48,7 +48,7 @@ #include #include #include -#include +#include /* Configuration Constants */ #define INA226_BUS_DEFAULT PX4_I2C_BUS_EXPANSION diff --git a/src/drivers/pwm_out_sim/PWMSim.hpp b/src/drivers/pwm_out_sim/PWMSim.hpp index a8d9ec7ecf01..81d26e8b63ab 100644 --- a/src/drivers/pwm_out_sim/PWMSim.hpp +++ b/src/drivers/pwm_out_sim/PWMSim.hpp @@ -41,7 +41,6 @@ #include #include #include -#include #include #include #include diff --git a/src/drivers/px4fmu/CMakeLists.txt b/src/drivers/px4fmu/CMakeLists.txt index 1f04bc13cedd..42083f40a2fb 100644 --- a/src/drivers/px4fmu/CMakeLists.txt +++ b/src/drivers/px4fmu/CMakeLists.txt @@ -38,6 +38,7 @@ px4_add_module( SRCS fmu.cpp DEPENDS + arch_io_pins circuit_breaker mixer pwm_limit diff --git a/src/drivers/px4fmu/fmu.cpp b/src/drivers/px4fmu/fmu.cpp index 07af2605af3c..9e2b1cd82e9c 100644 --- a/src/drivers/px4fmu/fmu.cpp +++ b/src/drivers/px4fmu/fmu.cpp @@ -58,7 +58,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/src/drivers/px4io/CMakeLists.txt b/src/drivers/px4io/CMakeLists.txt index b5b9881cb828..e7fb8eb177b0 100644 --- a/src/drivers/px4io/CMakeLists.txt +++ b/src/drivers/px4io/CMakeLists.txt @@ -38,11 +38,10 @@ px4_add_module( -Wno-cast-align # TODO: fix and enable SRCS px4io.cpp - px4io_uploader.cpp px4io_serial.cpp - px4io_serial_f4.cpp - px4io_serial_f7.cpp + px4io_uploader.cpp DEPENDS + arch_px4io_serial circuit_breaker mixer ) diff --git a/src/drivers/px4io/px4io_serial.cpp b/src/drivers/px4io/px4io_serial.cpp index e3808c80e887..a46478b929a0 100644 --- a/src/drivers/px4io/px4io_serial.cpp +++ b/src/drivers/px4io/px4io_serial.cpp @@ -39,14 +39,14 @@ #include "px4io_driver.h" -#include "px4io_serial.h" +#include static PX4IO_serial *g_interface; device::Device *PX4IO_serial_interface() { - return new PX4IO_INTERFACE_CLASS(); + return new ArchPX4IOSerial(); } PX4IO_serial::PX4IO_serial() : diff --git a/src/drivers/qshell/qurt/qshell.cpp b/src/drivers/qshell/qurt/qshell.cpp index d159be1bc811..9a7c55417ac6 100644 --- a/src/drivers/qshell/qurt/qshell.cpp +++ b/src/drivers/qshell/qurt/qshell.cpp @@ -43,7 +43,6 @@ #include #include #include -#include #include #include diff --git a/src/drivers/qshell/qurt/qshell_main.cpp b/src/drivers/qshell/qurt/qshell_main.cpp index 95da6bbbb764..ecf966f1aba8 100644 --- a/src/drivers/qshell/qurt/qshell_main.cpp +++ b/src/drivers/qshell/qurt/qshell_main.cpp @@ -38,9 +38,9 @@ * @author Nicolas de Palezieux */ -#include #include #include +#include #include "qshell.h" extern "C" __EXPORT int qshell_entry(int argc, char **argv); diff --git a/src/platforms/qurt/fc_addon/mpu_spi/CMakeLists.txt b/src/drivers/qurt/fc_addon/mpu_spi/CMakeLists.txt similarity index 100% rename from src/platforms/qurt/fc_addon/mpu_spi/CMakeLists.txt rename to src/drivers/qurt/fc_addon/mpu_spi/CMakeLists.txt diff --git a/src/platforms/qurt/fc_addon/mpu_spi/mpu9x50_main.cpp b/src/drivers/qurt/fc_addon/mpu_spi/mpu9x50_main.cpp similarity index 100% rename from src/platforms/qurt/fc_addon/mpu_spi/mpu9x50_main.cpp rename to src/drivers/qurt/fc_addon/mpu_spi/mpu9x50_main.cpp diff --git a/src/platforms/qurt/fc_addon/mpu_spi/mpu9x50_params.c b/src/drivers/qurt/fc_addon/mpu_spi/mpu9x50_params.c similarity index 100% rename from src/platforms/qurt/fc_addon/mpu_spi/mpu9x50_params.c rename to src/drivers/qurt/fc_addon/mpu_spi/mpu9x50_params.c diff --git a/src/platforms/qurt/fc_addon/rc_receiver/CMakeLists.txt b/src/drivers/qurt/fc_addon/rc_receiver/CMakeLists.txt similarity index 100% rename from src/platforms/qurt/fc_addon/rc_receiver/CMakeLists.txt rename to src/drivers/qurt/fc_addon/rc_receiver/CMakeLists.txt diff --git a/src/platforms/qurt/fc_addon/rc_receiver/rc_receiver_main.cpp b/src/drivers/qurt/fc_addon/rc_receiver/rc_receiver_main.cpp similarity index 100% rename from src/platforms/qurt/fc_addon/rc_receiver/rc_receiver_main.cpp rename to src/drivers/qurt/fc_addon/rc_receiver/rc_receiver_main.cpp diff --git a/src/platforms/qurt/fc_addon/rc_receiver/rc_receiver_params.c b/src/drivers/qurt/fc_addon/rc_receiver/rc_receiver_params.c similarity index 100% rename from src/platforms/qurt/fc_addon/rc_receiver/rc_receiver_params.c rename to src/drivers/qurt/fc_addon/rc_receiver/rc_receiver_params.c diff --git a/src/platforms/qurt/fc_addon/uart_esc/CMakeLists.txt b/src/drivers/qurt/fc_addon/uart_esc/CMakeLists.txt similarity index 100% rename from src/platforms/qurt/fc_addon/uart_esc/CMakeLists.txt rename to src/drivers/qurt/fc_addon/uart_esc/CMakeLists.txt diff --git a/src/platforms/qurt/fc_addon/uart_esc/uart_esc_main.cpp b/src/drivers/qurt/fc_addon/uart_esc/uart_esc_main.cpp similarity index 100% rename from src/platforms/qurt/fc_addon/uart_esc/uart_esc_main.cpp rename to src/drivers/qurt/fc_addon/uart_esc/uart_esc_main.cpp diff --git a/src/platforms/qurt/fc_addon/uart_esc/uart_esc_params.c b/src/drivers/qurt/fc_addon/uart_esc/uart_esc_params.c similarity index 100% rename from src/platforms/qurt/fc_addon/uart_esc/uart_esc_params.c rename to src/drivers/qurt/fc_addon/uart_esc/uart_esc_params.c diff --git a/src/platforms/qurt/tests/hello/CMakeLists.txt b/src/drivers/qurt/tests/hello/CMakeLists.txt similarity index 100% rename from src/platforms/qurt/tests/hello/CMakeLists.txt rename to src/drivers/qurt/tests/hello/CMakeLists.txt diff --git a/src/platforms/qurt/tests/hello/hello_example.cpp b/src/drivers/qurt/tests/hello/hello_example.cpp similarity index 100% rename from src/platforms/qurt/tests/hello/hello_example.cpp rename to src/drivers/qurt/tests/hello/hello_example.cpp diff --git a/src/platforms/qurt/tests/hello/hello_example.h b/src/drivers/qurt/tests/hello/hello_example.h similarity index 100% rename from src/platforms/qurt/tests/hello/hello_example.h rename to src/drivers/qurt/tests/hello/hello_example.h diff --git a/src/platforms/qurt/tests/hello/hello_main.cpp b/src/drivers/qurt/tests/hello/hello_main.cpp similarity index 98% rename from src/platforms/qurt/tests/hello/hello_main.cpp rename to src/drivers/qurt/tests/hello/hello_main.cpp index 35e72e8b364d..e8ed25bab8d5 100644 --- a/src/platforms/qurt/tests/hello/hello_main.cpp +++ b/src/drivers/qurt/tests/hello/hello_main.cpp @@ -37,9 +37,9 @@ * * @author Mark Charlebois */ -#include #include #include +#include #include "hello_example.h" #include diff --git a/src/platforms/qurt/tests/hello/hello_start_qurt.cpp b/src/drivers/qurt/tests/hello/hello_start_qurt.cpp similarity index 100% rename from src/platforms/qurt/tests/hello/hello_start_qurt.cpp rename to src/drivers/qurt/tests/hello/hello_start_qurt.cpp diff --git a/src/platforms/qurt/tests/muorb/CMakeLists.txt b/src/drivers/qurt/tests/muorb/CMakeLists.txt similarity index 100% rename from src/platforms/qurt/tests/muorb/CMakeLists.txt rename to src/drivers/qurt/tests/muorb/CMakeLists.txt diff --git a/src/platforms/qurt/tests/muorb/muorb_test_example.cpp b/src/drivers/qurt/tests/muorb/muorb_test_example.cpp similarity index 100% rename from src/platforms/qurt/tests/muorb/muorb_test_example.cpp rename to src/drivers/qurt/tests/muorb/muorb_test_example.cpp diff --git a/src/platforms/qurt/tests/muorb/muorb_test_example.h b/src/drivers/qurt/tests/muorb/muorb_test_example.h similarity index 100% rename from src/platforms/qurt/tests/muorb/muorb_test_example.h rename to src/drivers/qurt/tests/muorb/muorb_test_example.h diff --git a/src/platforms/qurt/tests/muorb/muorb_test_main.cpp b/src/drivers/qurt/tests/muorb/muorb_test_main.cpp similarity index 98% rename from src/platforms/qurt/tests/muorb/muorb_test_main.cpp rename to src/drivers/qurt/tests/muorb/muorb_test_main.cpp index c6818a9270fb..fc172f7a909c 100644 --- a/src/platforms/qurt/tests/muorb/muorb_test_main.cpp +++ b/src/drivers/qurt/tests/muorb/muorb_test_main.cpp @@ -37,9 +37,9 @@ * * @author Mark Charlebois */ -#include #include #include +#include #include "muorb_test_example.h" extern "C" __EXPORT int muorb_test_entry(int argc, char **argv); diff --git a/src/platforms/qurt/tests/muorb/muorb_test_start_qurt.cpp b/src/drivers/qurt/tests/muorb/muorb_test_start_qurt.cpp similarity index 99% rename from src/platforms/qurt/tests/muorb/muorb_test_start_qurt.cpp rename to src/drivers/qurt/tests/muorb/muorb_test_start_qurt.cpp index ba44169ec3a0..0eef795ca34f 100644 --- a/src/platforms/qurt/tests/muorb/muorb_test_start_qurt.cpp +++ b/src/drivers/qurt/tests/muorb/muorb_test_start_qurt.cpp @@ -39,6 +39,7 @@ #include "muorb_test_example.h" #include #include +#include #include #include #include diff --git a/src/drivers/rpi_rc_in/rpi_rc_in.h b/src/drivers/rpi_rc_in/rpi_rc_in.h index 27031823ad52..2398cde8423f 100644 --- a/src/drivers/rpi_rc_in/rpi_rc_in.h +++ b/src/drivers/rpi_rc_in/rpi_rc_in.h @@ -49,7 +49,7 @@ #include #include -#include +#include #include #include diff --git a/src/drivers/safety_button/SafetyButton.hpp b/src/drivers/safety_button/SafetyButton.hpp index da59bca09baa..0cab2b385fde 100644 --- a/src/drivers/safety_button/SafetyButton.hpp +++ b/src/drivers/safety_button/SafetyButton.hpp @@ -41,7 +41,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/src/drivers/stm32/CMakeLists.txt b/src/drivers/stm32/CMakeLists.txt deleted file mode 100644 index aa444a97dd4f..000000000000 --- a/src/drivers/stm32/CMakeLists.txt +++ /dev/null @@ -1,44 +0,0 @@ -############################################################################ -# -# Copyright (c) 2015 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. -# -############################################################################ - -add_library(drivers_arch - drv_hrt.c - drv_io_timer.c - drv_pwm_servo.c - drv_pwm_trigger.c - drv_input_capture.c - drv_led_pwm.cpp -) -add_dependencies(drivers_arch prebuild_targets) -target_link_libraries(drivers_arch PRIVATE drivers_board) -target_compile_options(drivers_arch PRIVATE -Wno-cast-align) # TODO: fix and enable diff --git a/src/drivers/stm32/drv_input_capture.h b/src/drivers/stm32/drv_input_capture.h deleted file mode 100644 index 968ce831efaf..000000000000 --- a/src/drivers/stm32/drv_input_capture.h +++ /dev/null @@ -1,42 +0,0 @@ -/**************************************************************************** - * - * Copyright (C) 2012-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 drv_input_capture.h - * - * stm32-specific input capture data. - */ - -#pragma once - -#include diff --git a/src/drivers/telemetry/bst/bst.cpp b/src/drivers/telemetry/bst/bst.cpp index 1745975adbc0..9f327ddbbf5b 100644 --- a/src/drivers/telemetry/bst/bst.cpp +++ b/src/drivers/telemetry/bst/bst.cpp @@ -41,7 +41,7 @@ #include #include -#include +#include #include #include #include diff --git a/src/drivers/tone_alarm/CMakeLists.txt b/src/drivers/tone_alarm/CMakeLists.txt index f51963a17893..a298671f8bdb 100644 --- a/src/drivers/tone_alarm/CMakeLists.txt +++ b/src/drivers/tone_alarm/CMakeLists.txt @@ -38,6 +38,6 @@ px4_add_module( ToneAlarm.cpp DEPENDS circuit_breaker - tone_alarm_interface + arch_tone_alarm tunes ) diff --git a/src/drivers/tone_alarm/ToneAlarm.h b/src/drivers/tone_alarm/ToneAlarm.h index 90cb46db4598..b01d7b58c9b1 100644 --- a/src/drivers/tone_alarm/ToneAlarm.h +++ b/src/drivers/tone_alarm/ToneAlarm.h @@ -43,10 +43,9 @@ #include #include #include -#include #include #include -#include +#include #include #include diff --git a/src/examples/hello/hello_main.cpp b/src/examples/hello/hello_main.cpp index 75bff11cd167..227bc0ebc52d 100644 --- a/src/examples/hello/hello_main.cpp +++ b/src/examples/hello/hello_main.cpp @@ -40,8 +40,8 @@ #include "hello_example.h" -#include #include +#include #include int PX4_MAIN(int argc, char **argv) diff --git a/src/lib/cdev/test/cdevtest_main.cpp b/src/lib/cdev/test/cdevtest_main.cpp index cf4c05a42d39..e642e80b9e9e 100644 --- a/src/lib/cdev/test/cdevtest_main.cpp +++ b/src/lib/cdev/test/cdevtest_main.cpp @@ -39,8 +39,8 @@ */ #include "cdevtest_example.h" -#include #include +#include #include int PX4_MAIN(int argc, char **argv) diff --git a/src/lib/drivers/CMakeLists.txt b/src/lib/drivers/CMakeLists.txt index 81e7612b73dd..3995d705bf38 100644 --- a/src/lib/drivers/CMakeLists.txt +++ b/src/lib/drivers/CMakeLists.txt @@ -41,4 +41,3 @@ add_subdirectory(linux_gpio) add_subdirectory(magnetometer) add_subdirectory(rangefinder) add_subdirectory(smbus) -add_subdirectory(tone_alarm) diff --git a/src/lib/drivers/airspeed/airspeed.h b/src/lib/drivers/airspeed/airspeed.h index f3742675484a..aff712c051df 100644 --- a/src/lib/drivers/airspeed/airspeed.h +++ b/src/lib/drivers/airspeed/airspeed.h @@ -42,7 +42,7 @@ #include #include #include -#include +#include /* Default I2C bus */ static constexpr uint8_t PX4_I2C_BUS_DEFAULT = PX4_I2C_BUS_EXPANSION; diff --git a/src/lib/drivers/tone_alarm/ToneAlarmInterface.h b/src/lib/drivers/tone_alarm/ToneAlarmInterface.h deleted file mode 100644 index 9d2b35d3bd72..000000000000 --- a/src/lib/drivers/tone_alarm/ToneAlarmInterface.h +++ /dev/null @@ -1,54 +0,0 @@ -/**************************************************************************** - * - * Copyright (C) 2013-2019 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 ToneAlarmInterface.cpp - */ - -namespace ToneAlarmInterface -{ -/** - * @brief Activates/configures the hardware registers. - */ -void init(); - -/** - * @brief Starts playing the note. - */ -void start_note(unsigned frequency); - -/** - * @brief Stops playing the current note and makes the player 'safe'. - */ -void stop_note(); -}; // ToneAlarmInterface diff --git a/src/lib/parameters/CMakeLists.txt b/src/lib/parameters/CMakeLists.txt index 5293f723bb3b..6ee025585670 100644 --- a/src/lib/parameters/CMakeLists.txt +++ b/src/lib/parameters/CMakeLists.txt @@ -155,7 +155,7 @@ if (NOT "${PX4_BOARD}" MATCHES "px4_io") -Wno-sign-compare # TODO: fix and enable ) else() - add_library(parameters ${PX4_SOURCE_DIR}/src/platforms/empty.c) + add_library(parameters ${PX4_SOURCE_DIR}/platforms/common/empty.c) endif() add_dependencies(parameters prebuild_targets) diff --git a/src/modules/airspeed_selector/airspeed_selector_main.cpp b/src/modules/airspeed_selector/airspeed_selector_main.cpp index f483d7e30ee5..274372ef6ed6 100644 --- a/src/modules/airspeed_selector/airspeed_selector_main.cpp +++ b/src/modules/airspeed_selector/airspeed_selector_main.cpp @@ -38,7 +38,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/src/modules/fw_att_control/FixedwingAttitudeControl.hpp b/src/modules/fw_att_control/FixedwingAttitudeControl.hpp index adc2febd446c..b9c41d0856e4 100644 --- a/src/modules/fw_att_control/FixedwingAttitudeControl.hpp +++ b/src/modules/fw_att_control/FixedwingAttitudeControl.hpp @@ -46,7 +46,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/src/modules/fw_pos_control_l1/FixedwingPositionControl.hpp b/src/modules/fw_pos_control_l1/FixedwingPositionControl.hpp index 726e795b9fe5..4f13b7e1e390 100644 --- a/src/modules/fw_pos_control_l1/FixedwingPositionControl.hpp +++ b/src/modules/fw_pos_control_l1/FixedwingPositionControl.hpp @@ -65,7 +65,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/src/modules/land_detector/LandDetector.h b/src/modules/land_detector/LandDetector.h index 36d90def5dd9..f28e082cc59d 100644 --- a/src/modules/land_detector/LandDetector.h +++ b/src/modules/land_detector/LandDetector.h @@ -51,7 +51,7 @@ #include #include #include -#include +#include using namespace time_literals; diff --git a/src/modules/load_mon/load_mon.cpp b/src/modules/load_mon/load_mon.cpp index 7781ffc71f84..a2b82ae15a8d 100644 --- a/src/modules/load_mon/load_mon.cpp +++ b/src/modules/load_mon/load_mon.cpp @@ -45,7 +45,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/src/modules/mc_att_control/mc_att_control.hpp b/src/modules/mc_att_control/mc_att_control.hpp index e871c16c155e..153002b2cdd4 100644 --- a/src/modules/mc_att_control/mc_att_control.hpp +++ b/src/modules/mc_att_control/mc_att_control.hpp @@ -40,7 +40,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/src/modules/muorb/adsp/px4muorb.cpp b/src/modules/muorb/adsp/px4muorb.cpp index 6b27cb742f6b..b791ebb9830c 100644 --- a/src/modules/muorb/adsp/px4muorb.cpp +++ b/src/modules/muorb/adsp/px4muorb.cpp @@ -35,7 +35,6 @@ #include "uORBFastRpcChannel.hpp" #include "uORBManager.hpp" -#include #include #include #include diff --git a/src/modules/muorb/test/muorb_test_main.cpp b/src/modules/muorb/test/muorb_test_main.cpp index 2d83e8e20174..995cc49da1f1 100644 --- a/src/modules/muorb/test/muorb_test_main.cpp +++ b/src/modules/muorb/test/muorb_test_main.cpp @@ -37,9 +37,9 @@ * * @author Mark Charlebois */ -#include #include #include +#include #include "muorb_test_example.h" #include #include "uORB/uORBManager.hpp" diff --git a/src/modules/px4iofirmware/CMakeLists.txt b/src/modules/px4iofirmware/CMakeLists.txt index b3a37b62203a..6dcb90f81797 100644 --- a/src/modules/px4iofirmware/CMakeLists.txt +++ b/src/modules/px4iofirmware/CMakeLists.txt @@ -45,6 +45,7 @@ add_library(px4iofirmware set_property(GLOBAL APPEND PROPERTY PX4_MODULE_LIBRARIES px4iofirmware) target_link_libraries(px4iofirmware PUBLIC + arch_io_pins nuttx_apps nuttx_arch nuttx_c @@ -52,4 +53,4 @@ target_link_libraries(px4iofirmware rc perf pwm_limit -) \ No newline at end of file +) diff --git a/src/modules/sensors/vehicle_acceleration/VehicleAcceleration.hpp b/src/modules/sensors/vehicle_acceleration/VehicleAcceleration.hpp index 3274cc325f65..f84cef18adf9 100644 --- a/src/modules/sensors/vehicle_acceleration/VehicleAcceleration.hpp +++ b/src/modules/sensors/vehicle_acceleration/VehicleAcceleration.hpp @@ -40,7 +40,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/src/modules/sensors/vehicle_angular_velocity/VehicleAngularVelocity.hpp b/src/modules/sensors/vehicle_angular_velocity/VehicleAngularVelocity.hpp index f9eaaf5cd76c..81ee9fff842f 100644 --- a/src/modules/sensors/vehicle_angular_velocity/VehicleAngularVelocity.hpp +++ b/src/modules/sensors/vehicle_angular_velocity/VehicleAngularVelocity.hpp @@ -40,7 +40,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/src/modules/uORB/SubscriptionCallback.hpp b/src/modules/uORB/SubscriptionCallback.hpp index cfee84e7bf58..1324f6ba24e2 100644 --- a/src/modules/uORB/SubscriptionCallback.hpp +++ b/src/modules/uORB/SubscriptionCallback.hpp @@ -40,7 +40,7 @@ #include #include -#include +#include namespace uORB { diff --git a/src/modules/vtol_att_control/vtol_att_control_main.h b/src/modules/vtol_att_control/vtol_att_control_main.h index 1f8ef9d3cef2..e3c714083fdc 100644 --- a/src/modules/vtol_att_control/vtol_att_control_main.h +++ b/src/modules/vtol_att_control/vtol_att_control_main.h @@ -60,7 +60,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/src/platforms/px4_common.h b/src/platforms/px4_common.h deleted file mode 100644 index 384b1bca656b..000000000000 --- a/src/platforms/px4_common.h +++ /dev/null @@ -1,7 +0,0 @@ -#pragma once - -#ifdef __PX4_QURT -#include -size_t strnlen(const char *s, size_t maxlen); - -#endif diff --git a/src/platforms/px4_init.h b/src/platforms/px4_init.h index 77cebfadf45d..a0bf68a1d291 100644 --- a/src/platforms/px4_init.h +++ b/src/platforms/px4_init.h @@ -36,3 +36,19 @@ __BEGIN_DECLS int px4_platform_init(void); __END_DECLS + +#ifdef __cplusplus + +namespace px4 +{ + +/** + * Startup init method. It has no specific functionality, just prints a welcome + * message and sets the thread name + */ +__EXPORT void init(int argc, char *argv[], const char *process_name); + +} // namespace px4 + +#endif /* __cplusplus */ + diff --git a/src/platforms/px4_micro_hal.h b/src/platforms/px4_micro_hal.h index 62b8b9261e43..4bea4d458baf 100644 --- a/src/platforms/px4_micro_hal.h +++ b/src/platforms/px4_micro_hal.h @@ -31,199 +31,11 @@ * ****************************************************************************/ #pragma once + /* * This file is a shim to bridge to the many SoC architecture supported by PX4 */ -#ifdef __PX4_NUTTX -__BEGIN_DECLS -#include -#include - -/* For historical reasons (NuttX STM32 numbering) PX4 bus numbering is 1 based - * All PX4 code, including, board code is written to assuming 1 based numbering. - * The following macros are used to allow the board config to define the bus - * numbers in terms of the NuttX driver numbering. 1,2,3 for one based numbering - * schemes or 0,1,2 for zero based schemes. - */ - -#define PX4_BUS_NUMBER_TO_PX4(x) ((x)+PX4_BUS_OFFSET) /* Use to define Zero based to match Nuttx Driver but provide 1 based to PX4 */ -#define PX4_BUS_NUMBER_FROM_PX4(x) ((x)-PX4_BUS_OFFSET) /* Use to map PX4 1 based to NuttX driver 0 based */ - -# define px4_enter_critical_section() enter_critical_section() -# define px4_leave_critical_section(flags) leave_critical_section(flags) - -# if defined(CONFIG_ARCH_CHIP_STM32) || defined(CONFIG_ARCH_CHIP_STM32F7) - -# if defined(CONFIG_ARCH_CHIP_STM32) -# include -# define PX4_SOC_ARCH_ID PX4_SOC_ARCH_ID_STM32F4 -# define PX4_FLASH_BASE STM32_FLASH_BASE -# if defined(CONFIG_STM32_STM32F4XXX) -# include -# define PX4_BBSRAM_SIZE STM32_BBSRAM_SIZE -# define PX4_BBSRAM_GETDESC_IOCTL STM32_BBSRAM_GETDESC_IOCTL -# endif -# define PX4_NUMBER_I2C_BUSES STM32_NI2C -# endif - -# if defined(CONFIG_ARCH_CHIP_STM32F7) -# define PX4_SOC_ARCH_ID PX4_SOC_ARCH_ID_STM32F7 -# include -# include -void stm32_flash_lock(void); -void stm32_flash_unlock(void); -int stm32_flash_writeprotect(size_t page, bool enabled); -# include //include up_systemreset() which is included on stm32.h -# include -# define PX4_BBSRAM_SIZE STM32F7_BBSRAM_SIZE -# define PX4_BBSRAM_GETDESC_IOCTL STM32F7_BBSRAM_GETDESC_IOCTL -# define PX4_FLASH_BASE 0x08000000 -# define PX4_NUMBER_I2C_BUSES STM32F7_NI2C -# endif - -# include -# include -# include - -/* STM32/32F7 defines the 96 bit UUID as - * init32_t[3] that can be read as bytes/half-words/words - * init32_t[0] PX4_CPU_UUID_ADDRESS[0] bits 31:0 (offset 0) - * init32_t[1] PX4_CPU_UUID_ADDRESS[1] bits 63:32 (offset 4) - * init32_t[2] PX4_CPU_UUID_ADDRESS[3] bits 96:64 (offset 8) - * - * The original PX4 stm32 (legacy) based implementation **displayed** the - * UUID as: ABCD EFGH IJKL - * Where: - * A was bit 31 and D was bit 0 - * E was bit 63 and H was bit 32 - * I was bit 95 and L was bit 64 - * - * Since the string was used by some manufactures to identify the units - * it must be preserved. - * - * For new targets moving forward we will use - * IJKL EFGH ABCD - */ -# define PX4_CPU_UUID_BYTE_LENGTH 12 -# define PX4_CPU_UUID_WORD32_LENGTH (PX4_CPU_UUID_BYTE_LENGTH/sizeof(uint32_t)) - -/* The mfguid will be an array of bytes with - * MSD @ index 0 - LSD @ index PX4_CPU_MFGUID_BYTE_LENGTH-1 - * - * It will be converted to a string with the MSD on left and LSD on the right most position. - */ -# define PX4_CPU_MFGUID_BYTE_LENGTH PX4_CPU_UUID_BYTE_LENGTH - -/* By not defining PX4_CPU_UUID_CORRECT_CORRELATION the following maintains the legacy incorrect order - * used for selection of significant digits of the UUID in the PX4 code base. - * This is done to avoid the ripple effects changing the IDs used on STM32 base platforms - */ -# if defined(PX4_CPU_UUID_CORRECT_CORRELATION) -# define PX4_CPU_UUID_WORD32_UNIQUE_H 0 /* Least significant digits change the most */ -# define PX4_CPU_UUID_WORD32_UNIQUE_M 1 /* Middle significant digits */ -# define PX4_CPU_UUID_WORD32_UNIQUE_L 2 /* Most significant digits change the least */ -# else -/* Legacy incorrect ordering */ -# define PX4_CPU_UUID_WORD32_UNIQUE_H 2 /* Most significant digits change the least */ -# define PX4_CPU_UUID_WORD32_UNIQUE_M 1 /* Middle significant digits */ -# define PX4_CPU_UUID_WORD32_UNIQUE_L 0 /* Least significant digits change the most */ -# endif - -/* Separator nnn:nnn:nnnn 2 char per byte term */ -# define PX4_CPU_UUID_WORD32_FORMAT_SIZE (PX4_CPU_UUID_WORD32_LENGTH-1+(2*PX4_CPU_UUID_BYTE_LENGTH)+1) -# define PX4_CPU_MFGUID_FORMAT_SIZE ((2*PX4_CPU_MFGUID_BYTE_LENGTH)+1) - -# define px4_savepanic(fileno, context, length) stm32_bbsram_savepanic(fileno, context, length) - -# define PX4_BUS_OFFSET 0 /* STM buses are 1 based no adjustment needed */ -# define px4_spibus_initialize(bus_num_1based) stm32_spibus_initialize(bus_num_1based) - -# define px4_i2cbus_initialize(bus_num_1based) stm32_i2cbus_initialize(bus_num_1based) -# define px4_i2cbus_uninitialize(pdev) stm32_i2cbus_uninitialize(pdev) - -# define px4_arch_configgpio(pinset) stm32_configgpio(pinset) -# define px4_arch_unconfiggpio(pinset) stm32_unconfiggpio(pinset) -# define px4_arch_gpioread(pinset) stm32_gpioread(pinset) -# define px4_arch_gpiowrite(pinset, value) stm32_gpiowrite(pinset, value) -# define px4_arch_gpiosetevent(pinset,r,f,e,fp,a) stm32_gpiosetevent(pinset,r,f,e,fp,a) -#endif // defined(CONFIG_ARCH_CHIP_STM32) || defined(CONFIG_ARCH_CHIP_STM32F7) - -#if defined(CONFIG_ARCH_CHIP_KINETIS) -# define PX4_SOC_ARCH_ID PX4_SOC_ARCH_ID_KINETISK66 - -# // Fixme: using ?? -# define PX4_BBSRAM_SIZE 2048 -# define PX4_BBSRAM_GETDESC_IOCTL 0 -# define PX4_NUMBER_I2C_BUSES KINETIS_NI2C - -# define GPIO_OUTPUT_SET GPIO_OUTPUT_ONE -# define GPIO_OUTPUT_CLEAR GPIO_OUTPUT_ZERO - -# include -# include -# include -# include - -/* Kinetis defines the 128 bit UUID as - * init32_t[4] that can be read as words - * init32_t[0] PX4_CPU_UUID_ADDRESS[0] bits 127:96 (offset 0) - * init32_t[1] PX4_CPU_UUID_ADDRESS[1] bits 95:64 (offset 4) - * init32_t[2] PX4_CPU_UUID_ADDRESS[1] bits 63:32 (offset 8) - * init32_t[3] PX4_CPU_UUID_ADDRESS[3] bits 31:0 (offset C) - * - * PX4 uses the words in bigendian order MSB to LSB - * word [0] [1] [2] [3] - * bits 127:96 95-64 63-32, 31-00, - */ -# define PX4_CPU_UUID_BYTE_LENGTH KINETIS_UID_SIZE -# define PX4_CPU_UUID_WORD32_LENGTH (PX4_CPU_UUID_BYTE_LENGTH/sizeof(uint32_t)) - -/* The mfguid will be an array of bytes with - * MSD @ index 0 - LSD @ index PX4_CPU_MFGUID_BYTE_LENGTH-1 - * - * It will be converted to a string with the MSD on left and LSD on the right most position. - */ -# define PX4_CPU_MFGUID_BYTE_LENGTH PX4_CPU_UUID_BYTE_LENGTH - -/* define common formating across all commands */ - -# define PX4_CPU_UUID_WORD32_FORMAT "%08x" -# define PX4_CPU_UUID_WORD32_SEPARATOR ":" - -# define PX4_CPU_UUID_WORD32_UNIQUE_H 3 /* Least significant digits change the most */ -# define PX4_CPU_UUID_WORD32_UNIQUE_M 2 /* Middle High significant digits */ -# define PX4_CPU_UUID_WORD32_UNIQUE_L 1 /* Middle Low significant digits */ -# define PX4_CPU_UUID_WORD32_UNIQUE_N 0 /* Most significant digits change the least */ - -/* Separator nnn:nnn:nnnn 2 char per byte term */ -# define PX4_CPU_UUID_WORD32_FORMAT_SIZE (PX4_CPU_UUID_WORD32_LENGTH-1+(2*PX4_CPU_UUID_BYTE_LENGTH)+1) -# define PX4_CPU_MFGUID_FORMAT_SIZE ((2*PX4_CPU_MFGUID_BYTE_LENGTH)+1) - -# define kinetis_bbsram_savepanic(fileno, context, length) (0) // todo:Not implemented yet - -# define px4_savepanic(fileno, context, length) kinetis_bbsram_savepanic(fileno, context, length) - -/* bus_num is zero based on kinetis and must be translated from the legacy one based */ - -# define PX4_BUS_OFFSET 1 /* Kinetis buses are 0 based and adjustment is needed */ - -# define px4_spibus_initialize(bus_num_1based) kinetis_spibus_initialize(PX4_BUS_NUMBER_FROM_PX4(bus_num_1based)) - -# define px4_i2cbus_initialize(bus_num_1based) kinetis_i2cbus_initialize(PX4_BUS_NUMBER_FROM_PX4(bus_num_1based)) -# define px4_i2cbus_uninitialize(pdev) kinetis_i2cbus_uninitialize(pdev) - -# define px4_arch_configgpio(pinset) kinetis_pinconfig(pinset) -# define px4_arch_unconfiggpio(pinset) -# define px4_arch_gpioread(pinset) kinetis_gpioread(pinset) -# define px4_arch_gpiowrite(pinset, value) kinetis_gpiowrite(pinset, value) - -/* kinetis_gpiosetevent is not implemented and will need to be added */ - -# define px4_arch_gpiosetevent(pinset,r,f,e,fp,a) kinetis_gpiosetevent(pinset,r,f,e,fp,a) -# endif - -#include +// include arch-specific header +#include -__END_DECLS -#endif diff --git a/src/systemcmds/tests/hrt_test/hrt_test_main.cpp b/src/systemcmds/tests/hrt_test/hrt_test_main.cpp index d90cffba4093..3509142d2448 100644 --- a/src/systemcmds/tests/hrt_test/hrt_test_main.cpp +++ b/src/systemcmds/tests/hrt_test/hrt_test_main.cpp @@ -42,8 +42,8 @@ #include -#include #include +#include int PX4_MAIN(int argc, char **argv) { diff --git a/src/systemcmds/topic_listener/generate_listener.py b/src/systemcmds/topic_listener/generate_listener.py index 8b7ca12344b6..d0f7adf5763a 100755 --- a/src/systemcmds/topic_listener/generate_listener.py +++ b/src/systemcmds/topic_listener/generate_listener.py @@ -89,7 +89,6 @@ */ #include -#include #include #include #include diff --git a/src/systemcmds/topic_listener/topic_listener.hpp b/src/systemcmds/topic_listener/topic_listener.hpp index ce856bd8e80b..be1b94077214 100644 --- a/src/systemcmds/topic_listener/topic_listener.hpp +++ b/src/systemcmds/topic_listener/topic_listener.hpp @@ -40,7 +40,6 @@ #include #include -#include #include #include #include