Compare commits
18
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b556b02e03 | ||
|
|
f736da7a1d | ||
|
|
8ca3ce7f6a | ||
|
|
6a9a634df0 | ||
|
|
26b117b63f | ||
|
|
13eac4fd0c | ||
|
|
d076d981ac | ||
|
|
634b69a55c | ||
|
|
830bc0849a | ||
|
|
9b63d79ae5 | ||
|
|
296787e883 | ||
|
|
7ab20696f9 | ||
|
|
e68913e92b | ||
|
|
e2729d6e1e | ||
|
|
aba5e8809e | ||
|
|
728b978961 | ||
|
|
8a16d3af97 | ||
|
|
4d77b14378 |
No files matched your search
@@ -0,0 +1,97 @@
|
|||||||
|
# Checkliste Spindel mit Linearführung
|
||||||
|
|
||||||
|
Stand: 05.11.2026, Branch `Stepper`, inklusive uncommitteter Änderungen an `stepper.c`.
|
||||||
|
|
||||||
|
Grundlage: Pflichtenheft, Interfacespezifikation und Anforderungen an den Laborbericht, abgeglichen mit dem Code. Kompiliert oder getestet wurde dabei nichts, „funktioniert“ stammt aus den Commit-Messages.
|
||||||
|
|
||||||
|
Bewertung: Die MUSS-Kriterien bringen 50 % der Punkte (Note 4,0), für die 1,0 sind 100 von 130 Punkten nötig. Die Punktzahlen pro Feature stehen nicht im extrahierten PDF-Text, die Reihenfolge der Wunschkriterien ist daher eine Einschätzung.
|
||||||
|
|
||||||
|
## Priorität 1: MUSS-Kriterien (Firmware)
|
||||||
|
|
||||||
|
### Tests und Capability
|
||||||
|
|
||||||
|
- [ ] **SpecTest-App besorgen:** Der `Test`-Ordner fehlt im Repo, und die MUSS-Features müssen diesen Test fehlerfrei bestehen.
|
||||||
|
- [ ] **Capability-Bits setzen:** Aktuell sind alle 0 (`main.c:143`). Nötig sind Bit 0 (Spindle), 1 (Spindle Status), 2 (Stepper), 7 (Referenzfahrt) und 11 (Reset).
|
||||||
|
|
||||||
|
### Spindel (F10_01–03)
|
||||||
|
|
||||||
|
- [ ] **Debug-Ausgaben entfernen:** Die `printf` in `spindel.c:22` und `:42` müssen raus. Der Spindel-Task kann sie beim Startup-Boost mitten in andere Befehlsausgaben schreiben.
|
||||||
|
- [ ] **Alle Fälle testen:** Negative RPM, Kappung bei Min/Max, Mehrfach-Start und -Stopp sowie `spindle status`.
|
||||||
|
|
||||||
|
### Stepper `reset` (F20_01)
|
||||||
|
|
||||||
|
- [ ] **Mehrfach testen:** `return result` ist neu und uncommittet, davor kam immer 0 zurück. Prüfen, ob wiederholtes `reset` weiterhin `OK` liefert, auch aus dem Fehlerzustand.
|
||||||
|
|
||||||
|
### Stepper `reference` (F20_02)
|
||||||
|
|
||||||
|
- [ ] **Endlosschleife beheben:** Die zweite Schleife ignoriert Fehler (`stepper.c:150-151`). Dann hängt die Konsole, und `stepper reset` ist nicht mehr möglich.
|
||||||
|
- [ ] **Rückgabewerte prüfen:** Das fehlt bei `SetPowerOutputs` (`stepper.c:117`) und beim Wegfahren um 5 mm (`stepper.c:121`).
|
||||||
|
- [ ] **Abbruch einbauen:** Es braucht ein internes Weg- oder Zeitlimit, falls der Sensor nie auslöst. Optional kann auch `LIMIT_SWITCH` abbrechen, er darf aber nicht zur Wegbestimmung dienen.
|
||||||
|
- [ ] **Bei Fehler Treiber abschalten:** Aktuell bleiben sie aktiv.
|
||||||
|
|
||||||
|
### Stepper `move` (F20_03)
|
||||||
|
|
||||||
|
- [ ] **Bug beheben:** `move` auf die aktuelle Position ergibt `FAIL` und `state = 0`, weil `L6474_StepIncremental` bei 0 Schritten einen Fehler liefert (`stepper.c:189-191`). Das muss direkt `OK` ergeben.
|
||||||
|
- [ ] **Eingabe prüfen:** `atof` macht aus `stepper move abc` die Position 0 mit `OK` (`stepper.c:301`).
|
||||||
|
- [ ] **Fahrbereich klären:** Die Grenzen 0–100 mm sind hartkodiert (`stepper.c:303`). Gegen den echten mechanischen Weg prüfen.
|
||||||
|
- [ ] **Fehlerbits auswerten:** Der Status wird gelesen, aber verworfen (`stepper.c:195-198`). OCD, TH_SD und UVLO prüfen und bei Fehlern in einen Fehlerzustand wechseln. Das deckt auch den geforderten Überlastschutz ab (Kap. 2.4).
|
||||||
|
- [ ] **Zustandsautomat umbauen:** Die Werte der Spezifikation nehmen: `scsINIT` 0x0, `scsREF` 0x1, `scsDIS` 0x2, `scsENA` 0x4, `scsFLT` 0x8.
|
||||||
|
- [ ] **Status-LEDs umsetzen:** Grün heißt fehlerfrei, Gelb blinkt mit 1 Hz bei aktiven Treibern, Rot heißt Fehler. Die Funktionen in `main.c` sind ungenutzt, und zwei davon sind Dauerschleifen. Besser ist ein einziger LED-Task, der `state` auswertet.
|
||||||
|
|
||||||
|
### Aufräumen und Abschluss
|
||||||
|
|
||||||
|
- [ ] **Nicht spezifizierte Befehle entfernen:** Das betrifft `fabi` (`main.c:317`) und `stepper step` (`stepper.c:222`).
|
||||||
|
- [ ] **Stand committen:** Die Änderungen an `stepper.c` sind nicht committet und `Stepper` ist nicht in `main` gemergt.
|
||||||
|
- [ ] **SpecTest komplett bestehen lassen.** Dabei auch die CM4-Firmware flashen, die laut Pflichtenheft ohnehin auf den zweiten Kern muss.
|
||||||
|
|
||||||
|
## Priorität 2: Laborbericht (verbindlich)
|
||||||
|
|
||||||
|
Im Repo gibt es dazu noch nichts.
|
||||||
|
|
||||||
|
### Messungen (am besten erst mit der finalen Firmware)
|
||||||
|
|
||||||
|
- [ ] SPI: SCK, MOSI, MISO, CS sowie ein L6474-Kommunikationsvorgang
|
||||||
|
- [ ] H-Brücken-PWM: Frequenz, Duty Cycle, Pegel
|
||||||
|
- [ ] DIR und PULSE: Richtungswechsel, Bezug zum Microstepping
|
||||||
|
|
||||||
|
### Inhalt
|
||||||
|
|
||||||
|
- [ ] Software-Architektur und Implementierungsansatz
|
||||||
|
- [ ] Stepper-Controller als Schwerpunkt, inklusive Abweichungen von der Spezifikation
|
||||||
|
- [ ] UML: Use-Case-Diagramm (Bring-Up bis Move) und Sequenzdiagramm
|
||||||
|
- [ ] Soll/Ist-Vergleich mit technischer Bewertung und Fazit
|
||||||
|
|
||||||
|
### Formales
|
||||||
|
|
||||||
|
- [ ] Mindestens 12 Seiten ohne Deckblatt und Literaturverzeichnis
|
||||||
|
- [ ] Abbildungen nummeriert und im Text referenziert
|
||||||
|
- [ ] Große Messreihen im Anhang, Quellen angegeben
|
||||||
|
|
||||||
|
## Priorität 3: Wunschkriterien
|
||||||
|
|
||||||
|
### Wenig Aufwand
|
||||||
|
|
||||||
|
- [ ] `stepper position`: Ausgabe in mm als Float (`100.0000`), aktuell Text mit Schritten
|
||||||
|
- [ ] `stepper status`: Zustand, Fehlerbits und Pending-Flag ausgeben
|
||||||
|
- [ ] `reference -e`, `-s` und `-t`: Flags werden noch gar nicht geparst
|
||||||
|
- [ ] `stepper config powerena`: ändert die Bring-Up-Sequenz, also `scsDIS` einbauen
|
||||||
|
- [ ] `move -r`
|
||||||
|
|
||||||
|
### Mehr Aufwand, aber lohnend
|
||||||
|
|
||||||
|
- [ ] **Timer-Pulserzeugung, Master/Slave (F20_09):** Aktuell sind etwa 37,5 mm/min möglich, 100 mm dauern also rund 160 s. Gefordert sind bis zu 1400 mm/min. Das kann auch für SpecTest-Timeouts relevant sein, darum am besten zuerst.
|
||||||
|
- [ ] **`move -s`:** Baut auf den Timer auf.
|
||||||
|
- [ ] **Asynchroner LibL6474-Betrieb (F20_11):** Dazu gehören `move -a` und `stepper cancel`.
|
||||||
|
- [ ] **`stepper config` mit den übrigen Parametern:** Das gibt Einzelpunkte pro Parameter.
|
||||||
|
- [ ] **Testprotokoll:** Entsteht aus dem SpecTest-Lauf.
|
||||||
|
|
||||||
|
### Zuletzt
|
||||||
|
|
||||||
|
- [ ] Netzwerk über OpenAMP (LibETHProducer)
|
||||||
|
- [ ] Unit-Tests mit CMocka: mindestens 4 Tests, nur unter Windows nutzbar
|
||||||
|
- [ ] Digital Twin: auch nur unter Windows, und der `Simulation`-Ordner fehlt im Repo
|
||||||
|
|
||||||
|
## Offene Fragen
|
||||||
|
|
||||||
|
- [ ] **Welcher Motor wird genutzt?** Der Code nutzt 700 mA und 800 Schritte/mm (`stepper.c:103`, `stepper.c:17`). Beim kleinen Labormotor sind maximal 0,6 A erlaubt, die 700 mA wären also zu viel. Mit seinen 400 Schritten wären außerdem 1600 Schritte/mm richtig, sonst fährt er nur die halbe Strecke. Beim 200-Schritt-Motor der Baugruppe passen die 800 Schritte/mm. Am besten beide Werte als Konstanten anlegen.
|
||||||
|
- [ ] **Sind die LEDs MUSS oder Wunsch?** Das Pflichtenheft widerspricht sich: Kap. 1.1.4 nennt sie als Wunschkriterium, F20_03 (MUSS) schreibt sie vor. Hier sind sie als MUSS eingeordnet. Am besten bei Herrn Kimmel nachfragen.
|
||||||
Binary file not shown.
Binary file not shown.
@@ -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="-889499008138449637" 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="1232117135261576401" 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="-889499008138449637" 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="1232117135261576401" 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>
|
||||||
|
|||||||
@@ -195,9 +195,9 @@
|
|||||||
<locationURI>PARENT-2-PROJECT_LOC/libs/LibSpindle/src/Spindle.c</locationURI>
|
<locationURI>PARENT-2-PROJECT_LOC/libs/LibSpindle/src/Spindle.c</locationURI>
|
||||||
</link>
|
</link>
|
||||||
<link>
|
<link>
|
||||||
<name>Core/Src/Stepper/src</name>
|
<name>Core/Src/Stepper/LibL6474x.c</name>
|
||||||
<type>2</type>
|
<type>1</type>
|
||||||
<locationURI>virtual:/virtual</locationURI>
|
<locationURI>PARENT-2-PROJECT_LOC/libs/LibL6474/src/LibL6474x.c</locationURI>
|
||||||
</link>
|
</link>
|
||||||
<link>
|
<link>
|
||||||
<name>Drivers/STM32H7xx_HAL_Driver/Inc/Legacy</name>
|
<name>Drivers/STM32H7xx_HAL_Driver/Inc/Legacy</name>
|
||||||
@@ -779,11 +779,6 @@
|
|||||||
<type>1</type>
|
<type>1</type>
|
||||||
<locationURI>PARENT-2-PROJECT_LOC/libs/LibL6474/inc/LibL6474.h</locationURI>
|
<locationURI>PARENT-2-PROJECT_LOC/libs/LibL6474/inc/LibL6474.h</locationURI>
|
||||||
</link>
|
</link>
|
||||||
<link>
|
|
||||||
<name>Core/Src/Stepper/src/LibL6474x.c</name>
|
|
||||||
<type>1</type>
|
|
||||||
<locationURI>PARENT-2-PROJECT_LOC/libs/LibL6474/src/LibL6474x.c</locationURI>
|
|
||||||
</link>
|
|
||||||
<link>
|
<link>
|
||||||
<name>Drivers/STM32H7xx_HAL_Driver/Inc/Legacy/stm32_hal_legacy.h</name>
|
<name>Drivers/STM32H7xx_HAL_Driver/Inc/Legacy/stm32_hal_legacy.h</name>
|
||||||
<type>1</type>
|
<type>1</type>
|
||||||
|
|||||||
@@ -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="-864768909920134975" 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="1170989325916314487" 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="-864768909920134975" 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="1170989325916314487" 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>
|
||||||
|
|||||||
@@ -0,0 +1,14 @@
|
|||||||
|
#include "Console.h"
|
||||||
|
#include <stdlib.h>
|
||||||
|
#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);
|
||||||
|
|
||||||
|
|
||||||
|
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,28 @@
|
|||||||
|
#include "Console.h"
|
||||||
|
#include "Spindle.h"
|
||||||
|
#include "main.h"
|
||||||
|
#include "FreeRTOS.h"
|
||||||
|
#include "task.h"
|
||||||
|
#include "openamp.h"
|
||||||
|
#include "LibL6474.h"
|
||||||
|
#include <stddef.h>
|
||||||
|
|
||||||
|
int StepperConsoleFunction( int argc, char** argv, void* ctx );
|
||||||
|
|
||||||
|
static void* StepLibraryMalloc( unsigned int size );
|
||||||
|
|
||||||
|
static void StepLibraryFree( const void* const ptr );
|
||||||
|
|
||||||
|
static int StepDriverSpiTransfer( void* pIO, char* pRX, const char* pTX, unsigned int length );
|
||||||
|
|
||||||
|
void StepDriverReset(void* pGPO, const int ena);
|
||||||
|
|
||||||
|
void StepLibraryDelay(unsigned int ms);
|
||||||
|
|
||||||
|
//void StepTimerAsync();
|
||||||
|
|
||||||
|
//void StepTimerCancelAsync();
|
||||||
|
|
||||||
|
L6474_Handle_t init_stepper(void* pIO, void* pGPO, void* pPWM);
|
||||||
|
|
||||||
|
int reset_stepper();
|
||||||
@@ -108,6 +108,15 @@ void Error_Handler(void);
|
|||||||
|
|
||||||
/* USER CODE END Private defines */
|
/* USER CODE END Private defines */
|
||||||
|
|
||||||
|
extern TIM_HandleTypeDef htim2;
|
||||||
|
extern SPI_HandleTypeDef hspi1;
|
||||||
|
|
||||||
|
void green_led();
|
||||||
|
void red_led();
|
||||||
|
void blink_yellow_led();
|
||||||
|
void yellow_led_start();
|
||||||
|
void yellow_led_stop();
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -0,0 +1,61 @@
|
|||||||
|
#include "Spindle/spindel.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static void SPINDLE_SetDutyCycle(SpindleHandle_t h, void* context, int backwards, float dutyCycle){
|
||||||
|
|
||||||
|
(void)h;
|
||||||
|
(void)context;
|
||||||
|
|
||||||
|
uint32_t period = __HAL_TIM_GET_AUTORELOAD(&htim2); // Gets ARR value
|
||||||
|
uint32_t pulse = (period + 1) * dutyCycle;
|
||||||
|
|
||||||
|
if(backwards==1){
|
||||||
|
__HAL_TIM_SET_COMPARE(&htim2, TIM_CHANNEL_3, pulse);
|
||||||
|
__HAL_TIM_SET_COMPARE(&htim2, TIM_CHANNEL_4, 0);
|
||||||
|
}else{
|
||||||
|
__HAL_TIM_SET_COMPARE(&htim2, TIM_CHANNEL_3, 0);
|
||||||
|
__HAL_TIM_SET_COMPARE(&htim2, TIM_CHANNEL_4, pulse);
|
||||||
|
}
|
||||||
|
|
||||||
|
//printf("duty=%f backwards=%d pulse=%lu\n", dutyCycle, backwards, (unsigned long)pulse);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
static void SPINDLE_EnaPWM(SpindleHandle_t h, void* context, int ena){
|
||||||
|
//ena = 1 enable PWM / ena = 0 disable PWM
|
||||||
|
(void)h;
|
||||||
|
(void)context;
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
|
}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);
|
||||||
|
|
||||||
|
}
|
||||||
|
printf("ena=%d\n", ena);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
SpindleHandle_t init_spindle(ConsoleHandle_t c, float maxRPM, float minRPM, float absMinRPM){
|
||||||
|
// set parameters for the physical system
|
||||||
|
static SpindlePhysicalParams_t s;
|
||||||
|
s.maxRPM = maxRPM;
|
||||||
|
s.minRPM = minRPM;
|
||||||
|
s.absMinRPM = absMinRPM;
|
||||||
|
s.setDutyCycle = SPINDLE_SetDutyCycle;
|
||||||
|
s.enaPWM = SPINDLE_EnaPWM;
|
||||||
|
s.context = NULL;
|
||||||
|
|
||||||
|
HAL_TIM_PWM_Start(&htim2, TIM_CHANNEL_3);
|
||||||
|
HAL_TIM_PWM_Start(&htim2, TIM_CHANNEL_4);
|
||||||
|
|
||||||
|
return SPINDLE_CreateInstance( 4*configMINIMAL_STACK_SIZE, configMAX_PRIORITIES - 3, c, &s);
|
||||||
|
}
|
||||||
@@ -0,0 +1,407 @@
|
|||||||
|
#include "Stepper/stepper.h"
|
||||||
|
#include "LibL6474.h"
|
||||||
|
#include "main.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* States:
|
||||||
|
* 0: need Reset
|
||||||
|
* 1: need Reference
|
||||||
|
* 2: all good
|
||||||
|
*/
|
||||||
|
|
||||||
|
int state = 0;
|
||||||
|
|
||||||
|
int mm_to_step(float mm){
|
||||||
|
return (int)(800 * mm);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void* StepLibraryMalloc( unsigned int size ){
|
||||||
|
return malloc(size);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void StepLibraryFree( const void* const ptr ){
|
||||||
|
free((void*)ptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int StepDriverSpiTransfer( void* pIO, char* pRX, const char* pTX, unsigned int length ){
|
||||||
|
for ( unsigned int i = 0; i < length; i++ )
|
||||||
|
{
|
||||||
|
HAL_GPIO_WritePin(STEP_SPI_CS_GPIO_Port, STEP_SPI_CS_Pin, GPIO_PIN_RESET);
|
||||||
|
HAL_SPI_TransmitReceive(&hspi1, (uint8_t*)&pTX[i], (uint8_t*)&pRX[i], 1, HAL_MAX_DELAY);
|
||||||
|
HAL_GPIO_WritePin(STEP_SPI_CS_GPIO_Port, STEP_SPI_CS_Pin, GPIO_PIN_SET);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void StepDriverReset(void* pGPO, const int ena){
|
||||||
|
if(ena==0){
|
||||||
|
HAL_GPIO_WritePin(STEP_RSTN_GPIO_Port, STEP_RSTN_Pin, GPIO_PIN_SET);
|
||||||
|
}else{
|
||||||
|
HAL_GPIO_WritePin(STEP_RSTN_GPIO_Port, STEP_RSTN_Pin, GPIO_PIN_RESET);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void StepLibraryDelay(unsigned int ms){
|
||||||
|
vTaskDelay(pdMS_TO_TICKS(ms));
|
||||||
|
}
|
||||||
|
|
||||||
|
// 1) Funktion schreiben (oben in stepper.c, vor init_stepper)
|
||||||
|
static int StepLibraryStep( void* pPWM, int dir, unsigned int numPulses ){
|
||||||
|
(void)pPWM;
|
||||||
|
|
||||||
|
if(dir == 1){
|
||||||
|
HAL_GPIO_WritePin(STEP_DIR_GPIO_Port, STEP_DIR_Pin, GPIO_PIN_SET);
|
||||||
|
}else{
|
||||||
|
HAL_GPIO_WritePin(STEP_DIR_GPIO_Port, STEP_DIR_Pin, GPIO_PIN_RESET);
|
||||||
|
}
|
||||||
|
|
||||||
|
for(unsigned int i = 0; i < numPulses; i++){
|
||||||
|
HAL_GPIO_WritePin(STEP_PULSE_GPIO_Port, STEP_PULSE_Pin, GPIO_PIN_SET);
|
||||||
|
vTaskDelay(pdMS_TO_TICKS(1));
|
||||||
|
HAL_GPIO_WritePin(STEP_PULSE_GPIO_Port, STEP_PULSE_Pin, GPIO_PIN_RESET);
|
||||||
|
vTaskDelay(pdMS_TO_TICKS(1));
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
L6474_Handle_t init_stepper(void* pIO, void* pGPO, void* pPWM){
|
||||||
|
|
||||||
|
(void)pIO;
|
||||||
|
(void)pGPO;
|
||||||
|
(void)pPWM;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static L6474x_Platform_t p;
|
||||||
|
p.malloc = StepLibraryMalloc;
|
||||||
|
p.free = StepLibraryFree;
|
||||||
|
p.transfer = StepDriverSpiTransfer;
|
||||||
|
p.reset = StepDriverReset;
|
||||||
|
p.sleep = StepLibraryDelay;
|
||||||
|
p.step = StepLibraryStep;
|
||||||
|
|
||||||
|
//p.stepAsync = StepTimerAsync;
|
||||||
|
//p.cancelStep = StepTimerCancelAsync;
|
||||||
|
L6474_Handle_t s = L6474_CreateInstance(&p, pIO, pGPO, pPWM);
|
||||||
|
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int stepper_check_status(L6474_Handle_t s){
|
||||||
|
L6474_Status_t st;
|
||||||
|
if(L6474_GetStatus(s, &st) != errcNONE){
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
if(st.UVLO || st.TH_SD || st.OCD || st.NOTPERF_CMD || st.WRONG_CMD){
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int reset_stepper(L6474_Handle_t s){
|
||||||
|
|
||||||
|
L6474_BaseParameter_t b;
|
||||||
|
L6474_SetBaseParameter(&b);
|
||||||
|
b.stepMode = smMICRO16;
|
||||||
|
b.OcdTh = ocdth1125mA;
|
||||||
|
L6474_EncodePhaseCurrentParameter(&b, 700.0f);
|
||||||
|
|
||||||
|
int result = 0;
|
||||||
|
|
||||||
|
// reset all and take all initialization steps
|
||||||
|
result |= L6474_ResetStandBy(s);
|
||||||
|
result |= L6474_Initialize(s, &b);
|
||||||
|
result |= L6474_SetPowerOutputs(s, 0);
|
||||||
|
yellow_led_stop();
|
||||||
|
|
||||||
|
return result;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#define REF_MAX_STEPS (mm_to_step(150))
|
||||||
|
|
||||||
|
int stepper_reference(L6474_Handle_t s, int flag){
|
||||||
|
if(L6474_SetPowerOutputs(s, 1) != errcNONE){
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
yellow_led_start();
|
||||||
|
//flag: 0 keiner, 1 -t, 2 -e, 3 -s
|
||||||
|
|
||||||
|
if(HAL_GPIO_ReadPin(REFERENCE_MARK_GPIO_Port, REFERENCE_MARK_Pin) == GPIO_PIN_RESET){
|
||||||
|
if(L6474_StepIncremental(s, mm_to_step(5)) != errcNONE){
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
if(stepper_check_status(s)){
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// zum Schalter fahren, mit Limit und Statuspruefung
|
||||||
|
int steps = 0;
|
||||||
|
while(HAL_GPIO_ReadPin(REFERENCE_MARK_GPIO_Port, REFERENCE_MARK_Pin) != GPIO_PIN_RESET){
|
||||||
|
if(L6474_StepIncremental(s, -1) != errcNONE){
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
if((++steps % 100) == 0 && stepper_check_status(s)){
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
if(steps > REF_MAX_STEPS){
|
||||||
|
return 1; // Schalter nie erreicht
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(stepper_check_status(s)){
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
if(L6474_SetAbsolutePosition(s, 0) != errcNONE){
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void stepper_softstart(L6474_Handle_t s, unsigned int duration){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
int stepper_pos(L6474_Handle_t s){
|
||||||
|
int position = 0;
|
||||||
|
if(L6474_GetAbsolutePosition(s, &position) != errcNONE){
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
printf("%d", (position/800));
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int stepper_status(L6474_Handle_t s){
|
||||||
|
L6474_Status_t status;
|
||||||
|
L6474_GetStatus(s, &status);
|
||||||
|
printf("Stepper status: ");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int stepper_move(L6474_Handle_t s, int pos){
|
||||||
|
|
||||||
|
int position = 0;
|
||||||
|
if(L6474_GetAbsolutePosition(s, &position) != errcNONE){
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int pos_diff = pos - position;
|
||||||
|
|
||||||
|
if(L6474_StepIncremental(s, pos_diff) != errcNONE){
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(stepper_check_status(s)){
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void print_binary_8bit(unsigned int val) {
|
||||||
|
for (int i = 7; i >= 0; i--) {
|
||||||
|
int bit = (val >> i) & 1;
|
||||||
|
printf("%d", bit);
|
||||||
|
if (i == 4) printf(" ");
|
||||||
|
}
|
||||||
|
printf("\r\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
int StepperConsoleFunction( int argc, char** argv, void* ctx )
|
||||||
|
// --------------------------------------------------------------------------------------------------------------------
|
||||||
|
{
|
||||||
|
//possible commands are
|
||||||
|
//(stepper) step 100
|
||||||
|
(void)argc;
|
||||||
|
(void)argv;
|
||||||
|
(void)ctx;
|
||||||
|
|
||||||
|
L6474_Handle_t h = (L6474_Handle_t)ctx;
|
||||||
|
|
||||||
|
// first decode the subcommand and all arguments
|
||||||
|
if ( argc == 0 )
|
||||||
|
{
|
||||||
|
printf("invalid number of arguments\r\n");
|
||||||
|
printf("FAIL\r\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
else if ( strcmp(argv[0], "step") == 0 )
|
||||||
|
{
|
||||||
|
if(state != 2){
|
||||||
|
printf("Please do reference\r\n");
|
||||||
|
printf("FAIL\r\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if ( argc < 2 )
|
||||||
|
{
|
||||||
|
printf("missing step value for step command\r\n");
|
||||||
|
printf("FAIL\r\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(L6474_StepIncremental(h, atoi(argv[1])) != errcNONE || stepper_check_status(h)){
|
||||||
|
state = 0;
|
||||||
|
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_14, GPIO_PIN_SET);
|
||||||
|
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_0, GPIO_PIN_RESET);
|
||||||
|
yellow_led_stop();
|
||||||
|
printf("FAIL\r\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("%d steps", (int)atoi(argv[1]));
|
||||||
|
|
||||||
|
}
|
||||||
|
else if ( strcmp(argv[0], "reset") == 0 )
|
||||||
|
{
|
||||||
|
if(reset_stepper(h)){
|
||||||
|
state = 0;
|
||||||
|
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_14, GPIO_PIN_SET);
|
||||||
|
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_0, GPIO_PIN_RESET);
|
||||||
|
yellow_led_stop();
|
||||||
|
printf("FAIL\r\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
state = 1;
|
||||||
|
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_14, GPIO_PIN_RESET);
|
||||||
|
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_0, GPIO_PIN_SET);
|
||||||
|
printf("OK\r\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
else if ( strcmp(argv[0], "reference") == 0 )
|
||||||
|
{
|
||||||
|
if(state < 1){
|
||||||
|
printf("Please do reset\r\n");
|
||||||
|
printf("FAIL\r\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(stepper_reference(h, 0)){
|
||||||
|
state = 0;
|
||||||
|
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_14, GPIO_PIN_SET);
|
||||||
|
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_0, GPIO_PIN_RESET);
|
||||||
|
yellow_led_stop();
|
||||||
|
printf("FAIL\r\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
state = 2;
|
||||||
|
printf("OK\r\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
else if ( strcmp(argv[0], "position") == 0 )
|
||||||
|
{
|
||||||
|
if(state != 2){
|
||||||
|
printf("Please do reference\r\n");
|
||||||
|
printf("FAIL\r\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(stepper_pos(h)){
|
||||||
|
state = 0;
|
||||||
|
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_14, GPIO_PIN_SET);
|
||||||
|
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_0, GPIO_PIN_RESET);
|
||||||
|
yellow_led_stop();
|
||||||
|
printf("\r\nFAIL\r\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("\r\nOK\r\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
else if ( strcmp(argv[0], "move") == 0 )
|
||||||
|
{
|
||||||
|
if(state != 2){
|
||||||
|
printf("Please do reference\r\n");
|
||||||
|
printf("FAIL\r\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( argc < 2 )
|
||||||
|
{
|
||||||
|
printf("missing position value for move command\r\n");
|
||||||
|
printf("FAIL\r\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
float target_mm = (float)atof(argv[1]);
|
||||||
|
|
||||||
|
if (target_mm < 0.0f || target_mm > 100.0f) {
|
||||||
|
printf("position out of range\r\n");
|
||||||
|
printf("FAIL\r\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(stepper_move(h, mm_to_step(target_mm))==1){
|
||||||
|
state = 0;
|
||||||
|
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_14, GPIO_PIN_SET);
|
||||||
|
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_0, GPIO_PIN_RESET);
|
||||||
|
yellow_led_stop();
|
||||||
|
printf("FAIL\r\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
printf("OK\r\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
else if (strcmp(argv[0], "status") == 0)
|
||||||
|
{
|
||||||
|
L6474x_State_t currentState;
|
||||||
|
L6474_Status_t stepperStatus;
|
||||||
|
int moving = 0;
|
||||||
|
|
||||||
|
// 1. get state of state machine
|
||||||
|
if (L6474_GetState(h, ¤tState) != errcNONE)
|
||||||
|
{
|
||||||
|
printf("failed to get state\r\nFAIL");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 2.get driver-state
|
||||||
|
if (L6474_GetStatus(h, &stepperStatus) != errcNONE)
|
||||||
|
{
|
||||||
|
printf("failed to get status\r\nFAIL");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned int errorBits = ((stepperStatus.WRONG_CMD & 0x01) << 8) |
|
||||||
|
((stepperStatus.UVLO & 0x01) << 7) |
|
||||||
|
((stepperStatus.TH_WARN & 0x01) << 6) |
|
||||||
|
((stepperStatus.TH_SD & 0x01) << 5) |
|
||||||
|
((stepperStatus.ONGOING & 0x01) << 4) |
|
||||||
|
((stepperStatus.OCD & 0x01) << 3) |
|
||||||
|
((stepperStatus.NOTPERF_CMD & 0x01) << 2) |
|
||||||
|
((stepperStatus.HIGHZ & 0x01) << 1) |
|
||||||
|
((stepperStatus.DIR & 0x01) << 0);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// 3. check for moving motor aka async pending operation (should be always 0 with no async mode)
|
||||||
|
L6474_IsMoving(h, &moving);
|
||||||
|
|
||||||
|
|
||||||
|
printf("0x%X\r\n", (unsigned int)currentState); //print state in first line
|
||||||
|
printf("0x%X\r\n", errorBits); //print error flags in second line
|
||||||
|
printf("internal error bits in binary: ");
|
||||||
|
print_binary_8bit(errorBits);
|
||||||
|
printf("%d\r\n", moving); //print async pending op in third line
|
||||||
|
printf("OK");
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
printf("passed invalid sub command\r\n");
|
||||||
|
printf("FAIL\r\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
@@ -27,8 +27,15 @@
|
|||||||
#include "queue.h"
|
#include "queue.h"
|
||||||
#include "stdio.h"
|
#include "stdio.h"
|
||||||
#include "assert.h"
|
#include "assert.h"
|
||||||
|
#include "Spindle.h"
|
||||||
|
#include "Console.h"
|
||||||
|
#include "Spindle/spindel.h"
|
||||||
|
#include "Stepper/stepper.h"
|
||||||
|
|
||||||
/* USER CODE END Includes */
|
/* USER CODE END Includes */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* Private typedef -----------------------------------------------------------*/
|
/* Private typedef -----------------------------------------------------------*/
|
||||||
/* USER CODE BEGIN PTD */
|
/* USER CODE BEGIN PTD */
|
||||||
|
|
||||||
@@ -56,6 +63,7 @@ TIM_HandleTypeDef htim2;
|
|||||||
|
|
||||||
UART_HandleTypeDef huart3;
|
UART_HandleTypeDef huart3;
|
||||||
|
|
||||||
|
|
||||||
/* USER CODE BEGIN PV */
|
/* USER CODE BEGIN PV */
|
||||||
|
|
||||||
/* USER CODE END PV */
|
/* USER CODE END PV */
|
||||||
@@ -98,17 +106,52 @@ QueueHandle_t uartRxQueue;
|
|||||||
/* Private user code ---------------------------------------------------------*/
|
/* Private user code ---------------------------------------------------------*/
|
||||||
/* USER CODE BEGIN 0 */
|
/* USER CODE BEGIN 0 */
|
||||||
// --------------------------------------------------------------------------------------------------------------------
|
// --------------------------------------------------------------------------------------------------------------------
|
||||||
static void playgroundTask(void* args)
|
|
||||||
// --------------------------------------------------------------------------------------------------------------------
|
|
||||||
{
|
|
||||||
(void)args;
|
|
||||||
|
|
||||||
|
void green_led(){
|
||||||
while(1){
|
while(1){
|
||||||
vTaskDelay(pdMS_TO_TICKS(10));
|
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_0, GPIO_PIN_SET);
|
||||||
|
HAL_GPIO_WritePin(GPIOE, GPIO_PIN_1, GPIO_PIN_RESET);
|
||||||
|
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_14, GPIO_PIN_RESET);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
vTaskDelete(xTaskGetCurrentTaskHandle());
|
static TaskHandle_t yellowLedTask = NULL;
|
||||||
|
|
||||||
|
void blink_yellow_led(){
|
||||||
|
while(1){
|
||||||
|
|
||||||
|
HAL_GPIO_WritePin(GPIOE, GPIO_PIN_1, GPIO_PIN_SET);
|
||||||
|
vTaskDelay(pdMS_TO_TICKS(500));
|
||||||
|
HAL_GPIO_WritePin(GPIOE, GPIO_PIN_1, GPIO_PIN_RESET);
|
||||||
|
vTaskDelay(pdMS_TO_TICKS(500));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void yellow_led_start(void)
|
||||||
|
{
|
||||||
|
if (yellowLedTask == NULL) {
|
||||||
|
xTaskCreate(blink_yellow_led, "blink_yellow_led", 1024, NULL, 1, &yellowLedTask);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void yellow_led_stop(void)
|
||||||
|
{
|
||||||
|
if (yellowLedTask != NULL) {
|
||||||
|
vTaskDelete(yellowLedTask);
|
||||||
|
yellowLedTask = NULL;
|
||||||
|
HAL_GPIO_WritePin(GPIOE, GPIO_PIN_1, GPIO_PIN_RESET);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void red_led(){
|
||||||
|
while(1){
|
||||||
|
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_14, GPIO_PIN_SET);
|
||||||
|
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_0, GPIO_PIN_RESET);
|
||||||
|
HAL_GPIO_WritePin(GPIOE, GPIO_PIN_1, GPIO_PIN_RESET);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// --------------------------------------------------------------------------------------------------------------------
|
// --------------------------------------------------------------------------------------------------------------------
|
||||||
static int CapabilityFunc( int argc, char** argv, void* ctx )
|
static int CapabilityFunc( int argc, char** argv, void* ctx )
|
||||||
@@ -118,19 +161,19 @@ static int CapabilityFunc( int argc, char** argv, void* ctx )
|
|||||||
(void)argv;
|
(void)argv;
|
||||||
(void)ctx;
|
(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",
|
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
|
1, // has spindle
|
||||||
0, // has spindle status
|
1, // has spindle status
|
||||||
0, // has stepper
|
1, // has stepper
|
||||||
0, // has stepper move relative
|
0, // has stepper move relative
|
||||||
0, // has stepper move speed
|
0, // has stepper move speed
|
||||||
0, // has stepper move async
|
0, // has stepper move async
|
||||||
0, // has stepper status
|
1, // has stepper status
|
||||||
0, // has stepper refrun
|
1, // has stepper refrun
|
||||||
0, // has stepper refrun timeout
|
0, // has stepper refrun timeout
|
||||||
0, // has stepper refrun skip
|
0, // has stepper refrun skip
|
||||||
0, // has stepper refrun stay enabled
|
0, // has stepper refrun stay enabled
|
||||||
0, // has stepper reset
|
1, // has stepper reset
|
||||||
0, // has stepper position
|
1, // has stepper position
|
||||||
0, // has stepper config
|
0, // has stepper config
|
||||||
0, // has stepper config torque
|
0, // has stepper config torque
|
||||||
0, // has stepper config throvercurr
|
0, // has stepper config throvercurr
|
||||||
@@ -150,6 +193,16 @@ static int CapabilityFunc( int argc, char** argv, void* ctx )
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static int fabi(int argc, char** argv, void* ctx){
|
||||||
|
(void)argc;
|
||||||
|
(void)argv;
|
||||||
|
(void)ctx;
|
||||||
|
printf("Hallo Fabi");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
#define BKPSRAM_BASE 0x38800000UL
|
#define BKPSRAM_BASE 0x38800000UL
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
@@ -272,8 +325,31 @@ int main(void)
|
|||||||
uartRxQueue = xQueueCreate(64, sizeof(char));
|
uartRxQueue = xQueueCreate(64, sizeof(char));
|
||||||
HAL_UART_Receive_IT(&huart3, (uint8_t *)&myChar, sizeof(myChar));
|
HAL_UART_Receive_IT(&huart3, (uint8_t *)&myChar, sizeof(myChar));
|
||||||
|
|
||||||
// create a playground task at the very beginning
|
|
||||||
xTaskCreate(playgroundTask, "playground", 128, NULL, 1, NULL);
|
|
||||||
|
//Konsole
|
||||||
|
ConsoleHandle_t c = CONSOLE_CreateInstance( 4*configMINIMAL_STACK_SIZE, configMAX_PRIORITIES - 5 );
|
||||||
|
L6474_Handle_t stepper1 = init_stepper(NULL, NULL, NULL);
|
||||||
|
|
||||||
|
CONSOLE_RegisterCommand(c, "capability", "prints a specified string of capability bits",
|
||||||
|
CapabilityFunc, NULL);
|
||||||
|
|
||||||
|
CONSOLE_RegisterCommand(c, "fabi", "prints a hallo fabi",
|
||||||
|
fabi, NULL);
|
||||||
|
|
||||||
|
CONSOLE_RegisterCommand(c, "stepper", "stepper command",
|
||||||
|
StepperConsoleFunction, stepper1);
|
||||||
|
|
||||||
|
//Spindle
|
||||||
|
init_spindle(c, 9000, -9000, 1600);
|
||||||
|
|
||||||
|
|
||||||
|
//Stepepr
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// tasks
|
||||||
|
|
||||||
// mask a compiler warning by referencing the function but not using it (void cast)
|
// mask a compiler warning by referencing the function but not using it (void cast)
|
||||||
(void)CapabilityFunc;
|
(void)CapabilityFunc;
|
||||||
|
|||||||
@@ -46,9 +46,9 @@
|
|||||||
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.stlink.stlink_check_serial_number" value="false"/>
|
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.stlink.stlink_check_serial_number" value="false"/>
|
||||||
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.stlink.stlink_txt_serial_number" value=""/>
|
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.stlink.stlink_txt_serial_number" value=""/>
|
||||||
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.stlink.watchdog_config" value="disable"/>
|
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.stlink.watchdog_config" value="disable"/>
|
||||||
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.stlinkenable_rtos" value="false"/>
|
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.stlinkenable_rtos" value="true"/>
|
||||||
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.stlinkrestart_configurations" value="{"fVersion":1,"fItems":[{"fDisplayName":"Reset","fIsSuppressible":false,"fResetAttribute":"Software system reset","fResetStrategies":[{"fDisplayName":"Software system reset","fLaunchAttribute":"system_reset","fGdbCommands":["monitor reset\r\n"],"fCmdOptions":["-g"]},{"fDisplayName":"Hardware reset","fLaunchAttribute":"hardware_reset","fGdbCommands":["monitor reset hardware\r\n"],"fCmdOptions":["-g"]},{"fDisplayName":"Core reset","fLaunchAttribute":"core_reset","fGdbCommands":["monitor reset core\r\n"],"fCmdOptions":["-g"]},{"fDisplayName":"None","fLaunchAttribute":"no_reset","fGdbCommands":[],"fCmdOptions":["-g"]}],"fGdbCommandGroup":{"name":"Additional commands","commands":[]},"fStartApplication":true}]}"/>
|
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.stlinkrestart_configurations" value="{"fVersion":1,"fItems":[{"fDisplayName":"Reset","fIsSuppressible":false,"fResetAttribute":"Software system reset","fResetStrategies":[{"fDisplayName":"Software system reset","fLaunchAttribute":"system_reset","fGdbCommands":["monitor reset\n"],"fCmdOptions":["-g"]},{"fDisplayName":"Hardware reset","fLaunchAttribute":"hardware_reset","fGdbCommands":["monitor reset hardware\n"],"fCmdOptions":["-g"]},{"fDisplayName":"Core reset","fLaunchAttribute":"core_reset","fGdbCommands":["monitor reset core\n"],"fCmdOptions":["-g"]},{"fDisplayName":"None","fLaunchAttribute":"no_reset","fGdbCommands":[],"fCmdOptions":["-g"]}],"fGdbCommandGroup":{"name":"Additional commands","commands":[]},"fStartApplication":true}]}"/>
|
||||||
<booleanAttribute key="com.st.stm32cube.ide.mcu.rtosproxy.enableRtosProxy" value="false"/>
|
<booleanAttribute key="com.st.stm32cube.ide.mcu.rtosproxy.enableRtosProxy" value="true"/>
|
||||||
<stringAttribute key="com.st.stm32cube.ide.mcu.rtosproxy.rtosProxyCustomProperties" value=""/>
|
<stringAttribute key="com.st.stm32cube.ide.mcu.rtosproxy.rtosProxyCustomProperties" value=""/>
|
||||||
<stringAttribute key="com.st.stm32cube.ide.mcu.rtosproxy.rtosProxyDriver" value="freertos"/>
|
<stringAttribute key="com.st.stm32cube.ide.mcu.rtosproxy.rtosProxyDriver" value="freertos"/>
|
||||||
<booleanAttribute key="com.st.stm32cube.ide.mcu.rtosproxy.rtosProxyDriverAuto" value="false"/>
|
<booleanAttribute key="com.st.stm32cube.ide.mcu.rtosproxy.rtosProxyDriverAuto" value="false"/>
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 799 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 2.0 KiB |
Reference in new issue
Block a user