mirror of
https://git.intern.spaceteamaachen.de/ALPAKA/sta-core.git
synced 2025-09-28 21:17:33 +00:00
First reworks for debugging
This commit is contained in:
@@ -2,8 +2,8 @@
|
||||
|
||||
namespace sta
|
||||
{
|
||||
UART::UART(const UARTSettings & settings, Mutex * mutex)
|
||||
: Interface{mutex}, settings_{settings}
|
||||
UART::UART(Mutex * mutex)
|
||||
: Interface{mutex}
|
||||
{
|
||||
|
||||
}
|
||||
|
@@ -4,9 +4,9 @@
|
||||
|
||||
#ifdef STA_PLATFORM_STM32
|
||||
|
||||
#include <sta/stm32/uart.hpp>
|
||||
#include <sta/devices/stm32/bus/uart.hpp>
|
||||
|
||||
#include <usart.h>
|
||||
// #include <usart.h>
|
||||
|
||||
// Set platform UART alias
|
||||
using PlatformUART = sta::STM32UART;
|
||||
|
@@ -119,4 +119,10 @@ namespace sta
|
||||
delete [] buffer;
|
||||
}
|
||||
|
||||
STM32I2CDevice::STM32I2CDevice(STM32I2C * intf, int address, bool master, bool blocking)
|
||||
: I2CDevice(intf, address, master, blocking)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
} // namespace sta
|
||||
|
@@ -1,4 +1,4 @@
|
||||
#include <sta/devices/stm32/spi.hpp>
|
||||
#include <sta/devices/stm32/bus/spi.hpp>
|
||||
#ifdef STA_STM32_SPI_ENABLED
|
||||
|
||||
#include <sta/assert.hpp>
|
58
src/devices/stm32/bus/uart.cpp
Normal file
58
src/devices/stm32/bus/uart.cpp
Normal file
@@ -0,0 +1,58 @@
|
||||
#include <sta/devices/stm32/bus/uart.hpp>
|
||||
#ifdef STA_STM32_UART_ENABLED
|
||||
|
||||
#include <sta/assert.hpp>
|
||||
#include <cstring>
|
||||
|
||||
namespace sta
|
||||
{
|
||||
STM32UART::STM32UART(UART_HandleTypeDef * handle, Mutex * mutex)
|
||||
: UART{mutex}, handle_{handle}
|
||||
{
|
||||
STA_ASSERT(handle != nullptr);
|
||||
}
|
||||
|
||||
void STM32UART::transfer(uint8_t value)
|
||||
{
|
||||
HAL_UART_Transmit(handle_, &value, 1, HAL_MAX_DELAY);
|
||||
}
|
||||
|
||||
void STM32UART::transfer16(uint16_t value)
|
||||
{
|
||||
HAL_UART_Transmit(handle_, reinterpret_cast<uint8_t *>(&value), 2, HAL_MAX_DELAY);
|
||||
}
|
||||
|
||||
void STM32UART::transfer(const uint8_t * buffer, size_t size)
|
||||
{
|
||||
STA_ASSERT(buffer != nullptr);
|
||||
|
||||
HAL_UART_Transmit(handle_, const_cast<uint8_t *>(buffer), size, HAL_MAX_DELAY);
|
||||
}
|
||||
|
||||
void STM32UART::transfer(const uint8_t * txBuffer, uint8_t * rxBuffer, size_t size)
|
||||
{
|
||||
// IS THIS A THING HERE?
|
||||
}
|
||||
|
||||
void STM32UART::receive(uint8_t * buffer, size_t size)
|
||||
{
|
||||
STA_ASSERT(buffer != nullptr);
|
||||
|
||||
HAL_UART_Receive(handle_, buffer, size, HAL_MAX_DELAY);
|
||||
}
|
||||
|
||||
void STM32UART::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);
|
||||
|
||||
// Transfer the buffer via the bus.
|
||||
transfer(buffer, count);
|
||||
|
||||
delete [] buffer;
|
||||
}
|
||||
} // namespace sta
|
||||
|
||||
|
||||
#endif // STA_STM32_UART_ENABLED
|
@@ -1,25 +0,0 @@
|
||||
#include <sta/devices/stm32/uart.hpp>
|
||||
#ifdef STA_STM32_UART_ENABLED
|
||||
|
||||
#include <sta/assert.hpp>
|
||||
|
||||
|
||||
namespace sta
|
||||
{
|
||||
STM32UART::STM32UART(UART_HandleTypeDef * handle)
|
||||
: handle_{handle}
|
||||
{
|
||||
STA_ASSERT(handle != nullptr);
|
||||
}
|
||||
|
||||
|
||||
void STM32UART::write(const uint8_t * buffer, size_t size)
|
||||
{
|
||||
STA_ASSERT(buffer != nullptr);
|
||||
|
||||
HAL_UART_Transmit(handle_, const_cast<uint8_t *>(buffer), size, HAL_MAX_DELAY);
|
||||
}
|
||||
} // namespace sta
|
||||
|
||||
|
||||
#endif // STA_STM32_UART_ENABLED
|
28
src/uart.cpp
28
src/uart.cpp
@@ -1,28 +0,0 @@
|
||||
#include <sta/uart.hpp>
|
||||
|
||||
#include <sta/printf.hpp>
|
||||
|
||||
#include <cinttypes>
|
||||
#include <cstring>
|
||||
|
||||
|
||||
namespace sta
|
||||
{
|
||||
void UART::write(uint8_t value)
|
||||
{
|
||||
// TODO Handle endian-ness
|
||||
write(&value, 1);
|
||||
}
|
||||
|
||||
void UART::write(uint16_t value)
|
||||
{
|
||||
// TODO Handle endian-ness
|
||||
write(reinterpret_cast<uint8_t *>(&value), sizeof(value));
|
||||
}
|
||||
|
||||
void UART::write(uint32_t value)
|
||||
{
|
||||
// TODO Handle endian-ness
|
||||
write(reinterpret_cast<uint8_t *>(&value), sizeof(value));
|
||||
}
|
||||
} // namespace sta
|
Reference in New Issue
Block a user