Begin I2C implementation and finalize other changes

This commit is contained in:
Ea-r-th
2025-09-10 01:53:16 -07:00
parent 8f3bd7ebd8
commit 914fbf5a17
5 changed files with 78 additions and 8 deletions

View File

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

View File

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

View File

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

View File

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

View File

@@ -46,7 +46,6 @@ public:
static SHAL_UART& get(uint8_t uart);
UARTManager() = delete;
private: