Rework SPI device interface

This commit is contained in:
Henrik Stickann
2022-05-09 21:12:59 +02:00
parent 99eb7e79fd
commit 7c0c05d296
2 changed files with 21 additions and 6 deletions

View File

@@ -1,14 +1,15 @@
#include <sta/intf/spi_device.hpp>
#include <sta/spi_device.hpp>
#include <sta/assert.hpp>
namespace sta
{
SpiDevice::SpiDevice(SpiInterface * intf)
: intf_{intf}
SpiDevice::SpiDevice(SpiInterface * intf, GpioPin * csPin)
: intf_{intf}, csPin_{csPin}
{
STA_ASSERT(intf != nullptr);
STA_ASSERT(csPin != nullptr);
}
void SpiDevice::beginTransmission()
@@ -73,4 +74,15 @@ namespace sta
{
return intf_->settings();
}
void SpiDevice::select()
{
csPin_->setState(GpioPinState::LOW);
}
void SpiDevice::deselect()
{
csPin_->setState(GpioPinState::HIGH);
}
} // namespace sta