mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-01-30 15:52:12 +01:00
Merge remote-tracking branch 'origin/stac/i2c_decoupling' into next
This commit is contained in:
commit
64202ce092
@ -50,7 +50,7 @@ ENABLE_AUX_UART ?= NO
|
|||||||
|
|
||||||
USE_GPS ?= YES
|
USE_GPS ?= YES
|
||||||
|
|
||||||
USE_I2C ?= NO
|
USE_I2C ?= YES
|
||||||
|
|
||||||
# Set to YES when using Code Sourcery toolchain
|
# Set to YES when using Code Sourcery toolchain
|
||||||
CODE_SOURCERY ?= YES
|
CODE_SOURCERY ?= YES
|
||||||
@ -65,7 +65,7 @@ endif
|
|||||||
FLASH_TOOL = OPENOCD
|
FLASH_TOOL = OPENOCD
|
||||||
|
|
||||||
# List of modules to include
|
# List of modules to include
|
||||||
OPTMODULES = CameraStab ComUsbBridge
|
OPTMODULES = CameraStab ComUsbBridge Altitude
|
||||||
ifeq ($(USE_GPS), YES)
|
ifeq ($(USE_GPS), YES)
|
||||||
OPTMODULES += GPS
|
OPTMODULES += GPS
|
||||||
endif
|
endif
|
||||||
@ -181,6 +181,7 @@ SRC += $(OPUAVSYNTHDIR)/receiveractivity.c
|
|||||||
SRC += $(OPUAVSYNTHDIR)/taskinfo.c
|
SRC += $(OPUAVSYNTHDIR)/taskinfo.c
|
||||||
SRC += $(OPUAVSYNTHDIR)/mixerstatus.c
|
SRC += $(OPUAVSYNTHDIR)/mixerstatus.c
|
||||||
SRC += $(OPUAVSYNTHDIR)/ratedesired.c
|
SRC += $(OPUAVSYNTHDIR)/ratedesired.c
|
||||||
|
SRC += $(OPUAVSYNTHDIR)/baroaltitude.c
|
||||||
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
@ -224,6 +225,7 @@ SRC += $(PIOSCOMMON)/pios_flash_w25x.c
|
|||||||
SRC += $(PIOSCOMMON)/pios_adxl345.c
|
SRC += $(PIOSCOMMON)/pios_adxl345.c
|
||||||
SRC += $(PIOSCOMMON)/pios_com.c
|
SRC += $(PIOSCOMMON)/pios_com.c
|
||||||
SRC += $(PIOSCOMMON)/pios_i2c_esc.c
|
SRC += $(PIOSCOMMON)/pios_i2c_esc.c
|
||||||
|
SRC += $(PIOSCOMMON)/pios_bmp085.c
|
||||||
SRC += $(PIOSCOMMON)/pios_iap.c
|
SRC += $(PIOSCOMMON)/pios_iap.c
|
||||||
SRC += $(PIOSCOMMON)/pios_bl_helper.c
|
SRC += $(PIOSCOMMON)/pios_bl_helper.c
|
||||||
SRC += $(PIOSCOMMON)/pios_rcvr.c
|
SRC += $(PIOSCOMMON)/pios_rcvr.c
|
||||||
@ -410,6 +412,9 @@ ifeq ($(USE_I2C), YES)
|
|||||||
CDEFS += -DUSE_I2C
|
CDEFS += -DUSE_I2C
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
# Declare all non-optional modules as built-in to force inclusion
|
||||||
|
CDEFS += ${foreach MOD, ${MODULES}, -DMODULE_$(MOD)_BUILTIN }
|
||||||
|
|
||||||
# Place project-specific -D and/or -U options for
|
# Place project-specific -D and/or -U options for
|
||||||
# Assembler with preprocessor here.
|
# Assembler with preprocessor here.
|
||||||
#ADEFS = -DUSE_IRQ_ASM_WRAPPER
|
#ADEFS = -DUSE_IRQ_ASM_WRAPPER
|
||||||
|
@ -77,6 +77,8 @@
|
|||||||
#define PIOS_INCLUDE_ADXL345
|
#define PIOS_INCLUDE_ADXL345
|
||||||
#define PIOS_INCLUDE_FLASH
|
#define PIOS_INCLUDE_FLASH
|
||||||
|
|
||||||
|
#define PIOS_INCLUDE_BMP085
|
||||||
|
|
||||||
/* A really shitty setting saving implementation */
|
/* A really shitty setting saving implementation */
|
||||||
#define PIOS_INCLUDE_FLASH_SECTOR_SETTINGS
|
#define PIOS_INCLUDE_FLASH_SECTOR_SETTINGS
|
||||||
|
|
||||||
|
@ -903,12 +903,12 @@ const struct pios_pwm_cfg pios_pwm_cfg = {
|
|||||||
* I2C Adapters
|
* I2C Adapters
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void PIOS_I2C_main_adapter_ev_irq_handler(void);
|
void PIOS_I2C_flexi_adapter_ev_irq_handler(void);
|
||||||
void PIOS_I2C_main_adapter_er_irq_handler(void);
|
void PIOS_I2C_flexi_adapter_er_irq_handler(void);
|
||||||
void I2C2_EV_IRQHandler() __attribute__ ((alias ("PIOS_I2C_main_adapter_ev_irq_handler")));
|
void I2C2_EV_IRQHandler() __attribute__ ((alias ("PIOS_I2C_flexi_adapter_ev_irq_handler")));
|
||||||
void I2C2_ER_IRQHandler() __attribute__ ((alias ("PIOS_I2C_main_adapter_er_irq_handler")));
|
void I2C2_ER_IRQHandler() __attribute__ ((alias ("PIOS_I2C_flexi_adapter_er_irq_handler")));
|
||||||
|
|
||||||
static const struct pios_i2c_adapter_cfg pios_i2c_main_adapter_cfg = {
|
static const struct pios_i2c_adapter_cfg pios_i2c_flexi_adapter_cfg = {
|
||||||
.regs = I2C2,
|
.regs = I2C2,
|
||||||
.init = {
|
.init = {
|
||||||
.I2C_Mode = I2C_Mode_I2C,
|
.I2C_Mode = I2C_Mode_I2C,
|
||||||
@ -955,17 +955,17 @@ static const struct pios_i2c_adapter_cfg pios_i2c_main_adapter_cfg = {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
uint32_t pios_i2c_main_adapter_id;
|
uint32_t pios_i2c_flexi_adapter_id;
|
||||||
void PIOS_I2C_main_adapter_ev_irq_handler(void)
|
void PIOS_I2C_flexi_adapter_ev_irq_handler(void)
|
||||||
{
|
{
|
||||||
/* Call into the generic code to handle the IRQ for this specific device */
|
/* Call into the generic code to handle the IRQ for this specific device */
|
||||||
PIOS_I2C_EV_IRQ_Handler(pios_i2c_main_adapter_id);
|
PIOS_I2C_EV_IRQ_Handler(pios_i2c_flexi_adapter_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PIOS_I2C_main_adapter_er_irq_handler(void)
|
void PIOS_I2C_flexi_adapter_er_irq_handler(void)
|
||||||
{
|
{
|
||||||
/* Call into the generic code to handle the IRQ for this specific device */
|
/* Call into the generic code to handle the IRQ for this specific device */
|
||||||
PIOS_I2C_ER_IRQ_Handler(pios_i2c_main_adapter_id);
|
PIOS_I2C_ER_IRQ_Handler(pios_i2c_flexi_adapter_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* PIOS_INCLUDE_I2C */
|
#endif /* PIOS_INCLUDE_I2C */
|
||||||
@ -1464,7 +1464,7 @@ void PIOS_Board_Init(void) {
|
|||||||
case HWSETTINGS_CC_FLEXIPORT_I2C:
|
case HWSETTINGS_CC_FLEXIPORT_I2C:
|
||||||
#if defined(PIOS_INCLUDE_I2C)
|
#if defined(PIOS_INCLUDE_I2C)
|
||||||
{
|
{
|
||||||
if (PIOS_I2C_Init(&pios_i2c_main_adapter_id, &pios_i2c_main_adapter_cfg)) {
|
if (PIOS_I2C_Init(&pios_i2c_flexi_adapter_id, &pios_i2c_flexi_adapter_cfg)) {
|
||||||
PIOS_Assert(0);
|
PIOS_Assert(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -37,6 +37,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "openpilot.h"
|
#include "openpilot.h"
|
||||||
|
#include "hwsettings.h"
|
||||||
#include "altitude.h"
|
#include "altitude.h"
|
||||||
#include "baroaltitude.h" // object that will be updated by the module
|
#include "baroaltitude.h" // object that will be updated by the module
|
||||||
#if defined(PIOS_INCLUDE_HCSR04)
|
#if defined(PIOS_INCLUDE_HCSR04)
|
||||||
@ -46,8 +47,7 @@
|
|||||||
// Private constants
|
// Private constants
|
||||||
#define STACK_SIZE_BYTES 500
|
#define STACK_SIZE_BYTES 500
|
||||||
#define TASK_PRIORITY (tskIDLE_PRIORITY+1)
|
#define TASK_PRIORITY (tskIDLE_PRIORITY+1)
|
||||||
//#define UPDATE_PERIOD 100
|
#define UPDATE_PERIOD 50
|
||||||
#define UPDATE_PERIOD 25
|
|
||||||
|
|
||||||
// Private types
|
// Private types
|
||||||
|
|
||||||
@ -60,6 +60,8 @@ static int32_t alt_ds_temp = 0;
|
|||||||
static int32_t alt_ds_pres = 0;
|
static int32_t alt_ds_pres = 0;
|
||||||
static int alt_ds_count = 0;
|
static int alt_ds_count = 0;
|
||||||
|
|
||||||
|
static bool altitudeEnabled;
|
||||||
|
|
||||||
// Private functions
|
// Private functions
|
||||||
static void altitudeTask(void *parameters);
|
static void altitudeTask(void *parameters);
|
||||||
|
|
||||||
@ -70,6 +72,7 @@ static void altitudeTask(void *parameters);
|
|||||||
int32_t AltitudeStart()
|
int32_t AltitudeStart()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
if (altitudeEnabled) {
|
||||||
BaroAltitudeInitialize();
|
BaroAltitudeInitialize();
|
||||||
#if defined(PIOS_INCLUDE_HCSR04)
|
#if defined(PIOS_INCLUDE_HCSR04)
|
||||||
SonarAltitudeInitialze();
|
SonarAltitudeInitialze();
|
||||||
@ -78,8 +81,9 @@ int32_t AltitudeStart()
|
|||||||
// Start main task
|
// Start main task
|
||||||
xTaskCreate(altitudeTask, (signed char *)"Altitude", STACK_SIZE_BYTES/4, NULL, TASK_PRIORITY, &taskHandle);
|
xTaskCreate(altitudeTask, (signed char *)"Altitude", STACK_SIZE_BYTES/4, NULL, TASK_PRIORITY, &taskHandle);
|
||||||
TaskMonitorAdd(TASKINFO_RUNNING_ALTITUDE, taskHandle);
|
TaskMonitorAdd(TASKINFO_RUNNING_ALTITUDE, taskHandle);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -88,6 +92,18 @@ int32_t AltitudeStart()
|
|||||||
*/
|
*/
|
||||||
int32_t AltitudeInitialize()
|
int32_t AltitudeInitialize()
|
||||||
{
|
{
|
||||||
|
#ifdef MODULE_Altitude_BUILTIN
|
||||||
|
altitudeEnabled = 1;
|
||||||
|
#else
|
||||||
|
HwSettingsInitialize();
|
||||||
|
uint8_t optionalModules[HWSETTINGS_OPTIONALMODULES_NUMELEM];
|
||||||
|
HwSettingsOptionalModulesGet(optionalModules);
|
||||||
|
if (optionalModules[HWSETTINGS_OPTIONALMODULES_ALTITUDE] == HWSETTINGS_OPTIONALMODULES_ENABLED) {
|
||||||
|
altitudeEnabled = 1;
|
||||||
|
} else {
|
||||||
|
altitudeEnabled = 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
// init down-sampling data
|
// init down-sampling data
|
||||||
alt_ds_temp = 0;
|
alt_ds_temp = 0;
|
||||||
@ -144,13 +160,21 @@ static void altitudeTask(void *parameters)
|
|||||||
#endif
|
#endif
|
||||||
// Update the temperature data
|
// Update the temperature data
|
||||||
PIOS_BMP085_StartADC(TemperatureConv);
|
PIOS_BMP085_StartADC(TemperatureConv);
|
||||||
|
#ifdef PIOS_BMP085_HAS_GPIOS
|
||||||
xSemaphoreTake(PIOS_BMP085_EOC, portMAX_DELAY);
|
xSemaphoreTake(PIOS_BMP085_EOC, portMAX_DELAY);
|
||||||
|
#else
|
||||||
|
vTaskDelay(5 / portTICK_RATE_MS);
|
||||||
|
#endif
|
||||||
PIOS_BMP085_ReadADC();
|
PIOS_BMP085_ReadADC();
|
||||||
alt_ds_temp += PIOS_BMP085_GetTemperature();
|
alt_ds_temp += PIOS_BMP085_GetTemperature();
|
||||||
|
|
||||||
// Update the pressure data
|
// Update the pressure data
|
||||||
PIOS_BMP085_StartADC(PressureConv);
|
PIOS_BMP085_StartADC(PressureConv);
|
||||||
|
#ifdef PIOS_BMP085_HAS_GPIOS
|
||||||
xSemaphoreTake(PIOS_BMP085_EOC, portMAX_DELAY);
|
xSemaphoreTake(PIOS_BMP085_EOC, portMAX_DELAY);
|
||||||
|
#else
|
||||||
|
vTaskDelay(26 / portTICK_RATE_MS);
|
||||||
|
#endif
|
||||||
PIOS_BMP085_ReadADC();
|
PIOS_BMP085_ReadADC();
|
||||||
alt_ds_pres += PIOS_BMP085_GetPressure();
|
alt_ds_pres += PIOS_BMP085_GetPressure();
|
||||||
|
|
||||||
|
@ -78,6 +78,10 @@ static float bound(float val, float limit);
|
|||||||
int32_t CameraStabInitialize(void)
|
int32_t CameraStabInitialize(void)
|
||||||
{
|
{
|
||||||
bool cameraStabEnabled;
|
bool cameraStabEnabled;
|
||||||
|
|
||||||
|
#ifdef MODULE_CameraStab_BUILTIN
|
||||||
|
cameraStabEnabled = true;
|
||||||
|
#else
|
||||||
uint8_t optionalModules[HWSETTINGS_OPTIONALMODULES_NUMELEM];
|
uint8_t optionalModules[HWSETTINGS_OPTIONALMODULES_NUMELEM];
|
||||||
|
|
||||||
HwSettingsInitialize();
|
HwSettingsInitialize();
|
||||||
@ -87,6 +91,7 @@ int32_t CameraStabInitialize(void)
|
|||||||
cameraStabEnabled = true;
|
cameraStabEnabled = true;
|
||||||
else
|
else
|
||||||
cameraStabEnabled = false;
|
cameraStabEnabled = false;
|
||||||
|
#endif
|
||||||
|
|
||||||
if (cameraStabEnabled) {
|
if (cameraStabEnabled) {
|
||||||
|
|
||||||
|
@ -94,6 +94,9 @@ static int32_t comUsbBridgeInitialize(void)
|
|||||||
usart_port = PIOS_COM_BRIDGE;
|
usart_port = PIOS_COM_BRIDGE;
|
||||||
vcp_port = PIOS_COM_VCP;
|
vcp_port = PIOS_COM_VCP;
|
||||||
|
|
||||||
|
#ifdef MODULE_ComUsbBridge_BUILTIN
|
||||||
|
bridge_enabled = true;
|
||||||
|
#else
|
||||||
HwSettingsInitialize();
|
HwSettingsInitialize();
|
||||||
uint8_t optionalModules[HWSETTINGS_OPTIONALMODULES_NUMELEM];
|
uint8_t optionalModules[HWSETTINGS_OPTIONALMODULES_NUMELEM];
|
||||||
|
|
||||||
@ -104,6 +107,7 @@ static int32_t comUsbBridgeInitialize(void)
|
|||||||
bridge_enabled = true;
|
bridge_enabled = true;
|
||||||
else
|
else
|
||||||
bridge_enabled = false;
|
bridge_enabled = false;
|
||||||
|
#endif
|
||||||
|
|
||||||
if (bridge_enabled) {
|
if (bridge_enabled) {
|
||||||
com2usb_buf = pvPortMalloc(BRIDGE_BUF_LEN);
|
com2usb_buf = pvPortMalloc(BRIDGE_BUF_LEN);
|
||||||
|
@ -40,6 +40,9 @@ static uint8_t active_fault;
|
|||||||
|
|
||||||
static int32_t fault_initialize(void)
|
static int32_t fault_initialize(void)
|
||||||
{
|
{
|
||||||
|
#ifdef MODULE_Fault_BUILTIN
|
||||||
|
module_enabled = true;
|
||||||
|
#else
|
||||||
HwSettingsInitialize();
|
HwSettingsInitialize();
|
||||||
uint8_t optionalModules[HWSETTINGS_OPTIONALMODULES_NUMELEM];
|
uint8_t optionalModules[HWSETTINGS_OPTIONALMODULES_NUMELEM];
|
||||||
|
|
||||||
@ -50,6 +53,7 @@ static int32_t fault_initialize(void)
|
|||||||
} else {
|
} else {
|
||||||
module_enabled = false;
|
module_enabled = false;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Do this outside the module_enabled test so that it
|
/* Do this outside the module_enabled test so that it
|
||||||
* can be changed even when the module has been disabled.
|
* can be changed even when the module has been disabled.
|
||||||
|
@ -121,6 +121,9 @@ int32_t GPSInitialize(void)
|
|||||||
{
|
{
|
||||||
gpsPort = PIOS_COM_GPS;
|
gpsPort = PIOS_COM_GPS;
|
||||||
|
|
||||||
|
#ifdef MODULE_GPS_BUILTIN
|
||||||
|
gpsEnabled = true;
|
||||||
|
#else
|
||||||
HwSettingsInitialize();
|
HwSettingsInitialize();
|
||||||
uint8_t optionalModules[HWSETTINGS_OPTIONALMODULES_NUMELEM];
|
uint8_t optionalModules[HWSETTINGS_OPTIONALMODULES_NUMELEM];
|
||||||
|
|
||||||
@ -130,6 +133,7 @@ int32_t GPSInitialize(void)
|
|||||||
gpsEnabled = true;
|
gpsEnabled = true;
|
||||||
else
|
else
|
||||||
gpsEnabled = false;
|
gpsEnabled = false;
|
||||||
|
#endif
|
||||||
|
|
||||||
if (gpsPort && gpsEnabled) {
|
if (gpsPort && gpsEnabled) {
|
||||||
GPSPositionInitialize();
|
GPSPositionInitialize();
|
||||||
|
@ -370,6 +370,9 @@ ifeq ($(ENABLE_AUX_UART), YES)
|
|||||||
CDEFS += -DPIOS_ENABLE_AUX_UART
|
CDEFS += -DPIOS_ENABLE_AUX_UART
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
# Declare all non-optional modules as built-in to force inclusion
|
||||||
|
CDEFS += ${foreach MOD, ${MODULES}, -DMODULE_$(MOD)_BUILTIN }
|
||||||
|
|
||||||
# Place project-specific -D and/or -U options for
|
# Place project-specific -D and/or -U options for
|
||||||
# Assembler with preprocessor here.
|
# Assembler with preprocessor here.
|
||||||
#ADEFS = -DUSE_IRQ_ASM_WRAPPER
|
#ADEFS = -DUSE_IRQ_ASM_WRAPPER
|
||||||
|
@ -110,8 +110,15 @@ TIM4 | RC In 1 | Servo 3 | Servo 2 | Servo 1
|
|||||||
// See also pios_board.c
|
// See also pios_board.c
|
||||||
//------------------------
|
//------------------------
|
||||||
#define PIOS_I2C_MAX_DEVS 1
|
#define PIOS_I2C_MAX_DEVS 1
|
||||||
extern uint32_t pios_i2c_main_adapter_id;
|
extern uint32_t pios_i2c_flexi_adapter_id;
|
||||||
#define PIOS_I2C_MAIN_ADAPTER (pios_i2c_main_adapter_id)
|
#define PIOS_I2C_MAIN_ADAPTER (pios_i2c_flexi_adapter_id)
|
||||||
|
#define PIOS_I2C_ESC_ADAPTER (pios_i2c_flexi_adapter_id)
|
||||||
|
#define PIOS_I2C_BMP085_ADAPTER (pios_i2c_flexi_adapter_id)
|
||||||
|
|
||||||
|
//------------------------
|
||||||
|
// PIOS_BMP085
|
||||||
|
//------------------------
|
||||||
|
#define PIOS_BMP085_OVERSAMPLING 3
|
||||||
|
|
||||||
//-------------------------
|
//-------------------------
|
||||||
// SPI
|
// SPI
|
||||||
|
@ -100,12 +100,14 @@ TIM8 | | | |
|
|||||||
#define PIOS_I2C_MAX_DEVS 3
|
#define PIOS_I2C_MAX_DEVS 3
|
||||||
extern uint32_t pios_i2c_pres_mag_adapter_id;
|
extern uint32_t pios_i2c_pres_mag_adapter_id;
|
||||||
#define PIOS_I2C_MAIN_ADAPTER (pios_i2c_pres_mag_adapter_id)
|
#define PIOS_I2C_MAIN_ADAPTER (pios_i2c_pres_mag_adapter_id)
|
||||||
|
#define PIOS_I2C_BMP085_ADAPTER (pios_i2c_pres_mag_adapter_id)
|
||||||
extern uint32_t pios_i2c_gyro_adapter_id;
|
extern uint32_t pios_i2c_gyro_adapter_id;
|
||||||
#define PIOS_I2C_GYRO_ADAPTER (pios_i2c_gyro_adapter_id)
|
#define PIOS_I2C_GYRO_ADAPTER (pios_i2c_gyro_adapter_id)
|
||||||
|
|
||||||
//------------------------
|
//------------------------
|
||||||
// PIOS_BMP085
|
// PIOS_BMP085
|
||||||
//------------------------
|
//------------------------
|
||||||
|
#define PIOS_BMP085_HAS_GPIOS
|
||||||
#define PIOS_BMP085_EOC_GPIO_PORT GPIOC
|
#define PIOS_BMP085_EOC_GPIO_PORT GPIOC
|
||||||
#define PIOS_BMP085_EOC_GPIO_PIN GPIO_Pin_2
|
#define PIOS_BMP085_EOC_GPIO_PIN GPIO_Pin_2
|
||||||
#define PIOS_BMP085_EOC_PORT_SOURCE GPIO_PortSourceGPIOC
|
#define PIOS_BMP085_EOC_PORT_SOURCE GPIO_PortSourceGPIOC
|
||||||
|
@ -115,10 +115,13 @@ TIM8 | Servo 5 | Servo 6 | Servo 7 | Servo 8
|
|||||||
#define PIOS_I2C_MAX_DEVS 1
|
#define PIOS_I2C_MAX_DEVS 1
|
||||||
extern uint32_t pios_i2c_main_adapter_id;
|
extern uint32_t pios_i2c_main_adapter_id;
|
||||||
#define PIOS_I2C_MAIN_ADAPTER (pios_i2c_main_adapter_id)
|
#define PIOS_I2C_MAIN_ADAPTER (pios_i2c_main_adapter_id)
|
||||||
|
#define PIOS_I2C_ESC_ADAPTER (pios_i2c_main_adapter_id)
|
||||||
|
#define PIOS_I2C_BMP085_ADAPTER (pios_i2c_main_adapter_id)
|
||||||
|
|
||||||
//------------------------
|
//------------------------
|
||||||
// PIOS_BMP085
|
// PIOS_BMP085
|
||||||
//------------------------
|
//------------------------
|
||||||
|
#define PIOS_BMP085_HAS_GPIOS
|
||||||
#define PIOS_BMP085_EOC_GPIO_PORT GPIOC
|
#define PIOS_BMP085_EOC_GPIO_PORT GPIOC
|
||||||
#define PIOS_BMP085_EOC_GPIO_PIN GPIO_Pin_15
|
#define PIOS_BMP085_EOC_GPIO_PIN GPIO_Pin_15
|
||||||
#define PIOS_BMP085_EOC_PORT_SOURCE GPIO_PortSourceGPIOC
|
#define PIOS_BMP085_EOC_PORT_SOURCE GPIO_PortSourceGPIOC
|
||||||
|
@ -38,12 +38,17 @@
|
|||||||
|
|
||||||
/* Glocal Variables */
|
/* Glocal Variables */
|
||||||
ConversionTypeTypeDef CurrentRead;
|
ConversionTypeTypeDef CurrentRead;
|
||||||
|
|
||||||
|
#ifdef PIOS_BMP085_HAS_GPIOS
|
||||||
|
|
||||||
#if defined(PIOS_INCLUDE_FREERTOS)
|
#if defined(PIOS_INCLUDE_FREERTOS)
|
||||||
xSemaphoreHandle PIOS_BMP085_EOC;
|
xSemaphoreHandle PIOS_BMP085_EOC;
|
||||||
#else
|
#else
|
||||||
int32_t PIOS_BMP085_EOC;
|
int32_t PIOS_BMP085_EOC;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#endif /* PIOS_BMP085_HAS_GPIOS */
|
||||||
|
|
||||||
/* Local Variables */
|
/* Local Variables */
|
||||||
static BMP085CalibDataTypeDef CalibData;
|
static BMP085CalibDataTypeDef CalibData;
|
||||||
|
|
||||||
@ -60,6 +65,9 @@ static volatile uint16_t Temperature;
|
|||||||
*/
|
*/
|
||||||
void PIOS_BMP085_Init(void)
|
void PIOS_BMP085_Init(void)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
#ifdef PIOS_BMP085_HAS_GPIOS
|
||||||
|
|
||||||
GPIO_InitTypeDef GPIO_InitStructure;
|
GPIO_InitTypeDef GPIO_InitStructure;
|
||||||
EXTI_InitTypeDef EXTI_InitStructure;
|
EXTI_InitTypeDef EXTI_InitStructure;
|
||||||
NVIC_InitTypeDef NVIC_InitStructure;
|
NVIC_InitTypeDef NVIC_InitStructure;
|
||||||
@ -101,6 +109,8 @@ void PIOS_BMP085_Init(void)
|
|||||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
|
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
|
||||||
GPIO_Init(PIOS_BMP085_XCLR_GPIO_PORT, &GPIO_InitStructure);
|
GPIO_Init(PIOS_BMP085_XCLR_GPIO_PORT, &GPIO_InitStructure);
|
||||||
|
|
||||||
|
#endif /* PIOS_BMP085_HAS_GPIOS */
|
||||||
|
|
||||||
/* Read all 22 bytes of calibration data in one transfer, this is a very optimized way of doing things */
|
/* Read all 22 bytes of calibration data in one transfer, this is a very optimized way of doing things */
|
||||||
uint8_t Data[BMP085_CALIB_LEN];
|
uint8_t Data[BMP085_CALIB_LEN];
|
||||||
while (!PIOS_BMP085_Read(BMP085_CALIB_ADDR, Data, BMP085_CALIB_LEN))
|
while (!PIOS_BMP085_Read(BMP085_CALIB_ADDR, Data, BMP085_CALIB_LEN))
|
||||||
@ -235,7 +245,7 @@ bool PIOS_BMP085_Read(uint8_t address, uint8_t * buffer, uint8_t len)
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
return PIOS_I2C_Transfer(PIOS_I2C_MAIN_ADAPTER, txn_list, NELEMENTS(txn_list));
|
return PIOS_I2C_Transfer(PIOS_I2C_BMP085_ADAPTER, txn_list, NELEMENTS(txn_list));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -264,7 +274,7 @@ bool PIOS_BMP085_Write(uint8_t address, uint8_t buffer)
|
|||||||
,
|
,
|
||||||
};
|
};
|
||||||
|
|
||||||
return PIOS_I2C_Transfer(PIOS_I2C_MAIN_ADAPTER, txn_list, NELEMENTS(txn_list));
|
return PIOS_I2C_Transfer(PIOS_I2C_BMP085_ADAPTER, txn_list, NELEMENTS(txn_list));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -93,7 +93,7 @@ bool PIOS_I2C_ESC_SetSpeed(uint8_t speed[4])
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
return PIOS_I2C_Transfer(PIOS_I2C_MAIN_ADAPTER, txn_list, NELEMENTS(txn_list));
|
return PIOS_I2C_Transfer(PIOS_I2C_ESC_ADAPTER, txn_list, NELEMENTS(txn_list));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PIOS_SetMKSpeed(uint8_t motornum, uint8_t speed) {
|
bool PIOS_SetMKSpeed(uint8_t motornum, uint8_t speed) {
|
||||||
@ -115,7 +115,7 @@ bool PIOS_SetMKSpeed(uint8_t motornum, uint8_t speed) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
return PIOS_I2C_Transfer(PIOS_I2C_MAIN_ADAPTER, txn_list, NELEMENTS(txn_list));
|
return PIOS_I2C_Transfer(PIOS_I2C_ESC_ADAPTER, txn_list, NELEMENTS(txn_list));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PIOS_SetAstec4Address(uint8_t new_address) {
|
bool PIOS_SetAstec4Address(uint8_t new_address) {
|
||||||
@ -134,7 +134,7 @@ bool PIOS_SetAstec4Address(uint8_t new_address) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
return PIOS_I2C_Transfer(PIOS_I2C_MAIN_ADAPTER, txn_list, NELEMENTS(txn_list));
|
return PIOS_I2C_Transfer(PIOS_I2C_ESC_ADAPTER, txn_list, NELEMENTS(txn_list));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PIOS_SetAstec4Speed(uint8_t motornum, uint8_t speed) {
|
bool PIOS_SetAstec4Speed(uint8_t motornum, uint8_t speed) {
|
||||||
@ -161,7 +161,7 @@ bool PIOS_SetAstec4Speed(uint8_t motornum, uint8_t speed) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
return PIOS_I2C_Transfer(PIOS_I2C_MAIN_ADAPTER, txn_list, NELEMENTS(txn_list));
|
return PIOS_I2C_Transfer(PIOS_I2C_ESC_ADAPTER, txn_list, NELEMENTS(txn_list));
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -44,7 +44,7 @@ void EXTI15_10_IRQHandler(void)
|
|||||||
portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE;
|
portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(PIOS_INCLUDE_BMP085)
|
#if defined(PIOS_INCLUDE_BMP085) && defined(PIOS_BMP085_HAS_GPIOS)
|
||||||
if (EXTI_GetITStatus(PIOS_BMP085_EOC_EXTI_LINE) != RESET) {
|
if (EXTI_GetITStatus(PIOS_BMP085_EOC_EXTI_LINE) != RESET) {
|
||||||
/* Read the ADC Value */
|
/* Read the ADC Value */
|
||||||
#if defined(PIOS_INCLUDE_FREERTOS)
|
#if defined(PIOS_INCLUDE_FREERTOS)
|
||||||
|
@ -891,6 +891,10 @@ int32_t PIOS_I2C_Init(uint32_t * i2c_id, const struct pios_i2c_adapter_cfg * cfg
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (i2c_adapter->cfg->remap) {
|
||||||
|
GPIO_PinRemapConfig(i2c_adapter->cfg->remap, ENABLE);
|
||||||
|
}
|
||||||
|
|
||||||
/* Initialize the state machine */
|
/* Initialize the state machine */
|
||||||
i2c_adapter_fsm_init(i2c_adapter);
|
i2c_adapter_fsm_init(i2c_adapter);
|
||||||
|
|
||||||
|
@ -37,6 +37,7 @@ struct pios_i2c_adapter_cfg {
|
|||||||
uint32_t transfer_timeout_ms;
|
uint32_t transfer_timeout_ms;
|
||||||
struct stm32_gpio scl;
|
struct stm32_gpio scl;
|
||||||
struct stm32_gpio sda;
|
struct stm32_gpio sda;
|
||||||
|
uint32_t remap;
|
||||||
struct stm32_irq event;
|
struct stm32_irq event;
|
||||||
struct stm32_irq error;
|
struct stm32_irq error;
|
||||||
};
|
};
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
<field name="USB_HIDPort" units="function" type="enum" elements="1" options="USBTelemetry,Disabled" defaultvalue="USBTelemetry"/>
|
<field name="USB_HIDPort" units="function" type="enum" elements="1" options="USBTelemetry,Disabled" defaultvalue="USBTelemetry"/>
|
||||||
<field name="USB_VCPPort" units="function" type="enum" elements="1" options="USBTelemetry,ComBridge,Disabled" defaultvalue="Disabled"/>
|
<field name="USB_VCPPort" units="function" type="enum" elements="1" options="USBTelemetry,ComBridge,Disabled" defaultvalue="Disabled"/>
|
||||||
|
|
||||||
<field name="OptionalModules" units="" type="enum" elementnames="CameraStab,GPS,ComUsbBridge,Fault" options="Disabled,Enabled" defaultvalue="Disabled"/>
|
<field name="OptionalModules" units="" type="enum" elementnames="CameraStab,GPS,ComUsbBridge,Fault,Altitude" options="Disabled,Enabled" defaultvalue="Disabled"/>
|
||||||
<field name="DSMxBind" units="" type="uint8" elements="1" defaultvalue="0"/>
|
<field name="DSMxBind" units="" type="uint8" elements="1" defaultvalue="0"/>
|
||||||
|
|
||||||
<access gcs="readwrite" flight="readwrite"/>
|
<access gcs="readwrite" flight="readwrite"/>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user