diff --git a/libraries/AP_BattMonitor/AP_BattMonitor_Bebop.cpp b/libraries/AP_BattMonitor/AP_BattMonitor_Bebop.cpp index d85c988276..2ad13d988a 100644 --- a/libraries/AP_BattMonitor/AP_BattMonitor_Bebop.cpp +++ b/libraries/AP_BattMonitor/AP_BattMonitor_Bebop.cpp @@ -24,11 +24,14 @@ #include #include -extern const AP_HAL::HAL& hal; - #define BATTERY_CAPACITY (1200U) /* mAh */ #define BATTERY_VOLTAGE_COMPENSATION_LANDED (0.2f) + +extern const AP_HAL::HAL &hal; + +using namespace Linux; + /* polynomial compensation coefficients */ static const float bat_comp_polynomial_coeffs[5] = { -1.2471059149657287e-16f, diff --git a/libraries/AP_HAL_Linux/AP_HAL_Linux_Namespace.h b/libraries/AP_HAL_Linux/AP_HAL_Linux_Namespace.h deleted file mode 100644 index afe6b9797c..0000000000 --- a/libraries/AP_HAL_Linux/AP_HAL_Linux_Namespace.h +++ /dev/null @@ -1,56 +0,0 @@ -#pragma once - -namespace Linux { - class UARTDriver; - class SPIUARTDriver; - class RPIOUARTDriver; - class I2CDevice; - class I2CDeviceManager; - class SPIDeviceManager; - class SPIDeviceDriver; - class Storage; - class GPIO_BBB; - class GPIO_RPI; - class GPIO_Sysfs; - class Storage; - class DigitalSource; - class DigitalSource_Sysfs; - class PeriodicThread; - class PWM_Sysfs; - class PWM_Sysfs_Bebop; - class PWM_Sysfs_Base; - class RCInput; - class RCInput_PRU; - class RCInput_AioPRU; - class RCInput_RPI; - class RCInput_Raspilot; - class RCInput_Navio2; - class RCInput_ZYNQ; - class RCInput_UART; - class RCInput_UDP; - class RCInput_DSM; - class RCInput_SBUS; - class RCOutput_PRU; - class RCOutput_AioPRU; - class RCOutput_PCA9685; - class RCOutput_Raspilot; - class RCOutput_ZYNQ; - class RCOutput_Bebop; - class RCOutput_Sysfs; - class RCOutput_QFLIGHT; - class RCOutput_Disco; - class Semaphore; - class Scheduler; - class Util; - class UtilRPI; - class ToneAlarm; - class ToneAlarm_Raspilot; - class Thread; - class Heat; - class HeatPwm; - class CameraSensor; - class CameraSensor_Mt9v117; - class VideoIn; - class OpticalFlow_Onboard; - class Flow_PX4; -} diff --git a/libraries/AP_HAL_Linux/CameraSensor.h b/libraries/AP_HAL_Linux/CameraSensor.h index f5858aa8a0..3fd0861f8d 100644 --- a/libraries/AP_HAL_Linux/CameraSensor.h +++ b/libraries/AP_HAL_Linux/CameraSensor.h @@ -16,7 +16,9 @@ #include "AP_HAL_Linux.h" -class Linux::CameraSensor { +namespace Linux { + +class CameraSensor { public: CameraSensor(const char *device_path) { _device_path = device_path; } @@ -26,3 +28,5 @@ public: private: const char *_device_path; }; + +} diff --git a/libraries/AP_HAL_Linux/Flow_PX4.h b/libraries/AP_HAL_Linux/Flow_PX4.h index fe5ec728f6..1c5b763045 100644 --- a/libraries/AP_HAL_Linux/Flow_PX4.h +++ b/libraries/AP_HAL_Linux/Flow_PX4.h @@ -16,7 +16,9 @@ #include "AP_HAL_Linux.h" -class Linux::Flow_PX4 { +namespace Linux { + +class Flow_PX4 { public: Flow_PX4(uint32_t width, uint32_t bytesperline, uint32_t max_flow_pixel, @@ -35,3 +37,5 @@ private: uint16_t _pixstep; uint8_t _num_blocks; }; + +} diff --git a/libraries/AP_HAL_Linux/GPIO.h b/libraries/AP_HAL_Linux/GPIO.h index c7d079f598..0c8aa85d32 100644 --- a/libraries/AP_HAL_Linux/GPIO.h +++ b/libraries/AP_HAL_Linux/GPIO.h @@ -2,7 +2,9 @@ #include "AP_HAL_Linux.h" -class Linux::DigitalSource : public AP_HAL::DigitalSource { +namespace Linux { + +class DigitalSource : public AP_HAL::DigitalSource { public: DigitalSource(uint8_t v); void mode(uint8_t output); @@ -14,6 +16,8 @@ private: }; +} + #if CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_PXF || CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_ERLEBOARD || CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_BBBMINI #include "GPIO_BBB.h" #elif CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_NAVIO || \ diff --git a/libraries/AP_HAL_Linux/GPIO_BBB.h b/libraries/AP_HAL_Linux/GPIO_BBB.h index 90ec8aa260..df07da8abb 100644 --- a/libraries/AP_HAL_Linux/GPIO_BBB.h +++ b/libraries/AP_HAL_Linux/GPIO_BBB.h @@ -103,7 +103,9 @@ #define BBB_P9_41 20 #define BBB_P9_42 7 -class Linux::GPIO_BBB : public AP_HAL::GPIO { +namespace Linux { + +class GPIO_BBB : public AP_HAL::GPIO { private: struct GPIO { volatile uint32_t *base; @@ -131,3 +133,5 @@ public: /* return true if USB cable is connected */ bool usb_connected(void); }; + +} diff --git a/libraries/AP_HAL_Linux/GPIO_RPI.h b/libraries/AP_HAL_Linux/GPIO_RPI.h index 91ef542496..59dc3ae808 100644 --- a/libraries/AP_HAL_Linux/GPIO_RPI.h +++ b/libraries/AP_HAL_Linux/GPIO_RPI.h @@ -41,7 +41,9 @@ #define RPI_GPIO_30 30 // Pin 5 #define RPI_GPIO_31 31 // Pin 6 -class Linux::GPIO_RPI : public AP_HAL::GPIO { +namespace Linux { + +class GPIO_RPI : public AP_HAL::GPIO { public: GPIO_RPI(); void init(); @@ -65,3 +67,5 @@ public: private: volatile uint32_t *_gpio; }; + +} diff --git a/libraries/AP_HAL_Linux/GPIO_Sysfs.h b/libraries/AP_HAL_Linux/GPIO_Sysfs.h index f42cb1f19f..46bcc7ef89 100644 --- a/libraries/AP_HAL_Linux/GPIO_Sysfs.h +++ b/libraries/AP_HAL_Linux/GPIO_Sysfs.h @@ -5,8 +5,10 @@ #include "GPIO.h" -class Linux::DigitalSource_Sysfs : public AP_HAL::DigitalSource { - friend class Linux::GPIO_Sysfs; +namespace Linux { + +class DigitalSource_Sysfs : public AP_HAL::DigitalSource { + friend class GPIO_Sysfs; public: ~DigitalSource_Sysfs(); uint8_t read(); @@ -23,8 +25,8 @@ private: /** * Generic implementation of AP_HAL::GPIO for Linux based boards. */ -class Linux::GPIO_Sysfs : public AP_HAL::GPIO { - friend class Linux::DigitalSource_Sysfs; +class GPIO_Sysfs : public AP_HAL::GPIO { + friend class DigitalSource_Sysfs; public: /* Fill this table with the real pin numbers. */ static const unsigned pin_table[]; @@ -76,3 +78,5 @@ protected: */ static bool _export_pin(uint8_t vpin); }; + +} diff --git a/libraries/AP_HAL_Linux/HAL_Linux_Class.h b/libraries/AP_HAL_Linux/HAL_Linux_Class.h index 351ae78e3c..9aa95ddc86 100644 --- a/libraries/AP_HAL_Linux/HAL_Linux_Class.h +++ b/libraries/AP_HAL_Linux/HAL_Linux_Class.h @@ -2,8 +2,6 @@ #include -#include "AP_HAL_Linux_Namespace.h" - class HAL_Linux : public AP_HAL::HAL { public: HAL_Linux(); diff --git a/libraries/AP_HAL_Linux/Heat.h b/libraries/AP_HAL_Linux/Heat.h index adc7b4dee7..d765b74ffa 100644 --- a/libraries/AP_HAL_Linux/Heat.h +++ b/libraries/AP_HAL_Linux/Heat.h @@ -15,8 +15,12 @@ */ #pragma once -class Linux::Heat { +namespace Linux { + +class Heat { public: virtual void set_imu_temp(float current) { } virtual void set_imu_target_temp(int8_t *target) { } }; + +} diff --git a/libraries/AP_HAL_Linux/Heat_Pwm.h b/libraries/AP_HAL_Linux/Heat_Pwm.h index 18bf5ee567..6c8d559392 100644 --- a/libraries/AP_HAL_Linux/Heat_Pwm.h +++ b/libraries/AP_HAL_Linux/Heat_Pwm.h @@ -19,7 +19,9 @@ #include "PWM_Sysfs.h" #include "Heat.h" -class Linux::HeatPwm : public Linux::Heat { +namespace Linux { + +class HeatPwm : public Heat { public: HeatPwm(uint8_t pwm_num, float Kp, float Ki, uint32_t period_ns); @@ -35,3 +37,5 @@ private: float _sum_error; int8_t *_target = nullptr; }; + +} diff --git a/libraries/AP_HAL_Linux/OpticalFlow_Onboard.h b/libraries/AP_HAL_Linux/OpticalFlow_Onboard.h index 7f17f04f56..9d18d8cf78 100644 --- a/libraries/AP_HAL_Linux/OpticalFlow_Onboard.h +++ b/libraries/AP_HAL_Linux/OpticalFlow_Onboard.h @@ -22,9 +22,12 @@ #include "AP_HAL_Linux.h" #include "CameraSensor.h" #include "Flow_PX4.h" +#include "PWM_Sysfs.h" #include "VideoIn.h" -class Linux::OpticalFlow_Onboard : public AP_HAL::OpticalFlow { +namespace Linux { + +class OpticalFlow_Onboard : public AP_HAL::OpticalFlow { public: void init(AP_HAL::OpticalFlow::Gyro_Cb); bool read(AP_HAL::OpticalFlow::Data_Frame& frame); @@ -59,3 +62,5 @@ private: AP_HAL::OpticalFlow::Gyro_Cb _get_gyro; Vector3f _last_gyro_rate; }; + +} diff --git a/libraries/AP_HAL_Linux/PWM_Sysfs.h b/libraries/AP_HAL_Linux/PWM_Sysfs.h index b3c6bb22fe..07bd02838a 100644 --- a/libraries/AP_HAL_Linux/PWM_Sysfs.h +++ b/libraries/AP_HAL_Linux/PWM_Sysfs.h @@ -5,7 +5,9 @@ #include "AP_HAL_Linux.h" #include "Util.h" -class Linux::PWM_Sysfs_Base { +namespace Linux { + +class PWM_Sysfs_Base { public: virtual ~PWM_Sysfs_Base(); @@ -51,7 +53,7 @@ private: char *_period_path = NULL; }; -class Linux::PWM_Sysfs : public Linux::PWM_Sysfs_Base { +class PWM_Sysfs : public PWM_Sysfs_Base { public: PWM_Sysfs(uint8_t chip, uint8_t channel); @@ -63,7 +65,7 @@ private: char *_generate_period_path(uint8_t chip, uint8_t channel); }; -class Linux::PWM_Sysfs_Bebop : public Linux::PWM_Sysfs_Base { +class PWM_Sysfs_Bebop : public PWM_Sysfs_Base { public: PWM_Sysfs_Bebop(uint8_t channel); @@ -81,3 +83,5 @@ private: return PWM_Sysfs::NORMAL; } }; + +} diff --git a/libraries/AP_HAL_Linux/RCInput.h b/libraries/AP_HAL_Linux/RCInput.h index bdd22aa03a..c7e4c68583 100644 --- a/libraries/AP_HAL_Linux/RCInput.h +++ b/libraries/AP_HAL_Linux/RCInput.h @@ -4,7 +4,9 @@ #define LINUX_RC_INPUT_NUM_CHANNELS 16 -class Linux::RCInput : public AP_HAL::RCInput { +namespace Linux { + +class RCInput : public AP_HAL::RCInput { public: RCInput(); @@ -31,8 +33,8 @@ public: // add some SBUS input bytes, for RCInput over a serial port void add_sbus_input(const uint8_t *bytes, size_t nbytes); - - + + protected: void _process_rc_pulse(uint16_t width_s0, uint16_t width_s1); void _update_periods(uint16_t *periods, uint8_t len); @@ -40,7 +42,7 @@ public: private: volatile bool new_rc_input; - uint16_t _pwm_values[LINUX_RC_INPUT_NUM_CHANNELS]; + uint16_t _pwm_values[LINUX_RC_INPUT_NUM_CHANNELS]; uint8_t _num_channels; void _process_ppmsum_pulse(uint16_t width); @@ -83,5 +85,4 @@ public: } sbus; }; -#include "RCInput_PRU.h" -#include "RCInput_ZYNQ.h" +} diff --git a/libraries/AP_HAL_Linux/RCInput_AioPRU.h b/libraries/AP_HAL_Linux/RCInput_AioPRU.h index 9c684b76b0..00eba5b78e 100644 --- a/libraries/AP_HAL_Linux/RCInput_AioPRU.h +++ b/libraries/AP_HAL_Linux/RCInput_AioPRU.h @@ -18,16 +18,18 @@ #include "AP_HAL_Linux.h" #define RCIN_PRUSS_RAM_BASE 0x4a303000 + // we use 300 ring buffer entries to guarantee that a full 25 byte // frame of 12 bits per byte -class Linux::RCInput_AioPRU : public Linux::RCInput -{ +namespace Linux { + +class RCInput_AioPRU : public RCInput { public: void init(); void _timer_tick(void); - private: +private: static const uint32_t TICK_PER_US = 200; static const uint32_t NUM_RING_ENTRIES = 300; // shared ring buffer with the PRU which records pin transitions @@ -41,3 +43,5 @@ public: }; volatile struct ring_buffer *ring_buffer; }; + +} diff --git a/libraries/AP_HAL_Linux/RCInput_DSM.h b/libraries/AP_HAL_Linux/RCInput_DSM.h index 3aa0de9a3b..f84e82f713 100644 --- a/libraries/AP_HAL_Linux/RCInput_DSM.h +++ b/libraries/AP_HAL_Linux/RCInput_DSM.h @@ -16,12 +16,15 @@ #pragma once #include + #if CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_QFLIGHT #include "RCInput.h" #include "RCInput_DSM.h" -class Linux::RCInput_DSM : public Linux::RCInput +namespace Linux { + +class RCInput_DSM : public RCInput { public: void init() override; @@ -32,5 +35,7 @@ private: const char *device_path; int32_t fd = -1; }; -#endif // CONFIG_HAL_BOARD_SUBTYPE +} + +#endif // CONFIG_HAL_BOARD_SUBTYPE diff --git a/libraries/AP_HAL_Linux/RCInput_Navio2.h b/libraries/AP_HAL_Linux/RCInput_Navio2.h index 235a852e50..d30362edc4 100644 --- a/libraries/AP_HAL_Linux/RCInput_Navio2.h +++ b/libraries/AP_HAL_Linux/RCInput_Navio2.h @@ -2,8 +2,10 @@ #include "RCInput.h" -class Linux::RCInput_Navio2 : public Linux::RCInput -{ + +namespace Linux { + +class RCInput_Navio2 : public RCInput { public: void init() override; void _timer_tick(void) override; @@ -18,3 +20,5 @@ private: int channels[CHANNEL_COUNT]; uint16_t periods[ARRAY_SIZE(channels)] = {0}; }; + +} diff --git a/libraries/AP_HAL_Linux/RCInput_PRU.cpp b/libraries/AP_HAL_Linux/RCInput_PRU.cpp index 00e6cf6816..bc2b4e5f76 100644 --- a/libraries/AP_HAL_Linux/RCInput_PRU.cpp +++ b/libraries/AP_HAL_Linux/RCInput_PRU.cpp @@ -3,6 +3,7 @@ #if CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_PXF || \ CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_ERLEBOARD || \ CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_BBBMINI +#include "RCInput_PRU.h" #include #include diff --git a/libraries/AP_HAL_Linux/RCInput_PRU.h b/libraries/AP_HAL_Linux/RCInput_PRU.h index b3f98acf9e..cde3e9e93d 100644 --- a/libraries/AP_HAL_Linux/RCInput_PRU.h +++ b/libraries/AP_HAL_Linux/RCInput_PRU.h @@ -5,14 +5,15 @@ doing the edge detection of the PPM sum input */ -#include "AP_HAL_Linux.h" +#include "RCInput.h" #define RCIN_PRUSS_SHAREDRAM_BASE 0x4a312000 // we use 300 ring buffer entries to guarantee that a full 25 byte // frame of 12 bits per byte -class Linux::RCInput_PRU : public Linux::RCInput -{ +namespace Linux { + +class RCInput_PRU : public RCInput { public: void init(); void _timer_tick(void); @@ -33,3 +34,5 @@ public: // time spent in the low state uint16_t _s0_time; }; + +} diff --git a/libraries/AP_HAL_Linux/RCInput_RPI.h b/libraries/AP_HAL_Linux/RCInput_RPI.h index 0724491ad4..c571e66a85 100644 --- a/libraries/AP_HAL_Linux/RCInput_RPI.h +++ b/libraries/AP_HAL_Linux/RCInput_RPI.h @@ -22,13 +22,14 @@ #include +namespace Linux { + enum state_t{ RCIN_RPI_INITIAL_STATE = -1, RCIN_RPI_ZERO_STATE = 0, RCIN_RPI_ONE_STATE = 1 }; - //Memory table structure typedef struct { void **virt_pages; @@ -45,8 +46,8 @@ typedef struct { class Memory_table { // Allow RCInput_RPI access to private members of Memory_table -friend class Linux::RCInput_RPI; - +friend class RCInput_RPI; + private: void** _virt_pages; void** _phys_pages; @@ -73,14 +74,14 @@ public: }; -class Linux::RCInput_RPI : public Linux::RCInput -{ +class RCInput_RPI : public RCInput +{ public: void init(); void _timer_tick(void); RCInput_RPI(); ~RCInput_RPI(); - + private: //Physical adresses of peripherals. Are different on different Raspberries. @@ -110,10 +111,10 @@ private: uint8_t curr_signal; uint8_t last_signal; - + state_t state; - - AP_HAL::DigitalSource *enable_pin; + + AP_HAL::DigitalSource *enable_pin; void init_dma_cb(dma_cb_t** cbp, uint32_t mode, uint32_t source, uint32_t dest, uint32_t length, uint32_t stride, uint32_t next_cb); void* map_peripheral(uint32_t base, uint32_t len); @@ -127,5 +128,6 @@ private: void set_sigaction(); void set_physical_addresses(int version); void deinit() override; - }; + +} diff --git a/libraries/AP_HAL_Linux/RCInput_Raspilot.h b/libraries/AP_HAL_Linux/RCInput_Raspilot.h index f967ab3b4a..1ee04b3f06 100644 --- a/libraries/AP_HAL_Linux/RCInput_Raspilot.h +++ b/libraries/AP_HAL_Linux/RCInput_Raspilot.h @@ -4,15 +4,20 @@ #include "RCInput.h" #include -class Linux::RCInput_Raspilot : public Linux::RCInput + +namespace Linux { + +class RCInput_Raspilot : public RCInput { public: void init(); - + private: uint32_t _last_timer; - + AP_HAL::OwnPtr _dev; - + void _poll_data(void); }; + +} diff --git a/libraries/AP_HAL_Linux/RCInput_SBUS.h b/libraries/AP_HAL_Linux/RCInput_SBUS.h index 1d9dfad45f..b8ab1e153f 100644 --- a/libraries/AP_HAL_Linux/RCInput_SBUS.h +++ b/libraries/AP_HAL_Linux/RCInput_SBUS.h @@ -21,7 +21,9 @@ #include "RCInput.h" #include "RCInput_SBUS.h" -class Linux::RCInput_SBUS : public Linux::RCInput +namespace Linux { + +class RCInput_SBUS : public RCInput { public: void init() override; @@ -32,4 +34,7 @@ private: const char *device_path = "/dev/uart-sbus"; int32_t fd = -1; }; + +} + #endif // CONFIG_HAL_BOARD_SUBTYPE diff --git a/libraries/AP_HAL_Linux/RCInput_UART.h b/libraries/AP_HAL_Linux/RCInput_UART.h index 95a1bf0b8b..fbbfd015ca 100644 --- a/libraries/AP_HAL_Linux/RCInput_UART.h +++ b/libraries/AP_HAL_Linux/RCInput_UART.h @@ -7,7 +7,9 @@ #define CHANNELS 8 -class Linux::RCInput_UART : public Linux::RCInput +namespace Linux { + +class RCInput_UART : public RCInput { public: RCInput_UART(const char *path); @@ -25,3 +27,5 @@ private: uint16_t values[CHANNELS]; } _data; }; + +} diff --git a/libraries/AP_HAL_Linux/RCInput_UDP.h b/libraries/AP_HAL_Linux/RCInput_UDP.h index 3658f73d95..5343594925 100644 --- a/libraries/AP_HAL_Linux/RCInput_UDP.h +++ b/libraries/AP_HAL_Linux/RCInput_UDP.h @@ -6,7 +6,9 @@ #define RCINPUT_UDP_DEF_PORT 777 -class Linux::RCInput_UDP : public Linux::RCInput +namespace Linux { + +class RCInput_UDP : public RCInput { public: RCInput_UDP(); @@ -19,3 +21,5 @@ private: uint64_t _last_buf_ts; uint16_t _last_buf_seq; }; + +} diff --git a/libraries/AP_HAL_Linux/RCInput_ZYNQ.cpp b/libraries/AP_HAL_Linux/RCInput_ZYNQ.cpp index 14ff12102d..be141e4649 100644 --- a/libraries/AP_HAL_Linux/RCInput_ZYNQ.cpp +++ b/libraries/AP_HAL_Linux/RCInput_ZYNQ.cpp @@ -1,3 +1,5 @@ +#include "RCInput_ZYNQ.h" + #include #include #include @@ -13,7 +15,6 @@ #include #include "GPIO.h" -#include "RCInput.h" extern const AP_HAL::HAL& hal; diff --git a/libraries/AP_HAL_Linux/RCInput_ZYNQ.h b/libraries/AP_HAL_Linux/RCInput_ZYNQ.h index ead6e779d0..30b66ab4be 100644 --- a/libraries/AP_HAL_Linux/RCInput_ZYNQ.h +++ b/libraries/AP_HAL_Linux/RCInput_ZYNQ.h @@ -5,18 +5,19 @@ logic doing the edge detection of the PPM sum input */ -#include "AP_HAL_Linux.h" +#include "RCInput.h" // FIXME A puppie dies when you hard code an address #define RCIN_ZYNQ_PULSE_INPUT_BASE 0x43c10000 -class Linux::RCInput_ZYNQ : public Linux::RCInput -{ +namespace Linux { + +class RCInput_ZYNQ : public RCInput { public: void init(); void _timer_tick(void); - private: +private: static const int TICK_PER_US=100; static const int TICK_PER_S=100000000; @@ -26,3 +27,5 @@ public: // time spent in the low state uint32_t _s0_time; }; + +} diff --git a/libraries/AP_HAL_Linux/RCOutput_AioPRU.h b/libraries/AP_HAL_Linux/RCOutput_AioPRU.h index 9e5ff56041..b041a76806 100644 --- a/libraries/AP_HAL_Linux/RCOutput_AioPRU.h +++ b/libraries/AP_HAL_Linux/RCOutput_AioPRU.h @@ -16,7 +16,9 @@ #define RCOUT_PRUSS_IRAM_BASE 0x4a338000 #define PWM_CHAN_COUNT 12 -class Linux::RCOutput_AioPRU : public AP_HAL::RCOutput { +namespace Linux { + +class RCOutput_AioPRU : public AP_HAL::RCOutput { void init(); void set_freq(uint32_t chmask, uint16_t freq_hz); uint16_t get_freq(uint8_t ch); @@ -40,3 +42,5 @@ private: volatile struct pwm *pwm; }; + +} diff --git a/libraries/AP_HAL_Linux/RCOutput_Bebop.h b/libraries/AP_HAL_Linux/RCOutput_Bebop.h index 348387db10..b213ced292 100644 --- a/libraries/AP_HAL_Linux/RCOutput_Bebop.h +++ b/libraries/AP_HAL_Linux/RCOutput_Bebop.h @@ -3,6 +3,10 @@ #include "AP_HAL_Linux.h" #include +struct bldc_info; + +namespace Linux { + enum bebop_bldc_motor { BEBOP_BLDC_MOTOR_1 = 0, #if CONFIG_HAL_BOARD_SUBTYPE != HAL_BOARD_SUBTYPE_LINUX_DISCO @@ -49,9 +53,7 @@ public: uint8_t temperature; }; -struct bldc_info; - -class Linux::RCOutput_Bebop : public AP_HAL::RCOutput { +class RCOutput_Bebop : public AP_HAL::RCOutput { public: RCOutput_Bebop(AP_HAL::OwnPtr dev); @@ -102,3 +104,5 @@ private: void _run_rcout(); static void *_control_thread(void *arg); }; + +} diff --git a/libraries/AP_HAL_Linux/RCOutput_Disco.h b/libraries/AP_HAL_Linux/RCOutput_Disco.h index 2be68d8a3b..f7b0977adc 100644 --- a/libraries/AP_HAL_Linux/RCOutput_Disco.h +++ b/libraries/AP_HAL_Linux/RCOutput_Disco.h @@ -4,7 +4,9 @@ #include "RCOutput_Sysfs.h" #include "RCOutput_Bebop.h" -class Linux::RCOutput_Disco : public AP_HAL::RCOutput { +namespace Linux { + +class RCOutput_Disco : public AP_HAL::RCOutput { public: RCOutput_Disco(AP_HAL::OwnPtr dev); ~RCOutput_Disco() {} @@ -51,5 +53,6 @@ private: { sysfs_out, 5 }, { sysfs_out, 0 }, }; - }; + +} diff --git a/libraries/AP_HAL_Linux/RCOutput_PCA9685.h b/libraries/AP_HAL_Linux/RCOutput_PCA9685.h index 7199ada4fa..79d545138e 100644 --- a/libraries/AP_HAL_Linux/RCOutput_PCA9685.h +++ b/libraries/AP_HAL_Linux/RCOutput_PCA9685.h @@ -9,8 +9,10 @@ #define PCA9685_TERTIARY_ADDRESS 0x42 #define PCA9685_QUATENARY_ADDRESS 0x55 -class Linux::RCOutput_PCA9685 : public AP_HAL::RCOutput { - public: +namespace Linux { + +class RCOutput_PCA9685 : public AP_HAL::RCOutput { +public: RCOutput_PCA9685(AP_HAL::OwnPtr dev, bool external_clock, uint8_t channel_offset, @@ -45,3 +47,5 @@ private: int16_t _oe_pin_number; uint16_t _pending_write_mask; }; + +} diff --git a/libraries/AP_HAL_Linux/RCOutput_PRU.h b/libraries/AP_HAL_Linux/RCOutput_PRU.h index 83ebde4d3b..3115787db7 100644 --- a/libraries/AP_HAL_Linux/RCOutput_PRU.h +++ b/libraries/AP_HAL_Linux/RCOutput_PRU.h @@ -13,7 +13,9 @@ #define PWM_CMD_CLR 5 /* clr a pwm output explicitly */ #define PWM_CMD_TEST 6 /* various crap */ -class Linux::RCOutput_PRU : public AP_HAL::RCOutput { +namespace Linux { + +class RCOutput_PRU : public AP_HAL::RCOutput { void init(); void set_freq(uint32_t chmask, uint16_t freq_hz); uint16_t get_freq(uint8_t ch); @@ -37,3 +39,5 @@ private: volatile struct pwm_cmd *sharedMem_cmd; }; + +} diff --git a/libraries/AP_HAL_Linux/RCOutput_Raspilot.h b/libraries/AP_HAL_Linux/RCOutput_Raspilot.h index eabf2a50a5..3eea9c95db 100644 --- a/libraries/AP_HAL_Linux/RCOutput_Raspilot.h +++ b/libraries/AP_HAL_Linux/RCOutput_Raspilot.h @@ -3,7 +3,10 @@ #include "AP_HAL_Linux.h" #include -class Linux::RCOutput_Raspilot : public AP_HAL::RCOutput { +namespace Linux { + +class RCOutput_Raspilot : public AP_HAL::RCOutput { +public: void init(); void set_freq(uint32_t chmask, uint16_t freq_hz); uint16_t get_freq(uint8_t ch); @@ -16,10 +19,12 @@ class Linux::RCOutput_Raspilot : public AP_HAL::RCOutput { private: void reset(); void _update(void); - + AP_HAL::OwnPtr _dev; - + uint32_t _last_update_timestamp; uint16_t _frequency; uint16_t _period_us[8]; }; + +} diff --git a/libraries/AP_HAL_Linux/RCOutput_Sysfs.h b/libraries/AP_HAL_Linux/RCOutput_Sysfs.h index 90fdd6e6c9..8591627434 100644 --- a/libraries/AP_HAL_Linux/RCOutput_Sysfs.h +++ b/libraries/AP_HAL_Linux/RCOutput_Sysfs.h @@ -3,7 +3,9 @@ #include "AP_HAL_Linux.h" #include "PWM_Sysfs.h" -class Linux::RCOutput_Sysfs : public AP_HAL::RCOutput { +namespace Linux { + +class RCOutput_Sysfs : public AP_HAL::RCOutput { public: RCOutput_Sysfs(uint8_t chip, uint8_t channel_base, uint8_t channel_count); ~RCOutput_Sysfs(); @@ -28,3 +30,5 @@ private: const uint8_t _channel_count; PWM_Sysfs_Base **_pwm_channels; }; + +} diff --git a/libraries/AP_HAL_Linux/RCOutput_ZYNQ.h b/libraries/AP_HAL_Linux/RCOutput_ZYNQ.h index 30a2bfdaf2..829e40af84 100644 --- a/libraries/AP_HAL_Linux/RCOutput_ZYNQ.h +++ b/libraries/AP_HAL_Linux/RCOutput_ZYNQ.h @@ -11,8 +11,13 @@ #define PWM_CMD_CLR 5 /* clr a pwm output explicitly */ #define PWM_CMD_TEST 6 /* various crap */ +#include -class Linux::RCOutput_ZYNQ : public AP_HAL::RCOutput { +namespace Linux { + + +class RCOutput_ZYNQ : public AP_HAL::RCOutput { +public: void init(); void set_freq(uint32_t chmask, uint16_t freq_hz); uint16_t get_freq(uint8_t ch); @@ -36,3 +41,5 @@ private: }; volatile struct pwm_cmd *sharedMem_cmd; }; + +} diff --git a/libraries/AP_HAL_Linux/RCOutput_qflight.h b/libraries/AP_HAL_Linux/RCOutput_qflight.h index 89e832acf4..fe0e1253fd 100644 --- a/libraries/AP_HAL_Linux/RCOutput_qflight.h +++ b/libraries/AP_HAL_Linux/RCOutput_qflight.h @@ -5,7 +5,9 @@ #if CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_QFLIGHT -class Linux::RCOutput_QFLIGHT : public AP_HAL::RCOutput { +namespace Linux { + +class RCOutput_QFLIGHT : public AP_HAL::RCOutput { public: void init(); void set_freq(uint32_t chmask, uint16_t freq_hz); @@ -19,18 +21,18 @@ public: private: const char *device = nullptr; - const uint32_t baudrate = 115200; + const uint32_t baudrate = 115200; static const uint8_t channel_count = 4; - + int32_t fd = -1; uint16_t enable_mask; uint16_t period[channel_count]; volatile bool need_write; - + void timer_update(void); void check_rc_in(void); - + uint32_t last_read_check_ms; struct PACKED rcin_frame { uint8_t magic; @@ -44,4 +46,6 @@ private: uint8_t nrcin_bytes; }; +} + #endif // CONFIG_HAL_BOARD_SUBTYPE diff --git a/libraries/AP_HAL_Linux/RPIOUARTDriver.h b/libraries/AP_HAL_Linux/RPIOUARTDriver.h index 047063c600..45d2a73a91 100644 --- a/libraries/AP_HAL_Linux/RPIOUARTDriver.h +++ b/libraries/AP_HAL_Linux/RPIOUARTDriver.h @@ -5,8 +5,9 @@ #include "UARTDriver.h" #include +namespace Linux { -class Linux::RPIOUARTDriver : public Linux::UARTDriver { +class RPIOUARTDriver : public UARTDriver { public: RPIOUARTDriver(); @@ -37,3 +38,5 @@ private: bool _need_set_baud; uint32_t _baudrate; }; + +} diff --git a/libraries/AP_HAL_Linux/SPIUARTDriver.h b/libraries/AP_HAL_Linux/SPIUARTDriver.h index 56f04847c6..f845e2f5ca 100644 --- a/libraries/AP_HAL_Linux/SPIUARTDriver.h +++ b/libraries/AP_HAL_Linux/SPIUARTDriver.h @@ -4,8 +4,9 @@ #include "UARTDriver.h" +namespace Linux { -class Linux::SPIUARTDriver : public Linux::UARTDriver { +class SPIUARTDriver : public UARTDriver { public: SPIUARTDriver(); void begin(uint32_t b, uint16_t rxS, uint16_t txS); @@ -23,3 +24,5 @@ protected: bool _external; }; + +} diff --git a/libraries/AP_HAL_Linux/Scheduler.h b/libraries/AP_HAL_Linux/Scheduler.h index 106f74c8e7..1aaf10645e 100644 --- a/libraries/AP_HAL_Linux/Scheduler.h +++ b/libraries/AP_HAL_Linux/Scheduler.h @@ -10,7 +10,9 @@ #define LINUX_SCHEDULER_MAX_TIMESLICED_PROCS 10 #define LINUX_SCHEDULER_MAX_IO_PROCS 10 -class Linux::Scheduler : public AP_HAL::Scheduler { +namespace Linux { + +class Scheduler : public AP_HAL::Scheduler { public: Scheduler(); @@ -109,3 +111,5 @@ private: Semaphore _timer_semaphore; Semaphore _io_semaphore; }; + +} diff --git a/libraries/AP_HAL_Linux/Semaphores.h b/libraries/AP_HAL_Linux/Semaphores.h index 7e8222a9fc..fdfc5e5e0f 100644 --- a/libraries/AP_HAL_Linux/Semaphores.h +++ b/libraries/AP_HAL_Linux/Semaphores.h @@ -6,7 +6,9 @@ #include "AP_HAL_Linux.h" -class Linux::Semaphore : public AP_HAL::Semaphore { +namespace Linux { + +class Semaphore : public AP_HAL::Semaphore { public: Semaphore() { pthread_mutex_init(&_lock, NULL); @@ -17,3 +19,5 @@ public: private: pthread_mutex_t _lock; }; + +} diff --git a/libraries/AP_HAL_Linux/Storage.h b/libraries/AP_HAL_Linux/Storage.h index b56ac5a28e..333fc43b34 100644 --- a/libraries/AP_HAL_Linux/Storage.h +++ b/libraries/AP_HAL_Linux/Storage.h @@ -1,7 +1,6 @@ #pragma once #include -#include "AP_HAL_Linux_Namespace.h" #define LINUX_STORAGE_SIZE HAL_STORAGE_SIZE #define LINUX_STORAGE_MAX_WRITE 512 @@ -9,7 +8,9 @@ #define LINUX_STORAGE_LINE_SIZE (1< -#include "AP_HAL_Linux_Namespace.h" - namespace Linux { /* diff --git a/libraries/AP_HAL_Linux/ToneAlarm.h b/libraries/AP_HAL_Linux/ToneAlarm.h index 138094231f..6471fcc886 100644 --- a/libraries/AP_HAL_Linux/ToneAlarm.h +++ b/libraries/AP_HAL_Linux/ToneAlarm.h @@ -1,7 +1,6 @@ #pragma once #include -#include "AP_HAL_Linux_Namespace.h" #define OCTAVE_OFFSET 0 @@ -109,7 +108,9 @@ #define TONE_NUMBER_OF_TUNES 11 -class Linux::ToneAlarm{ +namespace Linux { + +class ToneAlarm { public: ToneAlarm(); void set_tune(uint8_t tone); @@ -141,3 +142,5 @@ private: int32_t duty_fd; int32_t run_fd; }; + +} diff --git a/libraries/AP_HAL_Linux/ToneAlarm_Raspilot.h b/libraries/AP_HAL_Linux/ToneAlarm_Raspilot.h index 86a3002c49..33be2581a8 100644 --- a/libraries/AP_HAL_Linux/ToneAlarm_Raspilot.h +++ b/libraries/AP_HAL_Linux/ToneAlarm_Raspilot.h @@ -4,7 +4,9 @@ #include "ToneAlarm.h" -class Linux::ToneAlarm_Raspilot : public Linux::ToneAlarm { +namespace Linux { + +class ToneAlarm_Raspilot : public ToneAlarm { public: ToneAlarm_Raspilot(); bool init() override; @@ -18,3 +20,5 @@ private: volatile uint32_t *_pwm; volatile uint32_t *_clk; }; + +} diff --git a/libraries/AP_HAL_Linux/UARTDriver.h b/libraries/AP_HAL_Linux/UARTDriver.h index ec2d18aa93..4f42f88538 100644 --- a/libraries/AP_HAL_Linux/UARTDriver.h +++ b/libraries/AP_HAL_Linux/UARTDriver.h @@ -5,7 +5,9 @@ #include "AP_HAL_Linux.h" #include "SerialDevice.h" -class Linux::UARTDriver : public AP_HAL::UARTDriver { +namespace Linux { + +class UARTDriver : public AP_HAL::UARTDriver { public: UARTDriver(bool default_console); @@ -54,14 +56,14 @@ private: uint16_t _base_port; char *_ip; char *_flag; - bool _connected; // true if a client has connected + bool _connected; // true if a client has connected bool _packetise; // true if writes should try to be on mavlink boundaries void _allocate_buffers(uint16_t rxS, uint16_t txS); void _deallocate_buffers(); AP_HAL::OwnPtr _parseDevicePath(const char *arg); - uint64_t _last_write_time; + uint64_t _last_write_time; protected: const char *device_path; @@ -85,3 +87,5 @@ protected: virtual int _read_fd(uint8_t *buf, uint16_t n); }; + +} diff --git a/libraries/AP_HAL_Linux/Util.h b/libraries/AP_HAL_Linux/Util.h index 47bdb65c10..8794d45935 100644 --- a/libraries/AP_HAL_Linux/Util.h +++ b/libraries/AP_HAL_Linux/Util.h @@ -3,11 +3,13 @@ #include #include -#include "AP_HAL_Linux_Namespace.h" +#include "Heat.h" #include "Perf.h" #include "ToneAlarm.h" #include "Semaphores.h" +namespace Linux { + enum hw_type { UTIL_HARDWARE_RPI1 = 0, UTIL_HARDWARE_RPI2, @@ -17,7 +19,7 @@ enum hw_type { UTIL_NUM_HARDWARES, }; -class Linux::Util : public AP_HAL::Util { +class Util : public AP_HAL::Util { public: static Util *from(AP_HAL::Util *util) { return static_cast(util); @@ -39,7 +41,7 @@ public: /* set system clock in UTC microseconds */ - void set_system_clock(uint64_t time_utc_usec); + void set_system_clock(uint64_t time_utc_usec); const char* get_custom_log_directory() { return custom_log_directory; } const char* get_custom_terrain_directory() { return custom_terrain_directory; } @@ -87,20 +89,22 @@ public: } // create a new semaphore - AP_HAL::Semaphore *new_semaphore(void) override { return new Linux::Semaphore; } + AP_HAL::Semaphore *new_semaphore(void) override { return new Semaphore; } int get_hw_arm32(); private: #if CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_RASPILOT - static Linux::ToneAlarm_Raspilot _toneAlarm; + static ToneAlarm_Raspilot _toneAlarm; #else - static Linux::ToneAlarm _toneAlarm; + static ToneAlarm _toneAlarm; #endif - Linux::Heat *_heat; + Heat *_heat; int saved_argc; char* const *saved_argv; const char* custom_log_directory = NULL; const char* custom_terrain_directory = NULL; static const char *_hw_names[UTIL_NUM_HARDWARES]; }; + +} diff --git a/libraries/AP_HAL_Linux/Util_RPI.h b/libraries/AP_HAL_Linux/Util_RPI.h index 8dc7a3ef75..fdd0aca365 100644 --- a/libraries/AP_HAL_Linux/Util_RPI.h +++ b/libraries/AP_HAL_Linux/Util_RPI.h @@ -2,7 +2,9 @@ #include "Util.h" -class Linux::UtilRPI : public Linux::Util { +namespace Linux { + +class UtilRPI : public Util { public: UtilRPI(); @@ -20,3 +22,5 @@ protected: private: int _rpi_version = 0; }; + +} diff --git a/libraries/AP_HAL_Linux/VideoIn.h b/libraries/AP_HAL_Linux/VideoIn.h index 436197786d..ed4fd90180 100644 --- a/libraries/AP_HAL_Linux/VideoIn.h +++ b/libraries/AP_HAL_Linux/VideoIn.h @@ -18,12 +18,14 @@ #include #include +namespace Linux { + struct buffer { unsigned int size; void *mem; }; -class Linux::VideoIn { +class VideoIn { public: /* This structure implements the fields of the v4l2_pix_format struct * that are considered useful for an optical flow application along @@ -80,3 +82,5 @@ private: uint32_t _sizeimage; uint32_t _memtype = V4L2_MEMORY_MMAP; }; + +}