mirror of
https://github.com/eddyem/stm32samples.git
synced 2025-12-06 10:45:11 +03:00
add some features to 3steppersLB
This commit is contained in:
parent
f880421d9e
commit
ab5f7bc87b
@ -188,6 +188,7 @@ static errcodes ustepsparser(uint8_t par, int32_t *val){
|
|||||||
if(m != 1<<MSB(m)) return ERR_BADVAL;
|
if(m != 1<<MSB(m)) return ERR_BADVAL;
|
||||||
if(the_conf.maxspd[n] * m > PCLK/(MOTORTIM_PSC+1)/(MOTORTIM_ARRMIN+1)) return ERR_BADVAL;
|
if(the_conf.maxspd[n] * m > PCLK/(MOTORTIM_PSC+1)/(MOTORTIM_ARRMIN+1)) return ERR_BADVAL;
|
||||||
the_conf.microsteps[n] = m;
|
the_conf.microsteps[n] = m;
|
||||||
|
update_stepper(n);
|
||||||
}
|
}
|
||||||
*val = the_conf.microsteps[n];
|
*val = the_conf.microsteps[n];
|
||||||
return ERR_OK;
|
return ERR_OK;
|
||||||
@ -218,6 +219,7 @@ static errcodes accparser(uint8_t par, int32_t *val){
|
|||||||
if(ISSETTER(par)){
|
if(ISSETTER(par)){
|
||||||
if(*val/the_conf.microsteps[n] > ACCELMAXSTEPS || *val < 1) return ERR_BADVAL;
|
if(*val/the_conf.microsteps[n] > ACCELMAXSTEPS || *val < 1) return ERR_BADVAL;
|
||||||
the_conf.accel[n] = *val;
|
the_conf.accel[n] = *val;
|
||||||
|
update_stepper(n);
|
||||||
}
|
}
|
||||||
*val = the_conf.accel[n];
|
*val = the_conf.accel[n];
|
||||||
return ERR_OK;
|
return ERR_OK;
|
||||||
@ -238,6 +240,7 @@ static errcodes maxspdparser(uint8_t par, int32_t *val){
|
|||||||
if(ISSETTER(par)){
|
if(ISSETTER(par)){
|
||||||
if(*val <= the_conf.minspd[n]) return ERR_BADVAL;
|
if(*val <= the_conf.minspd[n]) return ERR_BADVAL;
|
||||||
the_conf.maxspd[n] = getSPD(n, *val);
|
the_conf.maxspd[n] = getSPD(n, *val);
|
||||||
|
update_stepper(n);
|
||||||
}
|
}
|
||||||
*val = the_conf.maxspd[n];
|
*val = the_conf.maxspd[n];
|
||||||
return ERR_OK;
|
return ERR_OK;
|
||||||
@ -248,6 +251,7 @@ static errcodes minspdparser(uint8_t par, int32_t *val){
|
|||||||
if(ISSETTER(par)){
|
if(ISSETTER(par)){
|
||||||
if(*val >= the_conf.maxspd[n]) return ERR_BADVAL;
|
if(*val >= the_conf.maxspd[n]) return ERR_BADVAL;
|
||||||
the_conf.minspd[n] = getSPD(n, *val);
|
the_conf.minspd[n] = getSPD(n, *val);
|
||||||
|
update_stepper(n);
|
||||||
}
|
}
|
||||||
*val = the_conf.minspd[n];
|
*val = the_conf.minspd[n];
|
||||||
return ERR_OK;
|
return ERR_OK;
|
||||||
@ -274,7 +278,7 @@ static errcodes encrevparser(uint8_t par, int32_t *val){
|
|||||||
if(ISSETTER(par)){
|
if(ISSETTER(par)){
|
||||||
if(*val < 1 || *val > MAXENCREV) return ERR_BADVAL;
|
if(*val < 1 || *val > MAXENCREV) return ERR_BADVAL;
|
||||||
the_conf.encrev[n] = *val;
|
the_conf.encrev[n] = *val;
|
||||||
enctimers[n]->ARR = *val;
|
update_stepper(n);
|
||||||
}
|
}
|
||||||
*val = the_conf.encrev[n];
|
*val = the_conf.encrev[n];
|
||||||
return ERR_OK;
|
return ERR_OK;
|
||||||
@ -284,6 +288,7 @@ static errcodes motflagsparser(uint8_t par, int32_t *val){
|
|||||||
uint8_t n; CHECKN(n, par);
|
uint8_t n; CHECKN(n, par);
|
||||||
if(ISSETTER(par)){
|
if(ISSETTER(par)){
|
||||||
the_conf.motflags[n] = *((motflags_t*)val);
|
the_conf.motflags[n] = *((motflags_t*)val);
|
||||||
|
update_stepper(n);
|
||||||
}
|
}
|
||||||
*(motflags_t*)val = the_conf.motflags[n];
|
*(motflags_t*)val = the_conf.motflags[n];
|
||||||
return ERR_OK;
|
return ERR_OK;
|
||||||
@ -295,6 +300,7 @@ static errcodes eswreactparser(uint8_t par, int32_t *val){
|
|||||||
if(ISSETTER(par)){
|
if(ISSETTER(par)){
|
||||||
if(*val < 0 || *val > ESW_AMOUNT-1) return ERR_BADVAL;
|
if(*val < 0 || *val > ESW_AMOUNT-1) return ERR_BADVAL;
|
||||||
the_conf.ESW_reaction[n] = *val;
|
the_conf.ESW_reaction[n] = *val;
|
||||||
|
update_stepper(n);
|
||||||
}
|
}
|
||||||
// *val = the_conf.ESW_reaction[n];
|
// *val = the_conf.ESW_reaction[n];
|
||||||
*val = geteswreact(n);
|
*val = geteswreact(n);
|
||||||
|
|||||||
@ -123,10 +123,7 @@ static int write2flash(const void *start, const void *wrdata, uint32_t stor_size
|
|||||||
FLASH->KEYR = FLASH_KEY1;
|
FLASH->KEYR = FLASH_KEY1;
|
||||||
FLASH->KEYR = FLASH_KEY2;
|
FLASH->KEYR = FLASH_KEY2;
|
||||||
}
|
}
|
||||||
while (FLASH->SR & FLASH_SR_BSY);
|
while (FLASH->SR & FLASH_SR_BSY) IWDG->KR = IWDG_REFRESH;
|
||||||
if(FLASH->SR & FLASH_SR_WRPRTERR){
|
|
||||||
return 1; // write protection
|
|
||||||
}
|
|
||||||
FLASH->SR = FLASH_SR_EOP | FLASH_SR_PGERR | FLASH_SR_WRPRTERR; // clear all flags
|
FLASH->SR = FLASH_SR_EOP | FLASH_SR_PGERR | FLASH_SR_WRPRTERR; // clear all flags
|
||||||
FLASH->CR |= FLASH_CR_PG;
|
FLASH->CR |= FLASH_CR_PG;
|
||||||
const uint16_t *data = (const uint16_t*) wrdata;
|
const uint16_t *data = (const uint16_t*) wrdata;
|
||||||
@ -135,14 +132,14 @@ static int write2flash(const void *start, const void *wrdata, uint32_t stor_size
|
|||||||
for (i = 0; i < count; ++i){
|
for (i = 0; i < count; ++i){
|
||||||
IWDG->KR = IWDG_REFRESH;
|
IWDG->KR = IWDG_REFRESH;
|
||||||
*(volatile uint16_t*)(address + i) = data[i];
|
*(volatile uint16_t*)(address + i) = data[i];
|
||||||
while (FLASH->SR & FLASH_SR_BSY);
|
while (FLASH->SR & FLASH_SR_BSY) IWDG->KR = IWDG_REFRESH;
|
||||||
if(FLASH->SR & FLASH_SR_PGERR){
|
if(FLASH->SR & FLASH_SR_PGERR){
|
||||||
|
SEND("Prog err\n");
|
||||||
ret = 1; // program error - meet not 0xffff
|
ret = 1; // program error - meet not 0xffff
|
||||||
break;
|
break;
|
||||||
}else while (!(FLASH->SR & FLASH_SR_EOP));
|
}
|
||||||
FLASH->SR = FLASH_SR_EOP | FLASH_SR_PGERR | FLASH_SR_WRPRTERR;
|
FLASH->SR = FLASH_SR_EOP | FLASH_SR_PGERR | FLASH_SR_WRPRTERR;
|
||||||
}
|
}
|
||||||
FLASH->CR |= FLASH_CR_LOCK; // lock it back
|
|
||||||
FLASH->CR &= ~(FLASH_CR_PG);
|
FLASH->CR &= ~(FLASH_CR_PG);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -166,39 +163,26 @@ static int erase_flash(const void *start, const void *end){
|
|||||||
}
|
}
|
||||||
nblocks = flsz / blocksize;
|
nblocks = flsz / blocksize;
|
||||||
if(nblocks == 0 || nblocks >= FLASH_SIZE) return 1;
|
if(nblocks == 0 || nblocks >= FLASH_SIZE) return 1;
|
||||||
|
if((FLASH->CR & FLASH_CR_LOCK) != 0){
|
||||||
|
FLASH->KEYR = FLASH_KEY1;
|
||||||
|
FLASH->KEYR = FLASH_KEY2;
|
||||||
|
}
|
||||||
|
while(FLASH->SR & FLASH_SR_BSY) IWDG->KR = IWDG_REFRESH;
|
||||||
|
FLASH->SR = FLASH_SR_EOP | FLASH_SR_PGERR | FLASH_SR_WRPRTERR;
|
||||||
|
FLASH->CR |= FLASH_CR_PER;
|
||||||
for(uint32_t i = 0; i < nblocks; ++i){
|
for(uint32_t i = 0; i < nblocks; ++i){
|
||||||
IWDG->KR = IWDG_REFRESH;
|
SEND("Erase block #"); printu(i); newline();
|
||||||
/* (1) Wait till no operation is on going */
|
FLASH->AR = (uint32_t)Flash_Data + i * blocksize;
|
||||||
/* (2) Clear error & EOP bits */
|
FLASH->CR |= FLASH_CR_STRT;
|
||||||
/* (3) Check that the Flash is unlocked */
|
while(FLASH->SR & FLASH_SR_BSY) IWDG->KR = IWDG_REFRESH;
|
||||||
/* (4) Perform unlock sequence */
|
FLASH->SR |= FLASH_SR_EOP;
|
||||||
while ((FLASH->SR & FLASH_SR_BSY) != 0){} /* (1) */
|
if(FLASH->SR & FLASH_SR_WRPRTERR){
|
||||||
FLASH->SR = FLASH_SR_EOP | FLASH_SR_PGERR | FLASH_SR_WRPRTERR; /* (2) */
|
|
||||||
/* if (FLASH->SR & FLASH_SR_EOP){
|
|
||||||
FLASH->SR |= FLASH_SR_EOP;
|
|
||||||
}*/
|
|
||||||
if ((FLASH->CR & FLASH_CR_LOCK) != 0){ /* (3) */
|
|
||||||
FLASH->KEYR = FLASH_KEY1; /* (4) */
|
|
||||||
FLASH->KEYR = FLASH_KEY2;
|
|
||||||
}
|
|
||||||
/* (1) Set the PER bit in the FLASH_CR register to enable page erasing */
|
|
||||||
/* (2) Program the FLASH_AR register to select a page to erase */
|
|
||||||
/* (3) Set the STRT bit in the FLASH_CR register to start the erasing */
|
|
||||||
/* (4) Wait until the EOP flag in the FLASH_SR register set */
|
|
||||||
/* (5) Clear EOP flag by software by writing EOP at 1 */
|
|
||||||
/* (6) Reset the PER Bit to disable the page erase */
|
|
||||||
FLASH->CR |= FLASH_CR_PER; /* (1) */
|
|
||||||
FLASH->AR = (uint32_t)Flash_Data + i*blocksize; /* (2) */
|
|
||||||
FLASH->CR |= FLASH_CR_STRT; /* (3) */
|
|
||||||
while(!(FLASH->SR & FLASH_SR_EOP));
|
|
||||||
FLASH->SR |= FLASH_SR_EOP; /* (5)*/
|
|
||||||
if(FLASH->SR & FLASH_SR_WRPRTERR){ /* Check Write protection error */
|
|
||||||
ret = 1;
|
ret = 1;
|
||||||
FLASH->SR |= FLASH_SR_WRPRTERR; /* Clear the flag by software by writing it at 1*/
|
FLASH->SR |= FLASH_SR_WRPRTERR;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
FLASH->CR &= ~FLASH_CR_PER; /* (6) */
|
|
||||||
}
|
}
|
||||||
|
FLASH->CR &= ~FLASH_CR_PER;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -24,7 +24,7 @@
|
|||||||
// Buttons: PA10, PA13, PA14, PA15, pullup (0 active)
|
// Buttons: PA10, PA13, PA14, PA15, pullup (0 active)
|
||||||
volatile GPIO_TypeDef *BTNports[BTNSNO] = {GPIOA, GPIOA, GPIOA, GPIOA};
|
volatile GPIO_TypeDef *BTNports[BTNSNO] = {GPIOA, GPIOA, GPIOA, GPIOA};
|
||||||
const uint32_t BTNpins[BTNSNO] = {1<<10, 1<<13, 1<<14, 1<<15};
|
const uint32_t BTNpins[BTNSNO] = {1<<10, 1<<13, 1<<14, 1<<15};
|
||||||
// Limit switches: PC13, PC14, PC15, pulldown (0 active)
|
// Limit switches: PC13, PC14, PC15, pullup (0 active)
|
||||||
volatile GPIO_TypeDef *ESWports[ESWNO] = {GPIOC, GPIOC, GPIOC};
|
volatile GPIO_TypeDef *ESWports[ESWNO] = {GPIOC, GPIOC, GPIOC};
|
||||||
const uint32_t ESWpins[ESWNO] = {1<<13, 1<<14, 1<<15};
|
const uint32_t ESWpins[ESWNO] = {1<<13, 1<<14, 1<<15};
|
||||||
// external GPIO
|
// external GPIO
|
||||||
@ -55,7 +55,7 @@ void gpio_setup(void){
|
|||||||
GPIO_MODER_MODER10_O | GPIO_MODER_MODER11_O | GPIO_MODER_MODER12_O | GPIO_MODER_MODER13_O |
|
GPIO_MODER_MODER10_O | GPIO_MODER_MODER11_O | GPIO_MODER_MODER12_O | GPIO_MODER_MODER13_O |
|
||||||
GPIO_MODER_MODER14_O | GPIO_MODER_MODER15_O ;
|
GPIO_MODER_MODER14_O | GPIO_MODER_MODER15_O ;
|
||||||
GPIOB->AFR[0] = (1 << (4*4)) | (1 << (5*4)) | (1 << (6*4)) | (1 << (7*4));
|
GPIOB->AFR[0] = (1 << (4*4)) | (1 << (5*4)) | (1 << (6*4)) | (1 << (7*4));
|
||||||
GPIOC->PUPDR = GPIO_PUPDR13_PD | GPIO_PUPDR14_PD | GPIO_PUPDR15_PD;
|
GPIOC->PUPDR = GPIO_PUPDR13_PU | GPIO_PUPDR14_PU | GPIO_PUPDR15_PU;
|
||||||
GPIOF->MODER = GPIO_MODER_MODER0_O;
|
GPIOF->MODER = GPIO_MODER_MODER0_O;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -22,6 +22,14 @@
|
|||||||
|
|
||||||
#include <stm32f0.h>
|
#include <stm32f0.h>
|
||||||
|
|
||||||
|
#ifndef FALSE
|
||||||
|
#define FALSE (0)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef TRUE
|
||||||
|
#define TRUE (1)
|
||||||
|
#endif
|
||||||
|
|
||||||
// PCLK frequency
|
// PCLK frequency
|
||||||
#ifndef PCLK
|
#ifndef PCLK
|
||||||
#define PCLK (48000000)
|
#define PCLK (48000000)
|
||||||
|
|||||||
@ -25,7 +25,6 @@
|
|||||||
#include "steppers.h"
|
#include "steppers.h"
|
||||||
#include "strfunct.h"
|
#include "strfunct.h"
|
||||||
#include "usb.h"
|
#include "usb.h"
|
||||||
#include "usb_lib.h"
|
|
||||||
|
|
||||||
volatile uint32_t Tms = 0;
|
volatile uint32_t Tms = 0;
|
||||||
|
|
||||||
|
|||||||
Binary file not shown.
@ -92,6 +92,16 @@ TRUE_INLINE void recalcARR(int i){
|
|||||||
curspeed[i] = (((PCLK/(MOTORTIM_PSC+1)) / (ARR+1)) >> ustepsshift[i]); // recalculate speed due to new val
|
curspeed[i] = (((PCLK/(MOTORTIM_PSC+1)) / (ARR+1)) >> ustepsshift[i]); // recalculate speed due to new val
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// update stepper's settings
|
||||||
|
void update_stepper(uint8_t i){
|
||||||
|
if(i >= MOTORSNO) return;
|
||||||
|
accdecsteps[i] = (the_conf.maxspd[i] * the_conf.maxspd[i]) / the_conf.accel[i] / 2;
|
||||||
|
ustepsshift[i] = MSB(the_conf.microsteps[i]);
|
||||||
|
encperstep[i] = the_conf.encrev[i] / STEPSPERREV;
|
||||||
|
enctimers[i]->ARR = the_conf.encrev[i];
|
||||||
|
ESW_reaction[i] = the_conf.ESW_reaction[i];
|
||||||
|
}
|
||||||
|
|
||||||
// run this function after each steppers parameters changing
|
// run this function after each steppers parameters changing
|
||||||
void init_steppers(){
|
void init_steppers(){
|
||||||
timers_setup(); // reinit timers & stop them
|
timers_setup(); // reinit timers & stop them
|
||||||
@ -101,13 +111,10 @@ void init_steppers(){
|
|||||||
stopflag[i] = 0;
|
stopflag[i] = 0;
|
||||||
motdir[i] = 0;
|
motdir[i] = 0;
|
||||||
curspeed[i] = 0;
|
curspeed[i] = 0;
|
||||||
accdecsteps[i] = (the_conf.maxspd[i] * the_conf.maxspd[i]) / the_conf.accel[i] / 2;
|
|
||||||
state[i] = STP_RELAX;
|
state[i] = STP_RELAX;
|
||||||
ustepsshift[i] = MSB(the_conf.microsteps[i]);
|
|
||||||
encperstep[i] = the_conf.encrev[i] / STEPSPERREV;
|
|
||||||
if(!the_conf.motflags[i].donthold) MOTOR_EN(i);
|
if(!the_conf.motflags[i].donthold) MOTOR_EN(i);
|
||||||
else MOTOR_DIS(i);
|
else MOTOR_DIS(i);
|
||||||
ESW_reaction[i] = the_conf.ESW_reaction[i];
|
update_stepper(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
1
F0:F030,F042,F072/3steppersLB/steppers.cflags
Normal file
1
F0:F030,F042,F072/3steppersLB/steppers.cflags
Normal file
@ -0,0 +1 @@
|
|||||||
|
-std=c17
|
||||||
5
F0:F030,F042,F072/3steppersLB/steppers.config
Normal file
5
F0:F030,F042,F072/3steppersLB/steppers.config
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
// Add predefined macros for your project here. For example:
|
||||||
|
// #define THE_ANSWER 42
|
||||||
|
#define EBUG
|
||||||
|
#define STM32F0
|
||||||
|
#define STM32F072xB
|
||||||
1
F0:F030,F042,F072/3steppersLB/steppers.creator
Normal file
1
F0:F030,F042,F072/3steppersLB/steppers.creator
Normal file
@ -0,0 +1 @@
|
|||||||
|
[General]
|
||||||
160
F0:F030,F042,F072/3steppersLB/steppers.creator.user
Normal file
160
F0:F030,F042,F072/3steppersLB/steppers.creator.user
Normal file
@ -0,0 +1,160 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE QtCreatorProject>
|
||||||
|
<!-- Written by QtCreator 6.0.0, 2022-10-28T17:08:49. -->
|
||||||
|
<qtcreator>
|
||||||
|
<data>
|
||||||
|
<variable>EnvironmentId</variable>
|
||||||
|
<value type="QByteArray">{cf63021e-ef53-49b0-b03b-2f2570cdf3b6}</value>
|
||||||
|
</data>
|
||||||
|
<data>
|
||||||
|
<variable>ProjectExplorer.Project.ActiveTarget</variable>
|
||||||
|
<value type="int">0</value>
|
||||||
|
</data>
|
||||||
|
<data>
|
||||||
|
<variable>ProjectExplorer.Project.EditorSettings</variable>
|
||||||
|
<valuemap type="QVariantMap">
|
||||||
|
<value type="bool" key="EditorConfiguration.AutoIndent">true</value>
|
||||||
|
<value type="bool" key="EditorConfiguration.AutoSpacesForTabs">false</value>
|
||||||
|
<value type="bool" key="EditorConfiguration.CamelCaseNavigation">true</value>
|
||||||
|
<valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.0">
|
||||||
|
<value type="QString" key="language">Cpp</value>
|
||||||
|
<valuemap type="QVariantMap" key="value">
|
||||||
|
<value type="QByteArray" key="CurrentPreferences">CppGlobal</value>
|
||||||
|
</valuemap>
|
||||||
|
</valuemap>
|
||||||
|
<valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.1">
|
||||||
|
<value type="QString" key="language">QmlJS</value>
|
||||||
|
<valuemap type="QVariantMap" key="value">
|
||||||
|
<value type="QByteArray" key="CurrentPreferences">QmlJSGlobal</value>
|
||||||
|
</valuemap>
|
||||||
|
</valuemap>
|
||||||
|
<value type="int" key="EditorConfiguration.CodeStyle.Count">2</value>
|
||||||
|
<value type="QByteArray" key="EditorConfiguration.Codec">KOI8-R</value>
|
||||||
|
<value type="bool" key="EditorConfiguration.ConstrainTooltips">false</value>
|
||||||
|
<value type="int" key="EditorConfiguration.IndentSize">4</value>
|
||||||
|
<value type="bool" key="EditorConfiguration.KeyboardTooltips">false</value>
|
||||||
|
<value type="int" key="EditorConfiguration.MarginColumn">80</value>
|
||||||
|
<value type="bool" key="EditorConfiguration.MouseHiding">true</value>
|
||||||
|
<value type="bool" key="EditorConfiguration.MouseNavigation">true</value>
|
||||||
|
<value type="int" key="EditorConfiguration.PaddingMode">1</value>
|
||||||
|
<value type="bool" key="EditorConfiguration.PreferSingleLineComments">false</value>
|
||||||
|
<value type="bool" key="EditorConfiguration.ScrollWheelZooming">false</value>
|
||||||
|
<value type="bool" key="EditorConfiguration.ShowMargin">false</value>
|
||||||
|
<value type="int" key="EditorConfiguration.SmartBackspaceBehavior">1</value>
|
||||||
|
<value type="bool" key="EditorConfiguration.SmartSelectionChanging">true</value>
|
||||||
|
<value type="bool" key="EditorConfiguration.SpacesForTabs">true</value>
|
||||||
|
<value type="int" key="EditorConfiguration.TabKeyBehavior">0</value>
|
||||||
|
<value type="int" key="EditorConfiguration.TabSize">8</value>
|
||||||
|
<value type="bool" key="EditorConfiguration.UseGlobal">true</value>
|
||||||
|
<value type="bool" key="EditorConfiguration.UseIndenter">false</value>
|
||||||
|
<value type="int" key="EditorConfiguration.Utf8BomBehavior">2</value>
|
||||||
|
<value type="bool" key="EditorConfiguration.addFinalNewLine">true</value>
|
||||||
|
<value type="bool" key="EditorConfiguration.cleanIndentation">true</value>
|
||||||
|
<value type="bool" key="EditorConfiguration.cleanWhitespace">true</value>
|
||||||
|
<value type="QString" key="EditorConfiguration.ignoreFileTypes">*.md, *.MD, Makefile</value>
|
||||||
|
<value type="bool" key="EditorConfiguration.inEntireDocument">true</value>
|
||||||
|
<value type="bool" key="EditorConfiguration.skipTrailingWhitespace">true</value>
|
||||||
|
</valuemap>
|
||||||
|
</data>
|
||||||
|
<data>
|
||||||
|
<variable>ProjectExplorer.Project.PluginSettings</variable>
|
||||||
|
<valuemap type="QVariantMap">
|
||||||
|
<valuemap type="QVariantMap" key="ClangTools">
|
||||||
|
<value type="bool" key="ClangTools.AnalyzeOpenFiles">true</value>
|
||||||
|
<value type="bool" key="ClangTools.BuildBeforeAnalysis">true</value>
|
||||||
|
<value type="QString" key="ClangTools.DiagnosticConfig">Builtin.DefaultTidyAndClazy</value>
|
||||||
|
<value type="int" key="ClangTools.ParallelJobs">4</value>
|
||||||
|
<valuelist type="QVariantList" key="ClangTools.SelectedDirs"/>
|
||||||
|
<valuelist type="QVariantList" key="ClangTools.SelectedFiles"/>
|
||||||
|
<valuelist type="QVariantList" key="ClangTools.SuppressedDiagnostics"/>
|
||||||
|
<value type="bool" key="ClangTools.UseGlobalSettings">true</value>
|
||||||
|
</valuemap>
|
||||||
|
</valuemap>
|
||||||
|
</data>
|
||||||
|
<data>
|
||||||
|
<variable>ProjectExplorer.Project.Target.0</variable>
|
||||||
|
<valuemap type="QVariantMap">
|
||||||
|
<value type="QString" key="DeviceType">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.Id">{91347f2c-5221-46a7-80b1-0a054ca02f79}</value>
|
||||||
|
<value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value>
|
||||||
|
<value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
|
||||||
|
<value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
|
||||||
|
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
|
||||||
|
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/home/eddy/Docs/SAO/ELECTRONICS/STM32/F0-srcs/usbcan_ringbuffer</value>
|
||||||
|
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
|
||||||
|
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
|
||||||
|
<valuelist type="QVariantList" key="GenericProjectManager.GenericMakeStep.BuildTargets">
|
||||||
|
<value type="QString">all</value>
|
||||||
|
</valuelist>
|
||||||
|
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">GenericProjectManager.GenericMakeStep</value>
|
||||||
|
</valuemap>
|
||||||
|
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Сборка</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Сборка</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
|
||||||
|
</valuemap>
|
||||||
|
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
|
||||||
|
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
|
||||||
|
<valuelist type="QVariantList" key="GenericProjectManager.GenericMakeStep.BuildTargets">
|
||||||
|
<value type="QString">clean</value>
|
||||||
|
</valuelist>
|
||||||
|
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">GenericProjectManager.GenericMakeStep</value>
|
||||||
|
</valuemap>
|
||||||
|
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Очистка</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Очистка</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
|
||||||
|
</valuemap>
|
||||||
|
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
|
||||||
|
<value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
|
||||||
|
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.CustomParsers"/>
|
||||||
|
<value type="bool" key="ProjectExplorer.BuildConfiguration.ParseStandardOutput">false</value>
|
||||||
|
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">По умолчанию</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">GenericProjectManager.GenericBuildConfiguration</value>
|
||||||
|
</valuemap>
|
||||||
|
<value type="int" key="ProjectExplorer.Target.BuildConfigurationCount">1</value>
|
||||||
|
<valuemap type="QVariantMap" key="ProjectExplorer.Target.DeployConfiguration.0">
|
||||||
|
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
|
||||||
|
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">0</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Развёртывание</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Развёртывание</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="int" key="ProjectExplorer.Target.DeployConfigurationCount">1</value>
|
||||||
|
<valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.0">
|
||||||
|
<valuelist type="QVariantList" key="CustomOutputParsers"/>
|
||||||
|
<value type="int" key="PE.EnvironmentAspect.Base">2</value>
|
||||||
|
<valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.CustomExecutableRunConfiguration</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.RunConfiguration.BuildKey"></value>
|
||||||
|
<value type="bool" key="RunConfiguration.UseCppDebugger">false</value>
|
||||||
|
<value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value>
|
||||||
|
<value type="bool" key="RunConfiguration.UseQmlDebugger">false</value>
|
||||||
|
<value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
|
||||||
|
</valuemap>
|
||||||
|
<value type="int" key="ProjectExplorer.Target.RunConfigurationCount">1</value>
|
||||||
|
</valuemap>
|
||||||
|
</data>
|
||||||
|
<data>
|
||||||
|
<variable>ProjectExplorer.Project.TargetCount</variable>
|
||||||
|
<value type="int">1</value>
|
||||||
|
</data>
|
||||||
|
<data>
|
||||||
|
<variable>ProjectExplorer.Project.Updater.FileVersion</variable>
|
||||||
|
<value type="int">22</value>
|
||||||
|
</data>
|
||||||
|
<data>
|
||||||
|
<variable>Version</variable>
|
||||||
|
<value type="int">22</value>
|
||||||
|
</data>
|
||||||
|
</qtcreator>
|
||||||
1
F0:F030,F042,F072/3steppersLB/steppers.cxxflags
Normal file
1
F0:F030,F042,F072/3steppersLB/steppers.cxxflags
Normal file
@ -0,0 +1 @@
|
|||||||
|
-std=c++17
|
||||||
24
F0:F030,F042,F072/3steppersLB/steppers.files
Normal file
24
F0:F030,F042,F072/3steppersLB/steppers.files
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
adc.c
|
||||||
|
adc.h
|
||||||
|
buttons.c
|
||||||
|
buttons.h
|
||||||
|
can.c
|
||||||
|
can.h
|
||||||
|
commonproto.c
|
||||||
|
commonproto.h
|
||||||
|
custom_buttons.c
|
||||||
|
custom_buttons.h
|
||||||
|
flash.c
|
||||||
|
flash.h
|
||||||
|
hardware.c
|
||||||
|
hardware.h
|
||||||
|
main.c
|
||||||
|
steppers.c
|
||||||
|
steppers.h
|
||||||
|
strfunct.c
|
||||||
|
strfunct.h
|
||||||
|
usb.c
|
||||||
|
usb_defs.h
|
||||||
|
usb.h
|
||||||
|
usb_lib.c
|
||||||
|
usb_lib.h
|
||||||
@ -23,6 +23,14 @@
|
|||||||
#include <stm32f0.h>
|
#include <stm32f0.h>
|
||||||
#include "commonproto.h"
|
#include "commonproto.h"
|
||||||
|
|
||||||
|
#ifndef FALSE
|
||||||
|
#define FALSE (0)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef TRUE
|
||||||
|
#define TRUE (1)
|
||||||
|
#endif
|
||||||
|
|
||||||
// amount of tries to detect motor stall
|
// amount of tries to detect motor stall
|
||||||
#define NSTALLEDMAX (5)
|
#define NSTALLEDMAX (5)
|
||||||
// amount of steps to detect stalled state
|
// amount of steps to detect stalled state
|
||||||
@ -55,6 +63,7 @@ void addmicrostep(uint8_t i);
|
|||||||
void encoders_UPD(uint8_t i);
|
void encoders_UPD(uint8_t i);
|
||||||
|
|
||||||
void init_steppers();
|
void init_steppers();
|
||||||
|
void update_stepper(uint8_t i);
|
||||||
int32_t encoder_position(uint8_t i);
|
int32_t encoder_position(uint8_t i);
|
||||||
int setencpos(uint8_t i, int32_t position);
|
int setencpos(uint8_t i, int32_t position);
|
||||||
errcodes setmotpos(uint8_t i, int32_t position);
|
errcodes setmotpos(uint8_t i, int32_t position);
|
||||||
|
|||||||
6
F0:F030,F042,F072/3steppersLB/steppers.includes
Normal file
6
F0:F030,F042,F072/3steppersLB/steppers.includes
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
.
|
||||||
|
../inc
|
||||||
|
../inc/Fx
|
||||||
|
../inc/cm
|
||||||
|
../inc/ld
|
||||||
|
../inc/startup
|
||||||
@ -84,7 +84,7 @@ static int usbwr(const uint8_t *buf, uint16_t l){
|
|||||||
}
|
}
|
||||||
|
|
||||||
static uint8_t usbbuff[USB_TXBUFSZ-1]; // temporary buffer (63 - to prevent need of ZLP)
|
static uint8_t usbbuff[USB_TXBUFSZ-1]; // temporary buffer (63 - to prevent need of ZLP)
|
||||||
static uint8_t buflen = 0; // amount of symbols in usbbuff
|
static volatile uint8_t buflen = 0; // amount of symbols in usbbuff
|
||||||
|
|
||||||
// send next up to 63 bytes of data in usbbuff
|
// send next up to 63 bytes of data in usbbuff
|
||||||
static void send_next(){
|
static void send_next(){
|
||||||
@ -172,4 +172,3 @@ uint8_t USB_receive(uint8_t *buf){
|
|||||||
rxNE = 0;
|
rxNE = 0;
|
||||||
return sz;
|
return sz;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -22,11 +22,11 @@
|
|||||||
ep_t endpoints[STM32ENDPOINTS];
|
ep_t endpoints[STM32ENDPOINTS];
|
||||||
|
|
||||||
usb_dev_t USB_Dev;
|
usb_dev_t USB_Dev;
|
||||||
uint8_t usbON = 0;
|
volatile uint8_t usbON = 0;
|
||||||
static usb_LineCoding lineCoding = {115200, 0, 0, 8};
|
static usb_LineCoding lineCoding = {115200, 0, 0, 8};
|
||||||
static config_pack_t setup_packet;
|
static config_pack_t setup_packet;
|
||||||
static uint8_t ep0databuf[EP0DATABUF_SIZE];
|
static uint8_t ep0databuf[EP0DATABUF_SIZE];
|
||||||
static uint8_t ep0dbuflen = 0;
|
static volatile uint8_t ep0dbuflen = 0;
|
||||||
|
|
||||||
usb_LineCoding getLineCoding(){return lineCoding;}
|
usb_LineCoding getLineCoding(){return lineCoding;}
|
||||||
|
|
||||||
|
|||||||
@ -166,7 +166,7 @@ typedef struct {
|
|||||||
|
|
||||||
extern ep_t endpoints[];
|
extern ep_t endpoints[];
|
||||||
extern usb_dev_t USB_Dev;
|
extern usb_dev_t USB_Dev;
|
||||||
extern uint8_t usbON;
|
extern volatile uint8_t usbON;
|
||||||
|
|
||||||
void USB_Init();
|
void USB_Init();
|
||||||
uint8_t USB_GetState();
|
uint8_t USB_GetState();
|
||||||
|
|||||||
@ -1,2 +1,2 @@
|
|||||||
#define BUILD_NUMBER "169"
|
#define BUILD_NUMBER "173"
|
||||||
#define BUILD_DATE "2023-01-11"
|
#define BUILD_DATE "2023-02-21"
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user