px4fmu-v4pro : board configuration

This commit is contained in:
klopezal 2017-01-24 18:16:51 +01:00 committed by Lorenz Meier
parent b14cb952ae
commit 089e50c574
4 changed files with 66 additions and 25 deletions

View File

@ -627,7 +627,7 @@ CONFIG_BOOT_RUNFROMFLASH=y
# Boot Memory Configuration
#
CONFIG_RAM_START=0x20000000
CONFIG_RAM_SIZE=327680
CONFIG_RAM_SIZE=393216
# CONFIG_ARCH_HAVE_SDRAM is not set
#

View File

@ -95,10 +95,11 @@ __BEGIN_DECLS
/* SPI Bus 1 Internal Sensors */
#define GPIO_SPI_CS_MPU9250 (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_2MHz|GPIO_OUTPUT_SET|GPIO_PORTC|GPIO_PIN2)
#define GPIO_SPI_CS_LIS3MDL (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_2MHz|GPIO_OUTPUT_SET|GPIO_PORTE|GPIO_PIN15)
#define GPIO_SPI_CS_MS5611 (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_2MHz|GPIO_OUTPUT_SET|GPIO_PORTD|GPIO_PIN7)
#define GPIO_SPI_CS_ICM_20608_G (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_2MHz|GPIO_OUTPUT_SET|GPIO_PORTC|GPIO_PIN15)
#define GPIO_SPI_CS_MPU9250 (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_2MHz|GPIO_OUTPUT_SET|GPIO_PORTC|GPIO_PIN2)
#define GPIO_SPI_CS_LIS3MDL (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_2MHz|GPIO_OUTPUT_SET|GPIO_PORTE|GPIO_PIN15)
#define GPIO_SPI_CS_MS5611 (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_2MHz|GPIO_OUTPUT_SET|GPIO_PORTD|GPIO_PIN7)
#define GPIO_SPI_CS_ICM_20608_G (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_2MHz|GPIO_OUTPUT_SET|GPIO_PORTC|GPIO_PIN15)
#define GPIO_SPI_CS_TEMPCAL_EEPROM (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_2MHz|GPIO_OUTPUT_SET|GPIO_PORTH|GPIO_PIN5)
/* SPI Bus 2 Memory */
@ -133,10 +134,11 @@ __BEGIN_DECLS
#define _PIN_OFF(def) (((def) & (GPIO_PORT_MASK | GPIO_PIN_MASK)) | (GPIO_INPUT|GPIO_PULLDOWN|GPIO_SPEED_2MHz))
#define GPIO_SPI_CS_OFF_MPU9250 _PIN_OFF(GPIO_SPI_CS_MPU9250)
#define GPIO_SPI_CS_OFF_LIS3MDL _PIN_OFF(GPIO_SPI_CS_LIS3MDL)
#define GPIO_SPI_CS_OFF_MS5611 _PIN_OFF(GPIO_SPI_CS_MS5611)
#define GPIO_SPI_CS_OFF_ICM_20608_G _PIN_OFF(GPIO_SPI_CS_ICM_20608_G)
#define GPIO_SPI_CS_OFF_MPU9250 _PIN_OFF(GPIO_SPI_CS_MPU9250)
#define GPIO_SPI_CS_OFF_LIS3MDL _PIN_OFF(GPIO_SPI_CS_LIS3MDL)
#define GPIO_SPI_CS_OFF_MS5611 _PIN_OFF(GPIO_SPI_CS_MS5611)
#define GPIO_SPI_CS_OFF_ICM_20608_G _PIN_OFF(GPIO_SPI_CS_ICM_20608_G)
#define GPIO_SPI_CS_OFF_TEMPCAL_EEPROM _PIN_OFF(GPIO_SPI_CS_OFF_TEMPCAL_EEPROM)
#define GPIO_DRDY_OFF_MPU9250 _PIN_OFF(GPIO_DRDY_MPU9250)
#define GPIO_DRDY_OFF_LIS3MDL _PIN_OFF(GPIO_DRDY_LIS3MDL)
@ -168,6 +170,7 @@ __BEGIN_DECLS
#define PX4_SPIDEV_BMA 9
#define PX4_SPIDEV_EXT0 10
#define PX4_SPIDEV_EXT1 11
#define PX4_SPIDEV_EEPROM 12
/* I2C busses */
@ -193,10 +196,22 @@ __BEGIN_DECLS
// ADC defines to be used in sensors.cpp to read from a particular channel
#define ADC_BATTERY_VOLTAGE_CHANNEL 2
#define ADC_BATTERY_CURRENT_CHANNEL 3
//#define ADC_BATTERY_VOLTAGE_CHANNEL2 4
//#define ADC_BATTERY_CURRENT_CHANNEL2 5
#define ADC_5V_RAIL_SENSE 4
#define ADC_RC_RSSI_CHANNEL 11
#define ADC_BATTERY2_VOLTAGE_CHANNEL 11
#define ADC_BATTERY2_CURRENT_CHANNEL 13
//#define ADC_RC_RSSI_CHANNEL 11
/* Define Battery 1 Voltage Divider and A per V
*/
#define BOARD_BATTERY1_V_DIV (6.490196078f)
#define BOARD_BATTERY1_A_PER_V (26.4f)
/* Define Battery 2 Voltage Divider and A per V
*/
#define BOARD_BATTERY2_V_DIV (6.490196078f)
#define BOARD_BATTERY2_A_PER_V (26.4f)
/* User GPIOs
*
@ -221,8 +236,9 @@ __BEGIN_DECLS
#define GPIO_VDD_BRICK2_VALID (GPIO_INPUT|GPIO_PULLUP|GPIO_PORTG|GPIO_PIN5)
#define GPIO_VDD_3V3_SENSORS_EN (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_2MHz|GPIO_OUTPUT_SET|GPIO_PORTE|GPIO_PIN3)
#define GPIO_VDD_3V3_PERIPH_EN (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_2MHz|GPIO_OUTPUT_SET|GPIO_PORTC|GPIO_PIN5)
#define GPIO_VDD_5V_PERIPH_EN (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_2MHz|GPIO_OUTPUT_CLEAR|GPIO_PORTG|GPIO_PIN10)
#define GPIO_VDD_5V_PERIPH_OC (GPIO_INPUT|GPIO_PULLUP|GPIO_PORTG|GPIO_PIN4)
#define GPIO_VDD_5V_RC_OC (GPIO_INPUT|GPIO_PULLUP|GPIO_PORTF|GPIO_PIN3)
#define GPIO_VDD_5V_HIPOWER_OC (GPIO_INPUT|GPIO_PULLUP|GPIO_PORTF|GPIO_PIN3)
#define GPIO_VBUS_VALID (GPIO_INPUT|GPIO_PULLUP|GPIO_PORTC|GPIO_PIN0)
/* Tone alarm output */
@ -283,8 +299,6 @@ __BEGIN_DECLS
#define GPIO_RSSI_IN (GPIO_INPUT|GPIO_PULLUP|GPIO_PORTC|GPIO_PIN1)
#define GPIO_LED_SAFETY (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_2MHz|GPIO_OUTPUT_SET|GPIO_PORTC|GPIO_PIN3)
#define GPIO_BTN_SAFETY (GPIO_INPUT|GPIO_PULLUP|GPIO_PORTC|GPIO_PIN4)
//#define GPIO_PERIPH_3V3_EN (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_2MHz|GPIO_OUTPUT_SET|GPIO_PORTC|GPIO_PIN5)
/* for R12, this signal is active high */
#define GPIO_SBUS_INV (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_2MHz|GPIO_OUTPUT_SET|GPIO_PORTC|GPIO_PIN13)
#define INVERT_RC_INPUT(_s) px4_arch_gpiowrite(GPIO_SBUS_INV, _s)
@ -315,7 +329,7 @@ __BEGIN_DECLS
#define BOARD_ADC_BRICK2_VALID (px4_arch_gpioread(GPIO_VDD_BRICK2_VALID))
#define BOARD_ADC_SERVO_VALID (1)
#define BOARD_ADC_PERIPH_5V_OC (px4_arch_gpioread(GPIO_VDD_5V_PERIPH_OC))
#define BOARD_ADC_HIPOWER_5V_OC (0)
#define BOARD_ADC_HIPOWER_5V_OC (px4_arch_gpioread(GPIO_VDD_5V_HIPOWER_OC))
#define BOARD_HAS_PWM DIRECT_PWM_OUTPUT_CHANNELS
@ -331,7 +345,7 @@ __BEGIN_DECLS
{GPIO_VDD_BRICK_VALID, 0, 0}, \
{GPIO_VDD_BRICK2_VALID, 0, 0}, \
{GPIO_VBUS_VALID, 0, 0}, \
{GPIO_VDD_5V_RC_OC, 0, 0}, \
{GPIO_VDD_5V_HIPOWER_OC, 0, 0}, \
{GPIO_VDD_5V_PERIPH_OC, 0, 0}, }
/*
@ -353,7 +367,7 @@ __BEGIN_DECLS
#define GPIO_BRICK2_VALID (1<<9) /**< PG5 - !GPIO_VDD_BRICK2_VALID */
#define GPIO_USB_VBUS_VALID (1<<10) /**< PC0 - !GPIO_VBUS_VALID */
#define GPIO_5V_RC_OC (1<<11) /**< PF3 - !GPIO_VDD_5V_RC_OC */
#define GPIO_5V_HIPOWER_OC (1<<11) /**< PF3 - !GPIO_VDD_5V_RC_OC */
#define GPIO_5V_PERIPH_OC (1<<12) /**< PE10 - !GPIO_VDD_5V_PERIPH_OC */

View File

@ -130,10 +130,11 @@ __END_DECLS
************************************************************************************/
__EXPORT void board_peripheral_reset(int ms)
{
/* set the peripheral rails off */
stm32_configgpio(GPIO_VDD_3V3_PERIPH_EN);
/* set the peripheral and sensor rails off */
stm32_gpiowrite(GPIO_VDD_3V3_PERIPH_EN, 0);
stm32_gpiowrite(GPIO_VDD_3V3_SENSORS_EN, 0);
stm32_gpiowrite(GPIO_VDD_5V_PERIPH_EN, 1);
stm32_gpiowrite(GPIO_VDD_3V3_PERIPH_EN, 0);
// bool last = stm32_gpioread(GPIO_SPEKTRUM_PWR_EN);
/* Keep Spektum on to discharge rail*/
@ -148,7 +149,8 @@ __EXPORT void board_peripheral_reset(int ms)
/* switch the peripheral rail back on */
// stm32_gpiowrite(GPIO_SPEKTRUM_PWR_EN, last);
stm32_gpiowrite(GPIO_VDD_3V3_PERIPH_EN, 1);
stm32_gpiowrite(GPIO_VDD_3V3_SENSORS_EN, 1);
stm32_gpiowrite(GPIO_VDD_5V_PERIPH_EN, 0);
}
/************************************************************************************
@ -168,15 +170,23 @@ stm32_boardinitialize(void)
board_autoled_initialize();
/* configure ADC pins */
//todo:Revisit! ADC3 etc
stm32_configgpio(GPIO_ADC1_IN2); /* BATT_VOLTAGE_SENS */
stm32_configgpio(GPIO_ADC1_IN3); /* BATT_CURRENT_SENS */
stm32_configgpio(GPIO_ADC1_IN4); /* VDD_5V_SENS */
stm32_configgpio(GPIO_ADC1_IN11); /* RSSI analog in */
stm32_configgpio(GPIO_ADC1_IN11); /* BATT2_VOLTAGE_SENS */
stm32_configgpio(GPIO_ADC1_IN13); /* BATT2_CURRENT_SENS */
/* configure power supply control/sense pins */
stm32_configgpio(GPIO_VDD_3V3_PERIPH_EN);
stm32_configgpio(GPIO_VDD_3V3_SENSORS_EN);
stm32_configgpio(GPIO_VDD_5V_PERIPH_EN);
stm32_configgpio(GPIO_VDD_BRICK_VALID);
stm32_configgpio(GPIO_VDD_BRICK2_VALID);
stm32_configgpio(GPIO_VDD_5V_PERIPH_OC);
stm32_configgpio(GPIO_VDD_5V_HIPOWER_OC);
stm32_configgpio(GPIO_VBUS_VALID);
stm32_configgpio(GPIO_SBUS_INV);
stm32_configgpio(GPIO_8266_GPIO0);

View File

@ -76,6 +76,7 @@ __EXPORT void stm32_spiinitialize(void)
stm32_configgpio(GPIO_SPI_CS_LIS3MDL);
stm32_configgpio(GPIO_SPI_CS_MS5611);
stm32_configgpio(GPIO_SPI_CS_ICM_20608_G);
stm32_configgpio(GPIO_SPI_CS_TEMPCAL_EEPROM);
stm32_configgpio(GPIO_DRDY_MPU9250);
stm32_configgpio(GPIO_DRDY_LIS3MDL);
@ -105,6 +106,7 @@ __EXPORT void stm32_spi1select(FAR struct spi_dev_s *dev, enum spi_dev_e devid,
stm32_gpiowrite(GPIO_SPI_CS_LIS3MDL, 1);
stm32_gpiowrite(GPIO_SPI_CS_MS5611, 1);
stm32_gpiowrite(GPIO_SPI_CS_ICM_20608_G, !selected);
stm32_gpiowrite(GPIO_SPI_CS_TEMPCAL_EEPROM, 1);
break;
case PX4_SPIDEV_BARO:
@ -113,6 +115,7 @@ __EXPORT void stm32_spi1select(FAR struct spi_dev_s *dev, enum spi_dev_e devid,
stm32_gpiowrite(GPIO_SPI_CS_LIS3MDL, 1);
stm32_gpiowrite(GPIO_SPI_CS_MS5611, !selected);
stm32_gpiowrite(GPIO_SPI_CS_ICM_20608_G, 1);
stm32_gpiowrite(GPIO_SPI_CS_TEMPCAL_EEPROM, 1);
break;
case PX4_SPIDEV_LIS:
@ -121,6 +124,7 @@ __EXPORT void stm32_spi1select(FAR struct spi_dev_s *dev, enum spi_dev_e devid,
stm32_gpiowrite(GPIO_SPI_CS_LIS3MDL, !selected);
stm32_gpiowrite(GPIO_SPI_CS_MS5611, 1);
stm32_gpiowrite(GPIO_SPI_CS_ICM_20608_G, 1);
stm32_gpiowrite(GPIO_SPI_CS_TEMPCAL_EEPROM, 1);
break;
case PX4_SPIDEV_MPU:
@ -129,7 +133,17 @@ __EXPORT void stm32_spi1select(FAR struct spi_dev_s *dev, enum spi_dev_e devid,
stm32_gpiowrite(GPIO_SPI_CS_LIS3MDL, 1);
stm32_gpiowrite(GPIO_SPI_CS_MS5611, 1);
stm32_gpiowrite(GPIO_SPI_CS_ICM_20608_G, 1);
stm32_gpiowrite(GPIO_SPI_CS_TEMPCAL_EEPROM, 1);
break;
case PX4_SPIDEV_EEPROM:
/* Making sure the other peripherals are not selected */
stm32_gpiowrite(GPIO_SPI_CS_MPU9250, 1);
stm32_gpiowrite(GPIO_SPI_CS_LIS3MDL, 1);
stm32_gpiowrite(GPIO_SPI_CS_MS5611, 1);
stm32_gpiowrite(GPIO_SPI_CS_ICM_20608_G, 1);
stm32_gpiowrite(GPIO_SPI_CS_TEMPCAL_EEPROM, !selected);
break;
default:
break;
@ -204,12 +218,14 @@ __EXPORT void board_spi_reset(int ms)
stm32_configgpio(GPIO_SPI_CS_OFF_LIS3MDL);
stm32_configgpio(GPIO_SPI_CS_OFF_MS5611);
stm32_configgpio(GPIO_SPI_CS_OFF_ICM_20608_G);
stm32_configgpio(GPIO_SPI_CS_TEMPCAL_EEPROM);
stm32_gpiowrite(GPIO_SPI_CS_OFF_MPU9250, 0);
stm32_gpiowrite(GPIO_SPI_CS_OFF_LIS3MDL, 0);
stm32_gpiowrite(GPIO_SPI_CS_OFF_MS5611, 0);
stm32_gpiowrite(GPIO_SPI_CS_OFF_ICM_20608_G, 0);
stm32_gpiowrite(GPIO_SPI_CS_TEMPCAL_EEPROM, 0);
stm32_configgpio(GPIO_SPI1_SCK_OFF);
stm32_configgpio(GPIO_SPI1_MISO_OFF);
stm32_configgpio(GPIO_SPI1_MOSI_OFF);
@ -248,6 +264,7 @@ __EXPORT void board_spi_reset(int ms)
stm32_configgpio(GPIO_SPI_CS_LIS3MDL);
stm32_configgpio(GPIO_SPI_CS_MS5611);
stm32_configgpio(GPIO_SPI_CS_ICM_20608_G);
stm32_configgpio(GPIO_SPI_CS_TEMPCAL_EEPROM);
stm32_configgpio(GPIO_SPI1_SCK);
stm32_configgpio(GPIO_SPI1_MISO);