Add kernel drivers for SPI and UART and make locking APIs more consistent (#489)
- Add kernel support for SPI driver - Add kernel support for UART driver - Implemented ESP32 UART kernel driver - Update existing UART-related code in Tactility to use new kernel driver - Remove UART from tt::hal::Configuration - Remove tt_hal_uart functionality but keep functions for now - Update devicetrees for UART changes - Kernel mutex and recursive mutex: improved locking API design - Other kernel improvements - Added device_exists_of_type() and device_find_by_name()
This commit is contained in:
committed by
GitHub
parent
7e24105d0c
commit
74127a5f6c
@@ -2,13 +2,13 @@
|
||||
|
||||
#include "Tactility/hal/gps/GpsDevice.h"
|
||||
|
||||
namespace tt::hal::uart { class Uart; }
|
||||
struct Device;
|
||||
|
||||
namespace tt::hal::gps {
|
||||
|
||||
/**
|
||||
* Init sequence on UART for a specific GPS model.
|
||||
*/
|
||||
bool init(uart::Uart& uart, GpsModel type);
|
||||
bool init(::Device* uart, GpsModel type);
|
||||
|
||||
}
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
#pragma once
|
||||
|
||||
#include "Tactility/hal/gps/GpsDevice.h"
|
||||
#include "Tactility/hal/uart/Uart.h"
|
||||
struct Device;
|
||||
|
||||
namespace tt::hal::gps {
|
||||
|
||||
GpsModel probe(uart::Uart& iart);
|
||||
GpsModel probe(::Device* uart);
|
||||
|
||||
}
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
#pragma once
|
||||
|
||||
#include "Tactility/hal/gps/GpsDevice.h"
|
||||
#include "Tactility/hal/uart/Uart.h"
|
||||
|
||||
#include <cstdint>
|
||||
#include <cstddef>
|
||||
|
||||
struct Device;
|
||||
|
||||
namespace tt::hal::gps::ublox {
|
||||
|
||||
void checksum(uint8_t* message, size_t length);
|
||||
@@ -13,15 +14,8 @@ void checksum(uint8_t* message, size_t length);
|
||||
// From https://github.com/meshtastic/firmware/blob/7648391f91f2b84e367ae2b38220b30936fb45b1/src/gps/GPS.cpp#L128
|
||||
uint8_t makePacket(uint8_t classId, uint8_t messageId, const uint8_t* payload, uint8_t payloadSize, uint8_t* bufferOut);
|
||||
|
||||
template<size_t DataSize>
|
||||
inline void sendPacket(uart_port_t port, uint8_t type, uint8_t id, uint8_t data[DataSize], const char* errorMessage, TickType_t timeout) {
|
||||
static uint8_t buffer[250] = {0};
|
||||
size_t length = makePacket(type, id, data, DataSize, buffer);
|
||||
// hal::uart::writeBytes(port, buffer, length);
|
||||
GpsModel probe(::Device* uart);
|
||||
|
||||
bool init(::Device* uart, GpsModel model);
|
||||
|
||||
}
|
||||
|
||||
GpsModel probe(uart::Uart& uart);
|
||||
|
||||
bool init(uart::Uart& uart, GpsModel model);
|
||||
|
||||
} // namespace tt::service::gps
|
||||
|
||||
@@ -1,36 +0,0 @@
|
||||
#pragma once
|
||||
#ifdef ESP_PLATFORM
|
||||
|
||||
#include "Tactility/Mutex.h"
|
||||
#include "Tactility/hal/uart/Uart.h"
|
||||
#include "Tactility/hal/uart/Configuration.h"
|
||||
|
||||
namespace tt::hal::uart {
|
||||
|
||||
class UartEsp final : public Uart {
|
||||
|
||||
Mutex mutex;
|
||||
const Configuration& configuration;
|
||||
bool started = false;
|
||||
|
||||
public:
|
||||
|
||||
explicit UartEsp(const Configuration& configuration) : configuration(configuration) {}
|
||||
|
||||
bool start() override;
|
||||
bool isStarted() const override;
|
||||
bool stop() override;
|
||||
size_t readBytes(std::byte* buffer, size_t bufferSize, TickType_t timeout) override;
|
||||
bool readByte(std::byte* output, TickType_t timeout) override;
|
||||
size_t writeBytes(const std::byte* buffer, size_t bufferSize, TickType_t timeout) override;
|
||||
size_t available(TickType_t timeout) override;
|
||||
bool setBaudRate(uint32_t baudRate, TickType_t timeout) override;
|
||||
uint32_t getBaudRate() override;
|
||||
void flushInput() override;
|
||||
};
|
||||
|
||||
std::unique_ptr<Uart> create(const Configuration& configuration);
|
||||
|
||||
} // namespace tt::hal::uart
|
||||
|
||||
#endif
|
||||
@@ -1,9 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "Tactility/hal/uart/Uart.h"
|
||||
|
||||
namespace tt::hal::uart {
|
||||
|
||||
bool init(const std::vector<uart::Configuration>& configurations);
|
||||
|
||||
}
|
||||
@@ -1,47 +0,0 @@
|
||||
#pragma once
|
||||
#ifndef ESP_PLATFORM
|
||||
|
||||
#include "Tactility/Mutex.h"
|
||||
#include "Tactility/hal/uart/Configuration.h"
|
||||
#include "Tactility/hal/uart/Uart.h"
|
||||
|
||||
#include <termios.h>
|
||||
|
||||
namespace tt::hal::uart {
|
||||
|
||||
class UartPosix final : public Uart {
|
||||
|
||||
private:
|
||||
struct AutoCloseFileDeleter {
|
||||
void operator()(FILE* file) {
|
||||
fclose(file);
|
||||
}
|
||||
};
|
||||
|
||||
Mutex mutex;
|
||||
const Configuration& configuration;
|
||||
std::unique_ptr<FILE, AutoCloseFileDeleter> device;
|
||||
|
||||
bool awaitAvailable(TickType_t timeout);
|
||||
|
||||
public:
|
||||
|
||||
explicit UartPosix(const Configuration& configuration) : configuration(configuration) {}
|
||||
|
||||
bool start() final;
|
||||
bool isStarted() const final;
|
||||
bool stop() final;
|
||||
size_t readBytes(std::byte* buffer, size_t bufferSize, TickType_t timeout) final;
|
||||
bool readByte(std::byte* output, TickType_t timeout) final;
|
||||
size_t writeBytes(const std::byte* buffer, size_t bufferSize, TickType_t timeout) final;
|
||||
size_t available(TickType_t timeout) final;
|
||||
bool setBaudRate(uint32_t baudRate, TickType_t timeout) final;
|
||||
uint32_t getBaudRate() final;
|
||||
void flushInput() final;
|
||||
};
|
||||
|
||||
std::unique_ptr<Uart> create(const Configuration& configuration);
|
||||
|
||||
} // namespace tt::hal::uart
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user