From 55f03031b333e85e36d14982d1e01beb0a7f4cac Mon Sep 17 00:00:00 2001 From: Ea-r-th <39779954+Ea-r-th@users.noreply.github.com> Date: Tue, 9 Sep 2025 20:11:17 -0700 Subject: [PATCH] Added files for I2C --- CMakeLists.txt | 2 ++ SHAL/Include/Core/SHAL_CORE.h | 13 +++++++--- .../Include/Peripheral/I2C/Reg/SHAL_I2C_REG.h | 8 ++++++ .../Peripheral/I2C/Reg/SHAL_I2C_REG_F072xB.h | 20 +++++++++++++++ .../Peripheral/I2C/Reg/SHAL_I2C_TYPES.h | 25 +++++++++++++++++++ SHAL/Include/Peripheral/I2C/SHAL_I2C.h | 8 ++++++ .../Peripheral/UART/Reg/SHAL_UART_TYPES.h | 12 +-------- 7 files changed, 74 insertions(+), 14 deletions(-) create mode 100644 SHAL/Include/Peripheral/I2C/Reg/SHAL_I2C_REG.h create mode 100644 SHAL/Include/Peripheral/I2C/Reg/SHAL_I2C_REG_F072xB.h create mode 100644 SHAL/Include/Peripheral/I2C/Reg/SHAL_I2C_TYPES.h create mode 100644 SHAL/Include/Peripheral/I2C/SHAL_I2C.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 7f5496a..dd62483 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -36,6 +36,8 @@ set(PROJECT_INCLUDE_DIRECTORIES SHAL/Include/Peripheral/GPIO/Reg SHAL/Include/Peripheral/UART SHAL/Include/Peripheral/UART/Reg + SHAL/Include/Peripheral/I2C + SHAL/Include/Peripheral/I2C/Reg SHAL/Include/Peripheral/EXT/ ${CMAKE_CURRENT_SOURCE_DIR}/SHAL/Include ) diff --git a/SHAL/Include/Core/SHAL_CORE.h b/SHAL/Include/Core/SHAL_CORE.h index c37cda4..3c4ef85 100644 --- a/SHAL/Include/Core/SHAL_CORE.h +++ b/SHAL/Include/Core/SHAL_CORE.h @@ -13,9 +13,16 @@ //Universal structs and defines --------------------------- - - - +enum class AF_Mask : uint8_t{ + AF0, + AF1, + AF2, + AF3, + AF4, + AF5, + AF6, + AF7 +}; //--------------------------------------------------------- diff --git a/SHAL/Include/Peripheral/I2C/Reg/SHAL_I2C_REG.h b/SHAL/Include/Peripheral/I2C/Reg/SHAL_I2C_REG.h new file mode 100644 index 0000000..291321a --- /dev/null +++ b/SHAL/Include/Peripheral/I2C/Reg/SHAL_I2C_REG.h @@ -0,0 +1,8 @@ +// +// Created by Luca on 9/9/2025. +// + +#ifndef SHMINGO_HAL_SHAL_I2C_REG_H +#define SHMINGO_HAL_SHAL_I2C_REG_H + +#endif //SHMINGO_HAL_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 new file mode 100644 index 0000000..ecee868 --- /dev/null +++ b/SHAL/Include/Peripheral/I2C/Reg/SHAL_I2C_REG_F072xB.h @@ -0,0 +1,20 @@ +// +// Created by Luca on 9/9/2025. +// + +#ifndef SHMINGO_HAL_SHAL_I2C_REG_F072XB_H +#define SHMINGO_HAL_SHAL_I2C_REG_F072XB_H + +#include "SHAL_CORE.h" + +enum class I2C_Pair : uint8_t{ + //I2C_1 + SCL1B6_SDA1B7, //AF1 + SCL1B8_SDA1B9, //AF1 + + //I2C_2 + SCL2B10_SDA2B11, //AF1 + SCL2B13_SDA2B14, //AF5 +}; + +#endif //SHMINGO_HAL_SHAL_I2C_REG_F072XB_H diff --git a/SHAL/Include/Peripheral/I2C/Reg/SHAL_I2C_TYPES.h b/SHAL/Include/Peripheral/I2C/Reg/SHAL_I2C_TYPES.h new file mode 100644 index 0000000..c88a007 --- /dev/null +++ b/SHAL/Include/Peripheral/I2C/Reg/SHAL_I2C_TYPES.h @@ -0,0 +1,25 @@ +// +// Created by Luca on 9/9/2025. +// + +#ifndef SHMINGO_HAL_SHAL_I2C_TYPES_H +#define SHMINGO_HAL_SHAL_I2C_TYPES_H + +#include "SHAL_CORE.h" +#include "SHAL_GPIO_REG.h" + +//Information necessary for I2C +struct SHAL_I2C_Pair { + I2C_TypeDef* I2CReg; + GPIO_Key SCL_Key; + GPIO_Key SDA_Key; + AF_Mask SCL_Mask; + AF_Mask SDA_Mask; +}; + +struct SHAL_I2C_Enable_REG{ + volatile uint32_t* reg; + uint32_t mask; +}; + +#endif //SHMINGO_HAL_SHAL_I2C_TYPES_H diff --git a/SHAL/Include/Peripheral/I2C/SHAL_I2C.h b/SHAL/Include/Peripheral/I2C/SHAL_I2C.h new file mode 100644 index 0000000..80476e9 --- /dev/null +++ b/SHAL/Include/Peripheral/I2C/SHAL_I2C.h @@ -0,0 +1,8 @@ +// +// Created by Luca on 9/9/2025. +// + +#ifndef SHMINGO_HAL_SHAL_I2C_H +#define SHMINGO_HAL_SHAL_I2C_H + +#endif //SHMINGO_HAL_SHAL_I2C_H diff --git a/SHAL/Include/Peripheral/UART/Reg/SHAL_UART_TYPES.h b/SHAL/Include/Peripheral/UART/Reg/SHAL_UART_TYPES.h index 1220373..a1d0a1f 100644 --- a/SHAL/Include/Peripheral/UART/Reg/SHAL_UART_TYPES.h +++ b/SHAL/Include/Peripheral/UART/Reg/SHAL_UART_TYPES.h @@ -8,20 +8,10 @@ #include "SHAL_CORE.h" #include "SHAL_GPIO_REG.h" -enum class AF_Mask : uint8_t{ - AF0, - AF1, - AF2, - AF3, - AF4, - AF5, - AF6, - AF7 -}; + //Represents a pair of pins usable for USART Tx + Rx in combination, and their alternate function mapping struct SHAL_UART_Pair{ - USART_TypeDef* USARTReg; GPIO_Key TxKey; GPIO_Key RxKey;