mirror of
https://git.intern.spaceteamaachen.de/ALPAKA/sta-core.git
synced 2025-08-05 18:21:54 +00:00
Added I2C support for raspi & first rework of debugging
This commit is contained in:
37
include/sta/bus/i2c/device.hpp
Normal file
37
include/sta/bus/i2c/device.hpp
Normal file
@@ -0,0 +1,37 @@
|
||||
#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 csPin The peripheral's address.
|
||||
*/
|
||||
I2cDevice(I2c * intf, int addr);
|
||||
|
||||
protected:
|
||||
void select() override;
|
||||
|
||||
void deselect() override;
|
||||
|
||||
private:
|
||||
int addr_; /**< device address */
|
||||
};
|
||||
|
||||
} // namespace sta
|
||||
|
||||
|
||||
|
||||
|
||||
#endif // STA_CORE_I2C_DEVICE_HPP
|
33
include/sta/bus/i2c/i2c.hpp
Normal file
33
include/sta/bus/i2c/i2c.hpp
Normal file
@@ -0,0 +1,33 @@
|
||||
#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 Address selection for the I2C bus.
|
||||
*
|
||||
* @param address The address to select.
|
||||
*/
|
||||
virtual void selectAddress(uint16_t address) = 0;
|
||||
};
|
||||
} // namespace sta
|
||||
|
||||
#endif // STA_CORE_I2C_I2C_HPP
|
Reference in New Issue
Block a user