stepper; doesnt work

This commit is contained in:
fewikay committed 2026-10-19 16:59:42 +02:00
1 parent 830bc0849a
commit 634b69a55c
7 files changed
+74 -16

No files matched your search

+3 -8
View File
@@ -195,9 +195,9 @@
<locationURI>PARENT-2-PROJECT_LOC/libs/LibSpindle/src/Spindle.c</locationURI>
</link>
<link>
<name>Core/Src/Stepper/src</name>
<type>2</type>
<locationURI>virtual:/virtual</locationURI>
<name>Core/Src/Stepper/LibL6474x.c</name>
<type>1</type>
<locationURI>PARENT-2-PROJECT_LOC/libs/LibL6474/src/LibL6474x.c</locationURI>
</link>
<link>
<name>Drivers/STM32H7xx_HAL_Driver/Inc/Legacy</name>
@@ -779,11 +779,6 @@
<type>1</type>
<locationURI>PARENT-2-PROJECT_LOC/libs/LibL6474/inc/LibL6474.h</locationURI>
</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>
<name>Drivers/STM32H7xx_HAL_Driver/Inc/Legacy/stm32_hal_legacy.h</name>
<type>1</type>
@@ -1,4 +1,5 @@
#include "Console.h"
#include <stdlib.h>
#include "Spindle.h"
#include "main.h"
#include "FreeRTOS.h"
@@ -2,6 +2,7 @@
#include "Spindle.h"
#include "main.h"
#include "FreeRTOS.h"
#include "task.h"
#include "openamp.h"
#include "LibL6474.h"
#include <stddef.h>
@@ -12,12 +13,14 @@ static void StepLibraryFree( const void* const ptr );
static int StepDriverSpiTransfer( void* pIO, char* pRX, const char* pTX, unsigned int length );
void StepDriverReset();
void StepDriverReset(void* pGPO, const int ena);
void StepLibraryDelay();
void StepLibraryDelay(unsigned int ms);
void StepTimerAsync();
//void StepTimerAsync();
void StepTimerCancelAsync();
//void StepTimerCancelAsync();
L6474_Handle_t init_stepper();
L6474_Handle_t init_stepper(void* pIO, void* pGPO, void* pPWM);
void reset_stepper();
@@ -109,6 +109,7 @@ void Error_Handler(void);
/* USER CODE END Private defines */
extern TIM_HandleTypeDef htim2;
extern SPI_HandleTypeDef hspi1;
#ifdef __cplusplus
}
@@ -1,4 +1,5 @@
#include "Stepper/stepper.h"
#include "LibL6474.h"
static void* StepLibraryMalloc( unsigned int size ){
@@ -12,14 +13,33 @@ static void StepLibraryFree( const void* const 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, pTX, pRX, 1, -1);
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));
}
L6474_Handle_t init_stepper(){
L6474_Handle_t init_stepper(void* pIO, void* pGPO, void* pPWM){
(void)pIO;
(void)pGPO;
(void)pPWM;
L6474x_Platform_t p;
p.malloc = StepLibraryMalloc;
p.free = StepLibraryFree;
@@ -28,4 +48,39 @@ L6474_Handle_t init_stepper(){
p.sleep = StepLibraryDelay;
//p.stepAsync = StepTimerAsync;
//p.cancelStep = StepTimerCancelAsync;
L6474_Handle_t s = L6474_CreateInstance(&p, pIO, pGPO, pPWM);
L6474_BaseParameter_t b;
b.stepMode = smMICRO4; // Mikroschritt 1/4
b.OcdTh = ocdth1125mA; // Überstromschwelle 1125 mA
b.TimeOnMin = 21; // µs (Datenblatt-Standard)
b.TimeOffMin = 21; // µs (Datenblatt-Standard)
b.TorqueVal = 700; // mA, bewusst unter OcdTh
b.TFast = 0x19; // Standardwert (Fast-Decay)
int result = 0;
// reset all and take all initialization steps
result |= L6474_ResetStandBy(s);
result |= L6474_Initialize(s, &b);
result |= L6474_SetPowerOutputs(s, 1);
// in case we have no error, we can enable the drivers
// and then we step a bit
if ( result == 0 )
{
result |= L6474_StepIncremental(s, 100000 );
}
else
{
// error handling
}
return s;
}
void reset_stepper(){
}
@@ -318,6 +318,9 @@ int main(void)
//Spindle
init_spindle(c, 9000, -9000, 1600);
//Stepepr
init_stepper(NULL, NULL, NULL);
// tasks
@@ -82,7 +82,7 @@ void NMI_Handler(void)
* @brief This function handles Hard fault interrupt.
*/
void HardFault_Handler(void)
{
{
/* USER CODE BEGIN HardFault_IRQn 0 */
/* USER CODE END HardFault_IRQn 0 */