mirror of
https://git.intern.spaceteamaachen.de/ALPAKA/sta-core.git
synced 2025-06-10 00:36:00 +00:00
42 lines
1016 B
C++
42 lines
1016 B
C++
#ifndef STA_CORE_I2C_DEVICE_HPP
|
|
#define STA_CORE_I2C_DEVICE_HPP
|
|
|
|
#include <sta/bus/i2c/i2c.hpp>
|
|
#include <sta/bus/device.hpp>
|
|
|
|
namespace sta
|
|
{
|
|
/**
|
|
* @brief Peripheral device connected via I2c.
|
|
*
|
|
* @ingroup sta_core_i2c
|
|
*/
|
|
class I2CDevice : public Device
|
|
{
|
|
public:
|
|
/**
|
|
* @param intf %I2C hardware interface
|
|
* @param address Device address
|
|
* @param master Whether the mcu is a master or slave
|
|
* @param blocking Whether to use blocking or non-blocking transmits / receives
|
|
*/
|
|
I2CDevice(I2C * intf, int address, bool master=true, bool blocking=true);
|
|
|
|
protected:
|
|
void select() override;
|
|
void deselect() override;
|
|
|
|
private:
|
|
I2C * intf_;
|
|
int address_; /**< device address */
|
|
int master_; /**< is the mcu the master? */
|
|
int blocking_; /**< blocking or non-blocking transmits / receives */
|
|
};
|
|
|
|
} // namespace sta
|
|
|
|
|
|
|
|
|
|
#endif // STA_CORE_I2C_DEVICE_HPP
|