Added files for I2C

This commit is contained in:
Ea-r-th
2025-09-09 20:11:17 -07:00
parent 9f1aad028d
commit 55f03031b3
7 changed files with 74 additions and 14 deletions

View File

@@ -36,6 +36,8 @@ set(PROJECT_INCLUDE_DIRECTORIES
SHAL/Include/Peripheral/GPIO/Reg SHAL/Include/Peripheral/GPIO/Reg
SHAL/Include/Peripheral/UART SHAL/Include/Peripheral/UART
SHAL/Include/Peripheral/UART/Reg SHAL/Include/Peripheral/UART/Reg
SHAL/Include/Peripheral/I2C
SHAL/Include/Peripheral/I2C/Reg
SHAL/Include/Peripheral/EXT/ SHAL/Include/Peripheral/EXT/
${CMAKE_CURRENT_SOURCE_DIR}/SHAL/Include ${CMAKE_CURRENT_SOURCE_DIR}/SHAL/Include
) )

View File

@@ -13,9 +13,16 @@
//Universal structs and defines --------------------------- //Universal structs and defines ---------------------------
enum class AF_Mask : uint8_t{
AF0,
AF1,
AF2,
AF3,
AF4,
AF5,
AF6,
AF7
};
//--------------------------------------------------------- //---------------------------------------------------------

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -8,20 +8,10 @@
#include "SHAL_CORE.h" #include "SHAL_CORE.h"
#include "SHAL_GPIO_REG.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 //Represents a pair of pins usable for USART Tx + Rx in combination, and their alternate function mapping
struct SHAL_UART_Pair{ struct SHAL_UART_Pair{
USART_TypeDef* USARTReg; USART_TypeDef* USARTReg;
GPIO_Key TxKey; GPIO_Key TxKey;
GPIO_Key RxKey; GPIO_Key RxKey;