Skip to content

Commit

Permalink
Merge pull request #2251 from jihlein/matek405
Browse files Browse the repository at this point in the history
Matek405 Target
  • Loading branch information
mlyle authored Jul 4, 2019
2 parents 69f5bf5 + 20d619a commit 42b2f80
Show file tree
Hide file tree
Showing 24 changed files with 4,388 additions and 41 deletions.
43 changes: 24 additions & 19 deletions flight/PiOS/Common/pios_mpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ static const uint8_t pios_mpu_whoami[PIOS_MPU_NUM] = {
[PIOS_MPU9150] = 0x68,
[PIOS_MPU9250] = 0x71,
[PIOS_ICM20608G] = 0xAF,
[PIOS_ICM20602] = 0x12,
[PIOS_ICM20689] = 0x98,
};

/**
Expand Down Expand Up @@ -641,8 +643,7 @@ void PIOS_MPU_SetGyroBandwidth(uint16_t bandwidth)
filter = PIOS_MPU6500_GYRO_LOWPASS_92_HZ;
else
filter = PIOS_MPU6500_GYRO_LOWPASS_184_HZ;
} else if ((mpu_dev->mpu_type == PIOS_MPU60X0) ||
(mpu_dev->mpu_type == PIOS_MPU9150)) {
} else if ((mpu_dev->mpu_type == PIOS_MPU60X0) || (mpu_dev->mpu_type == PIOS_MPU9150)) {
if (bandwidth <= 5)
filter = PIOS_MPU60X0_GYRO_LOWPASS_5_HZ;
else if (bandwidth <= 10)
Expand All @@ -657,23 +658,23 @@ void PIOS_MPU_SetGyroBandwidth(uint16_t bandwidth)
filter = PIOS_MPU60X0_GYRO_LOWPASS_188_HZ;
} else {
if (bandwidth <= 5)
filter = PIOS_ICM20608G_GYRO_LOWPASS_5_HZ;
filter = PIOS_ICM206XX_GYRO_LOWPASS_5_HZ;
else if (bandwidth <= 10)
filter = PIOS_ICM20608G_GYRO_LOWPASS_10_HZ;
filter = PIOS_ICM206XX_GYRO_LOWPASS_10_HZ;
else if (bandwidth <= 20)
filter = PIOS_ICM20608G_GYRO_LOWPASS_20_HZ;
filter = PIOS_ICM206XX_GYRO_LOWPASS_20_HZ;
else if (bandwidth <= 92)
filter = PIOS_ICM20608G_GYRO_LOWPASS_92_HZ;
filter = PIOS_ICM206XX_GYRO_LOWPASS_92_HZ;
else
filter = PIOS_ICM20608G_GYRO_LOWPASS_176_HZ;
filter = PIOS_ICM206XX_GYRO_LOWPASS_176_HZ;
#if 0
/* Unsupported/higher sample rates */
else if (bandwidth <= 176)
filter = PIOS_ICM20608G_GYRO_LOWPASS_176_HZ;
filter = PIOS_ICM206XX_GYRO_LOWPASS_176_HZ;
else if (bandwidth <= 250)
filter = PIOS_ICM20608G_GYRO_LOWPASS_250_HZ;
filter = PIOS_ICM206XX_GYRO_LOWPASS_250_HZ;
else
filter = PIOS_ICM20608G_GYRO_LOWPASS_3281_HZ;
filter = PIOS_ICM206XX_GYRO_LOWPASS_3281_HZ;
#endif
}

Expand All @@ -682,7 +683,11 @@ void PIOS_MPU_SetGyroBandwidth(uint16_t bandwidth)

void PIOS_MPU_SetAccelBandwidth(uint16_t bandwidth)
{
if (mpu_dev->mpu_type != PIOS_MPU6500 && mpu_dev->mpu_type != PIOS_MPU9250 && mpu_dev->mpu_type != PIOS_ICM20608G)
if (mpu_dev->mpu_type != PIOS_MPU6500 &&
mpu_dev->mpu_type != PIOS_MPU9250 &&
mpu_dev->mpu_type != PIOS_ICM20608G &&
mpu_dev->mpu_type != PIOS_ICM20602 &&
mpu_dev->mpu_type != PIOS_ICM20689)
return;

enum pios_mpu6500_accel_filter filter;
Expand All @@ -703,19 +708,19 @@ void PIOS_MPU_SetAccelBandwidth(uint16_t bandwidth)
filter = PIOS_MPU6500_ACCEL_LOWPASS_460_HZ;
} else {
if (bandwidth <= 5)
filter = PIOS_ICM20608G_ACCEL_LOWPASS_5_HZ;
filter = PIOS_ICM206XX_ACCEL_LOWPASS_5_HZ;
else if (bandwidth <= 10)
filter = PIOS_ICM20608G_ACCEL_LOWPASS_10_HZ;
filter = PIOS_ICM206XX_ACCEL_LOWPASS_10_HZ;
else if (bandwidth <= 21)
filter = PIOS_ICM20608G_ACCEL_LOWPASS_21_HZ;
filter = PIOS_ICM206XX_ACCEL_LOWPASS_21_HZ;
else if (bandwidth <= 45)
filter = PIOS_ICM20608G_ACCEL_LOWPASS_45_HZ;
filter = PIOS_ICM206XX_ACCEL_LOWPASS_45_HZ;
else if (bandwidth <= 99)
filter = PIOS_ICM20608G_ACCEL_LOWPASS_99_HZ;
filter = PIOS_ICM206XX_ACCEL_LOWPASS_99_HZ;
else if (bandwidth <= 218)
filter = PIOS_ICM20608G_ACCEL_LOWPASS_218_HZ;
filter = PIOS_ICM206XX_ACCEL_LOWPASS_218_HZ;
else
filter = PIOS_ICM20608G_ACCEL_LOWPASS_420_HZ;
filter = PIOS_ICM206XX_ACCEL_LOWPASS_420_HZ;
}

PIOS_MPU_WriteReg(PIOS_MPU_ACCEL_CFG2_REG, filter);
Expand Down Expand Up @@ -1282,4 +1287,4 @@ static int PIOS_MPU_parse_data(struct pios_mpu_dev *p)
/**
* @}
* @}
*/
*/
46 changes: 24 additions & 22 deletions flight/PiOS/inc/pios_mpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,14 @@ enum pios_mpu_error {
* Supported IMU devices
*/
enum pios_mpu_type {
PIOS_MPU60X0, /**< MPU-6000, SPI/I2C or MPU-6050, I2C */
PIOS_MPU6500, /**< MPU-6500, SPI/I2C */
PIOS_MPU9150, /**< MPU-9150, contains MPU-6050+AK8975C */
PIOS_MPU9250, /**< MPU-9250, contains MPU-6500+AK8963 */
PIOS_MPU60X0, /**< MPU-6000, SPI/I2C or MPU-6050, I2C */
PIOS_MPU6500, /**< MPU-6500, SPI/I2C */
PIOS_MPU9150, /**< MPU-9150, contains MPU-6050+AK8975C */
PIOS_MPU9250, /**< MPU-9250, contains MPU-6500+AK8963 */
PIOS_ICM20608G, /**<ICM-20608-G, SPI/I2C */
PIOS_MPU_NUM /**< Number of elements */
PIOS_ICM20602, /**< ICM-20602, SPI/I2C */
PIOS_ICM20689, /**< ICM-20689, SPI/I2C */
PIOS_MPU_NUM /**< Number of elements */
};

enum pios_mpu60x0_gyro_filter {
Expand All @@ -78,15 +80,15 @@ enum pios_mpu6500_gyro_filter {
PIOS_MPU6500_GYRO_LOWPASS_5_HZ = 0x06
};

enum pios_icm20608g_gyro_filter {
PIOS_ICM20608G_GYRO_LOWPASS_250_HZ = 0x00, // 8KHz sample mode
PIOS_ICM20608G_GYRO_LOWPASS_176_HZ = 0x01,
PIOS_ICM20608G_GYRO_LOWPASS_92_HZ = 0x02,
PIOS_ICM20608G_GYRO_LOWPASS_41_HZ = 0x03,
PIOS_ICM20608G_GYRO_LOWPASS_20_HZ = 0x04,
PIOS_ICM20608G_GYRO_LOWPASS_10_HZ = 0x05,
PIOS_ICM20608G_GYRO_LOWPASS_5_HZ = 0x06,
PIOS_ICM20608G_GYRO_LOWPASS_3281_HZ = 0x07 // 8KHz sample mode
enum pios_icm206xx_gyro_filter {
PIOS_ICM206XX_GYRO_LOWPASS_250_HZ = 0x00, // 8KHz sample mode
PIOS_ICM206XX_GYRO_LOWPASS_176_HZ = 0x01,
PIOS_ICM206XX_GYRO_LOWPASS_92_HZ = 0x02,
PIOS_ICM206XX_GYRO_LOWPASS_41_HZ = 0x03,
PIOS_ICM206XX_GYRO_LOWPASS_20_HZ = 0x04,
PIOS_ICM206XX_GYRO_LOWPASS_10_HZ = 0x05,
PIOS_ICM206XX_GYRO_LOWPASS_5_HZ = 0x06,
PIOS_ICM206XX_GYRO_LOWPASS_3281_HZ = 0x07 // 8KHz sample mode
};

enum pios_mpu6500_accel_filter {
Expand All @@ -99,14 +101,14 @@ enum pios_mpu6500_accel_filter {
PIOS_MPU6500_ACCEL_LOWPASS_5_HZ = 0x06
};

enum pios_icm20608g_accel_filter {
PIOS_ICM20608G_ACCEL_LOWPASS_218_HZ = 0x00, // 0x00 and 0x01 are identical.
PIOS_ICM20608G_ACCEL_LOWPASS_99_HZ = 0x02,
PIOS_ICM20608G_ACCEL_LOWPASS_45_HZ = 0x03,
PIOS_ICM20608G_ACCEL_LOWPASS_21_HZ = 0x04,
PIOS_ICM20608G_ACCEL_LOWPASS_10_HZ = 0x05,
PIOS_ICM20608G_ACCEL_LOWPASS_5_HZ = 0x06,
PIOS_ICM20608G_ACCEL_LOWPASS_420_HZ = 0x07
enum pios_icm206xx_accel_filter {
PIOS_ICM206XX_ACCEL_LOWPASS_218_HZ = 0x00, // 0x00 and 0x01 are identical.
PIOS_ICM206XX_ACCEL_LOWPASS_99_HZ = 0x02,
PIOS_ICM206XX_ACCEL_LOWPASS_45_HZ = 0x03,
PIOS_ICM206XX_ACCEL_LOWPASS_21_HZ = 0x04,
PIOS_ICM206XX_ACCEL_LOWPASS_10_HZ = 0x05,
PIOS_ICM206XX_ACCEL_LOWPASS_5_HZ = 0x06,
PIOS_ICM206XX_ACCEL_LOWPASS_420_HZ = 0x07
};

enum pios_mpu_gyro_range {
Expand Down
99 changes: 99 additions & 0 deletions flight/targets/matek405/bl/pios_board.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
/**
******************************************************************************
* @addtogroup Bootloader Bootloaders
* @{
* @addtogroup MATEK405 Matek MATEK405
* @{
*
* @file matek405/bl/pios_board.c
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
* @author Tau Labs, http://taulabs.org, Copyright (C) 2012-2013
* @brief Board specific initialization for the bootloader
* @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, see <http://www.gnu.org/licenses/>
*/

/* Pull in the board-specific static HW definitions.
* Including .c files is a bit ugly but this allows all of
* the HW definitions to be const and static to limit their
* scope.
*
* NOTE: THIS IS THE ONLY PLACE THAT SHOULD EVER INCLUDE THIS FILE
*/
#include "board_hw_defs.c"

#include <pios_board_info.h>
#include <pios.h>

uintptr_t pios_com_telem_usb_id;

void PIOS_Board_Init() {

/* Delay system */
PIOS_DELAY_Init();

const struct pios_board_info * bdinfo = &pios_board_info_blob;

#if defined(PIOS_INCLUDE_ANNUNC)
const struct pios_annunc_cfg * led_cfg = PIOS_BOARD_HW_DEFS_GetLedCfg(bdinfo->board_rev);
PIOS_Assert(led_cfg);
PIOS_ANNUNC_Init(led_cfg);
#endif /* PIOS_INCLUDE_ANNUNC */

PWR_BackupAccessCmd(ENABLE);
RCC_LSEConfig(RCC_LSE_OFF);

PIOS_ANNUNC_On(PIOS_LED_HEARTBEAT);
PIOS_ANNUNC_On(PIOS_LED_ALARM);

#if defined(PIOS_INCLUDE_FLASH)
/* Initialize all flash drivers */
PIOS_Flash_Internal_Init(&pios_internal_flash_id, &flash_internal_cfg);

/* Register the partition table */
PIOS_FLASH_register_partition_table(pios_flash_partition_table, NELEMENTS(pios_flash_partition_table));
#endif /* PIOS_INCLUDE_FLASH */

#if defined(PIOS_INCLUDE_USB)
/* Initialize board specific USB data */
PIOS_USB_BOARD_DATA_Init();

/* Activate the HID-only USB configuration */
PIOS_USB_DESC_HID_ONLY_Init();

uintptr_t pios_usb_id;
PIOS_USB_Init(&pios_usb_id, PIOS_BOARD_HW_DEFS_GetUsbCfg(bdinfo->board_rev));

#if defined(PIOS_INCLUDE_USB_HID) && defined(PIOS_INCLUDE_COM_MSG)
uintptr_t pios_usb_hid_id;
if (PIOS_USB_HID_Init(&pios_usb_hid_id, &pios_usb_hid_cfg, pios_usb_id)) {
PIOS_Assert(0);
}
if (PIOS_COM_MSG_Init(&pios_com_telem_usb_id, &pios_usb_hid_com_driver, pios_usb_hid_id)) {
PIOS_Assert(0);
}
#endif /* PIOS_INCLUDE_USB_HID && PIOS_INCLUDE_COM_MSG */

PIOS_USBHOOK_Activate();

#endif /* PIOS_INCLUDE_USB */
}

/**
* @}
* @}
*/
51 changes: 51 additions & 0 deletions flight/targets/matek405/bl/pios_config.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/**
******************************************************************************
* @addtogroup Bootloader Bootloaders
* @{
* @addtogroup MATEK405 Matek MATEK405
* @{
*
* @file matek405/bl/pios_config.h
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
* @author Tau Labs, http://taulabs.org, Copyright (C) 2012-2013
* @author dRonin, http://dRonin.org/, Copyright (C) 2015
* @brief Board specific bootloader configuration file for PiOS
* @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, see <http://www.gnu.org/licenses/>
*/

#ifndef PIOS_CONFIG_H
#define PIOS_CONFIG_H

/* Enable/Disable PiOS Modules */
#define PIOS_INCLUDE_ANNUNC
#define PIOS_INCLUDE_SPI
#define PIOS_INCLUDE_SYS
#define PIOS_INCLUDE_IAP
#define PIOS_INCLUDE_USB
#define PIOS_INCLUDE_USB_HID
#define PIOS_INCLUDE_COM_MSG
#define PIOS_INCLUDE_FLASH
#define PIOS_INCLUDE_FLASH_INTERNAL
#define PIOS_INCLUDE_FLASH_JEDEC

#endif /* PIOS_CONFIG_H */

/**
* @}
* @}
*/
31 changes: 31 additions & 0 deletions flight/targets/matek405/board-info/board-info.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
BOARD_TYPE := 0x95
BOARD_REVISION := 0x01
BOOTLOADER_VERSION := 0x88
HW_TYPE := 0x00

CHIP := STM32F405RGT6
BOARD := STM32F405
MODEL := HD
MODEL_SUFFIX :=

USB_VEND := "Matek"
USB_PROD := "Matek405"

# Note: These must match the values in link_$(BOARD)_memory.ld
BL_BANK_BASE := 0x08000000 # Start of bootloader flash
BL_BANK_SIZE := 0x00008000 # Should include BD_INFO region (32kb)

# Leave the remaining 16KB and 64KB sectors for other uses
FW_BANK_BASE := 0x08020000 # Start of firmware flash (128kb)
FW_BANK_SIZE := 0x00060000 # Should include FW_DESC_SIZE (384kb)

FW_DESC_SIZE := 0x00000064

EE_BANK_BASE := 0x00000000
EE_BANK_SIZE := 0x00000000

EF_BANK_BASE := 0x08000000 # Start of entire flash image (usually start of bootloader as well)
EF_BANK_SIZE := 0x00080000 # Size of the entire flash image (from bootloader until end of firmware)

OSCILLATOR_FREQ := 8000000
SYSCLK_FREQ := 168000000
Loading

0 comments on commit 42b2f80

Please sign in to comment.