added spindel.h and spindel.c
This commit is contained in:
1 parent
aba5e8809e
commit
e2729d6e1e
3 files changed
+56
-23
No files matched your search
@@ -0,0 +1,12 @@
|
|||||||
|
#include "Console.h"
|
||||||
|
#include "Spindle.h"
|
||||||
|
#include "main.h"
|
||||||
|
#include "FreeRTOS.h"
|
||||||
|
#include <stddef.h>
|
||||||
|
|
||||||
|
SpindleHandle_t init_spindle(ConsoleHandle_t c, float maxRPM, float minRPM, float absMinRPM);
|
||||||
|
|
||||||
|
|
||||||
|
static void SPINDLE_SetDutyCycle(SpindleHandle_t h, void* context, int backwards, float dutyCycle);
|
||||||
|
|
||||||
|
static void SPINDLE_EnaPWM(SpindleHandle_t h, void* context, int ena);
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
#include "Spindle/spindel.h"
|
||||||
|
|
||||||
|
|
||||||
|
SpindleHandle_t init_spindle(ConsoleHandle_t c, float maxRPM, float minRPM, float absMinRPM){
|
||||||
|
// set parameters for the physical system
|
||||||
|
SpindlePhysicalParams_t s;
|
||||||
|
s.maxRPM = maxRPM;
|
||||||
|
s.minRPM = minRPM;
|
||||||
|
s.absMinRPM = absMinRPM;
|
||||||
|
s.setDutyCycle = SPINDLE_SetDutyCycle;
|
||||||
|
s.enaPWM = SPINDLE_EnaPWM;
|
||||||
|
s.context = NULL;
|
||||||
|
|
||||||
|
return SPINDLE_CreateInstance( 4*configMINIMAL_STACK_SIZE, configMAX_PRIORITIES - 3, c, &s);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void SPINDLE_SetDutyCycle(SpindleHandle_t h, void* context, int backwards, float dutyCycle){
|
||||||
|
|
||||||
|
//TODO: Herausfinden welcher Timer und diesen einstellen backwards beachten!
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
}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
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -29,6 +29,7 @@
|
|||||||
#include "assert.h"
|
#include "assert.h"
|
||||||
#include "Spindle.h"
|
#include "Spindle.h"
|
||||||
#include "Console.h"
|
#include "Console.h"
|
||||||
|
#include "Spindle/spindel.h"
|
||||||
/* USER CODE END Includes */
|
/* USER CODE END Includes */
|
||||||
|
|
||||||
/* Private typedef -----------------------------------------------------------*/
|
/* Private typedef -----------------------------------------------------------*/
|
||||||
@@ -100,18 +101,6 @@ QueueHandle_t uartRxQueue;
|
|||||||
/* Private user code ---------------------------------------------------------*/
|
/* Private user code ---------------------------------------------------------*/
|
||||||
/* USER CODE BEGIN 0 */
|
/* USER CODE BEGIN 0 */
|
||||||
// --------------------------------------------------------------------------------------------------------------------
|
// --------------------------------------------------------------------------------------------------------------------
|
||||||
static void playgroundTask(void* args)
|
|
||||||
// --------------------------------------------------------------------------------------------------------------------
|
|
||||||
{
|
|
||||||
(void)args;
|
|
||||||
|
|
||||||
while(1) {
|
|
||||||
printf("test \n");
|
|
||||||
vTaskDelay(pdMS_TO_TICKS(10));
|
|
||||||
}
|
|
||||||
|
|
||||||
vTaskDelete(xTaskGetCurrentTaskHandle());
|
|
||||||
}
|
|
||||||
|
|
||||||
void blink_green_led(){
|
void blink_green_led(){
|
||||||
while(1){
|
while(1){
|
||||||
@@ -181,7 +170,6 @@ static int CapabilityFunc( int argc, char** argv, void* ctx )
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
SpindlePhysicalParams_t s;
|
|
||||||
|
|
||||||
|
|
||||||
static int fabi(int argc, char** argv, void* ctx){
|
static int fabi(int argc, char** argv, void* ctx){
|
||||||
@@ -325,19 +313,10 @@ int main(void)
|
|||||||
CONSOLE_RegisterCommand(c, "fabi", "prints a hallo fabi",
|
CONSOLE_RegisterCommand(c, "fabi", "prints a hallo fabi",
|
||||||
fabi, NULL);
|
fabi, NULL);
|
||||||
|
|
||||||
//Spindel
|
|
||||||
s.maxRPM = 9000.0f;
|
|
||||||
s.minRPM = -9000.0f;
|
|
||||||
s.absMinRPM = 1600.0f;
|
|
||||||
s.setDirection = SPINDLE_SetDirection;
|
|
||||||
s.setDutyCycle = SPINDLE_SetDutyCycle;
|
|
||||||
s.enaPWM = SPINDLE_EnaPWM;
|
|
||||||
s.context = NULL;
|
|
||||||
SPINDLE_CreateInstance( 4*configMINIMAL_STACK_SIZE, configMAX_PRIORITIES - 3, c, &s);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// create a playground task at the very beginning
|
// tasks
|
||||||
xTaskCreate(blink_green_led, "blink_green_led", 1024, NULL, 1, NULL);
|
xTaskCreate(blink_green_led, "blink_green_led", 1024, NULL, 1, NULL);
|
||||||
xTaskCreate(blink_yellow_led, "blink_yellow_led", 1024, NULL, 1, NULL);
|
xTaskCreate(blink_yellow_led, "blink_yellow_led", 1024, NULL, 1, NULL);
|
||||||
xTaskCreate(blink_red_led, "blink_red_led", 1024, NULL, 1, NULL);
|
xTaskCreate(blink_red_led, "blink_red_led", 1024, NULL, 1, NULL);
|
||||||
|
|||||||
Reference in new issue
Block a user