mirror of
https://git.intern.spaceteamaachen.de/ALPAKA/sta-core.git
synced 2025-09-28 21:17:33 +00:00
Merge branch 'raspi-support' of ssh://git.intern.spaceteamaachen.de:22222/ALPAKA/sta-core into raspi-support
This commit is contained in:
68
src/devices/arduino/bus/i2c.cpp
Normal file
68
src/devices/arduino/bus/i2c.cpp
Normal file
@@ -0,0 +1,68 @@
|
||||
#include <sta/devices/arduino/bus/i2c.hpp>
|
||||
|
||||
#ifdef STA_PLATFORM_ARDUINO
|
||||
|
||||
#include <sta/devices/arduino/hal.hpp>
|
||||
|
||||
|
||||
namespace sta
|
||||
{
|
||||
ArduinoI2C::ArduinoI2C(Mutex * mutex, uint16_t address)
|
||||
: I2C{mutex}
|
||||
{
|
||||
Wire.begin(address);
|
||||
}
|
||||
|
||||
void ArduinoI2C::transfer16(uint16_t value)
|
||||
{
|
||||
Wire.write(value);
|
||||
}
|
||||
|
||||
void ArduinoI2C::transfer(const uint8_t * buffer, size_t size)
|
||||
{
|
||||
Wire.write(buffer, size);
|
||||
}
|
||||
|
||||
void ArduinoI2C::transfer(const uint8_t * txBuffer, uint8_t * rxBuffer, size_t size)
|
||||
{
|
||||
// NOT REALLY A THING HERE, IS IT?
|
||||
}
|
||||
|
||||
void ArduinoI2C::receive(uint8_t * buffer, size_t size)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void ArduinoI2C::fill(uint8_t value, size_t count)
|
||||
{
|
||||
// Initialize a buffer of size count and fill it with the value.
|
||||
uint8_t *buffer = new uint8_t[count];
|
||||
memset(buffer, value, count);
|
||||
|
||||
Serial.write(buffer, count);
|
||||
|
||||
delete [] buffer;
|
||||
}
|
||||
|
||||
void ArduinoI2C::acquire()
|
||||
{
|
||||
I2C::acquire();
|
||||
|
||||
Wire.beginTransmission(address_);
|
||||
}
|
||||
|
||||
void ArduinoI2C::release()
|
||||
{
|
||||
Wire.endTransmission();
|
||||
|
||||
I2C::release();
|
||||
}
|
||||
|
||||
ArduinoI2CDevice::ArduinoI2CDevice(I2C * intf, int address, bool master, bool blocking)
|
||||
: I2CDevice{intf, address, master, blocking}
|
||||
{
|
||||
|
||||
}
|
||||
} // namespace sta
|
||||
|
||||
#endif // STA_PLATFORM_ARDUINO
|
0
src/devices/arduino/bus/spi.cpp
Normal file
0
src/devices/arduino/bus/spi.cpp
Normal file
20
src/devices/arduino/delay.cpp
Normal file
20
src/devices/arduino/delay.cpp
Normal file
@@ -0,0 +1,20 @@
|
||||
#include <sta/devices/arduino/delay.hpp>
|
||||
|
||||
#ifdef STA_PLATFORM_ARDUINO
|
||||
|
||||
#include <sta/devices/arduino/hal.hpp>
|
||||
|
||||
namespace sta
|
||||
{
|
||||
void delayMs(uint32_t ms)
|
||||
{
|
||||
delay(ms);
|
||||
}
|
||||
|
||||
void delayUs(uint32_t us)
|
||||
{
|
||||
delayMicroseconds(us);
|
||||
}
|
||||
} // namespace sta
|
||||
|
||||
#endif // STA_PLATFORM_ARDUINO
|
28
src/devices/arduino/gpio_pin.cpp
Normal file
28
src/devices/arduino/gpio_pin.cpp
Normal file
@@ -0,0 +1,28 @@
|
||||
#include <sta/devices/arduino/gpio_pin.hpp>
|
||||
|
||||
#ifdef STA_PLATFORM_ARDUINO
|
||||
|
||||
#include <sta/devices/arduino/hal.hpp>
|
||||
|
||||
namespace sta
|
||||
{
|
||||
ArduinoGpioPin::ArduinoGpioPin(uint16_t pin) : pin_{pin} { }
|
||||
|
||||
void ArduinoGpioPin::setState(GpioPinState state)
|
||||
{
|
||||
digitalWrite(pin_, (state == GpioPinState::GPIO_LOW) ? LOW : HIGH);
|
||||
}
|
||||
|
||||
GpioPinState ArduinoGpioPin::getState()
|
||||
{
|
||||
return digitalRead(pin_) == HIGH ? GpioPinState::GPIO_HIGH : GpioPinState::GPIO_LOW;
|
||||
}
|
||||
|
||||
uint16_t ArduinoGpioPin::getPin() const
|
||||
{
|
||||
return pin_;
|
||||
}
|
||||
|
||||
} // namespace sta
|
||||
|
||||
#endif // STA_PLATFORM_ARDUINO
|
Reference in New Issue
Block a user