Fixed broken imports after dir structure rework & added stm32 i2c

This commit is contained in:
dvdb97
2023-06-24 15:44:56 +02:00
parent 6b4acfd27b
commit e7ddbbf365
26 changed files with 224 additions and 150 deletions

View File

@@ -0,0 +1,44 @@
#ifndef STA_CORE_STM32_I2C_HPP
#define STA_CORE_STM32_I2C_HPP
#include <sta/config.hpp>
#ifdef STA_PLATFORM_STM32
# include <sta/devices/stm32/hal.hpp>
# ifdef HAL_I2C_MODULE_ENABLED
# define STA_STM32_I2C_ENABLED
# endif // HAL_SPI_MODULE_ENABLED
#endif // STA_PLATFORM_STM32
#ifdef STA_STM32_I2C_ENABLED
#include <sta/bus/i2c/i2c.hpp>
#include <sta/bus/i2c/device.hpp>
namespace sta
{
class STM32I2C : public I2C
{
public:
STM32I2C(I2C_HandleTypeDef * handle, Mutex * mutex=nullptr);
void transfer(uint8_t value) override;
void transfer16(uint16_t value) override;
void transfer(const uint8_t * buffer, size_t size) override;
void transfer(const uint8_t * txBuffer, uint8_t * rxBuffer, size_t size) override;
void receive(uint8_t * buffer, size_t size) override;
void fill(uint8_t value, size_t count) override;
private:
I2C_HandleTypeDef * handle_;
const uint32_t timeout_ = HAL_MAX_DELAY;
};
class STM32I2CDevice : public I2CDevice
{
STM32I2CDevice();
};
}
#endif // STA_STM32_I2C_ENABLED
#endif // STA_CORE_STM32_I2C_HPP

View File

@@ -19,7 +19,7 @@
// Only enable module on STM32 platform w/ HAL CAN module enabled
#include <sta/config.hpp>
#ifdef STA_PLATFORM_STM32
# include <sta/stm32/hal.hpp>
# include <sta/devices/stm32/hal.hpp>
# ifdef HAL_CAN_MODULE_ENABLED
# define STA_STM32_CAN_ENABLED
# endif // HAL_CAN_MODULE_ENABLED

View File

@@ -12,7 +12,7 @@
#if defined(STA_PLATFORM_STM32) || defined(DOXYGEN)
#include <sta/stm32/hal.hpp>
#include <sta/devices/stm32/hal.hpp>
/**

View File

@@ -9,7 +9,7 @@
// Only enable module on STM32 platform w/ HAL GPIO module enabled
#include <sta/config.hpp>
#ifdef STA_PLATFORM_STM32
# include <sta/stm32/hal.hpp>
# include <sta/devices/stm32/hal.hpp>
# ifdef HAL_GPIO_MODULE_ENABLED
# define STA_STM32_GPIO_ENABLED
# endif // HAL_GPIO_MODULE_ENABLED

View File

@@ -1,39 +0,0 @@
#ifndef STA_STM32_I2C_HPP
#define STA_STM32_I2C_HPP
#include <sta/config.hpp>
#ifdef STA_PLATFORM_STM32
# include <sta/stm32/hal.hpp>
# ifdef HAL_I2C_MODULE_ENABLED
# define STA_STM32_I2C_ENABLED
# endif // HAL_SPI_MODULE_ENABLED
#endif // STA_PLATFORM_STM32
#ifdef STA_STM32_I2C_ENABLED
#include <sta/i2c.hpp>
namespace sta {
class STM32I2cDevice : public I2cDevice {
private:
I2C_HandleTypeDef* i2cHandle;
const uint32_t timeout = HAL_MAX_DELAY;
public:
STM32I2cDevice(
I2C_HandleTypeDef* i2cHandle,
uint16_t address,
Mutex* mutex=nullptr,
bool master=false,
bool blocking=true
);
bool transmit(uint8_t* data, uint16_t size) override;
bool receive(uint8_t* data, uint16_t size) override;
bool deviceReady();
};
}
#endif // STA_STM32_I2C_ENABLED
#endif // STA_STM32_I2C_HPP

View File

@@ -11,7 +11,7 @@
#endif // !STM32F411xE
#include <sta/stm32/mcu/common.hpp>
#include <sta/devices/stm32/mcu/common.hpp>
// Peripheral clock mappings

View File

@@ -9,7 +9,7 @@
// Only enable module on STM32 platform w/ HAL SPI module enabled
#include <sta/config.hpp>
#ifdef STA_PLATFORM_STM32
# include <sta/stm32/hal.hpp>
# include <sta/devices/stm32/hal.hpp>
# ifndef HAL_GPIO_MODULE_ENABLED
# error "STM32 GPIO module required!"
# endif // !HAL_GPIO_MODULE_ENABLED

View File

@@ -9,7 +9,7 @@
// Only enable module on STM32 platform w/ HAL UART module enabled
#include <sta/config.hpp>
#ifdef STA_PLATFORM_STM32
# include <sta/stm32/hal.hpp>
# include <sta/devices/stm32/hal.hpp>
# ifdef HAL_UART_MODULE_ENABLED
# define STA_STM32_UART_ENABLED
# endif // HAL_UART_MODULE_ENABLED