mirror of
https://git.intern.spaceteamaachen.de/ALPAKA/sta-core.git
synced 2025-08-05 18:21:54 +00:00
Fixed broken imports after dir structure rework & added stm32 i2c
This commit is contained in:
44
include/sta/devices/stm32/bus/i2c.hpp
Normal file
44
include/sta/devices/stm32/bus/i2c.hpp
Normal 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
|
@@ -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
|
||||
|
@@ -12,7 +12,7 @@
|
||||
|
||||
#if defined(STA_PLATFORM_STM32) || defined(DOXYGEN)
|
||||
|
||||
#include <sta/stm32/hal.hpp>
|
||||
#include <sta/devices/stm32/hal.hpp>
|
||||
|
||||
|
||||
/**
|
||||
|
@@ -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
|
||||
|
@@ -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
|
@@ -11,7 +11,7 @@
|
||||
#endif // !STM32F411xE
|
||||
|
||||
|
||||
#include <sta/stm32/mcu/common.hpp>
|
||||
#include <sta/devices/stm32/mcu/common.hpp>
|
||||
|
||||
|
||||
// Peripheral clock mappings
|
||||
|
@@ -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
|
||||
|
@@ -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
|
||||
|
Reference in New Issue
Block a user