mirror of
https://git.intern.spaceteamaachen.de/ALPAKA/sta-core.git
synced 2025-08-06 10:27:34 +00:00
Added first implementations for Arduino
This commit is contained in:
36
include/sta/devices/arduino/bus/i2c.hpp
Normal file
36
include/sta/devices/arduino/bus/i2c.hpp
Normal file
@@ -0,0 +1,36 @@
|
||||
#ifndef STA_CORE_ARDUINO_I2C_HPP
|
||||
#define STA_CORE_ARDUINO_I2C_HPP
|
||||
|
||||
#include <sta/config.hpp>
|
||||
#ifdef STA_PLATFORM_ARDUINO
|
||||
|
||||
#include <sta/bus/i2c/device.hpp>
|
||||
#include <sta/bus/i2c/i2c.hpp>
|
||||
|
||||
namespace sta
|
||||
{
|
||||
class ArduinoI2C : public I2C
|
||||
{
|
||||
public:
|
||||
ArduinoI2C(Mutex * mutex=nullptr, uint16_t address);
|
||||
|
||||
void transfer16(uint16_t value) override;
|
||||
void transfer(const uint8_t * buffer, size_t size) override;
|
||||
void transfer(const uint8_t * txBuffer, uint8_t * rxBuffer, size_t size) override;
|
||||
void receive(uint8_t * buffer, size_t size) override;
|
||||
void fill(uint8_t value, size_t count) override;
|
||||
|
||||
void acquire();
|
||||
void release();
|
||||
};
|
||||
|
||||
class ArduinoI2CDevice : public I2CDevice
|
||||
{
|
||||
public:
|
||||
ArduinoI2CDevice(I2C * intf, int address, bool master=false, bool blocking=true);
|
||||
};
|
||||
} // namespace sta
|
||||
|
||||
#endif // STA_PLATFORM_ARDUINO
|
||||
|
||||
#endif // STA_CORE_ARDUINO_I2C_HPP
|
0
include/sta/devices/arduino/bus/spi.hpp
Normal file
0
include/sta/devices/arduino/bus/spi.hpp
Normal file
28
include/sta/devices/arduino/delay.hpp
Normal file
28
include/sta/devices/arduino/delay.hpp
Normal file
@@ -0,0 +1,28 @@
|
||||
#ifndef STA_CORE_ARDUINO_DELAY_HPP
|
||||
#define STA_CORE_ARDUINO_DELAY_HPP
|
||||
|
||||
// Only enable module on Arduino platform
|
||||
#include <sta/config.hpp>
|
||||
|
||||
#if defined(STA_PLATFORM_ARDUINO) || defined(DOXYGEN)
|
||||
|
||||
namespace sta
|
||||
{
|
||||
/**
|
||||
* @brief Millisecond delay.
|
||||
*
|
||||
* @param ms Milliseconds
|
||||
*/
|
||||
void delayMs(uint32_t ms);
|
||||
|
||||
/**
|
||||
* @brief Microsecond delay.
|
||||
*
|
||||
* @param us Microseconds
|
||||
*/
|
||||
void delayUs(uint32_t us);
|
||||
} // namespace sta
|
||||
|
||||
#endif // STA_PLATFORM_ARDUINO
|
||||
|
||||
#endif // STA_CORE_ARDUINO_DELAY_HPP
|
44
include/sta/devices/arduino/gpio_pin.hpp
Normal file
44
include/sta/devices/arduino/gpio_pin.hpp
Normal file
@@ -0,0 +1,44 @@
|
||||
/**
|
||||
* @file
|
||||
* @brief Wrapper for Arduino GPIO pins.
|
||||
*/
|
||||
#ifndef STA_CORE_ARDUINO_GPIO_PIN_HPP
|
||||
#define STA_CORE_ARDUINO_GPIO_PIN_HPP
|
||||
|
||||
// Only enable module on Arduino platform w/ HAL GPIO module enabled
|
||||
#include <sta/config.hpp>
|
||||
|
||||
#if defined(STA_PLATFORM_ARDUINO) || defined(DOXYGEN)
|
||||
|
||||
#include <sta/gpio_pin.hpp>
|
||||
#include <cstdint>
|
||||
|
||||
namespace sta
|
||||
{
|
||||
class ArduinoGpioPin : public GpioPin
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @param port GPIO port
|
||||
* @param pin Pin index
|
||||
*/
|
||||
ArduinoGpioPin(uint16_t pin);
|
||||
|
||||
void setState(GpioPinState state) override;
|
||||
|
||||
GpioPinState getState() override;
|
||||
|
||||
/**
|
||||
* @brief Get pin index for pin.
|
||||
*
|
||||
* @return Pin index
|
||||
*/
|
||||
uint16_t getPin() const;
|
||||
private:
|
||||
uint16_t pin_; /**< GPIO pin */
|
||||
};
|
||||
} // namespace sta
|
||||
|
||||
#endif // STA_ARDUINO_GPIO_ENABLED
|
||||
|
||||
#endif // STA_CORE_ARDUINO_GPIO_PIN_HPP
|
8
include/sta/devices/arduino/hal.hpp
Normal file
8
include/sta/devices/arduino/hal.hpp
Normal file
@@ -0,0 +1,8 @@
|
||||
#ifndef STA_CORE_ARDUINO_HAL_HPP
|
||||
#define STA_CORE_ARDUINO_HAL_HPP
|
||||
|
||||
#include<Arduino.h>
|
||||
#include<Wire.h>
|
||||
#include<SPI.h>
|
||||
|
||||
#endif // STA_CORE_ARDUINO_HAL_HPP
|
7
include/sta/devices/arduino/mcu/common.hpp
Normal file
7
include/sta/devices/arduino/mcu/common.hpp
Normal file
@@ -0,0 +1,7 @@
|
||||
#ifndef STA_CORE_ARDUINO_MCU_COMMON_HPP
|
||||
#define STA_CORE_ARDUINO_MCU_COMMON_HPP
|
||||
|
||||
// Enable Arduino platform
|
||||
#define STA_PLATFORM_ARDUINO
|
||||
|
||||
#endif // STA_CORE_ARDUINO_MCU_COMMON_HPP
|
6
include/sta/devices/arduino/mcu/uno_r3.hpp
Normal file
6
include/sta/devices/arduino/mcu/uno_r3.hpp
Normal file
@@ -0,0 +1,6 @@
|
||||
#ifndef STA_CORE_ARDUINO_MCU_UNO_R3_HPP
|
||||
#define STA_CORE_ARDUINO_MCU_UNO_R3_HPP
|
||||
|
||||
#include <sta/devices/arduino/mcu/common.hpp>
|
||||
|
||||
#endif // STA_CORE_ARDUINO_MCU_UNO_R3_HPPs
|
@@ -1,12 +0,0 @@
|
||||
#ifndef STA_CORE_ARDUINO_NOT_IMPLEMENTED_HPP
|
||||
#define STA_CORE_ARDUINO_NOT_IMPLEMENTED_HPP
|
||||
|
||||
|
||||
/**
|
||||
* @defgroup sta_core_arduino Arduino
|
||||
* @ingroup sta_core_platforms
|
||||
* @brief Modules implemented for the Arduino platform.
|
||||
*/
|
||||
|
||||
|
||||
#endif // STA_CORE_ARDUINO_NOT_IMPLEMENTED_HPP
|
Reference in New Issue
Block a user