2 Commits

Author SHA1 Message Date
Ea-r-th
55f03031b3 Added files for I2C 2025-09-09 20:11:17 -07:00
9f1aad028d Added friendly reminder 2025-09-08 02:33:01 -07:00
8 changed files with 75 additions and 15 deletions

View File

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

View File

@@ -13,9 +13,16 @@
//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_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;

View File

@@ -51,7 +51,7 @@ void UART::begin(uint32_t baudRate) volatile {
usart->CR1 = USART_CR1_TE | USART_CR1_RE; //Tx enable and Rx Enable
usart->BRR = 8000000 / baudRate; //MAKE SURE ANY FUNCTION THAT CHANGES CLOCK UPDATES THIS!
usart->BRR = 8000000 / baudRate; //MAKE SURE ANY FUNCTION THAT CHANGES CLOCK UPDATES THIS! //TODO DO NOT HARDCODE THIS SHIT
usart->CR1 |= USART_CR1_UE;