From f8569ac39e3db79f8f48cf0771620ca4a96eed1d Mon Sep 17 00:00:00 2001 From: night-ghost Date: Sat, 3 Feb 2018 07:35:15 +1100 Subject: [PATCH] AP_HAL: added F4Light HAL --- libraries/AP_HAL/AP_HAL_Boards.h | 5 ++- libraries/AP_HAL/Device.h | 9 ++++ libraries/AP_HAL/HAL.h | 8 ++++ libraries/AP_HAL/board/f4light.h | 73 ++++++++++++++++++++++++++++++++ 4 files changed, 94 insertions(+), 1 deletion(-) create mode 100644 libraries/AP_HAL/board/f4light.h diff --git a/libraries/AP_HAL/AP_HAL_Boards.h b/libraries/AP_HAL/AP_HAL_Boards.h index 05b76b9770..0b14ec8e27 100644 --- a/libraries/AP_HAL/AP_HAL_Boards.h +++ b/libraries/AP_HAL/AP_HAL_Boards.h @@ -13,7 +13,8 @@ #define HAL_BOARD_VRBRAIN 8 #define HAL_BOARD_QURT 9 #define HAL_BOARD_CHIBIOS 10 -#define HAL_BOARD_EMPTY 99 +#define HAL_BOARD_F4LIGHT 11 +#define HAL_BOARD_EMPTY 99 /* Default board subtype is -1 */ #define HAL_BOARD_SUBTYPE_NONE -1 @@ -170,6 +171,8 @@ #include #elif CONFIG_HAL_BOARD == HAL_BOARD_CHIBIOS #include +#elif CONFIG_HAL_BOARD == HAL_BOARD_F4LIGHT + #include #else #error "Unknown CONFIG_HAL_BOARD type" #endif diff --git a/libraries/AP_HAL/Device.h b/libraries/AP_HAL/Device.h index 12ec67d5d4..7dffca8e75 100644 --- a/libraries/AP_HAL/Device.h +++ b/libraries/AP_HAL/Device.h @@ -191,6 +191,15 @@ public: */ virtual bool unregister_callback(PeriodicHandle h) { return false; } + + /* + allows to set callback that will be called after DMA transfer complete. + if this callback is set then any read/write operation will return directly after transfer setup and + bus semaphore must not be released until register_completion_callback(0) called from callback itself + */ + virtual void register_completion_callback(AP_HAL::MemberProc proc) {} + virtual void register_completion_callback(AP_HAL::Proc proc) {} + /* * support for direct control of SPI chip select. Needed for * devices with unusual SPI transfer patterns that include diff --git a/libraries/AP_HAL/HAL.h b/libraries/AP_HAL/HAL.h index da8b8f8171..81056b4dea 100644 --- a/libraries/AP_HAL/HAL.h +++ b/libraries/AP_HAL/HAL.h @@ -1,5 +1,7 @@ #pragma once +class AP_Param; + #include "AP_HAL_Namespace.h" #include "AnalogIn.h" @@ -15,6 +17,12 @@ #include "CAN.h" #endif + +#if defined(HAL_NEEDS_PARAM_HELPER) +#include +class AP_Param_Helper; +#endif + class AP_HAL::HAL { public: HAL(AP_HAL::UARTDriver* _uartA, // console diff --git a/libraries/AP_HAL/board/f4light.h b/libraries/AP_HAL/board/f4light.h new file mode 100644 index 0000000000..b35b1993fb --- /dev/null +++ b/libraries/AP_HAL/board/f4light.h @@ -0,0 +1,73 @@ +#include + +#define HAL_NEEDS_PARAM_HELPER + +#define AP_HAL_BOARD_DRIVER AP_HAL_F4Light +#define HAL_SERIAL0_BAUD_DEFAULT (115200) +#define CONFIG_HAL_BOARD_SUBTYPE HAL_BOARD_SUBTYPE_NONE + + +#define HAL_BOARD_NAME BOARD_OWN_NAME + +#define HAL_CPU_CLASS HAL_CPU_CLASS_150 +#define HAL_OS_POSIX_IO 0 + +#define HAL_STORAGE_SIZE BOARD_STORAGE_SIZE // EEPROM size + +#define HAL_BARO_DEFAULT BOARD_BARO_DEFAULT + +#define HAL_COMPASS_DEFAULT BOARD_COMPASS_DEFAULT + +#define HAL_INS_DEFAULT BOARD_INS_DEFAULT +#define HAL_INS_DEFAULT_ROTATION BOARD_INS_ROTATION +#define HAL_INS_MPU60x0_NAME BOARD_INS_MPU60x0_NAME + +#define INVENSENSE_DRDY_PIN BOARD_MPU6000_DRDY_PIN +// via interrupt + +#ifdef BOARD_HMC5883_DRDY_PIN +#define HMC5883_DRDY_PIN BOARD_HMC5883_DRDY_PIN +#endif + +#ifdef BOARD_DATAFLASH_NAME +#define HAL_DATAFLASH_NAME BOARD_DATAFLASH_NAME +#endif + + +#ifdef BOARD_BUZZER_PIN +#define BUZZER_PIN BOARD_BUZZER_PIN +#endif + +# define PUSHBUTTON_PIN BOARD_PUSHBUTTON_PIN +# define USB_MUX_PIN BOARD_USB_MUX_PIN +# define BATTERY_VOLT_PIN BOARD_BATTERY_VOLT_PIN // Battery voltage on A0 (PC2) D8 +# define BATTERY_CURR_PIN BOARD_BATTERY_CURR_PIN // Battery current on A1 (PC1) D7 +# define CONFIG_SONAR_SOURCE_ANALOG_PIN BOARD_SONAR_SOURCE_ANALOG_PIN + + + +#undef TOSHIBA_LED_I2C_BUS // someone placed this not in board config +#define TOSHIBA_LED_I2C_ADDR 0x55 // default I2C bus address +#define TOSHIBA_LED_I2C_BUS 2 // external I2C + + + #define HAL_MINIMIZE_FEATURES 1 + + #define AC_TERRAIN DISABLED // no SD card with POSIX IO + #define PRECISION_LANDING DISABLED + #define CONFIG_PUSHBUTTON DISABLED + #define SPRAYER DISABLED + #define EPM_ENABLED DISABLED + #define CLI_ENABLED DISABLED + #define GRIPPER_ENABLED DISABLED // not for large quads + + + // disable for debugging with -O0 +// #define FRSKY_TELEM_ENABLED DISABLED +// #define CAMERA DISABLED +// #define CONFIG_RELAY DISABLED +// #define MOUNT DISABLED +// #define ADSB_ENABLED DISABLED + + + #define LOGGING_ENABLED ENABLED