mirror of
https://git.intern.spaceteamaachen.de/ALPAKA/sta-core.git
synced 2025-08-02 09:21:54 +00:00
added a delay check and updated README
This commit is contained in:
parent
7cc6108a40
commit
3fe276f19d
@ -85,6 +85,13 @@ Configuration:
|
|||||||
TIM time base must be started before using `sta::delayUs` by calling `sta::initHAL`.
|
TIM time base must be started before using `sta::delayUs` by calling `sta::initHAL`.
|
||||||
When using the startup system task this is handled automatically.
|
When using the startup system task this is handled automatically.
|
||||||
|
|
||||||
|
Steps to enable delayUs:
|
||||||
|
* Include sta/devices/stm32/delay.hpp in the file where the delayUs function is called
|
||||||
|
* Enable a timer TIM in .ioc file with the settings: Slave Mode=Disable, Trigger Mode=Disable, Clock Source=Internal Clock, all other channels =Disable)
|
||||||
|
* Define STA_STM32_DELAY_US_TIM in App/Inc/sta/config.hpp as the timer handle (can be found in Core/Inc/tim.h). For TIM1, this would be htim1
|
||||||
|
* Do not use this timer for delays of over 1000 us; we have delayMs for that
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## Interfaces
|
## Interfaces
|
||||||
|
|
||||||
|
@ -44,7 +44,7 @@ namespace sta
|
|||||||
*
|
*
|
||||||
* @param us Microseconds
|
* @param us Microseconds
|
||||||
*/
|
*/
|
||||||
void delayUs(uint32_t us);
|
void delayUs(uint16_t us);
|
||||||
#endif // STA_STM32_DELAY_US_TIM
|
#endif // STA_STM32_DELAY_US_TIM
|
||||||
|
|
||||||
|
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
#ifndef STA_CORE_STM32_INIT_HPP
|
#ifndef STA_CORE_STM32_INIT_HPP
|
||||||
#define STA_CORE_STM32_INIT_HPP
|
#define STA_CORE_STM32_INIT_HPP
|
||||||
|
|
||||||
|
#include <sta/devices/stm32/hal.hpp>
|
||||||
|
|
||||||
namespace sta
|
namespace sta
|
||||||
{
|
{
|
||||||
|
@ -62,10 +62,11 @@ namespace sta
|
|||||||
return (updateFreq >= 1000000);
|
return (updateFreq >= 1000000);
|
||||||
}
|
}
|
||||||
|
|
||||||
void delayUs(uint32_t us)
|
void delayUs(uint16_t us)
|
||||||
{
|
{
|
||||||
// Check if the specified timer is usable for microsecond delays.
|
// Check if the specified timer is usable for microsecond delays.
|
||||||
STA_ASSERT(isValidDelayUsTIM());
|
STA_ASSERT(isValidDelayUsTIM());
|
||||||
|
STA_ASSERT(us < 1000);
|
||||||
|
|
||||||
__HAL_TIM_SET_COUNTER(&STA_STM32_DELAY_US_TIM, 0);
|
__HAL_TIM_SET_COUNTER(&STA_STM32_DELAY_US_TIM, 0);
|
||||||
while (__HAL_TIM_GET_COUNTER(&STA_STM32_DELAY_US_TIM) < us * gDelayUsMul);
|
while (__HAL_TIM_GET_COUNTER(&STA_STM32_DELAY_US_TIM) < us * gDelayUsMul);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user