mirror of
https://git.intern.spaceteamaachen.de/ALPAKA/sta-core.git
synced 2025-06-12 01:25:59 +00:00
Added SPATZ tick feature
This commit is contained in:
parent
21dd8c1b99
commit
b79279dcbc
@ -24,6 +24,11 @@ namespace sta
|
|||||||
*/
|
*/
|
||||||
void init(Mutex * mutex, Event * signal);
|
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.
|
* @brief Request bytes for a specific sensor id via the printable.
|
||||||
*
|
*
|
||||||
@ -59,13 +64,15 @@ namespace sta
|
|||||||
|
|
||||||
#define STA_SPATZ_INIT(mutex, signal) sta::spatz::init(mutex, signal)
|
#define STA_SPATZ_INIT(mutex, signal) sta::spatz::init(mutex, signal)
|
||||||
|
|
||||||
|
#define STA_SPATZ_TICK() sta::spatz::tick();
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
namespace sta
|
namespace sta
|
||||||
{
|
{
|
||||||
namespace spatz
|
namespace spatz
|
||||||
{
|
{
|
||||||
void init(Mutex * mutex);
|
void init(Mutex * mutex, Event * signal);
|
||||||
} // namespace spatz
|
} // namespace spatz
|
||||||
} // namespace sta
|
} // namespace sta
|
||||||
|
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
#endif // STA_INIT_SPATZ_ID
|
#endif // STA_INIT_SPATZ_ID
|
||||||
|
|
||||||
#include <usart.h>
|
#include <usart.h>
|
||||||
|
#include <sta/time.hpp>
|
||||||
|
|
||||||
namespace sta
|
namespace sta
|
||||||
{
|
{
|
||||||
@ -29,29 +30,42 @@ namespace sta
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void tick()
|
||||||
|
{
|
||||||
|
mutex_->acquire();
|
||||||
|
Debug->println('~');
|
||||||
|
mutex_->release();
|
||||||
|
}
|
||||||
|
|
||||||
void request(uint8_t id, uint8_t * buffer, size_t length)
|
void request(uint8_t id, uint8_t * buffer, size_t length)
|
||||||
{
|
{
|
||||||
sta::lock_guard<sta::Mutex> lock(*mutex_);
|
mutex_->acquire();
|
||||||
|
|
||||||
Debug->printf("%d", id);
|
Debug->printf("%d", id);
|
||||||
Debug->read(buffer, length);
|
Debug->read(buffer, length);
|
||||||
|
|
||||||
|
mutex_->release();
|
||||||
}
|
}
|
||||||
|
|
||||||
void request(uint8_t id, float * buffer, size_t length)
|
void request(uint8_t id, float * buffer, size_t length)
|
||||||
{
|
{
|
||||||
sta::lock_guard<sta::Mutex> lock(*mutex_);
|
mutex_->acquire();
|
||||||
|
|
||||||
HAL_UART_Receive_IT(&huart1, reinterpret_cast<uint8_t*>(buffer), length * sizeof(float));
|
HAL_UART_Receive_IT(&huart1, reinterpret_cast<uint8_t*>(buffer), length * sizeof(float));
|
||||||
Debug->printf("%d", id);
|
Debug->printf("%d", id);
|
||||||
signal_->wait(0x01);
|
signal_->wait(0x01, 100);
|
||||||
|
|
||||||
|
mutex_->release();
|
||||||
}
|
}
|
||||||
|
|
||||||
void request(uint8_t id, double * buffer, size_t length)
|
void request(uint8_t id, double * buffer, size_t length)
|
||||||
{
|
{
|
||||||
sta::lock_guard<sta::Mutex> lock(*mutex_);
|
mutex_->acquire();
|
||||||
|
|
||||||
Debug->printf("%d", id);
|
Debug->printf("%d", id);
|
||||||
Debug->read(buffer, length);
|
Debug->read(buffer, length);
|
||||||
|
|
||||||
|
mutex_->release();
|
||||||
}
|
}
|
||||||
|
|
||||||
void notify(uint8_t id)
|
void notify(uint8_t id)
|
||||||
@ -69,22 +83,19 @@ void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart)
|
|||||||
sta::spatz::signal_->set(0x01);
|
sta::spatz::signal_->set(0x01);
|
||||||
sta::spatz::signal_->clear(0x01);
|
sta::spatz::signal_->clear(0x01);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
namespace sta
|
namespace sta
|
||||||
{
|
{
|
||||||
namespace spatz
|
namespace spatz
|
||||||
{
|
{
|
||||||
void init(sta::Mutex * mutex)
|
void init(sta::Mutex * mutex, Event * signal)
|
||||||
{
|
{
|
||||||
// Nothing to do here.
|
// Nothing to do here.
|
||||||
}
|
}
|
||||||
} // namespace spatz
|
} // namespace spatz
|
||||||
} // namespace sta
|
} // namespace sta
|
||||||
|
|
||||||
|
|
||||||
#endif // STA_SPATZ_ENABLED
|
#endif // STA_SPATZ_ENABLED
|
||||||
|
Loading…
x
Reference in New Issue
Block a user