#ifndef STA_STM32_I2C_HPP #define STA_STM32_I2C_HPP #include #ifdef STA_PLATFORM_STM32 # include # 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 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