added void SPINDLE_SetDutyCycle; built.
This commit is contained in:
1 parent
e68913e92b
commit
7ab20696f9
3 files changed
+12
-4
No files matched your search
@@ -2,6 +2,7 @@
|
||||
#include "Spindle.h"
|
||||
#include "main.h"
|
||||
#include "FreeRTOS.h"
|
||||
#include "openamp.h"
|
||||
#include <stddef.h>
|
||||
|
||||
SpindleHandle_t init_spindle(ConsoleHandle_t c, float maxRPM, float minRPM, float absMinRPM);
|
||||
|
||||
@@ -108,6 +108,8 @@ void Error_Handler(void);
|
||||
|
||||
/* USER CODE END Private defines */
|
||||
|
||||
extern TIM_HandleTypeDef htim2;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -17,25 +17,30 @@ SpindleHandle_t init_spindle(ConsoleHandle_t c, float maxRPM, float minRPM, floa
|
||||
|
||||
static void SPINDLE_SetDutyCycle(SpindleHandle_t h, void* context, int backwards, float dutyCycle){
|
||||
|
||||
//TODO: Herausfinden welcher Timer und diesen einstellen backwards beachten!
|
||||
uint32_t period = __HAL_TIM_GET_AUTORELOAD(&htim2); // Gets ARR value
|
||||
uint32_t pulse = (period + 1) * dutyCycle / 100;
|
||||
|
||||
__HAL_TIM_SET_COMPARE(&htim2, TIM_CHANNEL_3, pulse);
|
||||
__HAL_TIM_SET_COMPARE(&htim2, TIM_CHANNEL_4, pulse);
|
||||
|
||||
}
|
||||
|
||||
static void SPINDLE_EnaPWM(SpindleHandle_t h, void* context, int ena){
|
||||
//ena = 1 enable PWM / ena = 0 disable PWM
|
||||
//TODO:
|
||||
|
||||
if(ena == 1){
|
||||
|
||||
HAL_GPIO_WritePin(SPINDLE_ENA_L_GPIO_Port, SPINDLE_ENA_L_Pin, GPIO_PIN_SET);
|
||||
HAL_GPIO_WritePin(SPINDLE_ENA_R_GPIO_Port, SPINDLE_ENA_R_Pin, GPIO_PIN_SET);
|
||||
//TODO: PWM aktivieren
|
||||
HAL_TIM_PWM_Start(&htim2, TIM_CHANNEL_3);
|
||||
HAL_TIM_PWM_Start(&htim2, TIM_CHANNEL_4);
|
||||
|
||||
}else if(ena == 0){
|
||||
|
||||
HAL_GPIO_WritePin(SPINDLE_ENA_L_GPIO_Port, SPINDLE_ENA_L_Pin, GPIO_PIN_RESET);
|
||||
HAL_GPIO_WritePin(SPINDLE_ENA_R_GPIO_Port, SPINDLE_ENA_R_Pin, GPIO_PIN_RESET);
|
||||
//TODO: PWM deaktivieren
|
||||
HAL_TIM_PWM_Stop(&htim2, TIM_CHANNEL_3);
|
||||
HAL_TIM_PWM_Stop(&htim2, TIM_CHANNEL_4);
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user