Fixed gpio pin implementation and SPI chip select

This commit is contained in:
dario
2024-02-09 20:34:18 +01:00
parent ec83b7026e
commit 5d1fef1b53
6 changed files with 33 additions and 8 deletions

View File

@@ -54,6 +54,8 @@ namespace sta
void ArduinoSPI::acquire()
{
SPI::acquire();
const SPISettings & set = settings();
uint8_t dataMode;
@@ -98,5 +100,13 @@ namespace sta
void ArduinoSPI::release()
{
SPIClass::endTransaction();
SPI::release();
}
ArduinoSPIDevice::ArduinoSPIDevice(ArduinoSPI * intf, ArduinoGpioPin * csPin)
: SPIDevice{intf, csPin}
{
csPin->setState(GpioPinState::GPIO_HIGH);
}
} // namespace sta

View File

@@ -6,7 +6,11 @@
namespace sta
{
ArduinoGpioPin::ArduinoGpioPin(uint16_t pin) : pin_{pin} { }
ArduinoGpioPin::ArduinoGpioPin(uint16_t pin, PinMode mode)
: pin_{pin}
{
pinMode(pin, (mode == PinMode::GPIO_OUTPUT) ? OUTPUT : INPUT);
}
void ArduinoGpioPin::setState(GpioPinState state)
{