mirror of
https://git.intern.spaceteamaachen.de/ALPAKA/sta-core.git
synced 2025-06-10 16:55:58 +00:00
Updated uart comunication for spatz
This commit is contained in:
parent
b0b775ffb0
commit
ac1344747b
@ -2,6 +2,7 @@
|
||||
#define STA_CORE_SPATZ_HPP
|
||||
|
||||
#include <sta/mutex.hpp>
|
||||
#include <sta/signal.hpp>
|
||||
|
||||
#include <sta/config.hpp>
|
||||
#ifdef STA_SPATZ_ENABLED
|
||||
@ -20,7 +21,7 @@ namespace sta
|
||||
*
|
||||
* @param mutex A mutex used to make SPATZ thread-safe.
|
||||
*/
|
||||
void init(Mutex * mutex);
|
||||
void init(Mutex * mutex, Signal * signal);
|
||||
|
||||
/**
|
||||
* @brief Request bytes for a specific sensor id via the printable.
|
||||
|
@ -22,7 +22,7 @@ namespace sta
|
||||
|
||||
Profiler::~Profiler()
|
||||
{
|
||||
STA_DEBUG_PRINTF("[PROFILER] %s took %d us", name_, timeUs() - start_);
|
||||
STA_DEBUG_PRINTF(">[PROFILER] %s took %d us", name_, timeUs() - start_);
|
||||
}
|
||||
} // namespace sta
|
||||
|
||||
|
@ -6,19 +6,20 @@
|
||||
# error "The ID used to communicate SPATZ initialization was not defined."
|
||||
#endif // STA_INIT_SPATZ_ID
|
||||
|
||||
#include <cmsis_os2.h>
|
||||
#include <FreeRTOS.h>
|
||||
#include <usart.h>
|
||||
|
||||
namespace sta
|
||||
{
|
||||
namespace spatz
|
||||
{
|
||||
sta::Mutex * mutex_;
|
||||
sta::Mutex * mutex_ = nullptr;
|
||||
sta::Signal * signal_ = nullptr;
|
||||
|
||||
void init(sta::Mutex * mutex)
|
||||
void init(sta::Mutex * mutex, Signal * signal)
|
||||
{
|
||||
mutex_ = mutex;
|
||||
signal_ = signal;
|
||||
|
||||
uint8_t msg = 0xFF;
|
||||
|
||||
sta::lock_guard<sta::Mutex> lock(*mutex_);
|
||||
@ -42,23 +43,9 @@ namespace sta
|
||||
{
|
||||
mutex_->acquire();
|
||||
|
||||
bool success = false;
|
||||
|
||||
while (!success)
|
||||
{
|
||||
Debug->printf("%d", id);
|
||||
|
||||
HAL_StatusTypeDef state = HAL_UART_Receive(&huart1, reinterpret_cast<uint8_t*>(buffer), length * sizeof(float), 100);
|
||||
|
||||
if (state == HAL_TIMEOUT)
|
||||
{
|
||||
success = false;
|
||||
Debug->println(">ERROR");
|
||||
break;
|
||||
}
|
||||
|
||||
success = true;
|
||||
}
|
||||
HAL_UART_Receive_IT(&huart1, reinterpret_cast<uint8_t*>(buffer), length * sizeof(float));
|
||||
Debug->printf("%d", id);
|
||||
signal_->wait();
|
||||
|
||||
mutex_->release();
|
||||
}
|
||||
@ -73,6 +60,14 @@ namespace sta
|
||||
} // namespace spatz
|
||||
} // namespace sta
|
||||
|
||||
|
||||
void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart)
|
||||
{
|
||||
if (sta::spatz::signal_ != nullptr)
|
||||
sta::spatz::signal_->notify();
|
||||
}
|
||||
|
||||
|
||||
#else
|
||||
|
||||
namespace sta
|
||||
|
Loading…
x
Reference in New Issue
Block a user