mirror of
https://github.com/eddyem/stm32samples.git
synced 2026-01-31 12:25:14 +03:00
add nocheck flags
This commit is contained in:
parent
9c0152d08f
commit
3697adba41
@ -398,11 +398,11 @@ Dump motor flags' bits (for `motflagsN`) and reaction to limit switches (`eswrea
|
|||||||
|
|
||||||
Motor flags:
|
Motor flags:
|
||||||
bit0 - 0: reverse - invert motor's rotation
|
bit0 - 0: reverse - invert motor's rotation
|
||||||
bit1 - 1: [reserved]
|
bit1 - 1: nocheck - don't check driver for errors
|
||||||
bit2 - 2: [reserved]
|
bit2 - 2: [reserved]
|
||||||
bit3 - 3: donthold - clear motor's power after stop
|
bit3 - 3: donthold - clear motor's power after stop
|
||||||
bit4 - 4: eswinv - inverse end-switches (1->0 instead of 0->1)
|
bit4 - 4: eswinv - inverse end-switches (1->0 instead of 0->1)
|
||||||
bit5 - 5: [reserved]
|
bit5 - 5: nodiag - don't check DIAG output
|
||||||
bit6 - 6,7: drvtype - driver type (0 - only step/dir, 1 - UART, 2 - SPI, 3 - reserved)
|
bit6 - 6,7: drvtype - driver type (0 - only step/dir, 1 - UART, 2 - SPI, 3 - reserved)
|
||||||
End-switches reaction:
|
End-switches reaction:
|
||||||
0 - ignore both end-switches
|
0 - ignore both end-switches
|
||||||
|
|||||||
@ -89,6 +89,7 @@ errcodes cu_button(uint8_t par, int32_t *val){
|
|||||||
|
|
||||||
errcodes cu_diagn(uint8_t par, int32_t *val){
|
errcodes cu_diagn(uint8_t par, int32_t *val){
|
||||||
uint8_t n = PARBASE(par);
|
uint8_t n = PARBASE(par);
|
||||||
|
uint8_t oldstate = DIAGMULCUR();
|
||||||
#if MOTORSNO > 8
|
#if MOTORSNO > 8
|
||||||
#error "Change this code!"
|
#error "Change this code!"
|
||||||
#endif
|
#endif
|
||||||
@ -99,10 +100,12 @@ errcodes cu_diagn(uint8_t par, int32_t *val){
|
|||||||
n |= motdiagn(i);
|
n |= motdiagn(i);
|
||||||
}
|
}
|
||||||
*val = n;
|
*val = n;
|
||||||
|
DIAGMUL(oldstate);
|
||||||
return ERR_OK;
|
return ERR_OK;
|
||||||
}
|
}
|
||||||
CHECKN(n, par);
|
CHECKN(n, par);
|
||||||
*val = motdiagn(n);
|
*val = motdiagn(n);
|
||||||
|
DIAGMUL(oldstate);
|
||||||
return ERR_OK;
|
return ERR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -32,7 +32,7 @@ static const uint32_t FLASH_blocksize = (uint32_t)&_BLOCKSIZE;
|
|||||||
// max amount of Config records stored (will be recalculate in flashstorage_init()
|
// max amount of Config records stored (will be recalculate in flashstorage_init()
|
||||||
static uint32_t maxCnum = 1024 / sizeof(user_conf); // can't use blocksize here
|
static uint32_t maxCnum = 1024 / sizeof(user_conf); // can't use blocksize here
|
||||||
|
|
||||||
#define DEFMF {.donthold = 1, .drvtype = DRVTYPE_UART}
|
#define DEFMF {.donthold = 1, .nodiag = 1, .drvtype = DRVTYPE_UART}
|
||||||
|
|
||||||
#define USERCONF_INITIALIZER { \
|
#define USERCONF_INITIALIZER { \
|
||||||
.userconf_sz = sizeof(user_conf) \
|
.userconf_sz = sizeof(user_conf) \
|
||||||
|
|||||||
@ -51,11 +51,11 @@ enum{
|
|||||||
// motor flags
|
// motor flags
|
||||||
typedef struct{
|
typedef struct{
|
||||||
uint8_t reverse : 1; // bit0 - reversing motor rotation
|
uint8_t reverse : 1; // bit0 - reversing motor rotation
|
||||||
uint8_t encreverse : 1; // bit1 - reversing encoder rotation - NOT USED HERE!!!
|
uint8_t nocheck : 1; // bit1 - don't check drivers for error state
|
||||||
uint8_t haveencoder : 1; // bit2 - have encoder - NOT USED HERE!!!
|
uint8_t haveencoder : 1; // bit2 - have encoder - NOT USED HERE!!!
|
||||||
uint8_t donthold : 1; // bit3 - clear power @ stop (don't hold motor when stopped)
|
uint8_t donthold : 1; // bit3 - clear power @ stop (don't hold motor when stopped)
|
||||||
uint8_t eswinv : 1; // bit4 - inverse end-switches
|
uint8_t eswinv : 1; // bit4 - inverse end-switches
|
||||||
uint8_t keeppos : 1; // bit5 - keep current position (as servo motor) - NOT USED HERE!!!
|
uint8_t nodiag : 1; // bit5 - don't check DIAG output
|
||||||
uint8_t drvtype : 2; // bits 6,7 - driver type (0 - only step/dir, 1 - UART, 2 - SPI, 3 - reserved)
|
uint8_t drvtype : 2; // bits 6,7 - driver type (0 - only step/dir, 1 - UART, 2 - SPI, 3 - reserved)
|
||||||
} motflags_t;
|
} motflags_t;
|
||||||
|
|
||||||
|
|||||||
@ -87,6 +87,7 @@ extern const uint32_t EXTpins[EXTNO];
|
|||||||
// DIAG output of motors (PE2) & its multiplexer (PE3 - 0, PE4 - 1, PE5 - 2)
|
// DIAG output of motors (PE2) & its multiplexer (PE3 - 0, PE4 - 1, PE5 - 2)
|
||||||
#define DIAG() (GPIOE->IDR & (1<<2) ? 0 : 1)
|
#define DIAG() (GPIOE->IDR & (1<<2) ? 0 : 1)
|
||||||
#define DIAGMUL(x) do{ register uint32_t v = x&7; GPIOE->BSRR = (v | (((~v)&7)<<16))<<3; }while(0)
|
#define DIAGMUL(x) do{ register uint32_t v = x&7; GPIOE->BSRR = (v | (((~v)&7)<<16))<<3; }while(0)
|
||||||
|
#define DIAGMULCUR() ((GPIOE->ODR >> 3) & 7)
|
||||||
|
|
||||||
extern volatile TIM_TypeDef *mottimers[MOTORSNO];
|
extern volatile TIM_TypeDef *mottimers[MOTORSNO];
|
||||||
|
|
||||||
|
|||||||
Binary file not shown.
@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<!DOCTYPE QtCreatorProject>
|
<!DOCTYPE QtCreatorProject>
|
||||||
<!-- Written by QtCreator 15.0.1, 2025-02-06T16:30:11. -->
|
<!-- Written by QtCreator 18.0.1, 2026-01-16T15:01:28. -->
|
||||||
<qtcreator>
|
<qtcreator>
|
||||||
<data>
|
<data>
|
||||||
<variable>EnvironmentId</variable>
|
<variable>EnvironmentId</variable>
|
||||||
@ -13,8 +13,8 @@
|
|||||||
<data>
|
<data>
|
||||||
<variable>ProjectExplorer.Project.EditorSettings</variable>
|
<variable>ProjectExplorer.Project.EditorSettings</variable>
|
||||||
<valuemap type="QVariantMap">
|
<valuemap type="QVariantMap">
|
||||||
|
<value type="bool" key="EditorConfiguration.AutoDetect">true</value>
|
||||||
<value type="bool" key="EditorConfiguration.AutoIndent">true</value>
|
<value type="bool" key="EditorConfiguration.AutoIndent">true</value>
|
||||||
<value type="bool" key="EditorConfiguration.AutoSpacesForTabs">false</value>
|
|
||||||
<value type="bool" key="EditorConfiguration.CamelCaseNavigation">true</value>
|
<value type="bool" key="EditorConfiguration.CamelCaseNavigation">true</value>
|
||||||
<valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.0">
|
<valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.0">
|
||||||
<value type="QString" key="language">Cpp</value>
|
<value type="QString" key="language">Cpp</value>
|
||||||
@ -86,12 +86,14 @@
|
|||||||
<valuelist type="QVariantList" key="ClangTools.SuppressedDiagnostics"/>
|
<valuelist type="QVariantList" key="ClangTools.SuppressedDiagnostics"/>
|
||||||
<value type="bool" key="ClangTools.UseGlobalSettings">true</value>
|
<value type="bool" key="ClangTools.UseGlobalSettings">true</value>
|
||||||
</valuemap>
|
</valuemap>
|
||||||
|
<value type="int" key="RcSync">0</value>
|
||||||
</valuemap>
|
</valuemap>
|
||||||
</data>
|
</data>
|
||||||
<data>
|
<data>
|
||||||
<variable>ProjectExplorer.Project.Target.0</variable>
|
<variable>ProjectExplorer.Project.Target.0</variable>
|
||||||
<valuemap type="QVariantMap">
|
<valuemap type="QVariantMap">
|
||||||
<value type="QString" key="DeviceType">Desktop</value>
|
<value type="QString" key="DeviceType">Desktop</value>
|
||||||
|
<value type="bool" key="HasPerBcDcs">true</value>
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop</value>
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop</value>
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop</value>
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop</value>
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">{91347f2c-5221-46a7-80b1-0a054ca02f79}</value>
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">{91347f2c-5221-46a7-80b1-0a054ca02f79}</value>
|
||||||
@ -109,8 +111,8 @@
|
|||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">GenericProjectManager.GenericMakeStep</value>
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">GenericProjectManager.GenericMakeStep</value>
|
||||||
</valuemap>
|
</valuemap>
|
||||||
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
|
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Сборка</value>
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Сборка</value>
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Build</value>
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
|
||||||
</valuemap>
|
</valuemap>
|
||||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
|
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
|
||||||
@ -122,8 +124,8 @@
|
|||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">GenericProjectManager.GenericMakeStep</value>
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">GenericProjectManager.GenericMakeStep</value>
|
||||||
</valuemap>
|
</valuemap>
|
||||||
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
|
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Очистка</value>
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Очистка</value>
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Clean</value>
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
|
||||||
</valuemap>
|
</valuemap>
|
||||||
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
|
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
|
||||||
@ -133,13 +135,48 @@
|
|||||||
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
|
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">По умолчанию</value>
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">По умолчанию</value>
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">GenericProjectManager.GenericBuildConfiguration</value>
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">GenericProjectManager.GenericBuildConfiguration</value>
|
||||||
|
<value type="qlonglong" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
|
||||||
|
<value type="qlonglong" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
|
||||||
|
<valuemap type="QVariantMap" key="ProjectExplorer.Target.DeployConfiguration.0">
|
||||||
|
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
|
||||||
|
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">0</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deploy</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Deploy</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Deploy</value>
|
||||||
|
</valuemap>
|
||||||
|
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">1</value>
|
||||||
|
<valuemap type="QVariantMap" key="ProjectExplorer.DeployConfiguration.CustomData"/>
|
||||||
|
<value type="bool" key="ProjectExplorer.DeployConfiguration.CustomDataEnabled">false</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.DefaultDeployConfiguration</value>
|
||||||
|
</valuemap>
|
||||||
|
<value type="qlonglong" key="ProjectExplorer.Target.DeployConfigurationCount">1</value>
|
||||||
|
<valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.0">
|
||||||
|
<value type="bool" key="Analyzer.Perf.Settings.UseGlobalSettings">true</value>
|
||||||
|
<value type="bool" key="Analyzer.QmlProfiler.Settings.UseGlobalSettings">true</value>
|
||||||
|
<value type="int" key="Analyzer.Valgrind.Callgrind.CostFormat">0</value>
|
||||||
|
<value type="bool" key="Analyzer.Valgrind.Settings.UseGlobalSettings">true</value>
|
||||||
|
<value type="QList<int>" key="Analyzer.Valgrind.VisibleErrorKinds"></value>
|
||||||
|
<valuelist type="QVariantList" key="CustomOutputParsers"/>
|
||||||
|
<value type="int" key="PE.EnvironmentAspect.Base">2</value>
|
||||||
|
<valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
|
||||||
|
<value type="bool" key="PE.EnvironmentAspect.PrintOnRun">false</value>
|
||||||
|
<value type="QString" key="PerfRecordArgsId">-e cpu-cycles --call-graph dwarf,4096 -F 250</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.CustomExecutableRunConfiguration</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.RunConfiguration.BuildKey"></value>
|
||||||
|
<value type="bool" key="ProjectExplorer.RunConfiguration.Customized">false</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.RunConfiguration.UniqueId"></value>
|
||||||
|
<value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value>
|
||||||
|
<value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
|
||||||
|
</valuemap>
|
||||||
|
<value type="qlonglong" key="ProjectExplorer.Target.RunConfigurationCount">1</value>
|
||||||
</valuemap>
|
</valuemap>
|
||||||
<value type="qlonglong" key="ProjectExplorer.Target.BuildConfigurationCount">1</value>
|
<value type="qlonglong" key="ProjectExplorer.Target.BuildConfigurationCount">1</value>
|
||||||
<valuemap type="QVariantMap" key="ProjectExplorer.Target.DeployConfiguration.0">
|
<valuemap type="QVariantMap" key="ProjectExplorer.Target.DeployConfiguration.0">
|
||||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
|
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
|
||||||
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">0</value>
|
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">0</value>
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Развёртывание</value>
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deploy</value>
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Развёртывание</value>
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Deploy</value>
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Deploy</value>
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Deploy</value>
|
||||||
</valuemap>
|
</valuemap>
|
||||||
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">1</value>
|
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">1</value>
|
||||||
@ -163,6 +200,7 @@
|
|||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.CustomExecutableRunConfiguration</value>
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.CustomExecutableRunConfiguration</value>
|
||||||
<value type="QString" key="ProjectExplorer.RunConfiguration.BuildKey"></value>
|
<value type="QString" key="ProjectExplorer.RunConfiguration.BuildKey"></value>
|
||||||
<value type="bool" key="ProjectExplorer.RunConfiguration.Customized">false</value>
|
<value type="bool" key="ProjectExplorer.RunConfiguration.Customized">false</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.RunConfiguration.UniqueId"></value>
|
||||||
<value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value>
|
<value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value>
|
||||||
<value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
|
<value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
|
||||||
</valuemap>
|
</valuemap>
|
||||||
@ -173,10 +211,6 @@
|
|||||||
<variable>ProjectExplorer.Project.TargetCount</variable>
|
<variable>ProjectExplorer.Project.TargetCount</variable>
|
||||||
<value type="qlonglong">1</value>
|
<value type="qlonglong">1</value>
|
||||||
</data>
|
</data>
|
||||||
<data>
|
|
||||||
<variable>ProjectExplorer.Project.Updater.FileVersion</variable>
|
|
||||||
<value type="int">22</value>
|
|
||||||
</data>
|
|
||||||
<data>
|
<data>
|
||||||
<variable>Version</variable>
|
<variable>Version</variable>
|
||||||
<value type="int">22</value>
|
<value type="int">22</value>
|
||||||
|
|||||||
@ -407,11 +407,11 @@ int fn_reset(uint32_t _U_ hash, char _U_ *args){ // "reset" (1907803304)
|
|||||||
|
|
||||||
static const char* motfl[MOTFLAGS_AMOUNT] = {
|
static const char* motfl[MOTFLAGS_AMOUNT] = {
|
||||||
"0: reverse - invert motor's rotation",
|
"0: reverse - invert motor's rotation",
|
||||||
"1: [reserved]",
|
"1: nocheck - don't check driver for errors",
|
||||||
"2: [reserved]",
|
"2: [reserved]",
|
||||||
"3: donthold - clear motor's power after stop",
|
"3: donthold - clear motor's power after stop",
|
||||||
"4: eswinv - inverse end-switches (1->0 instead of 0->1)",
|
"4: eswinv - inverse end-switches (1->0 instead of 0->1)",
|
||||||
"5: [reserved]",
|
"5: nodiag - don't check DIAG output",
|
||||||
"6,7: drvtype - driver type (0 - only step/dir, 1 - UART, 2 - SPI, 3 - reserved)"
|
"6,7: drvtype - driver type (0 - only step/dir, 1 - UART, 2 - SPI, 3 - reserved)"
|
||||||
};
|
};
|
||||||
static const char *eswfl[ESW_AMOUNT] = {
|
static const char *eswfl[ESW_AMOUNT] = {
|
||||||
|
|||||||
@ -325,38 +325,48 @@ void addmicrostep(uint8_t i){
|
|||||||
static void chkstepper(int i){
|
static void chkstepper(int i){
|
||||||
int32_t i32;
|
int32_t i32;
|
||||||
static uint8_t stopctr[MOTORSNO] = {0}; // counters for encoders/position zeroing after stopping @ esw
|
static uint8_t stopctr[MOTORSNO] = {0}; // counters for encoders/position zeroing after stopping @ esw
|
||||||
// check DIAGN only for UART/SPI
|
char Nch = '0' + i;
|
||||||
if(the_conf.motflags[i].drvtype == DRVTYPE_UART || the_conf.motflags[i].drvtype == DRVTYPE_SPI){
|
// check driver status only for UART/SPI
|
||||||
if(motdiagn(i) && state[i] != STP_ERR){ // error occured - DIAGN is low
|
if(!the_conf.motflags[i].nocheck){
|
||||||
//DBG("Oldstate: "); USB_putbyte('0' + state[i]); newline();
|
if(state[i] != STP_ERR && (the_conf.motflags[i].drvtype == DRVTYPE_UART || the_conf.motflags[i].drvtype == DRVTYPE_SPI)){
|
||||||
/*char Nm = '0'+i;
|
if(the_conf.motflags[i].nodiag){ // check by pdn-uart
|
||||||
USB_sendstr(STR_STATE); USB_putbyte(Nm); USB_sendstr("=6\n");
|
uint32_t u32;
|
||||||
switch(the_conf.motflags[i].drvtype){
|
switch(the_conf.motflags[i].drvtype){
|
||||||
case DRVTYPE_UART:
|
case DRVTYPE_UART:
|
||||||
pdnuart_setmotno(i);
|
pdnuart_setmotno(i);
|
||||||
if(pdnuart_readreg(TMC2209Reg_GSTAT, &u32)){
|
if(pdnuart_readreg(TMC2209Reg_GSTAT, &u32)){
|
||||||
USB_sendstr("GSTAT"); USB_putbyte(Nm); USB_putbyte('=');
|
TMC2209_gstat_reg_t s;
|
||||||
USB_sendstr(u2str(u32)); newline();
|
s.value = u32;
|
||||||
}
|
if(s.drv_err || s.uv_cp){
|
||||||
if(pdnuart_readreg(TMC2209Reg_DRV_STATUS, &u32)){
|
if(pdnuart_readreg(TMC2209Reg_DRV_STATUS, &u32)){
|
||||||
USB_sendstr("DRV_STATUS"); USB_putbyte(Nm); USB_putbyte('=');
|
//TMC2209_drv_status_reg_t d;
|
||||||
USB_sendstr(u2str(u32)); newline();
|
//d.value = u32;
|
||||||
|
USB_sendstr("DRV_STATUS"); USB_putbyte(Nch);
|
||||||
|
USB_putbyte('='); USB_sendstr(u2str(u32));
|
||||||
|
newline();
|
||||||
|
}
|
||||||
|
USB_sendstr("state"); USB_putbyte(Nch);
|
||||||
|
USB_sendstr("=6\n");
|
||||||
|
emstopmotor(i);
|
||||||
|
state[i] = STP_ERR;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}*/
|
}
|
||||||
|
}else if(DIAG()){ // error occured - DIAGN is low
|
||||||
emstopmotor(i);
|
emstopmotor(i);
|
||||||
state[i] = STP_ERR;
|
state[i] = STP_ERR;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}}
|
||||||
#ifdef EBUG
|
#ifdef EBUG
|
||||||
if(stp[i]){
|
if(stp[i]){
|
||||||
stp[i] = 0;
|
stp[i] = 0;
|
||||||
// motor state could be changed outside of interrupt, so return it to relax
|
// motor state could be changed outside of interrupt, so return it to relax
|
||||||
state[i] = STP_RELAX;
|
state[i] = STP_RELAX;
|
||||||
USB_sendstr("MOTOR"); USB_putbyte('0'+i); USB_sendstr(" stop @"); printi(stppos[i]);
|
USB_sendstr("MOTOR"); USB_putbyte(Nch); USB_sendstr(" stop @"); printi(stppos[i]);
|
||||||
USB_sendstr(", V="); printu(curspeed[i]);
|
USB_sendstr(", V="); printu(curspeed[i]);
|
||||||
USB_sendstr(", curstate="); printu(state[i]); newline();
|
USB_sendstr(", curstate="); printu(state[i]); newline();
|
||||||
}
|
}
|
||||||
@ -368,7 +378,7 @@ static void chkstepper(int i){
|
|||||||
curspeed[i] = the_conf.maxspd[i];
|
curspeed[i] = the_conf.maxspd[i];
|
||||||
state[i] = STP_MOVE;
|
state[i] = STP_MOVE;
|
||||||
#ifdef EBUG
|
#ifdef EBUG
|
||||||
USB_sendstr("MOTOR"); USB_putbyte('0'+i);
|
USB_sendstr("MOTOR"); USB_putbyte(Nch);
|
||||||
USB_sendstr(" -> MOVE@"); printi(stppos[i]); USB_sendstr(", V="); printu(curspeed[i]); newline();
|
USB_sendstr(" -> MOVE@"); printi(stppos[i]); USB_sendstr(", V="); printu(curspeed[i]); newline();
|
||||||
#endif
|
#endif
|
||||||
}else{ // increase speed
|
}else{ // increase speed
|
||||||
@ -407,7 +417,7 @@ static void chkstepper(int i){
|
|||||||
curspeed[i] = the_conf.minspd[i];
|
curspeed[i] = the_conf.minspd[i];
|
||||||
state[i] = STP_MVSLOW;
|
state[i] = STP_MVSLOW;
|
||||||
#ifdef EBUG
|
#ifdef EBUG
|
||||||
USB_sendstr("MOTOR"); USB_putbyte('0'+i);
|
USB_sendstr("MOTOR"); USB_putbyte(Nch);
|
||||||
USB_sendstr(" -> MVSLOW@"); printi(stppos[i]); newline();
|
USB_sendstr(" -> MVSLOW@"); printi(stppos[i]); newline();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@ -420,7 +430,7 @@ static void chkstepper(int i){
|
|||||||
case M0FAST:
|
case M0FAST:
|
||||||
if(state[i] == STP_RELAX || state[i] == STP_STALL){ // stopped -> move to +
|
if(state[i] == STP_RELAX || state[i] == STP_STALL){ // stopped -> move to +
|
||||||
#ifdef EBUG
|
#ifdef EBUG
|
||||||
USB_putbyte('M'); USB_putbyte('0'+i); USB_sendstr("FAST: motor stopped\n");
|
USB_putbyte('M'); USB_putbyte(Nch); USB_sendstr("FAST: motor stopped\n");
|
||||||
#endif
|
#endif
|
||||||
if(ERR_OK != motor_relslow(i, 1000)){
|
if(ERR_OK != motor_relslow(i, 1000)){
|
||||||
#ifdef EBUG
|
#ifdef EBUG
|
||||||
@ -443,7 +453,7 @@ static void chkstepper(int i){
|
|||||||
}
|
}
|
||||||
if((state[i] == STP_RELAX || state[i] == STP_STALL) && ++stopctr[i] > 5){ // wait at least 50ms
|
if((state[i] == STP_RELAX || state[i] == STP_STALL) && ++stopctr[i] > 5){ // wait at least 50ms
|
||||||
#ifdef EBUG
|
#ifdef EBUG
|
||||||
USB_putbyte('M'); USB_putbyte('0'+i); USND("SLOW: motor stopped");
|
USB_putbyte('M'); USB_putbyte(Nch); USND("SLOW: motor stopped");
|
||||||
#endif
|
#endif
|
||||||
ESW_reaction[i] = the_conf.ESW_reaction[i];
|
ESW_reaction[i] = the_conf.ESW_reaction[i];
|
||||||
prevstppos[i] = targstppos[i] = stppos[i] = 0;
|
prevstppos[i] = targstppos[i] = stppos[i] = 0;
|
||||||
@ -489,15 +499,20 @@ void stopmotor(uint8_t i){
|
|||||||
TODECEL();
|
TODECEL();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// process only one stepper per run
|
||||||
void process_steppers(){
|
void process_steppers(){
|
||||||
static uint32_t Tlast = 0;
|
static uint32_t Tlast = 0;
|
||||||
if(Tms - Tlast < MOTCHKINTERVAL) return; // hit every 10ms
|
if(Tms - Tlast < MOTCHKINTERVAL / MOTORSNO) return; // hit every ~10ms for full circle
|
||||||
Tlast = Tms;
|
Tlast = Tms;
|
||||||
static int firstrun = 1;
|
static int firstrun = 1;
|
||||||
if(firstrun){ firstrun = 0; init_steppers(); return; }
|
if(firstrun){ firstrun = 0; init_steppers(); DIAGMUL(0); return; }
|
||||||
for(int i = 0; i < MOTORSNO; ++i){
|
static int curmotno = 0;
|
||||||
|
chkstepper(curmotno++);
|
||||||
|
if(curmotno == MOTORSNO) curmotno = 0;
|
||||||
|
DIAGMUL(curmotno);
|
||||||
|
/*for(int i = 0; i < MOTORSNO; ++i){
|
||||||
chkstepper(i);
|
chkstepper(i);
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t geteswreact(uint8_t i){
|
uint8_t geteswreact(uint8_t i){
|
||||||
|
|||||||
@ -1,2 +1,2 @@
|
|||||||
#define BUILD_NUMBER "202"
|
#define BUILD_NUMBER "205"
|
||||||
#define BUILD_DATE "2025-04-16"
|
#define BUILD_DATE "2026-01-16"
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user