Updated debug printing for raspi + added persistent_open setting for raspi spi

This commit is contained in:
Dario
2023-05-16 14:58:09 +01:00
parent 21cb870014
commit 0bc924bba2
14 changed files with 529 additions and 93 deletions

View File

@@ -15,7 +15,7 @@
namespace sta
{
class RaspiGpioPin : GpioPin
class RaspiGpioPin : public GpioPin
{
public:
enum class GpioMode {
@@ -31,18 +31,18 @@ namespace sta
void setState(GpioPinState state) override;
static RaspiGpioPin DUMMY_GPIO;
static RaspiGpioPin * DUMMY_GPIO;
private:
uint8_t pin_;
GpioMode mode_;
};
class DummyGpioPin : RaspiGpioPin {
class DummyGpioPin : public RaspiGpioPin {
DummyGpioPin();
void setState(GpioPinState state) override;
}
};
} // namespace sta
#endif // STA_RASPI_GPIO_ENABLED

View File

@@ -2,7 +2,7 @@
#define STA_CORE_RASPI_HAL_HPP
#include <wiringPi.h>
#include <wiringPiI2C.h>
#include <stdio.h>
#include <sys/ioctl.h>
#endif //STA_CORE_RASPI_HAL_HPP

View File

@@ -0,0 +1,13 @@
/**
* @file
* @brief Common configuration for Raspberry Pi MCUs
*/
#ifndef STA_CORE_RASPI_MCU_COMMON_HPP
#define STA_CORE_RASPI_MCU_COMMON_HPP
#define STA_MCU_LITTLE_ENDIAN
// Enable STM32 platform
#define STA_PLATFORM_RASPI
#endif // STA_CORE_RASPI_MCU_COMMON_HPP

View File

@@ -9,10 +9,15 @@
namespace sta
{
enum class SPINode {
DEV_0_0,
DEV_0_1
};
class RaspiSPI : public SPI
{
public:
RaspiSPI(const char * dev, const SPISettings & settings, Mutex * mutex = nullptr);
RaspiSPI(SPINode node, const SPISettings & settings, Mutex * mutex = nullptr, bool persistent_open = true);
~RaspiSPI();
void transfer(uint8_t value) override;
@@ -30,18 +35,17 @@ namespace sta
char * spidev_;
int spifd_;
bool open_;
const bool persistent_open_;
void update_setting(int setting, int value);
int get_setting(int setting, void * rslt_ptr);
void update_settings();
};
class RaspiSPIDevice : SPIDevice
class RaspiSPIDevice : public SPIDevice
{
public:
RaspiSPIDevice(RaspiSPI * intf);
void select() override;
void deselect() override;
};
} // namespace sta