From ecae5eb98fc2d926ec60820afad56f62970e5419 Mon Sep 17 00:00:00 2001 From: Andrey Date: Sat, 10 Jun 2023 22:02:04 -0400 Subject: [PATCH] small board --- .../config/boards/hellen/hellen-common64.mk | 7 +++++++ .../config/boards/hellen/hellen_common.cpp | 17 +++++++++++++-- .../config/boards/hellen/hellen_leds_64.cpp | 2 +- .../boards/hellen/small-can-board/board.mk | 3 +++ .../small-can-board/board_configuration.cpp | 10 +++++++++ firmware/config/boards/hellen_meta.h | 21 +++++++++++++++++-- 6 files changed, 55 insertions(+), 5 deletions(-) create mode 100644 firmware/config/boards/hellen/hellen-common64.mk create mode 100644 firmware/config/boards/hellen/small-can-board/board_configuration.cpp diff --git a/firmware/config/boards/hellen/hellen-common64.mk b/firmware/config/boards/hellen/hellen-common64.mk new file mode 100644 index 0000000000..a1531fecc3 --- /dev/null +++ b/firmware/config/boards/hellen/hellen-common64.mk @@ -0,0 +1,7 @@ +ifeq ($(LED_CRITICAL_ERROR_BRAIN_PIN),) + LED_CRITICAL_ERROR_BRAIN_PIN = -DLED_CRITICAL_ERROR_BRAIN_PIN=H64_LED1_RED +endif + +DDEFS += $(LED_CRITICAL_ERROR_BRAIN_PIN) + +include $(BOARDS_DIR)/hellen/hellen-common.mk diff --git a/firmware/config/boards/hellen/hellen_common.cpp b/firmware/config/boards/hellen/hellen_common.cpp index e7d4275920..8179fcbef2 100644 --- a/firmware/config/boards/hellen/hellen_common.cpp +++ b/firmware/config/boards/hellen/hellen_common.cpp @@ -10,17 +10,30 @@ void setHellenCan() { engineConfiguration->canRxPin = Gpio::D0; } +void setHellen64Can() { + engineConfiguration->canTxPin = Gpio::B9; + engineConfiguration->canRxPin = Gpio::B8; +} + static OutputPin megaEn; -void setHellenMegaEnPin() { +static void setHellenMegaEnPin(Gpio pin) { static bool initialized = false; if (!initialized) { initialized = true; - megaEn.initPin("mm-EN", H144_GP8); // OUT_PWR_EN + megaEn.initPin("mm-EN", pin); megaEn.setValue(1); } } +void setHellenMegaEnPin() { + setHellenMegaEnPin(H144_GP8); // OUT_PWR_EN +} + +void setHellen64MegaEnPin() { + setHellenMegaEnPin(H64_IO1); // OUT_PWR_EN +} + void hellenBoardStandBy() { // we need to turn 'megaEn' and pause for a bit to make sure that WBO is off and does not wake main firmware right away megaEn.setValue(0); diff --git a/firmware/config/boards/hellen/hellen_leds_64.cpp b/firmware/config/boards/hellen/hellen_leds_64.cpp index 696c0fc9d4..f8b43b0f9d 100644 --- a/firmware/config/boards/hellen/hellen_leds_64.cpp +++ b/firmware/config/boards/hellen/hellen_leds_64.cpp @@ -1,3 +1,3 @@ Gpio getCommsLedPin() { - return H64_BLUE_LED; // blue + return H64_LED2_BLUE; } diff --git a/firmware/config/boards/hellen/small-can-board/board.mk b/firmware/config/boards/hellen/small-can-board/board.mk index 5cc57e32b9..07de6225ad 100644 --- a/firmware/config/boards/hellen/small-can-board/board.mk +++ b/firmware/config/boards/hellen/small-can-board/board.mk @@ -1,3 +1,6 @@ +BOARDCPPSRC = $(BOARD_DIR)/board_configuration.cpp DDEFS += -DFIRMWARE_ID=\"small-can-board\" DDEFS += -DSHORT_BOARD_NAME=small-can + +include $(BOARDS_DIR)/hellen/hellen-common64.mk diff --git a/firmware/config/boards/hellen/small-can-board/board_configuration.cpp b/firmware/config/boards/hellen/small-can-board/board_configuration.cpp new file mode 100644 index 0000000000..3a14e120ea --- /dev/null +++ b/firmware/config/boards/hellen/small-can-board/board_configuration.cpp @@ -0,0 +1,10 @@ +#include "pch.h" +#include "hellen_meta.h" + +#include "hellen_leds_64.cpp" + +void setBoardConfigOverrides() { + setHellen64Can(); + setHellen64MegaEnPin(); + setHellen64SdCardSpi1(); +} \ No newline at end of file diff --git a/firmware/config/boards/hellen_meta.h b/firmware/config/boards/hellen_meta.h index 2b73ce3600..0e10d1a84d 100644 --- a/firmware/config/boards/hellen_meta.h +++ b/firmware/config/boards/hellen_meta.h @@ -24,15 +24,23 @@ void hellenWbo(); void setHellenMegaEnPin(); +void setHellen64MegaEnPin(); void hellenBoardStandBy(); void configureHellenMegaAccCS2Pin(); void configureHellenCanTerminator(); void setHellenCan(); +void setHellen64Can(); int detectHellenBoardId(); void detectHellenBoardType(); +#define H64_LED1_RED Gpio::B0 +#define H64_LED2_BLUE Gpio::B1 + +#define H64_IO1 Gpio::C13 +#define H64_SPI1_CS1 Gpio::D2 + // stm32 UART8 #define H144_UART1_RX Gpio::E0 #define H144_UART1_TX Gpio::E1 @@ -231,16 +239,25 @@ void detectHellenBoardType(); #define H_SPI3_SCK Gpio::C10 #define H_SPI3_CS Gpio::A15 -static void setHellenSdCardSpi1() { +static void setHellenSdCardSpi1NoCS() { engineConfiguration->isSdCardEnabled = true; engineConfiguration->sdCardSpiDevice = SPI_DEVICE_1; engineConfiguration->spi1mosiPin = H_SPI1_MOSI; engineConfiguration->spi1misoPin = H_SPI1_MISO; engineConfiguration->spi1sckPin = H_SPI1_SCK; - engineConfiguration->sdCardCsPin = H_SPI1_CS1; engineConfiguration->is_enabled_spi_1 = true; } +static void setHellenSdCardSpi1() { + setHellenSdCardSpi1NoCS(); + engineConfiguration->sdCardCsPin = H_SPI1_CS1; +} + +static void setHellen64SdCardSpi1() { + setHellenSdCardSpi1NoCS(); + engineConfiguration->sdCardCsPin = H64_SPI1_CS1; +} + static void setHellenSdCardSpi2() { engineConfiguration->isSdCardEnabled = true; engineConfiguration->sdCardSpiDevice = SPI_DEVICE_2;