From 914fbf5a170e5e244df5e5530b804bd2c10a927f Mon Sep 17 00:00:00 2001 From: Ea-r-th <39779954+Ea-r-th@users.noreply.github.com> Date: Wed, 10 Sep 2025 01:53:16 -0700 Subject: [PATCH] Begin I2C implementation and finalize other changes --- .../Include/Peripheral/I2C/Reg/SHAL_I2C_REG.h | 42 +++++++++++++++++-- .../Peripheral/I2C/Reg/SHAL_I2C_REG_F072xB.h | 3 ++ SHAL/Include/Peripheral/I2C/SHAL_I2C.h | 36 ++++++++++++++++ .../Peripheral/UART/Reg/SHAL_UART_REG.h | 4 -- SHAL/Include/Peripheral/UART/SHAL_UART.h | 1 - 5 files changed, 78 insertions(+), 8 deletions(-) diff --git a/SHAL/Include/Peripheral/I2C/Reg/SHAL_I2C_REG.h b/SHAL/Include/Peripheral/I2C/Reg/SHAL_I2C_REG.h index 291321a..6ebdccb 100644 --- a/SHAL/Include/Peripheral/I2C/Reg/SHAL_I2C_REG.h +++ b/SHAL/Include/Peripheral/I2C/Reg/SHAL_I2C_REG.h @@ -2,7 +2,43 @@ // Created by Luca on 9/9/2025. // -#ifndef SHMINGO_HAL_SHAL_I2C_REG_H -#define SHMINGO_HAL_SHAL_I2C_REG_H +#ifndef SHAL_I2C_REG_H +#define SHAL_I2C_REG_H -#endif //SHMINGO_HAL_SHAL_I2C_REG_H +#if defined(STM32F030x6) +#include "stm32f030x6.h" +#elif defined(STM32F030x8) +#include "stm32f030x8.h" +#elif defined(STM32F031x6) +#include "stm32f031x6.h" +#elif defined(STM32F038xx) +#include "stm32f038xx.h" +#elif defined(STM32F042x6) +#include "stm32f042x6.h" +#elif defined(STM32F048xx) +#include "stm32f048xx.h" +#elif defined(STM32F051x8) +#include "stm32f051x8.h" +#elif defined(STM32F058xx) +#include "stm32f058xx.h" +#elif defined(STM32F070x6) +#include "stm32f070x6.h" +#elif defined(STM32F070xB) +#include "stm32f070xb.h" +#elif defined(STM32F071xB) +#include "stm32f071xb.h" +#elif defined(STM32F072xB) +#include "SHAL_I2C_REG_F072xB.h" +#elif defined(STM32F078xx) +#include "stm32f078xx.h" +#elif defined(STM32F091xC) + #include "stm32f091xc.h" +#elif defined(STM32F098xx) + #include "stm32f098xx.h" +#elif defined(STM32F030xC) + #include "stm32f030xc.h" +#else + #error "Please select first the target STM32F0xx device used in your application (in stm32f0xx.h file)" +#endif + +#endif //SHAL_I2C_REG_H diff --git a/SHAL/Include/Peripheral/I2C/Reg/SHAL_I2C_REG_F072xB.h b/SHAL/Include/Peripheral/I2C/Reg/SHAL_I2C_REG_F072xB.h index 53ed576..0e2d114 100644 --- a/SHAL/Include/Peripheral/I2C/Reg/SHAL_I2C_REG_F072xB.h +++ b/SHAL/Include/Peripheral/I2C/Reg/SHAL_I2C_REG_F072xB.h @@ -10,6 +10,9 @@ #include "SHAL_I2C_TYPES.h" +#define NUM_I2C_BUSES 2 + + enum class I2C_Pair : uint8_t{ //I2C_1 SCL1B6_SDA1B7, //AF1 diff --git a/SHAL/Include/Peripheral/I2C/SHAL_I2C.h b/SHAL/Include/Peripheral/I2C/SHAL_I2C.h index 80476e9..4a9768d 100644 --- a/SHAL/Include/Peripheral/I2C/SHAL_I2C.h +++ b/SHAL/Include/Peripheral/I2C/SHAL_I2C.h @@ -5,4 +5,40 @@ #ifndef SHMINGO_HAL_SHAL_I2C_H #define SHMINGO_HAL_SHAL_I2C_H +#include "SHAL_CORE.h" +#include "SHAL_I2C_REG.h" + + +class SHAL_I2C{ + + friend class I2CManager; + +public: + +private: + + SHAL_I2C() = default; + + I2C_Pair m_I2CPair = I2C_Pair::INVALID; //Initialize to invalid + +}; + + + + + +class I2CManager{ + +public: + + static SHAL_I2C& get(uint8_t i2c); + + I2CManager() = delete; + +private: + + inline static SHAL_I2C m_UARTs[NUM_I2C_BUSES] = {}; + +}; + #endif //SHMINGO_HAL_SHAL_I2C_H diff --git a/SHAL/Include/Peripheral/UART/Reg/SHAL_UART_REG.h b/SHAL/Include/Peripheral/UART/Reg/SHAL_UART_REG.h index ec6009c..a89c0da 100644 --- a/SHAL/Include/Peripheral/UART/Reg/SHAL_UART_REG.h +++ b/SHAL/Include/Peripheral/UART/Reg/SHAL_UART_REG.h @@ -5,10 +5,6 @@ #ifndef SHAL_UART_REG_H #define SHAL_UART_REG_H -// -// Created by Luca on 9/6/2025. -// - #if defined(STM32F030x6) #include "stm32f030x6.h" diff --git a/SHAL/Include/Peripheral/UART/SHAL_UART.h b/SHAL/Include/Peripheral/UART/SHAL_UART.h index 6f35660..e1cbb45 100644 --- a/SHAL/Include/Peripheral/UART/SHAL_UART.h +++ b/SHAL/Include/Peripheral/UART/SHAL_UART.h @@ -46,7 +46,6 @@ public: static SHAL_UART& get(uint8_t uart); - UARTManager() = delete; private: