2023-08-20 17:55:40 +02:00

41 lines
985 B
C++

#ifndef STA_CORE_I2C_I2C_HPP
#define STA_CORE_I2C_I2C_HPP
#include <sta/bus/interface.hpp>
#include <sta/mutex.hpp>
#include <cstddef>
#include <cstdint>
namespace sta
{
/**
* @brief Interface class for %I2C hardware.
*
* Represents a single %I2C bus that can be shared by multiple devices.
*
* @ingroup sta_core_i2c
*/
class I2C : public Interface
{
public:
I2C(Mutex * mutex=nullptr);
/**
* @brief Specify the mode of communication via the bus.
*
* @param address The peripheral's address to communicate with.
* @param master Whether the mcu is a master or slave.
* @param blocking Whether to use blocking or non-blocking transmits / receives.
*/
void setSettings(uint16_t address, bool master, bool blocking);
protected:
uint16_t address_;
bool master_;
bool blocking_;
};
} // namespace sta
#endif // STA_CORE_I2C_I2C_HPP