10 Commits
Author SHA1 Message Date
fewikay 6a6a1589ee LEDS fix 2026-11-06 14:26:37 +01:00
fewikay fef883dca4 Test Pulse mit Timer 1 (Master) und Timer 4 (Slave) 2026-11-05 21:15:46 +01:00
fewikay f736da7a1d mm integration + Checkliste 2026-11-05 21:03:23 +01:00
fewikay 8ca3ce7f6a Fehlerbehandlung 2026-11-02 17:01:30 +01:00
fewikay 6a9a634df0 Reference + move funktioniert (Fehlerbehandlung muss implementiert werden) 2026-11-02 14:36:12 +01:00
fewikay 26b117b63f implemented reference (untested) 2026-10-26 16:18:12 +01:00
fewikay 13eac4fd0c console fix + stepper step läuft 2026-10-23 17:02:17 +02:00
fewikay d076d981ac stepper funktioniert 2026-10-23 15:45:58 +02:00
fewikay 634b69a55c stepper; doesnt work 2026-10-19 16:59:42 +02:00
fewikay 830bc0849a stepper first steps 2026-10-19 14:53:10 +02:00
12 changed files with 902 additions and 39 deletions

No files matched your search

+97
View File
@@ -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.
+3 -8
View File
@@ -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>
@@ -1,4 +1,5 @@
#include "Console.h" #include "Console.h"
#include <stdlib.h>
#include "Spindle.h" #include "Spindle.h"
#include "main.h" #include "main.h"
#include "FreeRTOS.h" #include "FreeRTOS.h"
@@ -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();
@@ -105,10 +105,19 @@ void Error_Handler(void);
#define LED_YELLOW_GPIO_Port GPIOE #define LED_YELLOW_GPIO_Port GPIOE
/* USER CODE BEGIN Private defines */ /* USER CODE BEGIN Private defines */
extern TIM_HandleTypeDef htim1;
/* USER CODE END Private defines */
extern TIM_HandleTypeDef htim2; extern TIM_HandleTypeDef htim2;
extern TIM_HandleTypeDef htim4;
extern TIM_HandleTypeDef htim3;
extern TIM_HandleTypeDef htim12;
extern SPI_HandleTypeDef hspi1;
void green_led();
void red_led();
void blink_yellow_led();
void yellow_led_start();
void yellow_led_stop();
/* USER CODE END Private defines */
#ifdef __cplusplus #ifdef __cplusplus
} }
@@ -0,0 +1,434 @@
#include "Stepper/stepper.h"
#include "LibL6474.h"
#include "main.h"
#include "semphr.h"
// TIM4 (Pulse an PD15) laeuft mit 200 MHz / 128, TIM1 zaehlt die Pulse (16 Bit)
#define STEP_TICK_HZ 1562500u
#define STEP_CHUNK 60000u
#define STEP_HZ_MOVE 4000u // 300 mm/min bei 800 Schritten/mm
#define STEP_HZ_REFERENCE 500u // 37,5 mm/min bei 800 Schritten/mm
#define STEP_POLL_MS 50u // Treiberstatus-Abfrage waehrend der Fahrt
static SemaphoreHandle_t stepDone;
static volatile unsigned int stepsLeft = 0;
static unsigned int stepHz = STEP_HZ_MOVE;
static L6474_Handle_t stepperHandle = NULL;
/*
* 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 wenn der Treiber nicht fahrbereit ist. L6474_GetStatus selbst meldet nur SPI-Fehler,
// die Flags muessen hier ausgewertet werden. HIGHZ bleibt nach OCD/UVLO/TH_SD stehen.
// Der Aufruf aus StepLibraryStep setzt LIBL6474_HAS_LOCKING 0 voraus.
static int StepperHasFault(L6474_Handle_t s){
L6474_Status_t status;
if(L6474_GetStatus(s, &status) != errcNONE){
return 1;
}
return status.HIGHZ || status.UVLO || status.TH_SD || status.OCD;
}
// Pulsfrequenz einstellen, nur aufrufen wenn gerade keine Pulse laufen
static void StepTimerSetSpeed(unsigned int hz){
uint32_t arr = (STEP_TICK_HZ / hz) - 1;
stepHz = hz;
TIM4->ARR = arr;
TIM4->CCR4 = (arr + 1) / 2; // 50 % Duty
TIM4->EGR = TIM_EGR_UG; // Werte uebernehmen, Zaehler auf 0
}
// TIM1 auf die naechsten n Pulse stellen und starten, das oeffnet das Gate von TIM4
static void StepTimerStartChunk(void){
unsigned int n;
if(stepsLeft > STEP_CHUNK){
n = STEP_CHUNK;
}else{
n = stepsLeft;
}
stepsLeft -= n;
TIM1->CNT = 0;
TIM1->CCR1 = n;
TIM1->SR = ~TIM_SR_CC1IF;
TIM1->CR1 |= TIM_CR1_CEN;
}
// Wird ueber TIM1_CC_IRQHandler aufgerufen, sobald TIM1 n Pulse gezaehlt hat
void HAL_TIM_OC_DelayElapsedCallback(TIM_HandleTypeDef *htim){
if(htim->Instance != TIM1){
return;
}
TIM1->CR1 &= ~TIM_CR1_CEN; // Gate zu
if(stepsLeft > 0){
StepTimerStartChunk();
return;
}
BaseType_t woken = pdFALSE;
xSemaphoreGiveFromISR(stepDone, &woken);
portYIELD_FROM_ISR(woken);
}
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);
}
(void)xSemaphoreTake(stepDone, 0); // altes Signal verwerfen
stepsLeft = numPulses;
StepTimerStartChunk();
// Erwartete Fahrzeit plus 1 s Reserve
uint32_t timeoutMs = (uint32_t)(((uint64_t)numPulses * 1000u) / stepHz) + 1000u;
TickType_t start = xTaskGetTickCount();
// Bei Fehler oder Timeout Pulse sofort stoppen
while(xSemaphoreTake(stepDone, pdMS_TO_TICKS(STEP_POLL_MS)) != pdTRUE){
if(StepperHasFault(stepperHandle) || (xTaskGetTickCount() - start) >= pdMS_TO_TICKS(timeoutMs)){
stepsLeft = 0; // zuerst, damit der Interrupt keinen neuen Chunk startet
TIM1->CR1 &= ~TIM_CR1_CEN;
return 1;
}
}
return 0;
}
L6474_Handle_t init_stepper(void* pIO, void* pGPO, void* pPWM){
(void)pIO;
(void)pGPO;
(void)pPWM;
stepDone = xSemaphoreCreateBinary();
StepTimerSetSpeed(STEP_HZ_MOVE);
TIM1->SR = ~TIM_SR_CC1IF; // sonst feuert der Interrupt sofort beim Freischalten
__HAL_TIM_ENABLE_IT(&htim1, TIM_IT_CC1);
HAL_TIM_PWM_Start(&htim4, TIM_CHANNEL_4); // laeuft erst bei offenem Gate
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);
stepperHandle = s;
return s;
}
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();
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_14, GPIO_PIN_RESET);
return result;
}
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;
}
int button_pressed = 0;
while(!button_pressed){
if(L6474_StepIncremental(s, -1) != errcNONE){
return 1;
}
if(HAL_GPIO_ReadPin(REFERENCE_MARK_GPIO_Port, REFERENCE_MARK_Pin) == GPIO_PIN_RESET){
button_pressed=1;
}
}
}
if(flag == 3){
L6474_SetAbsolutePosition(s, 0);
return StepperHasFault(s);
}
int button_pressed = 0;
while(!button_pressed){
if(L6474_StepIncremental(s, -1) != errcNONE){
return 1;
}
if(HAL_GPIO_ReadPin(REFERENCE_MARK_GPIO_Port, REFERENCE_MARK_Pin) == GPIO_PIN_RESET){
button_pressed=1;
}
}
L6474_SetAbsolutePosition(s, 0);
return StepperHasFault(s);
}
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("Stepper position: %d", position);
return StepperHasFault(s);
}
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;
// StepIncremental lehnt 0 Schritte als Fehler ab
if(pos_diff != 0 && L6474_StepIncremental(s, pos_diff) != errcNONE){
return 1;
}
return StepperHasFault(s);
}
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 commandFAIL\r\n");
return -1;
}
int steps = atoi(argv[1]);
if((steps != 0 && L6474_StepIncremental(h, steps) != errcNONE) || StepperHasFault(h)){
state = 0;
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_14, GPIO_PIN_SET);
printf("FAIL\r\n");
return -1;
}
printf("%d steps", steps);
}
else if ( strcmp(argv[0], "reset") == 0 )
{
if(reset_stepper(h)){
state = 0;
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_0, GPIO_PIN_RESET);
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_14, GPIO_PIN_SET);
yellow_led_stop();
printf("FAIL\r\n");
return -1;
}
state = 1;
HAL_GPIO_WritePin(GPIOE, GPIO_PIN_1, 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;
}
StepTimerSetSpeed(STEP_HZ_REFERENCE);
int refResult = stepper_reference(h, 0);
StepTimerSetSpeed(STEP_HZ_MOVE);
if(refResult){
state = 0;
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_0, GPIO_PIN_RESET);
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_14, GPIO_PIN_SET);
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_0, GPIO_PIN_RESET);
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_14, GPIO_PIN_SET);
yellow_led_stop();
printf("FAIL\r\n");
return -1;
}
printf("OK\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_0, GPIO_PIN_RESET);
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_14, GPIO_PIN_SET);
yellow_led_stop();
printf("FAIL\r\n");
return -1;
}
printf("OK\r\n");
return 0;
}
else
{
printf("passed invalid sub command\r\n");
printf("FAIL\r\n");
return -1;
}
return 0;
}
+196 -21
View File
@@ -30,8 +30,12 @@
#include "Spindle.h" #include "Spindle.h"
#include "Console.h" #include "Console.h"
#include "Spindle/spindel.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 */
@@ -55,10 +59,18 @@
SPI_HandleTypeDef hspi1; SPI_HandleTypeDef hspi1;
TIM_HandleTypeDef htim1;
TIM_HandleTypeDef htim2; TIM_HandleTypeDef htim2;
TIM_HandleTypeDef htim4;
//Für LEDS
TIM_HandleTypeDef htim3;
TIM_HandleTypeDef htim12;
UART_HandleTypeDef huart3; UART_HandleTypeDef huart3;
/* USER CODE BEGIN PV */ /* USER CODE BEGIN PV */
/* USER CODE END PV */ /* USER CODE END PV */
@@ -70,6 +82,8 @@ static void MX_GPIO_Init(void);
static void MX_SPI1_Init(void); static void MX_SPI1_Init(void);
static void MX_TIM2_Init(void); static void MX_TIM2_Init(void);
static void MX_USART3_UART_Init(void); static void MX_USART3_UART_Init(void);
static void MX_TIM1_Init(void);
static void MX_TIM4_Init(void);
/* USER CODE BEGIN PFP */ /* USER CODE BEGIN PFP */
extern void initialise_stdlib_abstraction( void ); extern void initialise_stdlib_abstraction( void );
@@ -102,34 +116,54 @@ QueueHandle_t uartRxQueue;
/* USER CODE BEGIN 0 */ /* USER CODE BEGIN 0 */
// -------------------------------------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------------------------------------
void blink_green_led(){ void green_led(){
while(1){ while(1){
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_0, GPIO_PIN_SET); HAL_GPIO_WritePin(GPIOB, GPIO_PIN_0, GPIO_PIN_SET);
vTaskDelay(pdMS_TO_TICKS(1000)); HAL_GPIO_WritePin(GPIOE, GPIO_PIN_1, GPIO_PIN_RESET);
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_0, GPIO_PIN_RESET); HAL_GPIO_WritePin(GPIOB, GPIO_PIN_14, GPIO_PIN_RESET);
vTaskDelay(pdMS_TO_TICKS(1000));
} }
} }
static TaskHandle_t yellowLedTask = NULL;
void blink_yellow_led(){ void blink_yellow_led(){
while(1){ while(1){
HAL_GPIO_WritePin(GPIOE, GPIO_PIN_1, GPIO_PIN_SET); HAL_GPIO_WritePin(GPIOE, GPIO_PIN_1, GPIO_PIN_SET);
vTaskDelay(pdMS_TO_TICKS(100)); vTaskDelay(pdMS_TO_TICKS(500));
HAL_GPIO_WritePin(GPIOE, GPIO_PIN_1, GPIO_PIN_RESET); HAL_GPIO_WritePin(GPIOE, GPIO_PIN_1, GPIO_PIN_RESET);
vTaskDelay(pdMS_TO_TICKS(2000)); vTaskDelay(pdMS_TO_TICKS(500));
} }
} }
void blink_red_led(){ 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){ while(1){
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_14, GPIO_PIN_SET); HAL_GPIO_WritePin(GPIOB, GPIO_PIN_14, GPIO_PIN_SET);
vTaskDelay(pdMS_TO_TICKS(1000)); HAL_GPIO_WritePin(GPIOB, GPIO_PIN_0, GPIO_PIN_RESET);
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_14, GPIO_PIN_RESET); HAL_GPIO_WritePin(GPIOE, GPIO_PIN_1, GPIO_PIN_RESET);
vTaskDelay(pdMS_TO_TICKS(1000));
} }
} }
// -------------------------------------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------------------------------------
static int CapabilityFunc( int argc, char** argv, void* ctx ) static int CapabilityFunc( int argc, char** argv, void* ctx )
// -------------------------------------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------------------------------------
@@ -138,9 +172,9 @@ 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
@@ -150,7 +184,7 @@ static int CapabilityFunc( int argc, char** argv, void* ctx )
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 0, // 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
@@ -296,6 +330,8 @@ int main(void)
MX_SPI1_Init(); MX_SPI1_Init();
MX_TIM2_Init(); MX_TIM2_Init();
MX_USART3_UART_Init(); MX_USART3_UART_Init();
MX_TIM1_Init();
MX_TIM4_Init();
/* USER CODE BEGIN 2 */ /* USER CODE BEGIN 2 */
// cretae a free rtos queue to buffer console characters received from debug uart // cretae a free rtos queue to buffer console characters received from debug uart
@@ -306,6 +342,7 @@ int main(void)
//Konsole //Konsole
ConsoleHandle_t c = CONSOLE_CreateInstance( 4*configMINIMAL_STACK_SIZE, configMAX_PRIORITIES - 5 ); 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", CONSOLE_RegisterCommand(c, "capability", "prints a specified string of capability bits",
CapabilityFunc, NULL); CapabilityFunc, NULL);
@@ -313,15 +350,19 @@ int main(void)
CONSOLE_RegisterCommand(c, "fabi", "prints a hallo fabi", CONSOLE_RegisterCommand(c, "fabi", "prints a hallo fabi",
fabi, NULL); fabi, NULL);
CONSOLE_RegisterCommand(c, "stepper", "stepper command",
StepperConsoleFunction, stepper1);
//Spindle //Spindle
init_spindle(c, 9000, -9000, 1600); init_spindle(c, 9000, -9000, 1600);
//Stepepr
// tasks // tasks
xTaskCreate(blink_green_led, "blink_green_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);
// 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;
@@ -512,6 +553,140 @@ static void MX_TIM2_Init(void)
} }
/**
* @brief TIM1 Initialization Function
* @param None
* @retval None
*/
static void MX_TIM1_Init(void)
{
/* USER CODE BEGIN TIM1_Init 0 */
/* USER CODE END TIM1_Init 0 */
TIM_SlaveConfigTypeDef sSlaveConfig = {0};
TIM_MasterConfigTypeDef sMasterConfig = {0};
TIM_OC_InitTypeDef sConfigOC = {0};
/* USER CODE BEGIN TIM1_Init 1 */
/* USER CODE END TIM1_Init 1 */
htim1.Instance = TIM1;
htim1.Init.Prescaler = 0;
htim1.Init.CounterMode = TIM_COUNTERMODE_UP;
htim1.Init.Period = 65535;
htim1.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
htim1.Init.RepetitionCounter = 0;
htim1.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE;
if (HAL_TIM_Base_Init(&htim1) != HAL_OK)
{
Error_Handler();
}
if (HAL_TIM_OC_Init(&htim1) != HAL_OK)
{
Error_Handler();
}
if (HAL_TIM_OnePulse_Init(&htim1, TIM_OPMODE_SINGLE) != HAL_OK)
{
Error_Handler();
}
sSlaveConfig.SlaveMode = TIM_SLAVEMODE_EXTERNAL1;
sSlaveConfig.InputTrigger = TIM_TS_ITR3;
if (HAL_TIM_SlaveConfigSynchro(&htim1, &sSlaveConfig) != HAL_OK)
{
Error_Handler();
}
sMasterConfig.MasterOutputTrigger = TIM_TRGO_ENABLE;
sMasterConfig.MasterOutputTrigger2 = TIM_TRGO2_ENABLE;
sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE;
if (HAL_TIMEx_MasterConfigSynchronization(&htim1, &sMasterConfig) != HAL_OK)
{
Error_Handler();
}
sConfigOC.OCMode = TIM_OCMODE_TIMING;
sConfigOC.Pulse = 0;
sConfigOC.OCPolarity = TIM_OCPOLARITY_HIGH;
sConfigOC.OCNPolarity = TIM_OCNPOLARITY_HIGH;
sConfigOC.OCFastMode = TIM_OCFAST_DISABLE;
sConfigOC.OCIdleState = TIM_OCIDLESTATE_RESET;
sConfigOC.OCNIdleState = TIM_OCNIDLESTATE_RESET;
if (HAL_TIM_OC_ConfigChannel(&htim1, &sConfigOC, TIM_CHANNEL_1) != HAL_OK)
{
Error_Handler();
}
/* USER CODE BEGIN TIM1_Init 2 */
/* USER CODE END TIM1_Init 2 */
}
/**
* @brief TIM4 Initialization Function
* @param None
* @retval None
*/
static void MX_TIM4_Init(void)
{
/* USER CODE BEGIN TIM4_Init 0 */
/* USER CODE END TIM4_Init 0 */
TIM_ClockConfigTypeDef sClockSourceConfig = {0};
TIM_SlaveConfigTypeDef sSlaveConfig = {0};
TIM_MasterConfigTypeDef sMasterConfig = {0};
TIM_OC_InitTypeDef sConfigOC = {0};
/* USER CODE BEGIN TIM4_Init 1 */
/* USER CODE END TIM4_Init 1 */
htim4.Instance = TIM4;
htim4.Init.Prescaler = 127;
htim4.Init.CounterMode = TIM_COUNTERMODE_UP;
htim4.Init.Period = 5624;
htim4.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
htim4.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_ENABLE;
if (HAL_TIM_Base_Init(&htim4) != HAL_OK)
{
Error_Handler();
}
sClockSourceConfig.ClockSource = TIM_CLOCKSOURCE_INTERNAL;
if (HAL_TIM_ConfigClockSource(&htim4, &sClockSourceConfig) != HAL_OK)
{
Error_Handler();
}
if (HAL_TIM_PWM_Init(&htim4) != HAL_OK)
{
Error_Handler();
}
sSlaveConfig.SlaveMode = TIM_SLAVEMODE_GATED;
sSlaveConfig.InputTrigger = TIM_TS_ITR0;
if (HAL_TIM_SlaveConfigSynchro(&htim4, &sSlaveConfig) != HAL_OK)
{
Error_Handler();
}
sMasterConfig.MasterOutputTrigger = TIM_TRGO_UPDATE;
sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE;
if (HAL_TIMEx_MasterConfigSynchronization(&htim4, &sMasterConfig) != HAL_OK)
{
Error_Handler();
}
sConfigOC.OCMode = TIM_OCMODE_PWM2;
sConfigOC.Pulse = 2812;
sConfigOC.OCPolarity = TIM_OCPOLARITY_HIGH;
sConfigOC.OCFastMode = TIM_OCFAST_DISABLE;
if (HAL_TIM_PWM_ConfigChannel(&htim4, &sConfigOC, TIM_CHANNEL_4) != HAL_OK)
{
Error_Handler();
}
/* USER CODE BEGIN TIM4_Init 2 */
/* USER CODE END TIM4_Init 2 */
HAL_TIM_MspPostInit(&htim4);
}
/** /**
* @brief USART3 Initialization Function * @brief USART3 Initialization Function
* @param None * @param None
@@ -586,7 +761,7 @@ static void MX_GPIO_Init(void)
HAL_GPIO_WritePin(GPIOB, LED_GREEN_Pin|LED_RED_Pin, GPIO_PIN_RESET); HAL_GPIO_WritePin(GPIOB, LED_GREEN_Pin|LED_RED_Pin, GPIO_PIN_RESET);
/*Configure GPIO pin Output Level */ /*Configure GPIO pin Output Level */
HAL_GPIO_WritePin(GPIOD, STEP_SPI_CS_Pin|STEP_PULSE_Pin, GPIO_PIN_RESET); HAL_GPIO_WritePin(STEP_SPI_CS_GPIO_Port, STEP_SPI_CS_Pin, GPIO_PIN_RESET);
/*Configure GPIO pin Output Level */ /*Configure GPIO pin Output Level */
HAL_GPIO_WritePin(GPIOG, STEP_RSTN_Pin|STEP_DIR_Pin, GPIO_PIN_RESET); HAL_GPIO_WritePin(GPIOG, STEP_RSTN_Pin|STEP_DIR_Pin, GPIO_PIN_RESET);
@@ -617,12 +792,12 @@ static void MX_GPIO_Init(void)
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
/*Configure GPIO pins : STEP_SPI_CS_Pin STEP_PULSE_Pin */ /*Configure GPIO pin : STEP_SPI_CS_Pin */
GPIO_InitStruct.Pin = STEP_SPI_CS_Pin|STEP_PULSE_Pin; GPIO_InitStruct.Pin = STEP_SPI_CS_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
HAL_GPIO_Init(GPIOD, &GPIO_InitStruct); HAL_GPIO_Init(STEP_SPI_CS_GPIO_Port, &GPIO_InitStruct);
/*Configure GPIO pins : STEP_RSTN_Pin STEP_DIR_Pin */ /*Configure GPIO pins : STEP_RSTN_Pin STEP_DIR_Pin */
GPIO_InitStruct.Pin = STEP_RSTN_Pin|STEP_DIR_Pin; GPIO_InitStruct.Pin = STEP_RSTN_Pin|STEP_DIR_Pin;
@@ -182,7 +182,23 @@ void HAL_SPI_MspDeInit(SPI_HandleTypeDef* hspi)
*/ */
void HAL_TIM_Base_MspInit(TIM_HandleTypeDef* htim_base) void HAL_TIM_Base_MspInit(TIM_HandleTypeDef* htim_base)
{ {
if(htim_base->Instance==TIM2) if(htim_base->Instance==TIM1)
{
/* USER CODE BEGIN TIM1_MspInit 0 */
/* USER CODE END TIM1_MspInit 0 */
/* Peripheral clock enable */
__HAL_RCC_TIM1_CLK_ENABLE();
/* TIM1 interrupt Init */
HAL_NVIC_SetPriority(TIM1_UP_IRQn, 5, 0);
HAL_NVIC_EnableIRQ(TIM1_UP_IRQn);
HAL_NVIC_SetPriority(TIM1_CC_IRQn, 5, 0);
HAL_NVIC_EnableIRQ(TIM1_CC_IRQn);
/* USER CODE BEGIN TIM1_MspInit 1 */
/* USER CODE END TIM1_MspInit 1 */
}
else if(htim_base->Instance==TIM2)
{ {
/* USER CODE BEGIN TIM2_MspInit 0 */ /* USER CODE BEGIN TIM2_MspInit 0 */
@@ -192,7 +208,20 @@ void HAL_TIM_Base_MspInit(TIM_HandleTypeDef* htim_base)
/* USER CODE BEGIN TIM2_MspInit 1 */ /* USER CODE BEGIN TIM2_MspInit 1 */
/* USER CODE END TIM2_MspInit 1 */ /* USER CODE END TIM2_MspInit 1 */
}
else if(htim_base->Instance==TIM4)
{
/* USER CODE BEGIN TIM4_MspInit 0 */
/* USER CODE END TIM4_MspInit 0 */
/* Peripheral clock enable */
__HAL_RCC_TIM4_CLK_ENABLE();
/* TIM4 interrupt Init */
HAL_NVIC_SetPriority(TIM4_IRQn, 5, 0);
HAL_NVIC_EnableIRQ(TIM4_IRQn);
/* USER CODE BEGIN TIM4_MspInit 1 */
/* USER CODE END TIM4_MspInit 1 */
} }
} }
@@ -222,6 +251,27 @@ void HAL_TIM_MspPostInit(TIM_HandleTypeDef* htim)
/* USER CODE END TIM2_MspPostInit 1 */ /* USER CODE END TIM2_MspPostInit 1 */
} }
else if(htim->Instance==TIM4)
{
/* USER CODE BEGIN TIM4_MspPostInit 0 */
/* USER CODE END TIM4_MspPostInit 0 */
__HAL_RCC_GPIOD_CLK_ENABLE();
/**TIM4 GPIO Configuration
PD15 ------> TIM4_CH4
*/
GPIO_InitStruct.Pin = STEP_PULSE_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
GPIO_InitStruct.Alternate = GPIO_AF2_TIM4;
HAL_GPIO_Init(STEP_PULSE_GPIO_Port, &GPIO_InitStruct);
/* USER CODE BEGIN TIM4_MspPostInit 1 */
/* USER CODE END TIM4_MspPostInit 1 */
}
} }
/** /**
@@ -232,7 +282,22 @@ void HAL_TIM_MspPostInit(TIM_HandleTypeDef* htim)
*/ */
void HAL_TIM_Base_MspDeInit(TIM_HandleTypeDef* htim_base) void HAL_TIM_Base_MspDeInit(TIM_HandleTypeDef* htim_base)
{ {
if(htim_base->Instance==TIM2) if(htim_base->Instance==TIM1)
{
/* USER CODE BEGIN TIM1_MspDeInit 0 */
/* USER CODE END TIM1_MspDeInit 0 */
/* Peripheral clock disable */
__HAL_RCC_TIM1_CLK_DISABLE();
/* TIM1 interrupt DeInit */
HAL_NVIC_DisableIRQ(TIM1_UP_IRQn);
HAL_NVIC_DisableIRQ(TIM1_CC_IRQn);
/* USER CODE BEGIN TIM1_MspDeInit 1 */
/* USER CODE END TIM1_MspDeInit 1 */
}
else if(htim_base->Instance==TIM2)
{ {
/* USER CODE BEGIN TIM2_MspDeInit 0 */ /* USER CODE BEGIN TIM2_MspDeInit 0 */
@@ -243,6 +308,20 @@ void HAL_TIM_Base_MspDeInit(TIM_HandleTypeDef* htim_base)
/* USER CODE END TIM2_MspDeInit 1 */ /* USER CODE END TIM2_MspDeInit 1 */
} }
else if(htim_base->Instance==TIM4)
{
/* USER CODE BEGIN TIM4_MspDeInit 0 */
/* USER CODE END TIM4_MspDeInit 0 */
/* Peripheral clock disable */
__HAL_RCC_TIM4_CLK_DISABLE();
/* TIM4 interrupt DeInit */
HAL_NVIC_DisableIRQ(TIM4_IRQn);
/* USER CODE BEGIN TIM4_MspDeInit 1 */
/* USER CODE END TIM4_MspDeInit 1 */
}
} }
@@ -55,6 +55,8 @@
/* USER CODE END 0 */ /* USER CODE END 0 */
/* External variables --------------------------------------------------------*/ /* External variables --------------------------------------------------------*/
extern TIM_HandleTypeDef htim1;
extern TIM_HandleTypeDef htim4;
extern UART_HandleTypeDef huart3; extern UART_HandleTypeDef huart3;
/* USER CODE BEGIN EV */ /* USER CODE BEGIN EV */
@@ -82,7 +84,7 @@ void NMI_Handler(void)
* @brief This function handles Hard fault interrupt. * @brief This function handles Hard fault interrupt.
*/ */
void HardFault_Handler(void) void HardFault_Handler(void)
{ {
/* USER CODE BEGIN HardFault_IRQn 0 */ /* USER CODE BEGIN HardFault_IRQn 0 */
/* USER CODE END HardFault_IRQn 0 */ /* USER CODE END HardFault_IRQn 0 */
@@ -210,6 +212,48 @@ void SysTick_Handler(void)
/* please refer to the startup file (startup_stm32h7xx.s). */ /* please refer to the startup file (startup_stm32h7xx.s). */
/******************************************************************************/ /******************************************************************************/
/**
* @brief This function handles TIM1 update interrupt.
*/
void TIM1_UP_IRQHandler(void)
{
/* USER CODE BEGIN TIM1_UP_IRQn 0 */
/* USER CODE END TIM1_UP_IRQn 0 */
HAL_TIM_IRQHandler(&htim1);
/* USER CODE BEGIN TIM1_UP_IRQn 1 */
/* USER CODE END TIM1_UP_IRQn 1 */
}
/**
* @brief This function handles TIM1 capture compare interrupt.
*/
void TIM1_CC_IRQHandler(void)
{
/* USER CODE BEGIN TIM1_CC_IRQn 0 */
/* USER CODE END TIM1_CC_IRQn 0 */
HAL_TIM_IRQHandler(&htim1);
/* USER CODE BEGIN TIM1_CC_IRQn 1 */
/* USER CODE END TIM1_CC_IRQn 1 */
}
/**
* @brief This function handles TIM4 global interrupt.
*/
void TIM4_IRQHandler(void)
{
/* USER CODE BEGIN TIM4_IRQn 0 */
/* USER CODE END TIM4_IRQn 0 */
HAL_TIM_IRQHandler(&htim4);
/* USER CODE BEGIN TIM4_IRQn 1 */
/* USER CODE END TIM4_IRQn 1 */
}
/** /**
* @brief This function handles USART3 global interrupt. * @brief This function handles USART3 global interrupt.
*/ */
@@ -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="{&quot;fVersion&quot;:1,&quot;fItems&quot;:[{&quot;fDisplayName&quot;:&quot;Reset&quot;,&quot;fIsSuppressible&quot;:false,&quot;fResetAttribute&quot;:&quot;Software system reset&quot;,&quot;fResetStrategies&quot;:[{&quot;fDisplayName&quot;:&quot;Software system reset&quot;,&quot;fLaunchAttribute&quot;:&quot;system_reset&quot;,&quot;fGdbCommands&quot;:[&quot;monitor reset\n&quot;],&quot;fCmdOptions&quot;:[&quot;-g&quot;]},{&quot;fDisplayName&quot;:&quot;Hardware reset&quot;,&quot;fLaunchAttribute&quot;:&quot;hardware_reset&quot;,&quot;fGdbCommands&quot;:[&quot;monitor reset hardware\n&quot;],&quot;fCmdOptions&quot;:[&quot;-g&quot;]},{&quot;fDisplayName&quot;:&quot;Core reset&quot;,&quot;fLaunchAttribute&quot;:&quot;core_reset&quot;,&quot;fGdbCommands&quot;:[&quot;monitor reset core\n&quot;],&quot;fCmdOptions&quot;:[&quot;-g&quot;]},{&quot;fDisplayName&quot;:&quot;None&quot;,&quot;fLaunchAttribute&quot;:&quot;no_reset&quot;,&quot;fGdbCommands&quot;:[],&quot;fCmdOptions&quot;:[&quot;-g&quot;]}],&quot;fGdbCommandGroup&quot;:{&quot;name&quot;:&quot;Additional commands&quot;,&quot;commands&quot;:[]},&quot;fStartApplication&quot;:true}]}"/> <stringAttribute key="com.st.stm32cube.ide.mcu.debug.stlinkrestart_configurations" value="{&quot;fVersion&quot;:1,&quot;fItems&quot;:[{&quot;fDisplayName&quot;:&quot;Reset&quot;,&quot;fIsSuppressible&quot;:false,&quot;fResetAttribute&quot;:&quot;Software system reset&quot;,&quot;fResetStrategies&quot;:[{&quot;fDisplayName&quot;:&quot;Software system reset&quot;,&quot;fLaunchAttribute&quot;:&quot;system_reset&quot;,&quot;fGdbCommands&quot;:[&quot;monitor reset\n&quot;],&quot;fCmdOptions&quot;:[&quot;-g&quot;]},{&quot;fDisplayName&quot;:&quot;Hardware reset&quot;,&quot;fLaunchAttribute&quot;:&quot;hardware_reset&quot;,&quot;fGdbCommands&quot;:[&quot;monitor reset hardware\n&quot;],&quot;fCmdOptions&quot;:[&quot;-g&quot;]},{&quot;fDisplayName&quot;:&quot;Core reset&quot;,&quot;fLaunchAttribute&quot;:&quot;core_reset&quot;,&quot;fGdbCommands&quot;:[&quot;monitor reset core\n&quot;],&quot;fCmdOptions&quot;:[&quot;-g&quot;]},{&quot;fDisplayName&quot;:&quot;None&quot;,&quot;fLaunchAttribute&quot;:&quot;no_reset&quot;,&quot;fGdbCommands&quot;:[],&quot;fCmdOptions&quot;:[&quot;-g&quot;]}],&quot;fGdbCommandGroup&quot;:{&quot;name&quot;:&quot;Additional commands&quot;,&quot;commands&quot;:[]},&quot;fStartApplication&quot;: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"/>
+3 -2
View File
@@ -445,7 +445,7 @@ SPI1.VirtualType=VM_MASTER
SYS.userName=SYS_M7 SYS.userName=SYS_M7
TIM1.Channel-Output\ Compare1\ No\ Output=TIM_CHANNEL_1 TIM1.Channel-Output\ Compare1\ No\ Output=TIM_CHANNEL_1
TIM1.IPParameters=Channel-Output Compare1 No Output,Period,TIM_MasterOutputTrigger,TIM_MasterOutputTrigger2 TIM1.IPParameters=Channel-Output Compare1 No Output,Period,TIM_MasterOutputTrigger,TIM_MasterOutputTrigger2
TIM1.Period=8191 TIM1.Period=65535
TIM1.TIM_MasterOutputTrigger=TIM_TRGO_ENABLE TIM1.TIM_MasterOutputTrigger=TIM_TRGO_ENABLE
TIM1.TIM_MasterOutputTrigger2=TIM_TRGO2_ENABLE TIM1.TIM_MasterOutputTrigger2=TIM_TRGO2_ENABLE
TIM2.Channel-PWM\ Generation3\ CH3=TIM_CHANNEL_3 TIM2.Channel-PWM\ Generation3\ CH3=TIM_CHANNEL_3
@@ -454,7 +454,8 @@ TIM2.IPParameters=Channel-PWM Generation3 CH3,Channel-PWM Generation4 CH4,Period
TIM2.Period=9999 TIM2.Period=9999
TIM4.AutoReloadPreload=TIM_AUTORELOAD_PRELOAD_ENABLE TIM4.AutoReloadPreload=TIM_AUTORELOAD_PRELOAD_ENABLE
TIM4.Channel-PWM\ Generation4\ CH4=TIM_CHANNEL_4 TIM4.Channel-PWM\ Generation4\ CH4=TIM_CHANNEL_4
TIM4.IPParameters=Channel-PWM Generation4 CH4,Prescaler,Period,AutoReloadPreload,TIM_MasterOutputTrigger,Pulse-PWM Generation4 CH4 TIM4.IPParameters=Channel-PWM Generation4 CH4,Prescaler,Period,AutoReloadPreload,TIM_MasterOutputTrigger,Pulse-PWM Generation4 CH4,OCMode_PWM-PWM Generation4 CH4
TIM4.OCMode_PWM-PWM\ Generation4\ CH4=TIM_OCMODE_PWM2
TIM4.Period=5624 TIM4.Period=5624
TIM4.Prescaler=127 TIM4.Prescaler=127
TIM4.Pulse-PWM\ Generation4\ CH4=2812 TIM4.Pulse-PWM\ Generation4\ CH4=2812