From ea3d6be9266ef4a1f4d406537226c4775c5ee080 Mon Sep 17 00:00:00 2001
From: Pietro Bortolus <Pietro.bortolus@skywarder.eu>
Date: Tue, 18 Mar 2025 23:28:17 +0100
Subject: [PATCH] Tinkered with pin definitions

Removed the I2C pin definitions since they are not needed anymore.
Renamed PS0, PS1, ... with NDX015A_0, ...
Maybe fixed the problem with the possibility of attaching different sensors to the
PG11 and PD7 pins
Changed the bsp to match the changes in the hwmapping
---
 .../interfaces-impl/bsp.cpp                   | 27 +++++++---------
 .../interfaces-impl/hwmapping.h               | 32 +++++++++----------
 2 files changed, 28 insertions(+), 31 deletions(-)

diff --git a/src/bsps/stm32f767zi_orion_biscotto/interfaces-impl/bsp.cpp b/src/bsps/stm32f767zi_orion_biscotto/interfaces-impl/bsp.cpp
index 9eb48d883..40a7bd3e6 100644
--- a/src/bsps/stm32f767zi_orion_biscotto/interfaces-impl/bsp.cpp
+++ b/src/bsps/stm32f767zi_orion_biscotto/interfaces-impl/bsp.cpp
@@ -290,11 +290,6 @@ void IRQbspInit()
     interfaces::uart4::rx::alternateFunction(8);
     interfaces::uart4::rx::mode(Mode::ALTERNATE);
 
-    interfaces::i2c1::sda::alternateFunction(4);
-    interfaces::i2c1::sda::mode(Mode::ALTERNATE);
-    interfaces::i2c1::scl::alternateFunction(4);
-    interfaces::i2c1::scl::mode(Mode::ALTERNATE);
-
     interfaces::can1::tx::alternateFunction(9);
     interfaces::can1::tx::mode(Mode::ALTERNATE);
     interfaces::can1::rx::alternateFunction(9);
@@ -316,22 +311,24 @@ void IRQbspInit()
     sensors::ADS131M08::cs::high();
     sensors::LPS22DF::cs::mode(Mode::OUTPUT);
     sensors::LPS22DF::cs::high();
-    sensors::LIS2MDL::cs::mode(Mode::OUTPUT);
-    sensors::LIS2MDL::cs::high();
+    sensors::LIS2MDL_EXT::cs::mode(Mode::OUTPUT);
+    sensors::LIS2MDL_EXT::cs::high();
+    sensors::LIS2MDL_IN_EXT::cs::mode(Mode::OUTPUT);
+    sensors::LIS2MDL_IN_EXT::cs::high();
     sensors::H3LIS331DL::cs::mode(Mode::OUTPUT);
     sensors::H3LIS331DL::cs::high();
     sensors::LSM6DSRX::cs::mode(Mode::OUTPUT);
     sensors::LSM6DSRX::cs::high();
     sensors::UBXGps::cs::mode(Mode::OUTPUT);
     sensors::UBXGps::cs::high();
-    sensors::PS0::cs::mode(Mode::OUTPUT);
-    sensors::PS0::cs::high();
-    sensors::PS1::cs::mode(Mode::OUTPUT);
-    sensors::PS1::cs::high();
-    sensors::PS2::cs::mode(Mode::OUTPUT);
-    sensors::PS2::cs::high();
-    sensors::PS3::cs::mode(Mode::OUTPUT);
-    sensors::PS3::cs::high();
+    sensors::ND015A_0::cs::mode(Mode::OUTPUT);
+    sensors::ND015A_0::cs::high();
+    sensors::ND015A_1::cs::mode(Mode::OUTPUT);
+    sensors::ND015A_1::cs::high();
+    sensors::ND015A_2::cs::mode(Mode::OUTPUT);
+    sensors::ND015A_2::cs::high();
+    sensors::ND015A_3::cs::mode(Mode::OUTPUT);
+    sensors::ND015A_3::cs::high();
 
     sensors::VN100::cs::mode(Mode::OUTPUT);
     sensors::VN100::cs::high();
diff --git a/src/bsps/stm32f767zi_orion_biscotto/interfaces-impl/hwmapping.h b/src/bsps/stm32f767zi_orion_biscotto/interfaces-impl/hwmapping.h
index d4cb22e7e..c34354728 100644
--- a/src/bsps/stm32f767zi_orion_biscotto/interfaces-impl/hwmapping.h
+++ b/src/bsps/stm32f767zi_orion_biscotto/interfaces-impl/hwmapping.h
@@ -111,13 +111,6 @@ using tx = Gpio<GPIOA_BASE, 0>;
 using rx = Gpio<GPIOA_BASE, 1>;
 }  // namespace uart4
 
-// LPS28
-namespace i2c1
-{
-using sda = Gpio<GPIOB_BASE, 9>;
-using scl = Gpio<GPIOB_BASE, 8>;
-}  // namespace i2c1
-
 namespace can1
 {
 using tx = Gpio<GPIOA_BASE, 12>;
@@ -148,12 +141,21 @@ namespace ADS131M08
 using cs = Gpio<GPIOG_BASE, 10>;
 }
 
+// Either the LPS22DF or the LIS2MDL_EXTERNAL sensors could be attached to the
+// PD7 pin (not together)
 namespace LPS22DF
 {
 using cs = Gpio<GPIOD_BASE, 7>;
 }
 
-namespace LIS2MDL
+namespace LIS2MDL_EXT
+{
+using cs = Gpio<GPIOD_BASE, 7>;
+}
+
+// The PG11 pin is either attacehd to the internal or the external LIS2MDL, it
+// doesn't matter software-side since they are the same sensor
+namespace LIS2MDL_IN_EXT
 {
 using cs = Gpio<GPIOG_BASE, 11>;
 }
@@ -163,7 +165,7 @@ namespace H3LIS331DL
 using cs = Gpio<GPIOG_BASE, 9>;
 }
 
-namespace LSM6DSRX
+namespace LSM6DSRX_0
 {
 using cs = Gpio<GPIOD_BASE, 12>;
 }
@@ -180,29 +182,27 @@ using syncIn  = Gpio<GPIOB_BASE, 7>;
 using syncOut = Gpio<GPIOE_BASE, 3>;
 }  // namespace VN100
 
-/*
-namespace LSM6_1
+namespace LSM6DSRX_1
 {
 using cs = Gpio<GPIOC_BASE, 7>;
 }
-*/
 
-namespace PS0
+namespace ND015A_0
 {
 using cs = Gpio<GPIOD_BASE, 5>;
 }
 
-namespace PS1
+namespace ND015A_1
 {
 using cs = Gpio<GPIOB_BASE, 9>;
 }
 
-namespace PS2
+namespace ND015A_2
 {
 using cs = Gpio<GPIOB_BASE, 8>;
 }
 
-namespace PS3
+namespace ND015A_3
 {
 using cs = Gpio<GPIOD_BASE, 3>;
 }
-- 
GitLab