Skip to content

Commit

Permalink
only:SPI fun
Browse files Browse the repository at this point in the history
  • Loading branch information
rusefillc committed Feb 26, 2024
1 parent d69027b commit 39bd952
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions firmware/controllers/algo/rusefi_enums.h
Expand Up @@ -342,7 +342,10 @@ typedef enum __attribute__ ((__packed__)) {
SPI_DEVICE_1 = 1,
SPI_DEVICE_2 = 2,
SPI_DEVICE_3 = 3,
// we do not seem to have much spi4 code
SPI_DEVICE_4 = 4,
// we seem to have zero SPI5 code
SPI_DEVICE_5 = 5,
} spi_device_e;

typedef enum __attribute__ ((__packed__)) {
Expand Down

1 comment on commit 39bd952

@pchmura4
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would this be needed?

diff --git a/firmware/hw_layer/hardware.cpp b/firmware/hw_layer/hardware.cpp
index 80b693c498..dc278c922c 100644
--- a/firmware/hw_layer/hardware.cpp
+++ b/firmware/hw_layer/hardware.cpp
@@ -102,6 +102,12 @@ static void initSpiModules() {
 	if (engineConfiguration->is_enabled_spi_4) {
 		turnOnSpi(SPI_DEVICE_4);
 	}
+	if (engineConfiguration->is_enabled_spi_5) {
+		turnOnSpi(SPI_DEVICE_5);
+	}
+	if (engineConfiguration->is_enabled_spi_6) {
+		turnOnSpi(SPI_DEVICE_6);
+	}
 }
 
 /**
@@ -130,6 +136,16 @@ SPIDriver * getSpiDevice(spi_device_e spiDevice) {
 	if (spiDevice == SPI_DEVICE_4) {
 		return &SPID4;
 	}
+#endif
+#if STM32_SPI_USE_SPI5
+	if (spiDevice == SPI_DEVICE_5) {
+		return &SPID5;
+	}
+#endif
+#if STM32_SPI_USE_SPI6
+	if (spiDevice == SPI_DEVICE_6) {
+		return &SPID6;
+	}
 #endif
 	firmwareError(ObdCode::CUSTOM_ERR_UNEXPECTED_SPI, "Unexpected SPI device: %d", spiDevice);
 	return NULL;

Please sign in to comment.