diff --git a/.project b/.project
new file mode 100644
index 0000000..59a6a12
--- /dev/null
+++ b/.project
@@ -0,0 +1,11 @@
+
+
+ Fr-ssspindel_HNP
+
+
+
+
+
+
+
+
diff --git a/stepper_h7/CM4/.settings/language.settings.xml b/stepper_h7/CM4/.settings/language.settings.xml
index 717f902..63a15e4 100644
--- a/stepper_h7/CM4/.settings/language.settings.xml
+++ b/stepper_h7/CM4/.settings/language.settings.xml
@@ -5,7 +5,7 @@
-
+
@@ -16,7 +16,7 @@
-
+
diff --git a/stepper_h7/CM4/.settings/stm32cubeide.project.prefs b/stepper_h7/CM4/.settings/stm32cubeide.project.prefs
index 222828d..3c49ccf 100644
--- a/stepper_h7/CM4/.settings/stm32cubeide.project.prefs
+++ b/stepper_h7/CM4/.settings/stm32cubeide.project.prefs
@@ -1,5 +1,5 @@
\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000=
-2F62501ED4689FB349E356AB974DBE57=EF232BB7A78569BB4DEEA5A8CE9841A0
-8DF89ED150041C4CBC7CB9A9CAA90856=EF232BB7A78569BB4DEEA5A8CE9841A0
+2F62501ED4689FB349E356AB974DBE57=CA438D07DDC379615403CE5F88B0F5D9
+8DF89ED150041C4CBC7CB9A9CAA90856=CA438D07DDC379615403CE5F88B0F5D9
DC22A860405A8BF2F2C095E5B6529F12=6EE9111B96141CC38C9D3E133C3B0FF1
eclipse.preferences.version=1
diff --git a/stepper_h7/CM7/.cproject b/stepper_h7/CM7/.cproject
index 87f7be0..5bf57fc 100644
--- a/stepper_h7/CM7/.cproject
+++ b/stepper_h7/CM7/.cproject
@@ -48,6 +48,8 @@
+
+
@@ -84,6 +86,8 @@
+
+
@@ -163,6 +167,8 @@
+
+
@@ -207,6 +213,8 @@
+
+
diff --git a/stepper_h7/CM7/.settings/language.settings.xml b/stepper_h7/CM7/.settings/language.settings.xml
index 0ec4c61..82d80ee 100644
--- a/stepper_h7/CM7/.settings/language.settings.xml
+++ b/stepper_h7/CM7/.settings/language.settings.xml
@@ -5,7 +5,7 @@
-
+
@@ -16,7 +16,7 @@
-
+
diff --git a/stepper_h7/CM7/.settings/stm32cubeide.project.prefs b/stepper_h7/CM7/.settings/stm32cubeide.project.prefs
index bf447c3..385195a 100644
--- a/stepper_h7/CM7/.settings/stm32cubeide.project.prefs
+++ b/stepper_h7/CM7/.settings/stm32cubeide.project.prefs
@@ -1,4 +1,4 @@
-2F62501ED4689FB349E356AB974DBE57=D0CF62532CA6CA2614F74C6DE0AF97FD
-8DF89ED150041C4CBC7CB9A9CAA90856=D0CF62532CA6CA2614F74C6DE0AF97FD
+2F62501ED4689FB349E356AB974DBE57=D62F61A551D27837AF2D0083502E0D87
+8DF89ED150041C4CBC7CB9A9CAA90856=D62F61A551D27837AF2D0083502E0D87
DC22A860405A8BF2F2C095E5B6529F12=7D1615E95F6C9AB913AD38D8A4D77383
eclipse.preferences.version=1
diff --git a/stepper_h7/CM7/Core/Inc/Console/consoleLogic.h b/stepper_h7/CM7/Core/Inc/Console/consoleLogic.h
new file mode 100644
index 0000000..6c14a49
--- /dev/null
+++ b/stepper_h7/CM7/Core/Inc/Console/consoleLogic.h
@@ -0,0 +1,10 @@
+#ifndef CONSOLE_LOGIC_H
+#define CONSOLE_LOGIC_H
+
+#include "Console.h"
+
+// --------------------------------------------------------------------------------------------------------------------
+// creates the console instance and returns its handle
+ConsoleHandle_t init_console_custom(void);
+
+#endif /* CONSOLE_LOGIC_H */
diff --git a/stepper_h7/CM7/Core/Inc/Spindle/spindleLogic.h b/stepper_h7/CM7/Core/Inc/Spindle/spindleLogic.h
new file mode 100644
index 0000000..f5a1407
--- /dev/null
+++ b/stepper_h7/CM7/Core/Inc/Spindle/spindleLogic.h
@@ -0,0 +1,10 @@
+#ifndef SPINDLE_LOGIC_H
+#define SPINDLE_LOGIC_H
+
+#include "Spindle.h"
+
+// --------------------------------------------------------------------------------------------------------------------
+// initialises the spindle (spindle instance and command registration)
+SpindleHandle_t init_spindle_custom(ConsoleHandle_t console, float maxRPM, float minRPM, float absMinRPM);
+
+#endif /* SPINDLE_LOGIC_H */
diff --git a/stepper_h7/CM7/Core/Src/Console/consoleLogic.c b/stepper_h7/CM7/Core/Src/Console/consoleLogic.c
new file mode 100644
index 0000000..cdf98dc
--- /dev/null
+++ b/stepper_h7/CM7/Core/Src/Console/consoleLogic.c
@@ -0,0 +1,59 @@
+#include "consoleLogic.h"
+#include "FreeRTOS.h"
+#include
+
+static ConsoleHandle_t s_console = NULL; // nur in dieser Datei sichtbar
+
+
+// --------------------------------------------------------------------------------------------------------------------
+static int CapabilityFunc( int argc, char** argv, void* ctx )
+// --------------------------------------------------------------------------------------------------------------------
+{
+ (void)argc;
+ (void)argv;
+ (void)ctx;
+ printf("%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d\r\nOK",
+ 0, // has spindle
+ 0, // has spindle status
+ 0, // has stepper
+ 0, // has stepper move relative
+ 0, // has stepper move speed
+ 0, // has stepper move async
+ 0, // has stepper status
+ 0, // has stepper refrun
+ 0, // has stepper refrun timeout
+ 0, // has stepper refrun skip
+ 0, // has stepper refrun stay enabled
+ 0, // has stepper reset
+ 0, // has stepper position
+ 0, // has stepper config
+ 0, // has stepper config torque
+ 0, // has stepper config throvercurr
+ 0, // has stepper config powerena
+ 0, // has stepper config stepmode
+ 0, // has stepper config timeoff
+ 0, // has stepper config timeon
+ 0, // has stepper config timefast
+ 0, // has stepper config mmperturn
+ 0, // has stepper config posmax
+ 0, // has stepper config posmin
+ 0, // has stepper config posref
+ 0, // has stepper config stepsperturn
+ 0 // has stepper cancel
+ );
+
+ return 0;
+}
+
+// --------------------------------------------------------------------------------------------------------------------
+ConsoleHandle_t init_console_custom(void)
+// --------------------------------------------------------------------------------------------------------------------
+{
+ s_console = CONSOLE_CreateInstance( 4*configMINIMAL_STACK_SIZE, configMAX_PRIORITIES - 5 );
+
+ // register capability function
+ CONSOLE_RegisterCommand(s_console, "capability", "prints a specified string of capability bits",
+ CapabilityFunc, NULL);
+
+ return s_console;
+}
diff --git a/stepper_h7/CM7/Core/Src/Spindle/spindleLogic.c b/stepper_h7/CM7/Core/Src/Spindle/spindleLogic.c
new file mode 100644
index 0000000..7b28cbd
--- /dev/null
+++ b/stepper_h7/CM7/Core/Src/Spindle/spindleLogic.c
@@ -0,0 +1,50 @@
+#include "spindleLogic.h"
+#include "FreeRTOS.h"
+#include
+
+// --------------------------------------------------------------------------------------------------------------------
+static void add_console_commands(void)
+// --------------------------------------------------------------------------------------------------------------------
+{
+
+}
+
+// --------------------------------------------------------------------------------------------------------------------
+// platform function: called by the spindle library to set the PWM duty cycle (0.0 .. 1.0) and the direction
+static void SPINDLE_SetDutyCycle(SpindleHandle_t h, void* context, int backwards, float dutyCycle)
+// --------------------------------------------------------------------------------------------------------------------
+{
+ (void)h;
+ (void)context;
+ (void)backwards;
+ (void)dutyCycle;
+ // TODO: set PWM duty cycle and direction
+}
+
+// --------------------------------------------------------------------------------------------------------------------
+// platform function: called by the spindle library to enable (1) or disable (0) PWM and the half bridges
+static void SPINDLE_EnaPWM(SpindleHandle_t h, void* context, int ena)
+// --------------------------------------------------------------------------------------------------------------------
+{
+ (void)h;
+ (void)context;
+ (void)ena;
+ // TODO: enable / disable PWM output and half bridges
+}
+
+// --------------------------------------------------------------------------------------------------------------------
+SpindleHandle_t init_spindle_custom(ConsoleHandle_t console, float maxRPM, float minRPM, float absMinRPM)
+// --------------------------------------------------------------------------------------------------------------------
+{
+ add_console_commands();
+ SpindlePhysicalParams_t s;
+ s.maxRPM = maxRPM;
+ s.minRPM = minRPM;
+ s.absMinRPM = absMinRPM;
+ s.setDutyCycle = SPINDLE_SetDutyCycle;
+ s.enaPWM = SPINDLE_EnaPWM;
+ s.context = NULL;
+
+ // the library copies the params, therefore a local struct is fine here
+ return SPINDLE_CreateInstance( 4*configMINIMAL_STACK_SIZE, configMAX_PRIORITIES - 3, console, &s );
+}
diff --git a/stepper_h7/CM7/Core/Src/main.c b/stepper_h7/CM7/Core/Src/main.c
index 19db834..b7f9cba 100644
--- a/stepper_h7/CM7/Core/Src/main.c
+++ b/stepper_h7/CM7/Core/Src/main.c
@@ -27,6 +27,9 @@
#include "queue.h"
#include "stdio.h"
#include "assert.h"
+#include "Console.h"
+#include "consoleLogic.h"
+#include "spindleLogic.h"
/* USER CODE END Includes */
/* Private typedef -----------------------------------------------------------*/
@@ -57,7 +60,8 @@ TIM_HandleTypeDef htim2;
UART_HandleTypeDef huart3;
/* USER CODE BEGIN PV */
-
+static ConsoleHandle_t console;
+static SpindleHandle_t spindle;
/* USER CODE END PV */
/* Private function prototypes -----------------------------------------------*/
@@ -103,7 +107,7 @@ static void playgroundTask(void* args)
{
(void)args;
- printf("Hello World\r\n");
+ printf("Hnot ello World\r\n");
while(1) {
vTaskDelay(pdMS_TO_TICKS(1000));
@@ -114,63 +118,6 @@ static void playgroundTask(void* args)
}
-static void playgroundTask2(void* args)
-// --------------------------------------------------------------------------------------------------------------------
-{
- (void)args;
-
- printf("Hello World\r\n");
-
-
- while(1) {
- vTaskDelay(pdMS_TO_TICKS(2000));
- HAL_GPIO_TogglePin(LED_YELLOW_GPIO_Port, LED_YELLOW_Pin);
- }
-
- vTaskDelete(xTaskGetCurrentTaskHandle());
-
-}
-
-// --------------------------------------------------------------------------------------------------------------------
-static int CapabilityFunc( int argc, char** argv, void* ctx )
-// --------------------------------------------------------------------------------------------------------------------
-{
- (void)argc;
- (void)argv;
- (void)ctx;
- printf("%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d\r\nOK",
- 0, // has spindle
- 0, // has spindle status
- 0, // has stepper
- 0, // has stepper move relative
- 0, // has stepper move speed
- 0, // has stepper move async
- 0, // has stepper status
- 0, // has stepper refrun
- 0, // has stepper refrun timeout
- 0, // has stepper refrun skip
- 0, // has stepper refrun stay enabled
- 0, // has stepper reset
- 0, // has stepper position
- 0, // has stepper config
- 0, // has stepper config torque
- 0, // has stepper config throvercurr
- 0, // has stepper config powerena
- 0, // has stepper config stepmode
- 0, // has stepper config timeoff
- 0, // has stepper config timeon
- 0, // has stepper config timefast
- 0, // has stepper config mmperturn
- 0, // has stepper config posmax
- 0, // has stepper config posmin
- 0, // has stepper config posref
- 0, // has stepper config stepsperturn
- 0 // has stepper cancel
- );
-
- return 0;
-}
-
#define BKPSRAM_BASE 0x38800000UL
typedef struct {
@@ -295,10 +242,12 @@ int main(void)
// create a playground task at the very beginning
xTaskCreate(playgroundTask, "playground", 1024, NULL, 1, NULL);
- xTaskCreate(playgroundTask2, "playground2", 1024, NULL, 1, NULL);
- // mask a compiler warning by referencing the function but not using it (void cast)
- (void)CapabilityFunc;
+ // create the console processor. There are no additional arguments required because it uses stdin, stderr and
+ // stdout of the stdlib of the platform
+ console = init_console_custom();
+ spindle = init_spindle_custom(console, 9000, -9000, 1600);
+
// start the scheduler and setup free rtos execution context
vTaskStartScheduler();