1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-02-28 17:54:15 +01:00

LP-480 Moved sensors initialization to pios_board_sensors.c

This commit is contained in:
Vladimir Zidar 2017-04-19 15:58:31 +02:00
parent c9f6ba55a0
commit 9eb1f3b5e5
28 changed files with 766 additions and 666 deletions

View File

@ -101,6 +101,7 @@ SRC += $(PIOSCOMMON)/pios_servo.c
SRC += $(PIOSCOMMON)/pios_openlrs.c SRC += $(PIOSCOMMON)/pios_openlrs.c
SRC += $(PIOSCOMMON)/pios_openlrs_rcvr.c SRC += $(PIOSCOMMON)/pios_openlrs_rcvr.c
SRC += $(PIOSCOMMON)/pios_board_io.c SRC += $(PIOSCOMMON)/pios_board_io.c
SRC += $(PIOSCOMMON)/pios_board_sensors.c
## Misc library functions ## Misc library functions
SRC += $(FLIGHTLIB)/sanitycheck.c SRC += $(FLIGHTLIB)/sanitycheck.c

View File

@ -67,21 +67,12 @@
# endif /* PIOS_INCLUDE_RCVR */ # endif /* PIOS_INCLUDE_RCVR */
#endif /* PIOS_INCLUDE_RFM22B */ #endif /* PIOS_INCLUDE_RFM22B */
#ifdef PIOS_INCLUDE_ADC
# include <pios_adc_priv.h>
#endif
#ifdef PIOS_INCLUDE_MS5611
# include <pios_ms5611.h>
#endif
#ifdef PIOS_INCLUDE_RCVR #ifdef PIOS_INCLUDE_RCVR
# include "manualcontrolsettings.h" # include "manualcontrolsettings.h"
uint32_t pios_rcvr_group_map[MANUALCONTROLSETTINGS_CHANNELGROUPS_NONE]; /* Receivers */ uint32_t pios_rcvr_group_map[MANUALCONTROLSETTINGS_CHANNELGROUPS_NONE]; /* Receivers */
#endif /* PIOS_INCLUDE_RCVR */ #endif /* PIOS_INCLUDE_RCVR */
#include "hwsettings.h" #include "hwsettings.h"
#include "auxmagsettings.h"
#include "gcsreceiver.h" #include "gcsreceiver.h"
#ifdef PIOS_INCLUDE_GPS #ifdef PIOS_INCLUDE_GPS
@ -118,14 +109,6 @@ uint32_t pios_com_telem_usb_id; /* USB telemetry */
uint32_t pios_usb_rctx_id; uint32_t pios_usb_rctx_id;
#endif #endif
#if defined(PIOS_INCLUDE_HMC5X83)
# include "pios_hmc5x83.h"
# if defined(PIOS_HMC5X83_HAS_GPIOS)
pios_hmc5x83_dev_t pios_hmc5x83_internal_id;
# endif
#endif
#include "pios_usb_board_data_priv.h" #include "pios_usb_board_data_priv.h"
#include "pios_usb_desc_hid_cdc_priv.h" #include "pios_usb_desc_hid_cdc_priv.h"
#include "pios_usb_desc_hid_only_priv.h" #include "pios_usb_desc_hid_only_priv.h"
@ -495,7 +478,7 @@ void PIOS_BOARD_IO_Configure_GCSRCVR()
#ifdef PIOS_INCLUDE_RFM22B #ifdef PIOS_INCLUDE_RFM22B
void PIOS_BOARD_IO_Configure_RFM22B(uint32_t spi_id, PIOS_BOARD_IO_RADIOAUX_Function radioaux_function) void PIOS_BOARD_IO_Configure_RFM22B(PIOS_BOARD_IO_RADIOAUX_Function radioaux_function)
{ {
#if defined(PIOS_INCLUDE_RFM22B) #if defined(PIOS_INCLUDE_RFM22B)
OPLinkSettingsInitialize(); OPLinkSettingsInitialize();
@ -533,7 +516,7 @@ void PIOS_BOARD_IO_Configure_RFM22B(uint32_t spi_id, PIOS_BOARD_IO_RADIOAUX_Func
uint32_t openlrs_id; uint32_t openlrs_id;
const struct pios_openlrs_cfg *openlrs_cfg = PIOS_BOARD_HW_DEFS_GetOpenLRSCfg(pios_board_info_blob.board_rev); const struct pios_openlrs_cfg *openlrs_cfg = PIOS_BOARD_HW_DEFS_GetOpenLRSCfg(pios_board_info_blob.board_rev);
PIOS_OpenLRS_Init(&openlrs_id, spi_id, 0, openlrs_cfg); PIOS_OpenLRS_Init(&openlrs_id, PIOS_SPI_RFM22B_ADAPTER, 0, openlrs_cfg);
uint32_t openlrsrcvr_id; uint32_t openlrsrcvr_id;
PIOS_OpenLRS_Rcvr_Init(&openlrsrcvr_id, openlrs_id); PIOS_OpenLRS_Rcvr_Init(&openlrsrcvr_id, openlrs_id);
@ -548,7 +531,7 @@ void PIOS_BOARD_IO_Configure_RFM22B(uint32_t spi_id, PIOS_BOARD_IO_RADIOAUX_Func
/* Configure the RFM22B device. */ /* Configure the RFM22B device. */
const struct pios_rfm22b_cfg *rfm22b_cfg = PIOS_BOARD_HW_DEFS_GetRfm22Cfg(pios_board_info_blob.board_rev); const struct pios_rfm22b_cfg *rfm22b_cfg = PIOS_BOARD_HW_DEFS_GetRfm22Cfg(pios_board_info_blob.board_rev);
if (PIOS_RFM22B_Init(&pios_rfm22b_id, spi_id, rfm22b_cfg->slave_num, rfm22b_cfg, oplinkSettings.RFBand)) { if (PIOS_RFM22B_Init(&pios_rfm22b_id, PIOS_SPI_RFM22B_ADAPTER, rfm22b_cfg->slave_num, rfm22b_cfg, oplinkSettings.RFBand)) {
PIOS_Assert(0); PIOS_Assert(0);
} }
#if defined(PIOS_INCLUDE_OPLINKRCVR) && defined(PIOS_INCLUDE_RCVR) #if defined(PIOS_INCLUDE_OPLINKRCVR) && defined(PIOS_INCLUDE_RCVR)
@ -646,7 +629,7 @@ void PIOS_BOARD_IO_Configure_RFM22B(uint32_t spi_id, PIOS_BOARD_IO_RADIOAUX_Func
uint16_t mavlink_rx_size = PIOS_COM_MAVLINK_RX_BUF_LEN; uint16_t mavlink_rx_size = PIOS_COM_MAVLINK_RX_BUF_LEN;
switch (radioaux_function) { switch (radioaux_function) {
default: ; default:;
case PIOS_BOARD_IO_RADIOAUX_DEBUGCONSOLE: case PIOS_BOARD_IO_RADIOAUX_DEBUGCONSOLE:
#ifdef PIOS_INCLUDE_DEBUG_CONSOLE #ifdef PIOS_INCLUDE_DEBUG_CONSOLE
if (PIOS_COM_Init(&pios_com_debug_id, &pios_rfm22b_aux_com_driver, pios_rfm22b_id, if (PIOS_COM_Init(&pios_com_debug_id, &pios_rfm22b_aux_com_driver, pios_rfm22b_id,
@ -657,10 +640,9 @@ void PIOS_BOARD_IO_Configure_RFM22B(uint32_t spi_id, PIOS_BOARD_IO_RADIOAUX_Func
#endif #endif
break; break;
case PIOS_BOARD_IO_RADIOAUX_COMBRIDGE: case PIOS_BOARD_IO_RADIOAUX_COMBRIDGE:
if(PIOS_COM_Init(&pios_com_bridge_id, &pios_rfm22b_aux_com_driver, pios_rfm22b_id, if (PIOS_COM_Init(&pios_com_bridge_id, &pios_rfm22b_aux_com_driver, pios_rfm22b_id,
0, PIOS_COM_BRIDGE_RX_BUF_LEN, 0, PIOS_COM_BRIDGE_RX_BUF_LEN,
0, PIOS_COM_BRIDGE_TX_BUF_LEN)) 0, PIOS_COM_BRIDGE_TX_BUF_LEN)) {
{
PIOS_Assert(0); PIOS_Assert(0);
} }
break; break;
@ -679,106 +661,3 @@ void PIOS_BOARD_IO_Configure_RFM22B(uint32_t spi_id, PIOS_BOARD_IO_RADIOAUX_Func
OPLinkStatusSet(&oplinkStatus); OPLinkStatusSet(&oplinkStatus);
} }
#endif /* ifdef PIOS_INCLUDE_RFM22B */ #endif /* ifdef PIOS_INCLUDE_RFM22B */
#ifdef PIOS_INCLUDE_I2C
void PIOS_BOARD_IO_Configure_I2C(uint32_t i2c_internal_id, uint32_t i2c_external_id)
{
// internal HMC5x83 mag
# ifdef PIOS_INCLUDE_HMC5X83_INTERNAL
const struct pios_hmc5x83_cfg *hmc5x83_internal_cfg = PIOS_BOARD_HW_DEFS_GetInternalHMC5x83Cfg(pios_board_info_blob.board_rev);
if (hmc5x83_internal_cfg) {
// attach the 5x83 mag to internal i2c bus
pios_hmc5x83_dev_t internal_mag = PIOS_HMC5x83_Init(hmc5x83_internal_cfg, i2c_internal_id, 0);
# ifdef PIOS_INCLUDE_WDG
// give HMC5x83 on I2C some extra time to allow for reset, etc. if needed
// this is not in a loop, so it is safe
PIOS_WDG_Clear();
# endif /* PIOS_INCLUDE_WDG */
#ifdef PIOS_HMC5X83_HAS_GPIOS
pios_hmc5x83_internal_id = internal_mag;
#endif
// add this sensor to the sensor task's list
PIOS_HMC5x83_Register(internal_mag, PIOS_SENSORS_TYPE_3AXIS_MAG);
}
# endif /* PIOS_INCLUDE_HMC5X83_INTERNAL */
// internal ms5611 baro
#if defined(PIOS_INCLUDE_MS5611)
PIOS_MS5611_Init(PIOS_BOARD_HW_DEFS_GetMS5611Cfg(pios_board_info_blob.board_rev), i2c_internal_id);
PIOS_MS5611_Register();
#endif
// internal bmp280 baro
// internal MPU6000 imu (i2c)
// internal eeprom (revo nano) - NOT HERE, should be initialized earlier
/* Initialize external sensors */
// aux mag
# ifdef PIOS_INCLUDE_HMC5X83
AuxMagSettingsInitialize();
AuxMagSettingsTypeOptions option;
AuxMagSettingsTypeGet(&option);
const struct pios_hmc5x83_cfg *hmc5x83_external_cfg = PIOS_BOARD_HW_DEFS_GetExternalHMC5x83Cfg(pios_board_info_blob.board_rev);
if (hmc5x83_external_cfg) {
uint32_t i2c_id = 0;
if (option == AUXMAGSETTINGS_TYPE_FLEXI) {
// i2c_external
i2c_id = i2c_external_id;
} else if (option == AUXMAGSETTINGS_TYPE_I2C) {
// i2c_internal (or Sparky2/F3 dedicated I2C port)
i2c_id = i2c_internal_id;
}
if (i2c_id) {
uint32_t external_mag = PIOS_HMC5x83_Init(hmc5x83_external_cfg, i2c_id, 0);
# ifdef PIOS_INCLUDE_WDG
// give HMC5x83 on I2C some extra time to allow for reset, etc. if needed
// this is not in a loop, so it is safe
PIOS_WDG_Clear();
# endif /* PIOS_INCLUDE_WDG */
// add this sensor to the sensor task's list
// be careful that you don't register a slow, unimportant sensor after registering the fastest sensor
// and before registering some other fast and important sensor
// as that would cause delay and time jitter for the second fast sensor
PIOS_HMC5x83_Register(external_mag, PIOS_SENSORS_TYPE_3AXIS_AUXMAG);
// mag alarm is cleared later, so use I2C
AlarmsSet(SYSTEMALARMS_ALARM_I2C, (external_mag) ? SYSTEMALARMS_ALARM_OK : SYSTEMALARMS_ALARM_WARNING);
}
}
# endif /* PIOS_INCLUDE_HMC5X83 */
// external ETASV3 Eagletree Airspeed v3
// external MS4525D PixHawk Airpeed based on MS4525DO
// BMA180 accelerometer?
// bmp085/bmp180 baro
// hmc5843 mag
// i2c esc (?)
// UBX DCC
}
#endif /* ifdef PIOS_INCLUDE_I2C */
#ifdef PIOS_INCLUDE_ADC
void PIOS_BOARD_IO_Configure_ADC()
{
PIOS_ADC_Init(PIOS_BOARD_HW_DEFS_GetAdcCfg(pios_board_info_blob.board_rev));
uint8_t adc_config[HWSETTINGS_ADCROUTING_NUMELEM];
HwSettingsADCRoutingArrayGet(adc_config);
for (uint32_t i = 0; i < HWSETTINGS_ADCROUTING_NUMELEM; i++) {
if (adc_config[i] != HWSETTINGS_ADCROUTING_DISABLED) {
PIOS_ADC_PinSetup(i);
}
}
}
#endif /* PIOS_INCLUDE_ADC */

View File

@ -0,0 +1,187 @@
/**
******************************************************************************
*
* @file pios_board_sensors.c
* @author The LibrePilot Project, http://www.librepilot.org Copyright (C) 2017.
* @brief board sensors setup
* --
* @see The GNU Public License (GPL) Version 3
*
*****************************************************************************/
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "pios_board_info.h"
#include "pios_board_sensors.h"
#include "pios_board_hw.h"
#include "uavobjectmanager.h"
#include "auxmagsettings.h"
#include "hwsettings.h"
#include <alarms.h>
#ifdef PIOS_INCLUDE_MPU6000
# include <pios_mpu6000.h>
# include <pios_mpu6000_config.h>
#endif
#ifdef PIOS_INCLUDE_MS5611
# include <pios_ms5611.h>
#endif
#if defined(PIOS_INCLUDE_ADXL345)
# include <pios_adxl345.h>
#endif
#ifdef PIOS_INCLUDE_MPU9250
# include <pios_mpu9250.h>
# include <pios_mpu9250_config.h>
#endif
#if defined(PIOS_INCLUDE_HMC5X83)
# include "pios_hmc5x83.h"
# if defined(PIOS_HMC5X83_HAS_GPIOS)
pios_hmc5x83_dev_t pios_hmc5x83_internal_id;
# endif
#endif
#ifdef PIOS_INCLUDE_ADC
# include "pios_adc_priv.h"
#endif
void PIOS_BOARD_Sensors_Configure()
{
#ifdef PIOS_INCLUDE_MPU6000
const struct pios_mpu6000_cfg *mpu6000_cfg = PIOS_BOARD_HW_DEFS_GetMPU6000Cfg(pios_board_info_blob.board_rev);
if (mpu6000_cfg) {
PIOS_MPU6000_Init(PIOS_SPI_MPU6000_ADAPTER, 0, mpu6000_cfg);
PIOS_MPU6000_CONFIG_Configure();
#ifndef PIOS_EXCLUDE_ADVANCED_FEATURES
PIOS_MPU6000_Register();
#endif
}
#endif /* PIOS_INCLUDE_MPU6000 */
#ifdef PIOS_INCLUDE_ADXL345
PIOS_ADXL345_Init(PIOS_SPI_ADXL345_ADAPTER, 0);
#endif
#ifdef PIOS_INCLUDE_MPU9250
const struct pios_mpu9250_cfg *mpu9250_cfg = PIOS_BOARD_HW_DEFS_GetMPU9250Cfg(pios_board_info_blob.board_rev);
if (mpu9250_cfg) {
PIOS_MPU9250_Init(PIOS_SPI_MPU9250_ADAPTER, 0, mpu9250_cfg);
PIOS_MPU9250_CONFIG_Configure();
PIOS_MPU9250_MainRegister();
PIOS_MPU9250_MagRegister();
}
#endif /* PIOS_INCLUDE_MPU9250 */
// internal HMC5x83 mag
# ifdef PIOS_INCLUDE_HMC5X83_INTERNAL
const struct pios_hmc5x83_cfg *hmc5x83_internal_cfg = PIOS_BOARD_HW_DEFS_GetInternalHMC5x83Cfg(pios_board_info_blob.board_rev);
if (hmc5x83_internal_cfg) {
// attach the 5x83 mag to internal i2c bus
pios_hmc5x83_dev_t internal_mag = PIOS_HMC5x83_Init(hmc5x83_internal_cfg, PIOS_I2C_HMC5X83_INTERNAL_ADAPTER, 0);
# ifdef PIOS_INCLUDE_WDG
// give HMC5x83 on I2C some extra time to allow for reset, etc. if needed
// this is not in a loop, so it is safe
PIOS_WDG_Clear();
# endif /* PIOS_INCLUDE_WDG */
#ifdef PIOS_HMC5X83_HAS_GPIOS
pios_hmc5x83_internal_id = internal_mag;
#endif
// add this sensor to the sensor task's list
PIOS_HMC5x83_Register(internal_mag, PIOS_SENSORS_TYPE_3AXIS_MAG);
}
# endif /* PIOS_INCLUDE_HMC5X83_INTERNAL */
# ifdef PIOS_INCLUDE_HMC5X83
AuxMagSettingsInitialize();
AuxMagSettingsTypeOptions option;
AuxMagSettingsTypeGet(&option);
const struct pios_hmc5x83_cfg *hmc5x83_external_cfg = PIOS_BOARD_HW_DEFS_GetExternalHMC5x83Cfg(pios_board_info_blob.board_rev);
if (hmc5x83_external_cfg) {
uint32_t i2c_id = 0;
if (option == AUXMAGSETTINGS_TYPE_FLEXI) {
// i2c_external
i2c_id = PIOS_I2C_EXTERNAL_ADAPTER;
} else if (option == AUXMAGSETTINGS_TYPE_I2C) {
// i2c_internal (or Sparky2/F3 dedicated I2C port)
i2c_id = PIOS_I2C_FLEXI_ADAPTER;
}
if (i2c_id) {
uint32_t external_mag = PIOS_HMC5x83_Init(hmc5x83_external_cfg, i2c_id, 0);
# ifdef PIOS_INCLUDE_WDG
// give HMC5x83 on I2C some extra time to allow for reset, etc. if needed
// this is not in a loop, so it is safe
PIOS_WDG_Clear();
# endif /* PIOS_INCLUDE_WDG */
// add this sensor to the sensor task's list
// be careful that you don't register a slow, unimportant sensor after registering the fastest sensor
// and before registering some other fast and important sensor
// as that would cause delay and time jitter for the second fast sensor
PIOS_HMC5x83_Register(external_mag, PIOS_SENSORS_TYPE_3AXIS_AUXMAG);
// mag alarm is cleared later, so use I2C
AlarmsSet(SYSTEMALARMS_ALARM_I2C, (external_mag) ? SYSTEMALARMS_ALARM_OK : SYSTEMALARMS_ALARM_WARNING);
}
}
# endif /* PIOS_INCLUDE_HMC5X83 */
// internal ms5611 baro
#if defined(PIOS_INCLUDE_MS5611)
const struct pios_ms5611_cfg *ms5611_cfg = PIOS_BOARD_HW_DEFS_GetMS5611Cfg(pios_board_info_blob.board_rev);
if (ms5611_cfg) {
PIOS_MS5611_Init(ms5611_cfg, PIOS_I2C_MS5611_INTERNAL_ADAPTER);
PIOS_MS5611_Register();
}
#endif
#ifdef PIOS_INCLUDE_ADC
PIOS_ADC_Init(PIOS_BOARD_HW_DEFS_GetAdcCfg(pios_board_info_blob.board_rev));
#ifndef PIOS_EXCLUDE_ADVANCED_FEATURES
uint8_t adc_config[HWSETTINGS_ADCROUTING_NUMELEM];
HwSettingsADCRoutingArrayGet(adc_config);
for (uint32_t i = 0; i < HWSETTINGS_ADCROUTING_NUMELEM; i++) {
if (adc_config[i] != HWSETTINGS_ADCROUTING_DISABLED) {
PIOS_ADC_PinSetup(i);
}
}
#endif
#endif /* PIOS_INCLUDE_ADC */
// internal bmp280 baro
// internal MPU6000 imu (i2c)
// external ETASV3 Eagletree Airspeed v3
// external MS4525D PixHawk Airpeed based on MS4525DO
// BMA180 accelerometer?
// bmp085/bmp180 baro
// hmc5843 mag
// i2c esc (?)
// UBX DCC
}

View File

@ -53,4 +53,10 @@ const struct pios_bmp280_cfg *PIOS_BOARD_HW_DEFS_GetBMP280Cfg(uint32_t board_rev
#ifdef PIOS_INCLUDE_ADC #ifdef PIOS_INCLUDE_ADC
const struct pios_adc_cfg *PIOS_BOARD_HW_DEFS_GetAdcCfg(uint32_t board_revision); const struct pios_adc_cfg *PIOS_BOARD_HW_DEFS_GetAdcCfg(uint32_t board_revision);
#endif #endif
#ifdef PIOS_INCLUDE_MPU6000
const struct pios_mpu6000_cfg *PIOS_BOARD_HW_DEFS_GetMPU6000Cfg(uint32_t board_revision);
#endif
#ifdef PIOS_INCLUDE_MPU9250
const struct pios_mpu9250_cfg *PIOS_BOARD_HW_DEFS_GetMPU9250Cfg(uint32_t board_revision);
#endif
#endif /* PIOS_BOARD_HW_H */ #endif /* PIOS_BOARD_HW_H */

View File

@ -206,10 +206,10 @@ typedef enum {
#ifdef PIOS_INCLUDE_USB #ifdef PIOS_INCLUDE_USB
void PIOS_BOARD_IO_Configure_USB(); void PIOS_BOARD_IO_Configure_USB();
//# if defined(PIOS_INCLUDE_USB_HID) // # if defined(PIOS_INCLUDE_USB_HID)
//# include <pios_usb_hid_priv.h> // # include <pios_usb_hid_priv.h>
//extern const struct pios_usb_hid_cfg pios_usb_hid_cfg; // extern const struct pios_usb_hid_cfg pios_usb_hid_cfg;
//# endif /* PIOS_INCLUDE_USB_HID */ // # endif /* PIOS_INCLUDE_USB_HID */
#endif /* PIOS_INCLUDE_USB */ #endif /* PIOS_INCLUDE_USB */
#ifdef PIOS_INCLUDE_PWM #ifdef PIOS_INCLUDE_PWM
void PIOS_BOARD_IO_Configure_PWM(const struct pios_pwm_cfg *pwm_cfg); void PIOS_BOARD_IO_Configure_PWM(const struct pios_pwm_cfg *pwm_cfg);
@ -221,11 +221,7 @@ void PIOS_BOARD_IO_Configure_PPM(const struct pios_ppm_cfg *ppm_cfg);
void PIOS_BOARD_IO_Configure_UART(const struct pios_usart_cfg *usart_cfg, PIOS_BOARD_IO_UART_Function function); void PIOS_BOARD_IO_Configure_UART(const struct pios_usart_cfg *usart_cfg, PIOS_BOARD_IO_UART_Function function);
#ifdef PIOS_INCLUDE_RFM22B #ifdef PIOS_INCLUDE_RFM22B
void PIOS_BOARD_IO_Configure_RFM22B(uint32_t spi_id, PIOS_BOARD_IO_RADIOAUX_Function function); void PIOS_BOARD_IO_Configure_RFM22B(PIOS_BOARD_IO_RADIOAUX_Function function);
#endif
#ifdef PIOS_INCLUDE_I2C
void PIOS_BOARD_IO_Configure_I2C(uint32_t i2c_internal_id, uint32_t i2c_external_id);
#endif #endif
#ifdef PIOS_INCLUDE_GCSRCVR #ifdef PIOS_INCLUDE_GCSRCVR

View File

@ -0,0 +1,33 @@
/**
******************************************************************************
*
* @file pios_board_sensors.h
* @author The LibrePilot Project, http://www.librepilot.org Copyright (C) 2017.
* @brief board sensors setup
* --
* @see The GNU Public License (GPL) Version 3
*
*****************************************************************************/
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef PIOS_BOARD_SENSORS_H
#define PIOS_BOARD_SENSORS_H
#include "pios.h"
void PIOS_BOARD_Sensors_Configure();
#endif /* PIOS_BOARD_SENSORS_H */

View File

@ -30,7 +30,7 @@
* Generic servo pin configuration structure for an STM32F10x * Generic servo pin configuration structure for an STM32F10x
*/ */
#define TIM_SERVO_CHANNEL_CONFIG(_timer, _channel, _gpio, _pin, _remap) \ #define TIM_SERVO_CHANNEL_CONFIG(_timer, _channel, _gpio, _pin, _remap) \
{ \ { \
.timer = _timer, \ .timer = _timer, \
.timer_chan = TIM_Channel_##_channel, \ .timer_chan = TIM_Channel_##_channel, \
.pin = { \ .pin = { \
@ -38,12 +38,12 @@
.init = { \ .init = { \
.GPIO_Pin = GPIO_Pin_##_pin, \ .GPIO_Pin = GPIO_Pin_##_pin, \
.GPIO_Mode = GPIO_Mode_IPD, \ .GPIO_Mode = GPIO_Mode_IPD, \
.GPIO_Speed = GPIO_Speed_2MHz,\ .GPIO_Speed = GPIO_Speed_2MHz, \
}, \ }, \
.pin_source = GPIO_PinSource##_pin, \ .pin_source = GPIO_PinSource##_pin, \
}, \ }, \
.remap = _remap, \ .remap = _remap, \
} }
#endif /* PIOS_SERVO_CONFIG_H_ */ #endif /* PIOS_SERVO_CONFIG_H_ */

View File

@ -186,11 +186,11 @@ static const struct pios_spi_cfg pios_spi_gyro_cfg = {
}, },
}; };
static uint32_t pios_spi_gyro_id; uint32_t pios_spi_gyro_adapter_id;
void PIOS_SPI_gyro_irq_handler(void) void PIOS_SPI_gyro_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_SPI_IRQ_Handler(pios_spi_gyro_id); PIOS_SPI_IRQ_Handler(pios_spi_gyro_adapter_id);
} }
@ -402,11 +402,11 @@ static const struct pios_spi_cfg pios_spi_flash_accel_cfg_cc = {
}, },
}; };
static uint32_t pios_spi_flash_accel_id; uint32_t pios_spi_flash_accel_adapter_id;
void PIOS_SPI_flash_accel_irq_handler(void) void PIOS_SPI_flash_accel_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_SPI_IRQ_Handler(pios_spi_flash_accel_id); PIOS_SPI_IRQ_Handler(pios_spi_flash_accel_adapter_id);
} }
#endif /* PIOS_INCLUDE_SPI */ #endif /* PIOS_INCLUDE_SPI */
@ -485,6 +485,11 @@ void PIOS_ADC_handler()
{ {
PIOS_ADC_DMA_Handler(); PIOS_ADC_DMA_Handler();
} }
const struct pios_adc_cfg *PIOS_BOARD_HW_DEFS_GetAdcCfg(__attribute__((unused)) uint32_t board_revision)
{
return &pios_adc_cfg;
}
#endif /* if defined(PIOS_INCLUDE_ADC) */ #endif /* if defined(PIOS_INCLUDE_ADC) */
#include "pios_tim_priv.h" #include "pios_tim_priv.h"
@ -988,7 +993,6 @@ const struct pios_usb_cfg *PIOS_BOARD_HW_DEFS_GetUsbCfg(uint32_t board_revision)
*/ */
#if defined(PIOS_INCLUDE_MPU6000) #if defined(PIOS_INCLUDE_MPU6000)
#include "pios_mpu6000.h" #include "pios_mpu6000.h"
#include "pios_mpu6000_config.h"
static const struct pios_exti_cfg pios_exti_mpu6000_cfg __exti_config = { static const struct pios_exti_cfg pios_exti_mpu6000_cfg __exti_config = {
.vector = PIOS_MPU6000_IRQHandler, .vector = PIOS_MPU6000_IRQHandler,
.line = EXTI_Line3, .line = EXTI_Line3,
@ -1037,6 +1041,9 @@ static const struct pios_mpu6000_cfg pios_mpu6000_cfg = {
.std_prescaler = PIOS_SPI_PRESCALER_64, .std_prescaler = PIOS_SPI_PRESCALER_64,
.max_downsample = 2 .max_downsample = 2
}; };
const struct pios_mpu6000_cfg *PIOS_BOARD_HW_DEFS_GetMPU6000Cfg(__attribute__((unused)) uint32_t board_revision)
{
return &pios_mpu6000_cfg;
}
#endif /* PIOS_INCLUDE_MPU6000 */ #endif /* PIOS_INCLUDE_MPU6000 */

View File

@ -38,11 +38,9 @@
#ifdef PIOS_INCLUDE_INSTRUMENTATION #ifdef PIOS_INCLUDE_INSTRUMENTATION
#include <pios_instrumentation.h> #include <pios_instrumentation.h>
#endif #endif
#if defined(PIOS_INCLUDE_ADXL345)
#include <pios_adxl345.h>
#endif
#include <pios_board_io.h> #include <pios_board_io.h>
#include <pios_board_sensors.h>
/* /*
* Pull in the board-specific static HW definitions. * Pull in the board-specific static HW definitions.
@ -133,12 +131,12 @@ void PIOS_Board_Init(void)
switch (bdinfo->board_rev) { switch (bdinfo->board_rev) {
case BOARD_REVISION_CC: case BOARD_REVISION_CC:
if (PIOS_SPI_Init(&pios_spi_flash_accel_id, &pios_spi_flash_accel_cfg_cc)) { if (PIOS_SPI_Init(&pios_spi_flash_accel_adapter_id, &pios_spi_flash_accel_cfg_cc)) {
PIOS_Assert(0); PIOS_Assert(0);
} }
break; break;
case BOARD_REVISION_CC3D: case BOARD_REVISION_CC3D:
if (PIOS_SPI_Init(&pios_spi_flash_accel_id, &pios_spi_flash_accel_cfg_cc3d)) { if (PIOS_SPI_Init(&pios_spi_flash_accel_adapter_id, &pios_spi_flash_accel_cfg_cc3d)) {
PIOS_Assert(0); PIOS_Assert(0);
} }
break; break;
@ -151,7 +149,7 @@ void PIOS_Board_Init(void)
uintptr_t flash_id; uintptr_t flash_id;
switch (bdinfo->board_rev) { switch (bdinfo->board_rev) {
case BOARD_REVISION_CC: case BOARD_REVISION_CC:
if (PIOS_Flash_Jedec_Init(&flash_id, pios_spi_flash_accel_id, 1)) { if (PIOS_Flash_Jedec_Init(&flash_id, pios_spi_flash_accel_adapter_id, 1)) {
PIOS_DEBUG_Assert(0); PIOS_DEBUG_Assert(0);
} }
if (PIOS_FLASHFS_Logfs_Init(&pios_uavo_settings_fs_id, &flashfs_w25x_cfg, &pios_jedec_flash_driver, flash_id)) { if (PIOS_FLASHFS_Logfs_Init(&pios_uavo_settings_fs_id, &flashfs_w25x_cfg, &pios_jedec_flash_driver, flash_id)) {
@ -159,7 +157,7 @@ void PIOS_Board_Init(void)
} }
break; break;
case BOARD_REVISION_CC3D: case BOARD_REVISION_CC3D:
if (PIOS_Flash_Jedec_Init(&flash_id, pios_spi_flash_accel_id, 0)) { if (PIOS_Flash_Jedec_Init(&flash_id, pios_spi_flash_accel_adapter_id, 0)) {
PIOS_DEBUG_Assert(0); PIOS_DEBUG_Assert(0);
} }
if (PIOS_FLASHFS_Logfs_Init(&pios_uavo_settings_fs_id, &flashfs_m25p_cfg, &pios_jedec_flash_driver, flash_id)) { if (PIOS_FLASHFS_Logfs_Init(&pios_uavo_settings_fs_id, &flashfs_m25p_cfg, &pios_jedec_flash_driver, flash_id)) {
@ -238,7 +236,7 @@ void PIOS_Board_Init(void)
PIOS_BOARD_IO_Configure_UART(&pios_usart_flexi_cfg, flexi_function_map[hwsettings_flexiport]); PIOS_BOARD_IO_Configure_UART(&pios_usart_flexi_cfg, flexi_function_map[hwsettings_flexiport]);
} }
switch(hwsettings_flexiport) { switch (hwsettings_flexiport) {
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_flexi_adapter_id, &pios_i2c_flexi_adapter_cfg)) { if (PIOS_I2C_Init(&pios_i2c_flexi_adapter_id, &pios_i2c_flexi_adapter_cfg)) {
@ -341,33 +339,23 @@ void PIOS_Board_Init(void)
switch (bdinfo->board_rev) { switch (bdinfo->board_rev) {
case BOARD_REVISION_CC: case BOARD_REVISION_CC:
// Revision 1 with invensense gyros, start the ADC
#if defined(PIOS_INCLUDE_ADC)
PIOS_ADC_Init(&pios_adc_cfg);
#endif
#if defined(PIOS_INCLUDE_ADXL345)
PIOS_ADXL345_Init(pios_spi_flash_accel_id, 0);
#endif
break; break;
case BOARD_REVISION_CC3D: case BOARD_REVISION_CC3D:
// Revision 2 with MPU6000 gyros, start a SPI interface and connect to it // Revision 2 with MPU6000 gyros, start a SPI interface and connect to it
GPIO_PinRemapConfig(GPIO_Remap_SWJ_JTAGDisable, ENABLE); GPIO_PinRemapConfig(GPIO_Remap_SWJ_JTAGDisable, ENABLE);
#if defined(PIOS_INCLUDE_MPU6000) // Set up the SPI interface to the mpu6000
// Set up the SPI interface to the serial flash if (PIOS_SPI_Init(&pios_spi_gyro_adapter_id, &pios_spi_gyro_cfg)) {
if (PIOS_SPI_Init(&pios_spi_gyro_id, &pios_spi_gyro_cfg)) {
PIOS_Assert(0); PIOS_Assert(0);
} }
PIOS_MPU6000_Init(pios_spi_gyro_id, 0, &pios_mpu6000_cfg);
PIOS_MPU6000_CONFIG_Configure();
init_test = !PIOS_MPU6000_Driver.test(0);
#endif /* PIOS_INCLUDE_MPU6000 */
break; break;
default: default:
PIOS_Assert(0); PIOS_Assert(0);
} }
PIOS_BOARD_Sensors_Configure();
/* Make sure we have at least one telemetry link configured or else fail initialization */ /* Make sure we have at least one telemetry link configured or else fail initialization */
PIOS_Assert(pios_com_telem_rf_id || pios_com_telem_usb_id); PIOS_Assert(pios_com_telem_rf_id || pios_com_telem_usb_id);

View File

@ -117,6 +117,10 @@ extern uint32_t pios_i2c_flexi_adapter_id;
// See also pios_board.c // See also pios_board.c
// ------------------------- // -------------------------
#define PIOS_SPI_MAX_DEVS 2 #define PIOS_SPI_MAX_DEVS 2
extern uint32_t pios_spi_gyro_adapter_id;
#define PIOS_SPI_MPU6000_ADAPTER (pios_spi_gyro_adapter_id)
extern uint32_t pios_spi_flash_accel_adapter_id;
#define PIOS_SPI_ADXL345_ADAPTER (pios_spi_flash_accel_adapter_id)
// ------------------------- // -------------------------
// PIOS_USART // PIOS_USART

View File

@ -343,15 +343,15 @@ static const struct pios_spi_cfg pios_spi_gyro_cfg = {
} }
}; };
static uint32_t pios_spi_gyro_id; uint32_t pios_spi_gyro_adapter_id;
void PIOS_SPI_gyro_irq_handler(void) void PIOS_SPI_gyro_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_SPI_IRQ_Handler(pios_spi_gyro_id); PIOS_SPI_IRQ_Handler(pios_spi_gyro_adapter_id);
} }
#if false #ifdef PIOS_INCLUDE_RFM22B
/* /*
* SPI3 Interface * SPI3 Interface
* Used for Flash and the RFM22B * Used for Flash and the RFM22B
@ -479,11 +479,11 @@ static const struct pios_spi_cfg pios_spi_telem_flash_cfg = {
}, },
}; };
uint32_t pios_spi_telem_flash_id; uint32_t pios_spi_telem_flash_adapter_id;
void PIOS_SPI_telem_flash_irq_handler(void) void PIOS_SPI_telem_flash_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_SPI_IRQ_Handler(pios_spi_telem_flash_id); PIOS_SPI_IRQ_Handler(pios_spi_telem_flash_adapter_id);
} }
@ -1448,7 +1448,6 @@ const struct pios_ms5611_cfg *PIOS_BOARD_HW_DEFS_GetMS5611Cfg(__attribute__((unu
*/ */
#if defined(PIOS_INCLUDE_MPU6000) #if defined(PIOS_INCLUDE_MPU6000)
#include "pios_mpu6000.h" #include "pios_mpu6000.h"
#include "pios_mpu6000_config.h"
static const struct pios_exti_cfg pios_exti_mpu6000_cfg __exti_config = { static const struct pios_exti_cfg pios_exti_mpu6000_cfg __exti_config = {
.vector = PIOS_MPU6000_IRQHandler, .vector = PIOS_MPU6000_IRQHandler,
.line = EXTI_Line4, .line = EXTI_Line4,
@ -1496,6 +1495,10 @@ static const struct pios_mpu6000_cfg pios_mpu6000_cfg = {
.filter = PIOS_MPU6000_LOWPASS_256_HZ, .filter = PIOS_MPU6000_LOWPASS_256_HZ,
.orientation = PIOS_MPU6000_TOP_180DEG .orientation = PIOS_MPU6000_TOP_180DEG
}; };
const struct pios_mpu6000_cfg *PIOS_BOARD_HW_DEFS_GetMPU6000Cfg(__attribute__((unused)) uint32_t board_revision)
{
return &pios_mpu6000_cfg;
}
#endif /* PIOS_INCLUDE_MPU6000 */ #endif /* PIOS_INCLUDE_MPU6000 */

View File

@ -35,6 +35,7 @@
#include <pios_usbhook.h> /* PIOS_USBHOOK_* */ #include <pios_usbhook.h> /* PIOS_USBHOOK_* */
#include <stdbool.h> #include <stdbool.h>
#include <pios_board_init.h> #include <pios_board_init.h>
#include <pios_board_io.h>
extern void FLASH_Download(); extern void FLASH_Download();
void check_bor(); void check_bor();

View File

@ -39,6 +39,7 @@
#endif #endif
#include <pios_board_io.h> #include <pios_board_io.h>
#include <pios_board_sensors.h>
/* /*
* Pull in the board-specific static HW definitions. * Pull in the board-specific static HW definitions.
@ -143,17 +144,20 @@ void PIOS_Board_Init(void)
#endif #endif
#if false #ifdef PIOS_INCLUDE_MPU6000
/* Set up the SPI interface to the gyro/acelerometer */ /* Set up the SPI interface to the gyro/acelerometer */
if (PIOS_SPI_Init(&pios_spi_gyro_id, &pios_spi_gyro_cfg)) { if (PIOS_SPI_Init(&pios_spi_gyro_adapter_id, &pios_spi_gyro_cfg)) {
PIOS_DEBUG_Assert(0); PIOS_DEBUG_Assert(0);
} }
#endif /* PIOS_INCLUDE_MPU6000 */
/* Set up the SPI interface to the flash and rfm22b */ #ifdef PIOS_INCLUDE_RFM22B
if (PIOS_SPI_Init(&pios_spi_telem_flash_id, &pios_spi_telem_flash_cfg)) { /* Set up the SPI interface to the rfm22b */
if (PIOS_SPI_Init(&pios_spi_telem_flash_adapter_id, &pios_spi_telem_flash_cfg)) {
PIOS_DEBUG_Assert(0); PIOS_DEBUG_Assert(0);
} }
#endif #endif /* PIOS_INCLUDE_RFM22B */
#if defined(PIOS_INCLUDE_FLASH) #if defined(PIOS_INCLUDE_FLASH)
/* Connect flash to the appropriate interface and configure it */ /* Connect flash to the appropriate interface and configure it */
uintptr_t flash_id; uintptr_t flash_id;
@ -251,8 +255,6 @@ void PIOS_Board_Init(void)
} }
PIOS_DELAY_WaitmS(50); PIOS_DELAY_WaitmS(50);
} }
PIOS_BOARD_IO_Configure_I2C(pios_i2c_mag_pressure_adapter_id, pios_i2c_flexiport_adapter_id);
#endif #endif
#if defined(PIOS_INCLUDE_USB) #if defined(PIOS_INCLUDE_USB)
@ -288,7 +290,7 @@ void PIOS_Board_Init(void)
uint8_t hwsettings_radioaux; uint8_t hwsettings_radioaux;
HwSettingsRadioAuxStreamGet(&hwsettings_radioaux); HwSettingsRadioAuxStreamGet(&hwsettings_radioaux);
if(hwsettings_radioaux < NELEMENTS(radioaux_function_map)) { if (hwsettings_radioaux < NELEMENTS(radioaux_function_map)) {
PIOS_BOARD_IO_Configure_RFM22B(pios_spi_telem_flash_id, radioaux_function_map[hwsettings_radioaux]); PIOS_BOARD_IO_Configure_RFM22B(pios_spi_telem_flash_id, radioaux_function_map[hwsettings_radioaux]);
} }
#endif /* PIOS_INCLUDE_RFM22B */ #endif /* PIOS_INCLUDE_RFM22B */
@ -357,11 +359,7 @@ void PIOS_Board_Init(void)
PIOS_DEBUG_Init(pios_tim_servoport_all_pins, NELEMENTS(pios_tim_servoport_all_pins)); PIOS_DEBUG_Init(pios_tim_servoport_all_pins, NELEMENTS(pios_tim_servoport_all_pins));
#endif #endif
#if defined(PIOS_INCLUDE_MPU6000) PIOS_BOARD_Sensors_Configure();
PIOS_MPU6000_Init(pios_spi_gyro_id, 0, &pios_mpu6000_cfg);
PIOS_MPU6000_CONFIG_Configure();
PIOS_MPU6000_Register();
#endif
#ifdef PIOS_INCLUDE_WS2811 #ifdef PIOS_INCLUDE_WS2811
PIOS_WS2811_Init(&pios_ws2811_cfg, &pios_ws2811_pin_cfg); PIOS_WS2811_Init(&pios_ws2811_cfg, &pios_ws2811_pin_cfg);
@ -377,8 +375,6 @@ void PIOS_Board_Init(void)
.GPIO_OType = GPIO_OType_OD, .GPIO_OType = GPIO_OType_OD,
}; };
GPIO_Init(GPIOA, &gpioA8); GPIO_Init(GPIOA, &gpioA8);
PIOS_BOARD_IO_Configure_ADC();
#endif // PIOS_INCLUDE_ADC #endif // PIOS_INCLUDE_ADC
} }

View File

@ -86,6 +86,10 @@
// See also pios_board.c // See also pios_board.c
// ------------------------ // ------------------------
#define PIOS_SPI_MAX_DEVS 3 #define PIOS_SPI_MAX_DEVS 3
extern uint32_t pios_spi_telem_flash_adapter_id;
#define PIOS_SPI_RFM22B_ADAPTER (pios_spi_telem_flash_adapter_id)
extern uint32_t pios_spi_gyro_adapter_id;
#define PIOS_SPI_MPU6000_ADAPTER (pios_spi_gyro_adapter_id)
// ------------------------ // ------------------------
// PIOS_WDG // PIOS_WDG
@ -104,10 +108,11 @@
// ------------------------ // ------------------------
#define PIOS_I2C_MAX_DEVS 3 #define PIOS_I2C_MAX_DEVS 3
extern uint32_t pios_i2c_mag_pressure_adapter_id; extern uint32_t pios_i2c_mag_pressure_adapter_id;
#define PIOS_I2C_MAIN_ADAPTER (pios_i2c_mag_pressure_adapter_id) #define PIOS_I2C_HMC5X83_INTERNAL_ADAPTER (pios_i2c_mag_pressure_adapter_id)
extern uint32_t pios_i2c_flexiport_adapter_id; extern uint32_t pios_i2c_flexiport_adapter_id;
#define PIOS_I2C_FLEXI_ADAPTER (pios_i2c_flexiport_adapter_id) #define PIOS_I2C_FLEXI_ADAPTER (pios_i2c_flexiport_adapter_id)
#define PIOS_I2C_ETASV3_ADAPTER (PIOS_I2C_FLEXI_ADAPTER) #define PIOS_I2C_ETASV3_ADAPTER (PIOS_I2C_FLEXI_ADAPTER)
#define PIOS_I2C_EXTERNAL_ADAPTER (PIOS_I2C_FLEXI_ADAPTER)
// ------------------------- // -------------------------
// PIOS_USART // PIOS_USART

View File

@ -464,11 +464,11 @@ static const struct pios_spi_cfg pios_spi_gyro_cfg = {
} }
}; };
static uint32_t pios_spi_gyro_id; uint32_t pios_spi_gyro_adapter_id;
void PIOS_SPI_gyro_irq_handler(void) void PIOS_SPI_gyro_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_SPI_IRQ_Handler(pios_spi_gyro_id); PIOS_SPI_IRQ_Handler(pios_spi_gyro_adapter_id);
} }
@ -599,11 +599,11 @@ static const struct pios_spi_cfg pios_spi_telem_flash_cfg = {
}, },
}; };
uint32_t pios_spi_telem_flash_id; uint32_t pios_spi_telem_flash_adapter_id;
void PIOS_SPI_telem_flash_irq_handler(void) void PIOS_SPI_telem_flash_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_SPI_IRQ_Handler(pios_spi_telem_flash_id); PIOS_SPI_IRQ_Handler(pios_spi_telem_flash_adapter_id);
} }
@ -1738,7 +1738,6 @@ const struct pios_ms5611_cfg *PIOS_BOARD_HW_DEFS_GetMS5611Cfg(__attribute__((unu
*/ */
#if defined(PIOS_INCLUDE_MPU6000) #if defined(PIOS_INCLUDE_MPU6000)
#include "pios_mpu6000.h" #include "pios_mpu6000.h"
#include "pios_mpu6000_config.h"
static const struct pios_exti_cfg pios_exti_mpu6000_cfg __exti_config = { static const struct pios_exti_cfg pios_exti_mpu6000_cfg __exti_config = {
.vector = PIOS_MPU6000_IRQHandler, .vector = PIOS_MPU6000_IRQHandler,
.line = EXTI_Line4, .line = EXTI_Line4,
@ -1789,4 +1788,10 @@ static const struct pios_mpu6000_cfg pios_mpu6000_cfg = {
.std_prescaler = PIOS_SPI_PRESCALER_64, .std_prescaler = PIOS_SPI_PRESCALER_64,
.max_downsample = 20, .max_downsample = 20,
}; };
const struct pios_mpu6000_cfg *PIOS_BOARD_HW_DEFS_GetMPU6000Cfg(__attribute__((unused)) uint32_t board_revision)
{
return &pios_mpu6000_cfg;
}
#endif /* PIOS_INCLUDE_MPU6000 */ #endif /* PIOS_INCLUDE_MPU6000 */

View File

@ -38,6 +38,7 @@
#endif #endif
#include <pios_board_io.h> #include <pios_board_io.h>
#include <pios_board_sensors.h>
/* /*
* Pull in the board-specific static HW definitions. * Pull in the board-specific static HW definitions.
@ -143,12 +144,12 @@ void PIOS_Board_Init(void)
#endif #endif
/* Set up the SPI interface to the gyro/acelerometer */ /* Set up the SPI interface to the gyro/acelerometer */
if (PIOS_SPI_Init(&pios_spi_gyro_id, &pios_spi_gyro_cfg)) { if (PIOS_SPI_Init(&pios_spi_gyro_adapter_id, &pios_spi_gyro_cfg)) {
PIOS_DEBUG_Assert(0); PIOS_DEBUG_Assert(0);
} }
/* Set up the SPI interface to the flash and rfm22b */ /* Set up the SPI interface to the flash and rfm22b */
if (PIOS_SPI_Init(&pios_spi_telem_flash_id, &pios_spi_telem_flash_cfg)) { if (PIOS_SPI_Init(&pios_spi_telem_flash_adapter_id, &pios_spi_telem_flash_cfg)) {
PIOS_DEBUG_Assert(0); PIOS_DEBUG_Assert(0);
} }
@ -157,7 +158,7 @@ void PIOS_Board_Init(void)
uintptr_t flash_id; uintptr_t flash_id;
// Initialize the external USER flash // Initialize the external USER flash
if (PIOS_Flash_Jedec_Init(&flash_id, pios_spi_telem_flash_id, 1)) { if (PIOS_Flash_Jedec_Init(&flash_id, pios_spi_telem_flash_adapter_id, 1)) {
PIOS_DEBUG_Assert(0); PIOS_DEBUG_Assert(0);
} }
@ -246,8 +247,6 @@ void PIOS_Board_Init(void)
} }
PIOS_DELAY_WaitmS(50); PIOS_DELAY_WaitmS(50);
} }
PIOS_BOARD_IO_Configure_I2C(pios_i2c_mag_pressure_adapter_id, pios_i2c_flexiport_adapter_id);
#endif #endif
/* Moved this here to allow DSM binding on flexiport */ /* Moved this here to allow DSM binding on flexiport */
@ -291,8 +290,8 @@ void PIOS_Board_Init(void)
uint8_t hwsettings_radioaux; uint8_t hwsettings_radioaux;
HwSettingsRadioAuxStreamGet(&hwsettings_radioaux); HwSettingsRadioAuxStreamGet(&hwsettings_radioaux);
if(hwsettings_radioaux < NELEMENTS(radioaux_function_map)) { if (hwsettings_radioaux < NELEMENTS(radioaux_function_map)) {
PIOS_BOARD_IO_Configure_RFM22B(pios_spi_telem_flash_id, radioaux_function_map[hwsettings_radioaux]); PIOS_BOARD_IO_Configure_RFM22B(radioaux_function_map[hwsettings_radioaux]);
} }
#endif /* PIOS_INCLUDE_RFM22B */ #endif /* PIOS_INCLUDE_RFM22B */
@ -359,11 +358,7 @@ void PIOS_Board_Init(void)
PIOS_DEBUG_Init(pios_tim_servoport_all_pins, NELEMENTS(pios_tim_servoport_all_pins)); PIOS_DEBUG_Init(pios_tim_servoport_all_pins, NELEMENTS(pios_tim_servoport_all_pins));
#endif #endif
#if defined(PIOS_INCLUDE_MPU6000) PIOS_BOARD_Sensors_Configure();
PIOS_MPU6000_Init(pios_spi_gyro_id, 0, &pios_mpu6000_cfg);
PIOS_MPU6000_CONFIG_Configure();
PIOS_MPU6000_Register();
#endif
#ifdef PIOS_INCLUDE_WS2811 #ifdef PIOS_INCLUDE_WS2811
HwSettingsWS2811LED_OutOptions ws2811_pin_settings; HwSettingsWS2811LED_OutOptions ws2811_pin_settings;
@ -384,8 +379,6 @@ void PIOS_Board_Init(void)
.GPIO_OType = GPIO_OType_OD, .GPIO_OType = GPIO_OType_OD,
}; };
GPIO_Init(GPIOA, &gpioA8); GPIO_Init(GPIOA, &gpioA8);
PIOS_BOARD_IO_Configure_ADC();
#endif // PIOS_INCLUDE_ADC #endif // PIOS_INCLUDE_ADC
DEBUG_PRINTF(2, "Board complete\r\n"); DEBUG_PRINTF(2, "Board complete\r\n");

View File

@ -104,6 +104,10 @@
// See also pios_board.c // See also pios_board.c
// ------------------------ // ------------------------
#define PIOS_SPI_MAX_DEVS 3 #define PIOS_SPI_MAX_DEVS 3
extern uint32_t pios_spi_gyro_adapter_id;
#define PIOS_SPI_MPU6000_ADAPTER (pios_spi_gyro_adapter_id)
extern uint32_t pios_spi_telem_flash_adapter_id;
#define PIOS_SPI_RFM22B_ADAPTER (pios_spi_telem_flash_adapter_id)
// ------------------------ // ------------------------
// PIOS_WDG // PIOS_WDG
@ -122,11 +126,13 @@
// ------------------------ // ------------------------
#define PIOS_I2C_MAX_DEVS 3 #define PIOS_I2C_MAX_DEVS 3
extern uint32_t pios_i2c_mag_pressure_adapter_id; extern uint32_t pios_i2c_mag_pressure_adapter_id;
#define PIOS_I2C_MAIN_ADAPTER (pios_i2c_mag_pressure_adapter_id) #define PIOS_I2C_HMC5X83_INTERNAL_ADAPTER (pios_i2c_mag_pressure_adapter_id)
#define PIOS_I2C_MS5611_INTERNAL_ADAPTER (pios_i2c_mag_pressure_adapter_id)
extern uint32_t pios_i2c_flexiport_adapter_id; extern uint32_t pios_i2c_flexiport_adapter_id;
#define PIOS_I2C_FLEXI_ADAPTER (pios_i2c_flexiport_adapter_id) #define PIOS_I2C_FLEXI_ADAPTER (pios_i2c_flexiport_adapter_id)
#define PIOS_I2C_ETASV3_ADAPTER (PIOS_I2C_FLEXI_ADAPTER) #define PIOS_I2C_ETASV3_ADAPTER (PIOS_I2C_FLEXI_ADAPTER)
#define PIOS_I2C_MS4525DO_ADAPTER (PIOS_I2C_FLEXI_ADAPTER) #define PIOS_I2C_MS4525DO_ADAPTER (PIOS_I2C_FLEXI_ADAPTER)
#define PIOS_I2C_EXTERNAL_ADAPTER (PIOS_I2C_FLEXI_ADAPTER)
// ------------------------- // -------------------------
// PIOS_USART // PIOS_USART

View File

@ -115,8 +115,8 @@ const struct pios_gpio_cfg *PIOS_BOARD_HW_DEFS_GetLedCfg(__attribute__((unused))
#include <pios_spi_priv.h> #include <pios_spi_priv.h>
/* /*
* SPI1 Interface * SPI2 Interface
* Used for MPU6000 gyro and accelerometer * Used for MPU9250 gyro and accelerometer
*/ */
void PIOS_SPI_gyro_irq_handler(void); void PIOS_SPI_gyro_irq_handler(void);
void DMA1_Stream3_IRQHandler(void) __attribute__((alias("PIOS_SPI_gyro_irq_handler"))); void DMA1_Stream3_IRQHandler(void) __attribute__((alias("PIOS_SPI_gyro_irq_handler")));
@ -229,11 +229,11 @@ static const struct pios_spi_cfg pios_spi_gyro_cfg = {
} }
}; };
static uint32_t pios_spi_gyro_id; uint32_t pios_spi_gyro_adapter_id;
void PIOS_SPI_gyro_irq_handler(void) void PIOS_SPI_gyro_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_SPI_IRQ_Handler(pios_spi_gyro_id); PIOS_SPI_IRQ_Handler(pios_spi_gyro_adapter_id);
} }
#endif /* PIOS_INCLUDE_SPI */ #endif /* PIOS_INCLUDE_SPI */
@ -329,7 +329,7 @@ __attribute__((alias("PIOS_I2C_pressure_adapter_ev_irq_handler")));
void I2C3_ER_IRQHandler() void I2C3_ER_IRQHandler()
__attribute__((alias("PIOS_I2C_pressure_adapter_er_irq_handler"))); __attribute__((alias("PIOS_I2C_pressure_adapter_er_irq_handler")));
static const struct pios_i2c_adapter_cfg pios_i2c_pressure_adapter_cfg = { static const struct pios_i2c_adapter_cfg pios_i2c_eeprom_pressure_adapter_cfg = {
.regs = I2C3, .regs = I2C3,
.remapSCL = GPIO_AF_I2C3, .remapSCL = GPIO_AF_I2C3,
.remapSDA = GPIO_AF9_I2C3, .remapSDA = GPIO_AF9_I2C3,
@ -382,17 +382,17 @@ static const struct pios_i2c_adapter_cfg pios_i2c_pressure_adapter_cfg = {
}, },
}; };
uint32_t pios_i2c_pressure_adapter_id; uint32_t pios_i2c_eeprom_pressure_adapter_id;
void PIOS_I2C_pressure_adapter_ev_irq_handler(void) void PIOS_I2C_pressure_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_pressure_adapter_id); PIOS_I2C_EV_IRQ_Handler(pios_i2c_eeprom_pressure_adapter_id);
} }
void PIOS_I2C_pressure_adapter_er_irq_handler(void) void PIOS_I2C_pressure_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_pressure_adapter_id); PIOS_I2C_ER_IRQ_Handler(pios_i2c_eeprom_pressure_adapter_id);
} }
@ -937,7 +937,6 @@ struct pios_flash_eeprom_cfg flash_main_chip_cfg = {
*/ */
#if defined(PIOS_INCLUDE_ADC) #if defined(PIOS_INCLUDE_ADC)
#include "pios_adc_priv.h" #include "pios_adc_priv.h"
@ -1019,7 +1018,6 @@ const struct pios_ms5611_cfg *PIOS_BOARD_HW_DEFS_GetMS5611Cfg(__attribute__((unu
*/ */
#if defined(PIOS_INCLUDE_MPU9250) #if defined(PIOS_INCLUDE_MPU9250)
#include "pios_mpu9250.h" #include "pios_mpu9250.h"
#include "pios_mpu9250_config.h"
static const struct pios_exti_cfg pios_exti_mpu9250_cfg __exti_config = { static const struct pios_exti_cfg pios_exti_mpu9250_cfg __exti_config = {
.vector = PIOS_MPU9250_IRQHandler, .vector = PIOS_MPU9250_IRQHandler,
.line = EXTI_Line15, .line = EXTI_Line15,
@ -1070,4 +1068,9 @@ static const struct pios_mpu9250_cfg pios_mpu9250_cfg = {
.std_prescaler = PIOS_SPI_PRESCALER_64, .std_prescaler = PIOS_SPI_PRESCALER_64,
.max_downsample = 26, .max_downsample = 26,
}; };
const struct pios_mpu9250_cfg *PIOS_BOARD_HW_DEFS_GetMPU9250Cfg(__attribute__((unused)) uint32_t board_revision)
{
return &pios_mpu9250_cfg;
}
#endif /* PIOS_INCLUDE_MPU9250 */ #endif /* PIOS_INCLUDE_MPU9250 */

View File

@ -41,6 +41,7 @@
#endif #endif
#include <pios_board_io.h> #include <pios_board_io.h>
#include <pios_board_sensors.h>
/* /*
* Pull in the board-specific static HW definitions. * Pull in the board-specific static HW definitions.
@ -129,18 +130,12 @@ void PIOS_Board_Init(void)
#endif #endif
/* Set up the SPI interface to the gyro/acelerometer */ /* Set up the SPI interface to the gyro/acelerometer */
if (PIOS_SPI_Init(&pios_spi_gyro_id, &pios_spi_gyro_cfg)) { if (PIOS_SPI_Init(&pios_spi_gyro_adapter_id, &pios_spi_gyro_cfg)) {
PIOS_DEBUG_Assert(0); PIOS_DEBUG_Assert(0);
} }
#if false
/* Set up the SPI interface to the flash and rfm22b */
if (PIOS_SPI_Init(&pios_spi_telem_flash_id, &pios_spi_telem_flash_cfg)) {
PIOS_DEBUG_Assert(0);
}
#endif
#ifdef PIOS_INCLUDE_I2C #ifdef PIOS_INCLUDE_I2C
if (PIOS_I2C_Init(&pios_i2c_pressure_adapter_id, &pios_i2c_pressure_adapter_cfg)) { if (PIOS_I2C_Init(&pios_i2c_eeprom_pressure_adapter_id, &pios_i2c_eeprom_pressure_adapter_cfg)) {
PIOS_DEBUG_Assert(0); PIOS_DEBUG_Assert(0);
} }
#endif #endif
@ -150,7 +145,7 @@ void PIOS_Board_Init(void)
uintptr_t flash_id = 0; uintptr_t flash_id = 0;
// Initialize the external USER flash // Initialize the external USER flash
if (PIOS_Flash_EEPROM_Init(&flash_id, &flash_main_chip_cfg, pios_i2c_pressure_adapter_id, 0x50)) { if (PIOS_Flash_EEPROM_Init(&flash_id, &flash_main_chip_cfg, pios_i2c_eeprom_pressure_adapter_id, 0x50)) {
PIOS_DEBUG_Assert(0); PIOS_DEBUG_Assert(0);
} }
@ -317,16 +312,7 @@ void PIOS_Board_Init(void)
PIOS_DELAY_WaitmS(50); PIOS_DELAY_WaitmS(50);
#if defined(PIOS_INCLUDE_ADC) PIOS_BOARD_Sensors_Configure();
PIOS_BOARD_IO_Configure_ADC();
#endif
#if defined(PIOS_INCLUDE_MPU9250)
PIOS_MPU9250_Init(pios_spi_gyro_id, 0, &pios_mpu9250_cfg);
PIOS_MPU9250_CONFIG_Configure();
PIOS_MPU9250_MainRegister();
PIOS_MPU9250_MagRegister();
#endif
// Attach the board config check hook // Attach the board config check hook
SANITYCHECK_AttachHook(&RevoNanoConfigHook); SANITYCHECK_AttachHook(&RevoNanoConfigHook);

View File

@ -104,7 +104,8 @@
// See also pios_board.c // See also pios_board.c
// ------------------------ // ------------------------
#define PIOS_SPI_MAX_DEVS 3 #define PIOS_SPI_MAX_DEVS 3
extern uint32_t pios_spi_gyro_adapter_id;
#define PIOS_SPI_MPU9250_ADAPTER (pios_spi_gyro_adapter_id)
// ------------------------ // ------------------------
// PIOS_WDG // PIOS_WDG
// ------------------------ // ------------------------
@ -121,12 +122,13 @@
// See also pios_board.c // See also pios_board.c
// ------------------------ // ------------------------
#define PIOS_I2C_MAX_DEVS 3 #define PIOS_I2C_MAX_DEVS 3
extern uint32_t pios_i2c_mag_pressure_adapter_id; extern uint32_t pios_i2c_eeprom_pressure_adapter_id;
#define PIOS_I2C_MAIN_ADAPTER (pios_i2c_mag_pressure_adapter_id) #define PIOS_I2C_MS5611_INTERNAL_ADAPTER (pios_i2c_eeprom_pressure_adapter_id)
extern uint32_t pios_i2c_flexiport_adapter_id; extern uint32_t pios_i2c_flexiport_adapter_id;
#define PIOS_I2C_FLEXI_ADAPTER (pios_i2c_flexiport_adapter_id) #define PIOS_I2C_FLEXI_ADAPTER (pios_i2c_flexiport_adapter_id)
#define PIOS_I2C_ETASV3_ADAPTER (PIOS_I2C_FLEXI_ADAPTER) #define PIOS_I2C_ETASV3_ADAPTER (PIOS_I2C_FLEXI_ADAPTER)
#define PIOS_I2C_MS4525DO_ADAPTER (PIOS_I2C_FLEXI_ADAPTER) #define PIOS_I2C_MS4525DO_ADAPTER (PIOS_I2C_FLEXI_ADAPTER)
#define PIOS_I2C_EXTERNAL_ADAPTER (PIOS_I2C_FLEXI_ADAPTER)
// ------------------------- // -------------------------
// PIOS_USART // PIOS_USART

View File

@ -254,11 +254,11 @@ static const struct pios_spi_cfg pios_spi_gyro_cfg = {
} }
}; };
static uint32_t pios_spi_gyro_id; uint32_t pios_spi_gyro_adapter_id;
void PIOS_SPI_gyro_irq_handler(void) void PIOS_SPI_gyro_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_SPI_IRQ_Handler(pios_spi_gyro_id); PIOS_SPI_IRQ_Handler(pios_spi_gyro_adapter_id);
} }
@ -389,11 +389,11 @@ static const struct pios_spi_cfg pios_spi_telem_flash_cfg = {
}, },
}; };
uint32_t pios_spi_telem_flash_id; uint32_t pios_spi_telem_flash_adapter_id;
void PIOS_SPI_telem_flash_irq_handler(void) void PIOS_SPI_telem_flash_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_SPI_IRQ_Handler(pios_spi_telem_flash_id); PIOS_SPI_IRQ_Handler(pios_spi_telem_flash_adapter_id);
} }
@ -642,14 +642,14 @@ static const struct pios_usart_cfg pios_usart_rcvr_cfg = {
/* /*
* I2C Adapters * I2C Adapters
*/ */
void PIOS_i2c_mag_pressure_adapter_ev_irq_handler(void); void PIOS_i2c_pressure_adapter_ev_irq_handler(void);
void PIOS_i2c_mag_pressure_adapter_er_irq_handler(void); void PIOS_i2c_pressure_adapter_er_irq_handler(void);
void I2C1_EV_IRQHandler() void I2C1_EV_IRQHandler()
__attribute__((alias("PIOS_i2c_mag_pressure_adapter_ev_irq_handler"))); __attribute__((alias("PIOS_i2c_pressure_adapter_ev_irq_handler")));
void I2C1_ER_IRQHandler() void I2C1_ER_IRQHandler()
__attribute__((alias("PIOS_i2c_mag_pressure_adapter_er_irq_handler"))); __attribute__((alias("PIOS_i2c_pressure_adapter_er_irq_handler")));
static const struct pios_i2c_adapter_cfg pios_i2c_mag_pressure_adapter_cfg = { static const struct pios_i2c_adapter_cfg pios_i2c_pressure_adapter_cfg = {
.regs = I2C1, .regs = I2C1,
.remapSCL = GPIO_AF_I2C1, .remapSCL = GPIO_AF_I2C1,
.remapSDA = GPIO_AF_I2C1, .remapSDA = GPIO_AF_I2C1,
@ -702,17 +702,17 @@ static const struct pios_i2c_adapter_cfg pios_i2c_mag_pressure_adapter_cfg = {
}, },
}; };
uint32_t pios_i2c_mag_pressure_adapter_id; uint32_t pios_i2c_pressure_adapter_id;
void PIOS_i2c_mag_pressure_adapter_ev_irq_handler(void) void PIOS_i2c_pressure_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_mag_pressure_adapter_id); PIOS_I2C_EV_IRQ_Handler(pios_i2c_pressure_adapter_id);
} }
void PIOS_i2c_mag_pressure_adapter_er_irq_handler(void) void PIOS_i2c_pressure_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_mag_pressure_adapter_id); PIOS_I2C_ER_IRQ_Handler(pios_i2c_pressure_adapter_id);
} }
@ -788,8 +788,8 @@ void PIOS_I2C_flexiport_adapter_er_irq_handler(void)
} }
void PIOS_i2c_mag_pressure_adapter_ev_irq_handler(void); void PIOS_i2c_pressure_adapter_ev_irq_handler(void);
void PIOS_i2c_mag_pressure_adapter_er_irq_handler(void); void PIOS_i2c_pressure_adapter_er_irq_handler(void);
#endif /* PIOS_INCLUDE_I2C */ #endif /* PIOS_INCLUDE_I2C */
@ -1307,7 +1307,6 @@ const struct pios_ms5611_cfg *PIOS_BOARD_HW_DEFS_GetMS5611Cfg(__attribute__((unu
*/ */
#if defined(PIOS_INCLUDE_MPU9250) #if defined(PIOS_INCLUDE_MPU9250)
#include "pios_mpu9250.h" #include "pios_mpu9250.h"
#include "pios_mpu9250_config.h"
static const struct pios_exti_cfg pios_exti_mpu9250_cfg __exti_config = { static const struct pios_exti_cfg pios_exti_mpu9250_cfg __exti_config = {
.vector = PIOS_MPU9250_IRQHandler, .vector = PIOS_MPU9250_IRQHandler,
.line = EXTI_Line5, .line = EXTI_Line5,
@ -1358,5 +1357,9 @@ static const struct pios_mpu9250_cfg pios_mpu9250_cfg = {
.std_prescaler = PIOS_SPI_PRESCALER_64, .std_prescaler = PIOS_SPI_PRESCALER_64,
.max_downsample = 26, .max_downsample = 26,
}; };
#endif /* PIOS_INCLUDE_MPU9250 */
const struct pios_mpu9250_cfg *PIOS_BOARD_HW_DEFS_GetMPU9250Cfg(__attribute__((unused)) uint32_t board_revision)
{
return &pios_mpu9250_cfg;
}
#endif /* PIOS_INCLUDE_MPU9250 */

View File

@ -41,7 +41,7 @@
#endif #endif
#include <pios_board_io.h> #include <pios_board_io.h>
#include <pios_board_sensors.h>
/* /*
* Pull in the board-specific static HW definitions. * Pull in the board-specific static HW definitions.
@ -140,12 +140,12 @@ void PIOS_Board_Init(void)
#endif #endif
/* Set up the SPI interface to the gyro/acelerometer */ /* Set up the SPI interface to the gyro/acelerometer */
if (PIOS_SPI_Init(&pios_spi_gyro_id, &pios_spi_gyro_cfg)) { if (PIOS_SPI_Init(&pios_spi_gyro_adapter_id, &pios_spi_gyro_cfg)) {
PIOS_DEBUG_Assert(0); PIOS_DEBUG_Assert(0);
} }
/* Set up the SPI interface to the flash and rfm22b */ /* Set up the SPI interface to the flash and rfm22b */
if (PIOS_SPI_Init(&pios_spi_telem_flash_id, &pios_spi_telem_flash_cfg)) { if (PIOS_SPI_Init(&pios_spi_telem_flash_adapter_id, &pios_spi_telem_flash_cfg)) {
PIOS_DEBUG_Assert(0); PIOS_DEBUG_Assert(0);
} }
@ -154,7 +154,7 @@ void PIOS_Board_Init(void)
uintptr_t flash_id = 0; uintptr_t flash_id = 0;
// Initialize the external USER flash // Initialize the external USER flash
if (PIOS_Flash_Jedec_Init(&flash_id, pios_spi_telem_flash_id, 1)) { if (PIOS_Flash_Jedec_Init(&flash_id, pios_spi_telem_flash_adapter_id, 1)) {
PIOS_DEBUG_Assert(0); PIOS_DEBUG_Assert(0);
} }
@ -231,7 +231,7 @@ void PIOS_Board_Init(void)
#if defined(PIOS_INCLUDE_I2C) #if defined(PIOS_INCLUDE_I2C)
/* Set up internal I2C bus */ /* Set up internal I2C bus */
if (PIOS_I2C_Init(&pios_i2c_mag_pressure_adapter_id, &pios_i2c_mag_pressure_adapter_cfg)) { if (PIOS_I2C_Init(&pios_i2c_pressure_adapter_id, &pios_i2c_pressure_adapter_cfg)) {
PIOS_DEBUG_Assert(0); PIOS_DEBUG_Assert(0);
} }
PIOS_DELAY_WaitmS(50); PIOS_DELAY_WaitmS(50);
@ -242,8 +242,6 @@ void PIOS_Board_Init(void)
} }
PIOS_DELAY_WaitmS(50); PIOS_DELAY_WaitmS(50);
} }
PIOS_BOARD_IO_Configure_I2C(pios_i2c_mag_pressure_adapter_id, pios_i2c_flexiport_adapter_id);
#endif #endif
/* Moved this here to allow binding on flexiport */ /* Moved this here to allow binding on flexiport */
@ -259,6 +257,7 @@ void PIOS_Board_Init(void)
uint8_t hwsettings_mainport; uint8_t hwsettings_mainport;
HwSettingsSPK2_MainPortGet(&hwsettings_mainport); HwSettingsSPK2_MainPortGet(&hwsettings_mainport);
if (hwsettings_mainport < NELEMENTS(main_function_map)) { if (hwsettings_mainport < NELEMENTS(main_function_map)) {
PIOS_BOARD_IO_Configure_UART(&pios_usart_main_cfg, main_function_map[hwsettings_mainport]); PIOS_BOARD_IO_Configure_UART(&pios_usart_main_cfg, main_function_map[hwsettings_mainport]);
} }
@ -267,8 +266,8 @@ void PIOS_Board_Init(void)
uint8_t hwsettings_radioaux; uint8_t hwsettings_radioaux;
HwSettingsRadioAuxStreamGet(&hwsettings_radioaux); HwSettingsRadioAuxStreamGet(&hwsettings_radioaux);
if(hwsettings_radioaux < NELEMENTS(radioaux_function_map)) { if (hwsettings_radioaux < NELEMENTS(radioaux_function_map)) {
PIOS_BOARD_IO_Configure_RFM22B(pios_spi_telem_flash_id, radioaux_function_map[hwsettings_radioaux]); PIOS_BOARD_IO_Configure_RFM22B(radioaux_function_map[hwsettings_radioaux]);
} }
#endif /* PIOS_INCLUDE_RFM22B */ #endif /* PIOS_INCLUDE_RFM22B */
@ -301,7 +300,7 @@ void PIOS_Board_Init(void)
} }
#if defined(PIOS_INCLUDE_PPM) #if defined(PIOS_INCLUDE_PPM)
if(hwsettings_rcvrport == HWSETTINGS_SPK2_RCVRPORT_PPM) { if (hwsettings_rcvrport == HWSETTINGS_SPK2_RCVRPORT_PPM) {
PIOS_BOARD_IO_Configure_PPM(&pios_ppm_cfg); PIOS_BOARD_IO_Configure_PPM(&pios_ppm_cfg);
} }
#endif #endif
@ -316,12 +315,7 @@ void PIOS_Board_Init(void)
PIOS_DEBUG_Init(pios_tim_servoport_all_pins, NELEMENTS(pios_tim_servoport_all_pins)); PIOS_DEBUG_Init(pios_tim_servoport_all_pins, NELEMENTS(pios_tim_servoport_all_pins));
#endif #endif
#if defined(PIOS_INCLUDE_MPU9250) PIOS_BOARD_Sensors_Configure();
PIOS_MPU9250_Init(pios_spi_gyro_id, 0, &pios_mpu9250_cfg);
PIOS_MPU9250_CONFIG_Configure();
PIOS_MPU9250_MainRegister();
PIOS_MPU9250_MagRegister();
#endif
#ifdef PIOS_INCLUDE_WS2811 #ifdef PIOS_INCLUDE_WS2811
HwSettingsWS2811LED_OutOptions ws2811_pin_settings; HwSettingsWS2811LED_OutOptions ws2811_pin_settings;
@ -342,10 +336,7 @@ void PIOS_Board_Init(void)
.GPIO_OType = GPIO_OType_OD, .GPIO_OType = GPIO_OType_OD,
}; };
GPIO_Init(GPIOA, &gpioA8); GPIO_Init(GPIOA, &gpioA8);
PIOS_BOARD_IO_Configure_ADC();
#endif /* PIOS_INCLUDE_ADC */ #endif /* PIOS_INCLUDE_ADC */
} }
/** /**

View File

@ -106,6 +106,10 @@
// See also pios_board.c // See also pios_board.c
// ------------------------ // ------------------------
#define PIOS_SPI_MAX_DEVS 3 #define PIOS_SPI_MAX_DEVS 3
extern uint32_t pios_spi_telem_flash_adapter_id;
#define PIOS_SPI_RFM22B_ADAPTER (pios_spi_telem_flash_adapter_id)
extern uint32_t pios_spi_gyro_adapter_id;
#define PIOS_SPI_MPU9250_ADAPTER (pios_spi_gyro_adapter_id)
// ------------------------ // ------------------------
// PIOS_WDG // PIOS_WDG
@ -123,8 +127,9 @@
// See also pios_board.c // See also pios_board.c
// ------------------------ // ------------------------
#define PIOS_I2C_MAX_DEVS 3 #define PIOS_I2C_MAX_DEVS 3
extern uint32_t pios_i2c_mag_pressure_adapter_id; extern uint32_t pios_i2c_pressure_adapter_id;
#define PIOS_I2C_MAIN_ADAPTER (pios_i2c_mag_pressure_adapter_id) #define PIOS_I2C_MS5611_INTERNAL_ADAPTER (pios_i2c_pressure_adapter_id)
#define PIOS_I2C_EXTERNAL_ADAPTER (pios_i2c_pressure_adapter_id)
extern uint32_t pios_i2c_flexiport_adapter_id; extern uint32_t pios_i2c_flexiport_adapter_id;
#define PIOS_I2C_FLEXI_ADAPTER (pios_i2c_flexiport_adapter_id) #define PIOS_I2C_FLEXI_ADAPTER (pios_i2c_flexiport_adapter_id)
#define PIOS_I2C_ETASV3_ADAPTER (PIOS_I2C_FLEXI_ADAPTER) #define PIOS_I2C_ETASV3_ADAPTER (PIOS_I2C_FLEXI_ADAPTER)