From f4d02a2937ddcf9bc9404b0e73ccb2cdeeb70cfd Mon Sep 17 00:00:00 2001 From: Viktor Vladic <42044810+vvladic@users.noreply.github.com> Date: Tue, 8 Feb 2022 01:55:49 +0100 Subject: [PATCH] MatekH743 board_id, usb vid/pid changes, and MPU6000 delay before transfer - not after (#18733) * Make board_id compatible with ardupilot * Initialize outputs for CAM1/CAM2 and Vsw pad * Correct board type 1013 in bootloader to match AP * Change usb vendor string to "Matek" * Change cdcacm pid to 1013 * Comment out FLASH_BASED_PARAMS because of #15331 --- .../extras/matek_h743-slim_bootloader.bin | Bin 42692 -> 42688 bytes boards/matek/h743-slim/firmware.prototype | 6 ++--- .../nuttx-config/bootloader/defconfig | 6 ++--- .../h743-slim/nuttx-config/nsh/defconfig | 8 +++--- boards/matek/h743-slim/src/board_config.h | 8 +++--- boards/matek/h743-slim/src/hw_config.h | 2 +- boards/matek/h743-slim/src/init.c | 23 ++++++++++++++++++ .../imu/invensense/mpu6000/MPU6000.cpp | 4 +-- 8 files changed, 41 insertions(+), 16 deletions(-) diff --git a/boards/matek/h743-slim/extras/matek_h743-slim_bootloader.bin b/boards/matek/h743-slim/extras/matek_h743-slim_bootloader.bin index 7e1a96cd8eff3fe1d9618c9bda3b700a59c8254d..ae95aca31b0de09c42ffe753a024871103687fb2 100755 GIT binary patch delta 240 zcmX?dmg&G*rVSgI8J}$4$SiHoduJ&F2M9AT0O`#)ox)WG=K;AKK+Fpg_9$?d-Rzig zoRQTA$kpG>oAsTAv0yW6elROz+2+WS$3l!Xn{C_mnHU=;=XU<*YyhfiVPH^c+FaTt z%+A=mxpQJZ2Wvl2biw4mGxsx|*t~aEG?$8pxrs4@5F-N<69a<-r;xA!BO@adGoyY= zYMFjsX-*Eq|2KywJ1kwmcxCd#rPZb}K>Z~^QyGEI{0{|RnSmTAcmR?Bg0(<(_CPv- Mg@Iw$y-t3rh zoRQT5$Ti)}oAsTAv1BuAelROz)#k{O$3lz^n{C_mnHXCp=XU<*YyqljVPH^c+g#cu z%+5G*bLYf-4%W#)(Iu1r&fL#2!CNlz^`X36qfovFf0FnTLjX-tw PKstbhfnnd|-etxBChATc diff --git a/boards/matek/h743-slim/firmware.prototype b/boards/matek/h743-slim/firmware.prototype index e8c0af1ec2..a1a9b1f725 100644 --- a/boards/matek/h743-slim/firmware.prototype +++ b/boards/matek/h743-slim/firmware.prototype @@ -1,10 +1,10 @@ { - "board_id": 139, + "board_id": 1013, "magic": "PX4FWv1", - "description": "Firmware for the MatekH743-slim board", + "description": "Firmware for the MatekH743 board", "image": "", "build_time": 0, - "summary": "MatekH743-slim", + "summary": "MatekH743", "version": "0.1", "image_size": 0, "image_maxsize": 1966080, diff --git a/boards/matek/h743-slim/nuttx-config/bootloader/defconfig b/boards/matek/h743-slim/nuttx-config/bootloader/defconfig index 2bb3fd8f67..92fb47fcec 100644 --- a/boards/matek/h743-slim/nuttx-config/bootloader/defconfig +++ b/boards/matek/h743-slim/nuttx-config/bootloader/defconfig @@ -30,11 +30,11 @@ CONFIG_BOARD_RESET_ON_ASSERT=2 CONFIG_C99_BOOL8=y CONFIG_CDCACM=y CONFIG_CDCACM_IFLOWCONTROL=y -CONFIG_CDCACM_PRODUCTID=0x004b -CONFIG_CDCACM_PRODUCTSTR="Matek H743-slim" +CONFIG_CDCACM_PRODUCTID=0x1013 +CONFIG_CDCACM_PRODUCTSTR="MatekH743" CONFIG_CDCACM_RXBUFSIZE=600 CONFIG_CDCACM_TXBUFSIZE=12000 -CONFIG_CDCACM_VENDORID=0x3162 +CONFIG_CDCACM_VENDORID=0x1209 CONFIG_CDCACM_VENDORSTR="Matek" CONFIG_CLOCK_MONOTONIC=y CONFIG_DEBUG_FULLOPT=y diff --git a/boards/matek/h743-slim/nuttx-config/nsh/defconfig b/boards/matek/h743-slim/nuttx-config/nsh/defconfig index cd804be1b2..2b103ac9a9 100644 --- a/boards/matek/h743-slim/nuttx-config/nsh/defconfig +++ b/boards/matek/h743-slim/nuttx-config/nsh/defconfig @@ -46,12 +46,12 @@ CONFIG_BUILTIN=y CONFIG_C99_BOOL8=y CONFIG_CDCACM=y CONFIG_CDCACM_IFLOWCONTROL=y -CONFIG_CDCACM_PRODUCTID=0x0036 -CONFIG_CDCACM_PRODUCTSTR="MatekH743-slim" +CONFIG_CDCACM_PRODUCTID=0x1013 +CONFIG_CDCACM_PRODUCTSTR="MatekH743" CONFIG_CDCACM_RXBUFSIZE=600 CONFIG_CDCACM_TXBUFSIZE=12000 -CONFIG_CDCACM_VENDORID=0x1B8C -CONFIG_CDCACM_VENDORSTR="PX4" +CONFIG_CDCACM_VENDORID=0x1209 +CONFIG_CDCACM_VENDORSTR="Matek" CONFIG_CLOCK_MONOTONIC=y CONFIG_DEBUG_FULLOPT=y CONFIG_DEBUG_HARDFAULT_ALERT=y diff --git a/boards/matek/h743-slim/src/board_config.h b/boards/matek/h743-slim/src/board_config.h index 17a9705404..13db68ab37 100644 --- a/boards/matek/h743-slim/src/board_config.h +++ b/boards/matek/h743-slim/src/board_config.h @@ -119,9 +119,9 @@ /* Spare GPIO */ -// #define GPIO_PG6 /* PG6 */ (GPIO_INPUT|GPIO_PULLUP|GPIO_PORTG|GPIO_PIN6) -// #define GPIO_PD15 /* PD15 */ (GPIO_INPUT|GPIO_FLOAT|GPIO_PORTD|GPIO_PIN15) -// #define GPIO_PG15 /* PG15 */ (GPIO_INPUT|GPIO_PULLUP|GPIO_PORTG|GPIO_PIN15) +#define GPIO_VIDEO_PWR /* PD10 */ (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_2MHz|GPIO_OUTPUT_CLEAR|GPIO_PORTD|GPIO_PIN10) +#define GPIO_VIDEO_CAM /* PD11 */ (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_2MHz|GPIO_OUTPUT_CLEAR|GPIO_PORTD|GPIO_PIN11) +// #define GPIO_PG15 /* PG15 */ (GPIO_INPUT|GPIO_PULLUP|GPIO_PORTG|GPIO_PIN15) /* Tone alarm output */ @@ -174,6 +174,8 @@ GPIO_nLED_BLUE, \ GPIO_nLED_GREEN, \ GPIO_TONE_ALARM_IDLE, \ + GPIO_VIDEO_PWR, \ + GPIO_VIDEO_CAM, \ } #define BOARD_ENABLE_CONSOLE_BUFFER diff --git a/boards/matek/h743-slim/src/hw_config.h b/boards/matek/h743-slim/src/hw_config.h index f289dc960d..3256b9c63d 100644 --- a/boards/matek/h743-slim/src/hw_config.h +++ b/boards/matek/h743-slim/src/hw_config.h @@ -96,7 +96,7 @@ #define INTERFACE_USART 1 #define INTERFACE_USART_CONFIG "/dev/ttyS0,57600" #define BOOT_DELAY_ADDRESS 0x000001a0 -#define BOARD_TYPE 139 +#define BOARD_TYPE 1013 #define _FLASH_KBYTES (*(uint32_t *)0x1FF1E880) #define BOARD_FLASH_SECTORS (15) #define BOARD_FLASH_SIZE (_FLASH_KBYTES * 1024) diff --git a/boards/matek/h743-slim/src/init.c b/boards/matek/h743-slim/src/init.c index a2a531882c..f78e570c5a 100644 --- a/boards/matek/h743-slim/src/init.c +++ b/boards/matek/h743-slim/src/init.c @@ -60,6 +60,10 @@ #include #include +// # if defined(FLASH_BASED_PARAMS) +// # include +// #endif + __BEGIN_DECLS extern void led_init(void); extern void led_on(int led); @@ -174,6 +178,25 @@ __EXPORT int board_app_initialize(uintptr_t arg) #endif + +// #if defined(FLASH_BASED_PARAMS) +// static sector_descriptor_t params_sector_map[] = { +// {6, 128 * 1024, 0x081C0000}, +// {7, 128 * 1024, 0x081E0000}, +// {0, 0, 0}, +// }; + +// /* Initialize the flashfs layer to use heap allocated memory */ +// int result = parameter_flashfs_init(params_sector_map, NULL, 0); + +// if (result != OK) { +// syslog(LOG_ERR, "[boot] FAILED to init params in FLASH %d\n", result); +// led_on(LED_BLUE); +// return -ENODEV; +// } + +// #endif + /* Configure the HW based on the manifest */ px4_platform_configure(); diff --git a/src/drivers/imu/invensense/mpu6000/MPU6000.cpp b/src/drivers/imu/invensense/mpu6000/MPU6000.cpp index 6415522780..701a330db9 100644 --- a/src/drivers/imu/invensense/mpu6000/MPU6000.cpp +++ b/src/drivers/imu/invensense/mpu6000/MPU6000.cpp @@ -436,8 +436,8 @@ uint8_t MPU6000::RegisterRead(Register reg) uint8_t cmd[2] {}; cmd[0] = static_cast(reg) | DIR_READ; set_frequency(SPI_SPEED); // low speed for regular registers - transfer(cmd, cmd, sizeof(cmd)); px4_udelay(10); + transfer(cmd, cmd, sizeof(cmd)); return cmd[1]; } @@ -445,8 +445,8 @@ void MPU6000::RegisterWrite(Register reg, uint8_t value) { uint8_t cmd[2] { (uint8_t)reg, value }; set_frequency(SPI_SPEED); // low speed for regular registers - transfer(cmd, cmd, sizeof(cmd)); px4_udelay(10); + transfer(cmd, cmd, sizeof(cmd)); } void MPU6000::RegisterSetAndClearBits(Register reg, uint8_t setbits, uint8_t clearbits)