mirror of
https://github.com/infiniteCable2/panda.git
synced 2026-02-18 17:23:52 +08:00
Revert "H7: detect board type with second ID pin group (#1975)"
This reverts commit 376408bb4f.
This commit is contained in:
@@ -15,4 +15,7 @@ for project_name, project in build_projects.items():
|
||||
if ("ENABLE_SPI" in os.environ or "h7" in project_name):
|
||||
flags.append('-DENABLE_SPI')
|
||||
|
||||
if "H723" in os.environ:
|
||||
flags.append('-DSTM32H723')
|
||||
|
||||
build_project(project_name, project, flags)
|
||||
|
||||
@@ -18,33 +18,36 @@
|
||||
#include "boards/cuatro.h"
|
||||
|
||||
|
||||
uint8_t get_board_id(void) {
|
||||
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) {
|
||||
// On STM32H7 pandas, we use two different sets of pins.
|
||||
const uint8_t id1 = 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);
|
||||
const uint8_t board_id = get_board_id();
|
||||
|
||||
const uint8_t id2 = 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);
|
||||
|
||||
if (id2 == 3U) {
|
||||
hw_type = HW_TYPE_CUATRO;
|
||||
current_board = &board_cuatro;
|
||||
} else if (id1 == 0U) {
|
||||
if (board_id == 0U) {
|
||||
hw_type = HW_TYPE_RED_PANDA;
|
||||
current_board = &board_red;
|
||||
} else if (id1 == 1U) {
|
||||
} else if (board_id == 1U) {
|
||||
// deprecated
|
||||
//hw_type = HW_TYPE_RED_PANDA_V2;
|
||||
hw_type = HW_TYPE_UNKNOWN;
|
||||
} else if (id1 == 2U) {
|
||||
} 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_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
|
||||
}
|
||||
|
||||
@@ -18,16 +18,12 @@ 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)
|
||||
#ifndef PANDA_JUNGLE
|
||||
if ((PWR->CR3 & PWR_CR3_SMPSEXTRDY) != 0U) {
|
||||
// Set power mode to direct SMPS power supply(depends on the board layout)
|
||||
#ifndef STM32H723
|
||||
register_set(&(PWR->CR3), PWR_CR3_SMPSEN, 0xFU); // powered only by SMPS
|
||||
#else
|
||||
if (true) {
|
||||
register_set(&(PWR->CR3), PWR_CR3_LDOEN, 0xFU);
|
||||
#endif
|
||||
register_set(&(PWR->CR3), PWR_CR3_SMPSEN, 0xFU); // powered only by SMPS
|
||||
} else {
|
||||
register_set(&(PWR->CR3), PWR_CR3_LDOEN, 0xFU);
|
||||
}
|
||||
// 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) == 0U);
|
||||
|
||||
Reference in New Issue
Block a user