mirror of
https://git.intern.spaceteamaachen.de/ALPAKA/sta-core.git
synced 2025-06-10 16:55:58 +00:00
88 lines
2.3 KiB
C++
88 lines
2.3 KiB
C++
#ifndef STA_CORE_SPATZ_HPP
|
|
#define STA_CORE_SPATZ_HPP
|
|
|
|
#include <sta/mutex.hpp>
|
|
#include <sta/signal.hpp>
|
|
#include <sta/event.hpp>
|
|
|
|
#include <sta/config.hpp>
|
|
#ifdef STA_SPATZ_ENABLED
|
|
|
|
#include <sta/debug/debug.hpp>
|
|
#ifndef STA_DEBUGGING_ENABLED
|
|
# error "Cannot use SPATZ without debugging being enabled."
|
|
#endif // STA_DEBUGGING_ENABLED
|
|
|
|
namespace sta
|
|
{
|
|
namespace spatz
|
|
{
|
|
/**
|
|
* @brief Initialize SPATZ for in-the-loop testing.
|
|
*
|
|
* @param mutex A mutex used to make SPATZ thread-safe.
|
|
*/
|
|
void init(Mutex * mutex, Event * signal);
|
|
|
|
/**
|
|
* @brief Notify SPATZ that a new tick has happened.
|
|
*/
|
|
void tick();
|
|
|
|
/**
|
|
* @brief Request bytes for a specific sensor id via the printable.
|
|
*
|
|
* @param id The id of the sensor to request data for.
|
|
* @param buffer The byte buffer to write the data to.
|
|
* @param length The number of the bytes to request.
|
|
*/
|
|
void request(uint8_t id, uint8_t * buffer, size_t length);
|
|
|
|
/**
|
|
* @brief Request floats for a specific sensor id via the printable.
|
|
*
|
|
* @param id The id of the sensor to request data for.
|
|
* @param buffer The float buffer to write the data to.
|
|
* @param length The number of floats to request.
|
|
*/
|
|
bool request(uint8_t id, float * buffer, size_t length);
|
|
|
|
/**
|
|
* @brief Request doubles for a specific sensor id via the printable.
|
|
*
|
|
* @param id The id of the sensor to request data for.
|
|
* @param buffer The double buffer to write the data to.
|
|
* @param length The number of doubles to request.
|
|
*/
|
|
void request(uint8_t id, double * buffer, size_t length);
|
|
|
|
void notify(uint8_t id);
|
|
} // namespace spatz
|
|
} // namespace sta
|
|
|
|
#define STA_SPATZ_NOTIFY(id) sta::spatz::notify(id)
|
|
|
|
#define STA_SPATZ_INIT(mutex, signal) sta::spatz::init(mutex, signal)
|
|
|
|
#define STA_SPATZ_TICK() sta::spatz::tick();
|
|
|
|
#else
|
|
|
|
namespace sta
|
|
{
|
|
namespace spatz
|
|
{
|
|
void init(Mutex * mutex, Event * signal);
|
|
} // namespace spatz
|
|
} // namespace sta
|
|
|
|
#define STA_SPATZ_NOTIFY(id) ((void)0)
|
|
|
|
#define STA_SPATZ_INIT(mutex, signal) ((void)0)
|
|
|
|
#define STA_SPATZ_TICK() ((void)0)
|
|
|
|
#endif // STA_SPATZ_ENABLED
|
|
|
|
#endif // STA_CORE_SPATZ_HPP
|