Move console and spindle setup into separate modules
Extract the terminal/console logic and the spindle initialisation out of main.c into dedicated modules so main only wires the components together. - Add consoleLogic.c/.h: init_console_custom() creates the console instance, registers the "capability" command and returns the handle. CapabilityFunc moved here from main.c. - Add spindleLogic.c/.h: init_spindle_custom(console, maxRPM, minRPM, absMinRPM) creates the spindle controller with the given RPM limits. Includes stub platform callbacks (SPINDLE_SetDutyCycle, SPINDLE_EnaPWM) that still need the PWM/H-bridge implementation. - main.c: keep console and spindle handles as static variables, pass the console handle to the spindle module, remove the second playground task. - .cproject: add Core/Inc/Console and Core/Inc/Spindle to the include paths of the CM7 project. - Include IDE-generated settings changes and the root Eclipse .project. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
bdb5db2009
commit
26fe4cc0cf
11 files changed
+167
-70
No files matched your search
@@ -0,0 +1,11 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<projectDescription>
|
||||||
|
<name>Fr-ssspindel_HNP</name>
|
||||||
|
<comment></comment>
|
||||||
|
<projects>
|
||||||
|
</projects>
|
||||||
|
<buildSpec>
|
||||||
|
</buildSpec>
|
||||||
|
<natures>
|
||||||
|
</natures>
|
||||||
|
</projectDescription>
|
||||||
@@ -5,7 +5,7 @@
|
|||||||
<provider-reference id="org.eclipse.cdt.ui.UserLanguageSettingsProvider" ref="shared-provider"/>
|
<provider-reference id="org.eclipse.cdt.ui.UserLanguageSettingsProvider" ref="shared-provider"/>
|
||||||
<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
|
<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
|
||||||
<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
|
<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
|
||||||
<provider class="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" console="false" env-hash="1445831975800947277" id="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" keep-relative-paths="false" name="MCU ARM GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD "${INPUTS}"" prefer-non-shared="true">
|
<provider class="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" console="false" env-hash="-1205804016607494110" id="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" keep-relative-paths="false" name="MCU ARM GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD "${INPUTS}"" prefer-non-shared="true">
|
||||||
<language-scope id="org.eclipse.cdt.core.gcc"/>
|
<language-scope id="org.eclipse.cdt.core.gcc"/>
|
||||||
<language-scope id="org.eclipse.cdt.core.g++"/>
|
<language-scope id="org.eclipse.cdt.core.g++"/>
|
||||||
</provider>
|
</provider>
|
||||||
@@ -16,7 +16,7 @@
|
|||||||
<provider-reference id="org.eclipse.cdt.ui.UserLanguageSettingsProvider" ref="shared-provider"/>
|
<provider-reference id="org.eclipse.cdt.ui.UserLanguageSettingsProvider" ref="shared-provider"/>
|
||||||
<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
|
<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
|
||||||
<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
|
<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
|
||||||
<provider class="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" console="false" env-hash="1445831975800947277" id="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" keep-relative-paths="false" name="MCU ARM GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD "${INPUTS}"" prefer-non-shared="true">
|
<provider class="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" console="false" env-hash="-1205804016607494110" id="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" keep-relative-paths="false" name="MCU ARM GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD "${INPUTS}"" prefer-non-shared="true">
|
||||||
<language-scope id="org.eclipse.cdt.core.gcc"/>
|
<language-scope id="org.eclipse.cdt.core.gcc"/>
|
||||||
<language-scope id="org.eclipse.cdt.core.g++"/>
|
<language-scope id="org.eclipse.cdt.core.g++"/>
|
||||||
</provider>
|
</provider>
|
||||||
|
|||||||
@@ -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=
|
\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
|
2F62501ED4689FB349E356AB974DBE57=CA438D07DDC379615403CE5F88B0F5D9
|
||||||
8DF89ED150041C4CBC7CB9A9CAA90856=EF232BB7A78569BB4DEEA5A8CE9841A0
|
8DF89ED150041C4CBC7CB9A9CAA90856=CA438D07DDC379615403CE5F88B0F5D9
|
||||||
DC22A860405A8BF2F2C095E5B6529F12=6EE9111B96141CC38C9D3E133C3B0FF1
|
DC22A860405A8BF2F2C095E5B6529F12=6EE9111B96141CC38C9D3E133C3B0FF1
|
||||||
eclipse.preferences.version=1
|
eclipse.preferences.version=1
|
||||||
@@ -48,6 +48,8 @@
|
|||||||
<listOptionValue builtIn="false" value="../../../libs/LibRTOSConsole/inc"/>
|
<listOptionValue builtIn="false" value="../../../libs/LibRTOSConsole/inc"/>
|
||||||
<listOptionValue builtIn="false" value="../../../libs/LibSpindle/inc"/>
|
<listOptionValue builtIn="false" value="../../../libs/LibSpindle/inc"/>
|
||||||
<listOptionValue builtIn="false" value="../Core/Inc/Stepper"/>
|
<listOptionValue builtIn="false" value="../Core/Inc/Stepper"/>
|
||||||
|
<listOptionValue builtIn="false" value="../Core/Inc/Console"/>
|
||||||
|
<listOptionValue builtIn="false" value="../Core/Inc/Spindle"/>
|
||||||
<listOptionValue builtIn="false" value="../../../libs/LibRTOSConsole/conf"/>
|
<listOptionValue builtIn="false" value="../../../libs/LibRTOSConsole/conf"/>
|
||||||
<listOptionValue builtIn="false" value="../OPENAMP"/>
|
<listOptionValue builtIn="false" value="../OPENAMP"/>
|
||||||
<listOptionValue builtIn="false" value="../../Middlewares/Third_Party/OpenAMP/libmetal/lib/include"/>
|
<listOptionValue builtIn="false" value="../../Middlewares/Third_Party/OpenAMP/libmetal/lib/include"/>
|
||||||
@@ -84,6 +86,8 @@
|
|||||||
<listOptionValue builtIn="false" value="../../../libs/LibRTOSConsole/inc"/>
|
<listOptionValue builtIn="false" value="../../../libs/LibRTOSConsole/inc"/>
|
||||||
<listOptionValue builtIn="false" value="../../../libs/LibSpindle/inc"/>
|
<listOptionValue builtIn="false" value="../../../libs/LibSpindle/inc"/>
|
||||||
<listOptionValue builtIn="false" value="../Core/Inc/Stepper"/>
|
<listOptionValue builtIn="false" value="../Core/Inc/Stepper"/>
|
||||||
|
<listOptionValue builtIn="false" value="../Core/Inc/Console"/>
|
||||||
|
<listOptionValue builtIn="false" value="../Core/Inc/Spindle"/>
|
||||||
<listOptionValue builtIn="false" value="../../../libs/LibRTOSConsole/conf"/>
|
<listOptionValue builtIn="false" value="../../../libs/LibRTOSConsole/conf"/>
|
||||||
<listOptionValue builtIn="false" value="../../Middlewares/Third_Party/OpenAMP/libmetal/lib/include"/>
|
<listOptionValue builtIn="false" value="../../Middlewares/Third_Party/OpenAMP/libmetal/lib/include"/>
|
||||||
<listOptionValue builtIn="false" value="../../Middlewares/Third_Party/OpenAMP/libmetal/lib/include/metal/compiler/gcc"/>
|
<listOptionValue builtIn="false" value="../../Middlewares/Third_Party/OpenAMP/libmetal/lib/include/metal/compiler/gcc"/>
|
||||||
@@ -163,6 +167,8 @@
|
|||||||
<listOptionValue builtIn="false" value="../../../libs/LibRTOSConsole/inc"/>
|
<listOptionValue builtIn="false" value="../../../libs/LibRTOSConsole/inc"/>
|
||||||
<listOptionValue builtIn="false" value="../../../libs/LibSpindle/inc"/>
|
<listOptionValue builtIn="false" value="../../../libs/LibSpindle/inc"/>
|
||||||
<listOptionValue builtIn="false" value="../Core/Inc/Stepper"/>
|
<listOptionValue builtIn="false" value="../Core/Inc/Stepper"/>
|
||||||
|
<listOptionValue builtIn="false" value="../Core/Inc/Console"/>
|
||||||
|
<listOptionValue builtIn="false" value="../Core/Inc/Spindle"/>
|
||||||
<listOptionValue builtIn="false" value="../../../libs/LibRTOSConsole/conf"/>
|
<listOptionValue builtIn="false" value="../../../libs/LibRTOSConsole/conf"/>
|
||||||
<listOptionValue builtIn="false" value="../OPENAMP"/>
|
<listOptionValue builtIn="false" value="../OPENAMP"/>
|
||||||
<listOptionValue builtIn="false" value="../../Middlewares/Third_Party/OpenAMP/libmetal/lib/include"/>
|
<listOptionValue builtIn="false" value="../../Middlewares/Third_Party/OpenAMP/libmetal/lib/include"/>
|
||||||
@@ -207,6 +213,8 @@
|
|||||||
<listOptionValue builtIn="false" value="../../../libs/LibRTOSConsole/inc"/>
|
<listOptionValue builtIn="false" value="../../../libs/LibRTOSConsole/inc"/>
|
||||||
<listOptionValue builtIn="false" value="../../../libs/LibSpindle/inc"/>
|
<listOptionValue builtIn="false" value="../../../libs/LibSpindle/inc"/>
|
||||||
<listOptionValue builtIn="false" value="../Core/Inc/Stepper"/>
|
<listOptionValue builtIn="false" value="../Core/Inc/Stepper"/>
|
||||||
|
<listOptionValue builtIn="false" value="../Core/Inc/Console"/>
|
||||||
|
<listOptionValue builtIn="false" value="../Core/Inc/Spindle"/>
|
||||||
<listOptionValue builtIn="false" value="../../../libs/LibRTOSConsole/conf"/>
|
<listOptionValue builtIn="false" value="../../../libs/LibRTOSConsole/conf"/>
|
||||||
<listOptionValue builtIn="false" value="../OPENAMP"/>
|
<listOptionValue builtIn="false" value="../OPENAMP"/>
|
||||||
<listOptionValue builtIn="false" value="../../Middlewares/Third_Party/OpenAMP/libmetal/lib/include"/>
|
<listOptionValue builtIn="false" value="../../Middlewares/Third_Party/OpenAMP/libmetal/lib/include"/>
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
<provider-reference id="org.eclipse.cdt.ui.UserLanguageSettingsProvider" ref="shared-provider"/>
|
<provider-reference id="org.eclipse.cdt.ui.UserLanguageSettingsProvider" ref="shared-provider"/>
|
||||||
<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
|
<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
|
||||||
<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
|
<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
|
||||||
<provider class="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" console="false" env-hash="1384704166455685363" id="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" keep-relative-paths="false" name="MCU ARM GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD "${INPUTS}"" prefer-non-shared="true">
|
<provider class="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" console="false" env-hash="-1299285867539043652" id="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" keep-relative-paths="false" name="MCU ARM GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD "${INPUTS}"" prefer-non-shared="true">
|
||||||
<language-scope id="org.eclipse.cdt.core.gcc"/>
|
<language-scope id="org.eclipse.cdt.core.gcc"/>
|
||||||
<language-scope id="org.eclipse.cdt.core.g++"/>
|
<language-scope id="org.eclipse.cdt.core.g++"/>
|
||||||
</provider>
|
</provider>
|
||||||
@@ -16,7 +16,7 @@
|
|||||||
<provider-reference id="org.eclipse.cdt.ui.UserLanguageSettingsProvider" ref="shared-provider"/>
|
<provider-reference id="org.eclipse.cdt.ui.UserLanguageSettingsProvider" ref="shared-provider"/>
|
||||||
<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
|
<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
|
||||||
<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
|
<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
|
||||||
<provider class="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" console="false" env-hash="1384704166455685363" id="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" keep-relative-paths="false" name="MCU ARM GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD "${INPUTS}"" prefer-non-shared="true">
|
<provider class="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" console="false" env-hash="-1299285867539043652" id="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" keep-relative-paths="false" name="MCU ARM GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD "${INPUTS}"" prefer-non-shared="true">
|
||||||
<language-scope id="org.eclipse.cdt.core.gcc"/>
|
<language-scope id="org.eclipse.cdt.core.gcc"/>
|
||||||
<language-scope id="org.eclipse.cdt.core.g++"/>
|
<language-scope id="org.eclipse.cdt.core.g++"/>
|
||||||
</provider>
|
</provider>
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
2F62501ED4689FB349E356AB974DBE57=D0CF62532CA6CA2614F74C6DE0AF97FD
|
2F62501ED4689FB349E356AB974DBE57=D62F61A551D27837AF2D0083502E0D87
|
||||||
8DF89ED150041C4CBC7CB9A9CAA90856=D0CF62532CA6CA2614F74C6DE0AF97FD
|
8DF89ED150041C4CBC7CB9A9CAA90856=D62F61A551D27837AF2D0083502E0D87
|
||||||
DC22A860405A8BF2F2C095E5B6529F12=7D1615E95F6C9AB913AD38D8A4D77383
|
DC22A860405A8BF2F2C095E5B6529F12=7D1615E95F6C9AB913AD38D8A4D77383
|
||||||
eclipse.preferences.version=1
|
eclipse.preferences.version=1
|
||||||
@@ -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 */
|
||||||
@@ -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 */
|
||||||
@@ -0,0 +1,59 @@
|
|||||||
|
#include "consoleLogic.h"
|
||||||
|
#include "FreeRTOS.h"
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
@@ -0,0 +1,50 @@
|
|||||||
|
#include "spindleLogic.h"
|
||||||
|
#include "FreeRTOS.h"
|
||||||
|
#include <stddef.h>
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------------------------------------------------------
|
||||||
|
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 );
|
||||||
|
}
|
||||||
@@ -27,6 +27,9 @@
|
|||||||
#include "queue.h"
|
#include "queue.h"
|
||||||
#include "stdio.h"
|
#include "stdio.h"
|
||||||
#include "assert.h"
|
#include "assert.h"
|
||||||
|
#include "Console.h"
|
||||||
|
#include "consoleLogic.h"
|
||||||
|
#include "spindleLogic.h"
|
||||||
/* USER CODE END Includes */
|
/* USER CODE END Includes */
|
||||||
|
|
||||||
/* Private typedef -----------------------------------------------------------*/
|
/* Private typedef -----------------------------------------------------------*/
|
||||||
@@ -57,7 +60,8 @@ TIM_HandleTypeDef htim2;
|
|||||||
UART_HandleTypeDef huart3;
|
UART_HandleTypeDef huart3;
|
||||||
|
|
||||||
/* USER CODE BEGIN PV */
|
/* USER CODE BEGIN PV */
|
||||||
|
static ConsoleHandle_t console;
|
||||||
|
static SpindleHandle_t spindle;
|
||||||
/* USER CODE END PV */
|
/* USER CODE END PV */
|
||||||
|
|
||||||
/* Private function prototypes -----------------------------------------------*/
|
/* Private function prototypes -----------------------------------------------*/
|
||||||
@@ -103,7 +107,7 @@ static void playgroundTask(void* args)
|
|||||||
{
|
{
|
||||||
(void)args;
|
(void)args;
|
||||||
|
|
||||||
printf("Hello World\r\n");
|
printf("Hnot ello World\r\n");
|
||||||
|
|
||||||
while(1) {
|
while(1) {
|
||||||
vTaskDelay(pdMS_TO_TICKS(1000));
|
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
|
#define BKPSRAM_BASE 0x38800000UL
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
@@ -295,10 +242,12 @@ int main(void)
|
|||||||
|
|
||||||
// create a playground task at the very beginning
|
// create a playground task at the very beginning
|
||||||
xTaskCreate(playgroundTask, "playground", 1024, NULL, 1, NULL);
|
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)
|
// create the console processor. There are no additional arguments required because it uses stdin, stderr and
|
||||||
(void)CapabilityFunc;
|
// 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
|
// start the scheduler and setup free rtos execution context
|
||||||
vTaskStartScheduler();
|
vTaskStartScheduler();
|
||||||
|
|||||||
Reference in new issue
Block a user