First reworks for debugging

This commit is contained in:
dvdb97
2023-07-12 13:33:34 +02:00
parent e7ddbbf365
commit 96d94edc52
15 changed files with 125 additions and 126 deletions

View File

@@ -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

View File

@@ -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>

View 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

View File

@@ -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