AgIsoStack++
A control-function-focused implementation of the major ISOBUS and J1939 protocols
Loading...
Searching...
No Matches
spi_interface_esp.hpp
Go to the documentation of this file.
1//================================================================================================
9//================================================================================================
10
11#ifndef SPI_INTERFACE_ESP_SYNC_HPP
12#define SPI_INTERFACE_ESP_SYNC_HPP
13
15
16#include "driver/spi_master.h"
17#include "freertos/semphr.h"
18
19namespace isobus
20{
21 //================================================================================================
25 //================================================================================================
27 {
28 public:
29 static constexpr std::uint32_t MAX_TIME_TO_WAIT = 5000 / portTICK_PERIOD_MS;
30
34 SPIInterfaceESP(const spi_device_interface_config_t *deviceConfig, const spi_host_device_t hostDevice);
35
37 virtual ~SPIInterfaceESP();
38
41 bool init();
42
44 void deinit();
45
48 void transmit(SPITransactionFrame *frame) override;
49
52 bool end_transaction() override;
53
54 private:
55 const spi_device_interface_config_t *deviceConfig;
56 const spi_host_device_t hostDevice;
57 const SemaphoreHandle_t spiMutex;
58 spi_device_handle_t spiDevice;
60 bool success;
61 };
62}
63#endif // SPI_INTERFACE_ESP_SYNC_HPP
An abstract base class for SPI communication.
A driver for (synchronous) SPI communication on ESP platforms.
void transmit(SPITransactionFrame *frame) override
Write (and read) a frame to the SPI bus.
bool init()
Initialize the SPI device.
bool success
The status of the current transaction.
void deinit()
Deinitialize the SPI device.
bool end_transaction() override
End the transaction. This function returns the status since the last end_transaction().
virtual ~SPIInterfaceESP()
Destructor of a SPI device on an ESP platform.
const SemaphoreHandle_t spiMutex
A mutex to prevent concurrent access to the SPI bus.
bool initialized
The status of the device.
spi_device_handle_t spiDevice
A handle to the SPI device.
SPIInterfaceESP(const spi_device_interface_config_t *deviceConfig, const spi_host_device_t hostDevice)
Constructor of a SPI device on an ESP platform.
const spi_device_interface_config_t * deviceConfig
The configuration of the SPI device.
static constexpr std::uint32_t MAX_TIME_TO_WAIT
timeout of 5 seconds for spi related calls, mostly arbitrary.
const spi_host_device_t hostDevice
The host spi device.
A class containing the data for a single SPI transaction.
This namespace encompasses all of the ISO11783 stack's functionality to reduce global namespace pollu...
A base class for SPI communication between hardware devices. Can be derived into your platform's requ...