-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(#54) Fixing FOC control and adding in microsecond timer
- Loading branch information
Showing
10 changed files
with
176 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#ifndef US_TIMER_H | ||
#define US_TIMER_H | ||
|
||
#include <stdint.h> | ||
|
||
/** | ||
* @brief Init microsecond timer | ||
* | ||
*/ | ||
void us_timer_init(); | ||
|
||
/** | ||
* @brief Get time in microseconds | ||
* | ||
* @return uint32_t | ||
*/ | ||
uint32_t us_timer_get(); | ||
|
||
#endif /* US_TIMER_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#include "us_timer.h" | ||
|
||
#include "stm32h7xx.h" | ||
#include "stm32h7xx_hal_tim.h" | ||
|
||
static TIM_HandleTypeDef *timer; | ||
|
||
void us_timer_init(TIM_HandleTypeDef *htim) | ||
{ | ||
timer = htim; | ||
HAL_TIM_Base_Start(timer); | ||
} | ||
|
||
uint32_t us_timer_get() | ||
{ | ||
// the count is prescaled in CubeMX to increment once per microsecond, so the count corresponds to microseconds | ||
return timer->Instance->CNT / 2; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.