From d6b5dbb3dcc57c4d64658292e2b9ff17d59b6015 Mon Sep 17 00:00:00 2001 From: Adeeb Shihadeh Date: Wed, 24 Jan 2024 15:39:11 -0800 Subject: [PATCH] Revert "detect 723 live (#1835)" This reverts commit 9d0caa1935ac4ec1d971fd1aeac7223ca9f67b47. --- board/SConscript | 3 +++ board/stm32h7/board.h | 29 +++++++++++++++-------------- board/stm32h7/clock.h | 14 +++++++------- board/stm32h7/stm32h7_config.h | 7 ------- 4 files changed, 25 insertions(+), 28 deletions(-) diff --git a/board/SConscript b/board/SConscript index 45fa0f41..81f1ef84 100644 --- a/board/SConscript +++ b/board/SConscript @@ -15,4 +15,7 @@ for project_name, project in build_projects.items(): if ("ENABLE_SPI" in os.environ or "h7" in project_name) and not project_name.startswith('pedal'): flags.append('-DENABLE_SPI') + if "H723" in os.environ: + flags.append('-DSTM32H723') + build_project(project_name, project, flags) diff --git a/board/stm32h7/board.h b/board/stm32h7/board.h index 7fa27988..d293a54c 100644 --- a/board/stm32h7/board.h +++ b/board/stm32h7/board.h @@ -19,20 +19,12 @@ #include "boards/tres.h" #include "boards/cuatro.h" + uint8_t get_board_id(void) { - uint8_t id = detect_with_pull(GPIOF, 7, PULL_UP) | - (detect_with_pull(GPIOF, 8, PULL_UP) << 1U) | - (detect_with_pull(GPIOF, 9, PULL_UP) << 2U) | - (detect_with_pull(GPIOF, 10, PULL_UP) << 3U); - - if (STM32H7_IS_100PIN) { - id = detect_with_pull(GPIOD, 4, PULL_UP) | - (detect_with_pull(GPIOD, 5, PULL_UP) << 1U) | - (detect_with_pull(GPIOD, 6, PULL_UP) << 2U) | - (detect_with_pull(GPIOD, 7, PULL_UP) << 3U); - } - - return id; + return detect_with_pull(GPIOF, 7, PULL_UP) | + (detect_with_pull(GPIOF, 8, PULL_UP) << 1U) | + (detect_with_pull(GPIOF, 9, PULL_UP) << 2U) | + (detect_with_pull(GPIOF, 10, PULL_UP) << 3U); } void detect_board_type(void) { @@ -41,14 +33,23 @@ void detect_board_type(void) { if (board_id == 0U) { hw_type = HW_TYPE_RED_PANDA; current_board = &board_red; + } else if (board_id == 1U) { + // deprecated + //hw_type = HW_TYPE_RED_PANDA_V2; } else if (board_id == 2U) { hw_type = HW_TYPE_TRES; current_board = &board_tres; } else if (board_id == 3U) { hw_type = HW_TYPE_CUATRO; - current_board = &board_cuatro; + current_board = &board_tres; } else { hw_type = HW_TYPE_UNKNOWN; print("Hardware type is UNKNOWN!\n"); } + + // TODO: detect this live +#ifdef STM32H723 + hw_type = HW_TYPE_CUATRO; + current_board = &board_cuatro; +#endif } diff --git a/board/stm32h7/clock.h b/board/stm32h7/clock.h index 97c22826..fc221c55 100644 --- a/board/stm32h7/clock.h +++ b/board/stm32h7/clock.h @@ -19,13 +19,13 @@ PCLK1: 60MHz (for USART2,3,4,5,7,8) void clock_init(void) { // Set power mode to direct SMPS power supply(depends on the board layout) - if (!STM32H7_IS_723) { - register_set(&(PWR->CR3), PWR_CR3_SMPSEN, 0xFU); // powered only by SMPS - // Set VOS level (VOS3 to 170Mhz, VOS2 to 300Mhz, VOS1 to 400Mhz, VOS0 to 550Mhz) - register_set(&(PWR->D3CR), PWR_D3CR_VOS_1 | PWR_D3CR_VOS_0, 0xC000U); //VOS1, needed for 80Mhz CAN FD - while ((PWR->CSR1 & PWR_CSR1_ACTVOSRDY) == 0); - while ((PWR->CSR1 & PWR_CSR1_ACTVOS) != (PWR->D3CR & PWR_D3CR_VOS)); // check that VOS level was actually set - } +#ifndef STM32H723 + register_set(&(PWR->CR3), PWR_CR3_SMPSEN, 0xFU); // powered only by SMPS + // Set VOS level (VOS3 to 170Mhz, VOS2 to 300Mhz, VOS1 to 400Mhz, VOS0 to 550Mhz) + register_set(&(PWR->D3CR), PWR_D3CR_VOS_1 | PWR_D3CR_VOS_0, 0xC000U); //VOS1, needed for 80Mhz CAN FD + while ((PWR->CSR1 & PWR_CSR1_ACTVOSRDY) == 0); + while ((PWR->CSR1 & PWR_CSR1_ACTVOS) != (PWR->D3CR & PWR_D3CR_VOS)); // check that VOS level was actually set +#endif // Configure Flash ACR register LATENCY and WRHIGHFREQ (VOS0 range!) register_set(&(FLASH->ACR), FLASH_ACR_LATENCY_2WS | 0x20U, 0x3FU); // VOS2, AXI 100MHz-150MHz // enable external oscillator HSE diff --git a/board/stm32h7/stm32h7_config.h b/board/stm32h7/stm32h7_config.h index 5c3abf4d..6f36a5aa 100644 --- a/board/stm32h7/stm32h7_config.h +++ b/board/stm32h7/stm32h7_config.h @@ -46,13 +46,6 @@ separate IRQs for RX and TX. #define PROVISION_CHUNK_ADDRESS 0x080FFFE0U #define DEVICE_SERIAL_NUMBER_ADDRESS 0x080FFFC0U -/* - panda supports 723 and 725-35, and sometimes we need to tell the difference. - 0x1 = LQFP100 Legacy / TFBGA100 Legacy -*/ -#define STM32H7_IS_723 ((SYSCFG->PKGR & SYSCFG_PKGR_PKG) == 0x1U) -#define STM32H7_IS_100PIN STM32H7_IS_723 - #include "can_definitions.h" #include "comms_definitions.h"