mirror of
https://git.intern.spaceteamaachen.de/ALPAKA/sta-core.git
synced 2025-06-10 16:55:58 +00:00
40 lines
881 B
C++
40 lines
881 B
C++
#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
|