wip
This commit is contained in:
@@ -36,7 +36,38 @@ extern "C" {
|
||||
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
/* USER CODE BEGIN ET */
|
||||
|
||||
typedef enum{
|
||||
omchiuso,
|
||||
omapertura1,
|
||||
omapertura2,
|
||||
omapertura3,
|
||||
omapertura4,
|
||||
omapertura5,
|
||||
omapertura6,
|
||||
omapertura7,
|
||||
omapertura8,
|
||||
omapertura9,
|
||||
omapertura10,
|
||||
omapertura11,
|
||||
omapertura12,
|
||||
omapertura13,
|
||||
omapertura14,
|
||||
omstopapertura,
|
||||
omaperto,
|
||||
omchiusura1,
|
||||
omchiusura2,
|
||||
omchiusura3,
|
||||
omchiusura4,
|
||||
omchiusura5,
|
||||
omchiusura6,
|
||||
omchiusura7,
|
||||
omchiusura8,
|
||||
omchiusura9,
|
||||
omchiusura10,
|
||||
omchiusura11,
|
||||
omchiusura12,
|
||||
omstopchiusura,
|
||||
}omCiclo_st;
|
||||
/* USER CODE END ET */
|
||||
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
|
||||
@@ -14,6 +14,7 @@ void StartMot(TIM_HandleTypeDef *htim,uint32_t Channel,uint16_t pwmval);
|
||||
void SetMotPwm(TIM_HandleTypeDef *htim,uint32_t Channel,uint16_t pwmval);
|
||||
void SetMot(uint8_t mot,uint8_t dir,uint16_t pwmval);
|
||||
void SetMotPerc(uint8_t mot,uint8_t dir,uint8_t perc);
|
||||
uint8_t ramp(uint8_t mot,uint8_t dir,uint8_t percStart,uint8_t percEnd,uint8_t tr,uint8_t mode);
|
||||
|
||||
#define timMot1 &htim2
|
||||
#define FWMot1 TIM_CHANNEL_1
|
||||
@@ -34,4 +35,10 @@ void SetMotPerc(uint8_t mot,uint8_t dir,uint8_t perc);
|
||||
#define FW 0
|
||||
#define BW 1
|
||||
|
||||
#define RAMPINIT 0
|
||||
#define RAMPRUN 10
|
||||
|
||||
#define DONE 0
|
||||
#define RUNNING 1
|
||||
|
||||
#endif /* INC_PWM_H_ */
|
||||
|
||||
@@ -20,6 +20,9 @@ extern uint16_t ch6 ;
|
||||
extern uint16_t ch7 ;
|
||||
extern uint16_t ch8 ;
|
||||
extern const uint8_t deftab[];
|
||||
extern omCiclo_st stCiclo;
|
||||
extern omCiclo_st memstCiclo;
|
||||
extern uint8_t stPulsanti;
|
||||
|
||||
bool toHex(char c1,char c2,char c3,char c4,uint16_t* retval){
|
||||
if((c1>='0')&&(c1<='9')){
|
||||
@@ -72,6 +75,7 @@ void manageCDC(void){
|
||||
if (rx < 0) return;
|
||||
//uint8_t out = (uint8_t)c;
|
||||
//if (out >= 'a' && out <= 'z') out -= 32; // to upper
|
||||
|
||||
rxbuf[rxidx]=rx;
|
||||
while (CDC_Transmit_FS(&rxbuf[rxidx], 1) == USBD_BUSY);//echo
|
||||
if((rx==0x0d)||(rx==0x0a)){
|
||||
@@ -86,6 +90,8 @@ void manageCDC(void){
|
||||
while (CDC_Transmit_FS(s, strlen((char*)s)) == USBD_BUSY);
|
||||
sprintf((char*)s,"\nP=0x%x ch4=%05d ch5=%05d ch6=%05d ch7=%05d ch8=%05d",pulsanti,ch4,ch5,ch6,ch7,ch8);
|
||||
while (CDC_Transmit_FS(s, strlen((char*)s)) == USBD_BUSY);
|
||||
sprintf((char*)s,"\nstCiclo=%05d stPulsanti=%05d",stCiclo,stPulsanti);
|
||||
while (CDC_Transmit_FS(s, 31) == USBD_BUSY);
|
||||
break;
|
||||
case 'I':
|
||||
sprintf((char*)s,"\nID000000");
|
||||
|
||||
@@ -10,6 +10,25 @@
|
||||
* [2..] Records...
|
||||
*/
|
||||
|
||||
extern uint16_t m1pwmap;
|
||||
extern uint16_t m1pwmch;
|
||||
extern uint16_t m2pwmap;
|
||||
extern uint16_t m2pwmch;
|
||||
extern uint16_t m3pwmap;
|
||||
extern uint16_t m3pwmch;
|
||||
extern uint16_t m4pwmap;
|
||||
extern uint16_t m4pwmch;
|
||||
extern uint16_t t1ap;
|
||||
extern uint16_t t2ap;
|
||||
extern uint16_t t3ap;
|
||||
extern uint16_t t4ap;
|
||||
extern uint16_t twap;
|
||||
extern uint16_t tramp;
|
||||
extern uint16_t t1ch;
|
||||
extern uint16_t t2ch;
|
||||
extern uint16_t t3ch;
|
||||
extern uint16_t twch;
|
||||
|
||||
const uint8_t deftab[32]={
|
||||
40, //m1pwmap
|
||||
60, //m1pwmch
|
||||
@@ -28,6 +47,10 @@ const uint8_t deftab[32]={
|
||||
8, //t3ap
|
||||
40, //t4ap
|
||||
1, //twap
|
||||
30, //t1ch
|
||||
30, //t2ch
|
||||
40, //t3ch
|
||||
1, //twch
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
@@ -38,11 +61,7 @@ const uint8_t deftab[32]={
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
10, //tramp
|
||||
};
|
||||
|
||||
typedef struct
|
||||
@@ -334,3 +353,24 @@ uint16_t EE_WriteVariable(uint16_t VirtAddress, uint16_t Data)
|
||||
st = EE_PageTransfer(VirtAddress, Data);
|
||||
return (uint16_t)st;
|
||||
}
|
||||
|
||||
void loadEE(void){
|
||||
EEW_Read(M1PWMAP, &m1pwmap);
|
||||
EEW_Read(M1PWMCH, &m1pwmch);
|
||||
EEW_Read(M2PWMAP, &m2pwmap);
|
||||
EEW_Read(M2PWMCH, &m2pwmch);
|
||||
EEW_Read(M3PWMAP, &m3pwmap);
|
||||
EEW_Read(M3PWMCH, &m3pwmch);
|
||||
EEW_Read(M4PWMAP, &m4pwmap);
|
||||
EEW_Read(M4PWMCH, &m4pwmch);
|
||||
EEW_Read(T1AP, &t1ap);
|
||||
EEW_Read(T2AP, &t2ap);
|
||||
EEW_Read(T3AP, &t3ap);
|
||||
EEW_Read(T4AP, &t4ap);
|
||||
EEW_Read(TWAP, &twap);
|
||||
EEW_Read(T1CH, &t1ch);
|
||||
EEW_Read(T2CH, &t2ch);
|
||||
EEW_Read(T3CH, &t3ch);
|
||||
EEW_Read(TWCH, &twch);
|
||||
EEW_Read(TRAMP, &tramp);
|
||||
}
|
||||
|
||||
@@ -65,6 +65,31 @@ typedef enum
|
||||
#define EE_NUM_VIRTUAL_ADDR 32U
|
||||
#define EEW_ADDR(i) (uint16_t)(0x0001 + (i)) // i = 0..31
|
||||
|
||||
|
||||
#define M1PWMAP 0 //m1pwmap
|
||||
#define M1PWMCH 1 //m1pwmch
|
||||
#define M2PWMAP 2 //m2pwmap
|
||||
#define M2PWMCH 3 //m2pwmch
|
||||
#define M3PWMAP 4 //m3pwmap
|
||||
#define M3PWMCH 5 //m3pwmch
|
||||
#define M4PWMAP 6 //m4pwmap
|
||||
#define M4PWMCH 7 //m4pwmch
|
||||
#define M1RAMPSTART 8 //m1rampstart
|
||||
#define M2RAMPSTART 9 //m2rampstart
|
||||
#define M3RAMPSTART 10 //m3rampstart
|
||||
#define M4RAMPSTART 11 //m4rampstart
|
||||
#define T1AP 12 //t1ap
|
||||
#define T2AP 13 //t2ap
|
||||
#define T3AP 14 //t3ap
|
||||
#define T4AP 15 //t4ap
|
||||
#define TWAP 16 //twap
|
||||
#define T1CH 17 //t1ch
|
||||
#define T2CH 18 //t2ch
|
||||
#define T3CH 19 //t3ch
|
||||
#define TWCH 20 //twch
|
||||
#define TRAMP 31 //tramp
|
||||
|
||||
|
||||
/* Virtual address table (defined in eeprom.c, can be customized) */
|
||||
extern const uint16_t EE_VirtAddrs[EE_NUM_VIRTUAL_ADDR];
|
||||
|
||||
@@ -72,7 +97,7 @@ extern const uint16_t EE_VirtAddrs[EE_NUM_VIRTUAL_ADDR];
|
||||
uint16_t EE_Init(void);
|
||||
uint16_t EE_ReadVariable(uint16_t VirtAddress, uint16_t *Data);
|
||||
uint16_t EE_WriteVariable(uint16_t VirtAddress, uint16_t Data);
|
||||
|
||||
void loadEE(void);
|
||||
/* Pseudo-array accessor EEW[idx] */
|
||||
static inline uint16_t EEW_Read(uint8_t idx, uint16_t *value)
|
||||
{
|
||||
|
||||
@@ -31,24 +31,7 @@
|
||||
|
||||
/* Private typedef -----------------------------------------------------------*/
|
||||
/* USER CODE BEGIN PTD */
|
||||
typedef enum{
|
||||
omchiuso,
|
||||
omapertura1,
|
||||
omapertura2,
|
||||
omapertura3,
|
||||
omapertura4,
|
||||
omapertura5,
|
||||
omapertura6,
|
||||
omstopapertura,
|
||||
omaperto,
|
||||
omchiusura1,
|
||||
omchiusura2,
|
||||
omchiusura3,
|
||||
omchiusura4,
|
||||
omchiusura5,
|
||||
omchiusura6,
|
||||
omstopchiusura,
|
||||
}omCiclo_st;
|
||||
|
||||
typedef enum{
|
||||
bzoff,
|
||||
bzmoving,
|
||||
@@ -61,6 +44,10 @@ typedef enum{
|
||||
#define P1STOP 0x02
|
||||
#define P2START 0x04
|
||||
#define P2STOP 0x08
|
||||
#define M1 1
|
||||
#define M2 2
|
||||
#define M3 3
|
||||
#define M4 4
|
||||
|
||||
/* USER CODE END PD */
|
||||
|
||||
@@ -88,11 +75,33 @@ extern uint16_t ch7 ;
|
||||
extern uint16_t ch8 ;
|
||||
|
||||
uint8_t pulsanti=0;
|
||||
volatile uint8_t rtP1=0;
|
||||
volatile uint8_t rtP2=0;
|
||||
volatile uint8_t rtP1=200;
|
||||
volatile uint8_t rtP2=200;
|
||||
volatile uint16_t rtramp[4];
|
||||
volatile uint16_t rtCiclo;
|
||||
uint16_t m1pwmap;
|
||||
uint16_t m1pwmch;
|
||||
uint16_t m2pwmap;
|
||||
uint16_t m2pwmch;
|
||||
uint16_t m3pwmap;
|
||||
uint16_t m3pwmch;
|
||||
uint16_t m4pwmap;
|
||||
uint16_t m4pwmch;
|
||||
uint16_t t1ap;
|
||||
uint16_t t2ap;
|
||||
uint16_t t3ap;
|
||||
uint16_t t4ap;
|
||||
uint16_t twap;
|
||||
uint16_t t1ch;
|
||||
uint16_t t2ch;
|
||||
uint16_t t3ch;
|
||||
uint16_t twch;
|
||||
uint16_t tramp;
|
||||
|
||||
uint16_t mrampstart[4];
|
||||
uint8_t stPulsanti=0;
|
||||
omCiclo_st stCiclo=omchiuso;
|
||||
omCiclo_st memstCiclo=omchiuso;
|
||||
volatile stBuz_st stBuz=bzoff;
|
||||
/* USER CODE END PV */
|
||||
|
||||
@@ -116,6 +125,7 @@ void HAL_SYSTICK_Callback(void){
|
||||
static uint8_t c1s = 0;
|
||||
static uint8_t inidx=0;
|
||||
static uint8_t inbuf[4];
|
||||
uint8_t i;
|
||||
|
||||
if (++c10ms >= 10) { // 10 ms
|
||||
c10ms = 0;
|
||||
@@ -133,6 +143,9 @@ void HAL_SYSTICK_Callback(void){
|
||||
readAdc();
|
||||
if (++c100ms >= 10) { // 10 ms
|
||||
c100ms = 0; //flag_10ms = 1; // set a flag; do real work in main loop
|
||||
for(i=0;i<4;i++){
|
||||
if(rtramp[i])rtramp[i]--;
|
||||
}
|
||||
//**** gestione buzzer *****************************************************************************
|
||||
if(stBuz==bzmoving){
|
||||
if(c1s>=5)HAL_GPIO_WritePin(GPIOA, BUZ_Pin, GPIO_PIN_RESET);else HAL_GPIO_WritePin(GPIOA, BUZ_Pin, GPIO_PIN_SET);
|
||||
@@ -142,6 +155,7 @@ void HAL_SYSTICK_Callback(void){
|
||||
//**************************************************************************************************
|
||||
if (++c1s >= 10) { // 10 ms
|
||||
c1s = 0;
|
||||
if(rtCiclo)rtCiclo--;
|
||||
HAL_GPIO_TogglePin(LED2_GPIO_Port, LED2_Pin);
|
||||
}
|
||||
}
|
||||
@@ -172,55 +186,218 @@ void manageCiclo(void){
|
||||
case omchiuso:
|
||||
if(stPulsanti&P1START){
|
||||
stBuz=bzmoving;
|
||||
(void)ramp(M2,BW,mrampstart[M2-1],m2pwmap,tramp,RAMPINIT);
|
||||
stCiclo=omapertura1;
|
||||
}
|
||||
if(stPulsanti&P1STOP)stCiclo=omstopapertura;
|
||||
break;
|
||||
case omapertura1:
|
||||
if(ramp(M2,BW,mrampstart[M2-1],m2pwmap,tramp,RAMPRUN)==DONE){
|
||||
rtCiclo=t1ap;
|
||||
stCiclo=omapertura2;
|
||||
}
|
||||
if(stPulsanti&P1STOP)stCiclo=omstopapertura;
|
||||
break;
|
||||
case omapertura2:
|
||||
if(rtCiclo==0){
|
||||
(void)ramp(M2,BW,m2pwmap,0,tramp,RAMPINIT);
|
||||
stCiclo=omapertura3;
|
||||
}
|
||||
if(stPulsanti&P1STOP)stCiclo=omstopapertura;
|
||||
break;
|
||||
case omapertura3:
|
||||
if(ramp(M2,BW,m2pwmap,0,tramp,RAMPRUN)==DONE){
|
||||
rtCiclo=twap;
|
||||
stCiclo=omapertura4;
|
||||
}
|
||||
if(stPulsanti&P1STOP)stCiclo=omstopapertura;
|
||||
break;
|
||||
case omapertura4:
|
||||
if(rtCiclo==0){
|
||||
(void)ramp(M1,FW,mrampstart[M1-1],m1pwmap,tramp,RAMPINIT);
|
||||
stCiclo=omapertura5;
|
||||
}
|
||||
if(stPulsanti&P1STOP)stCiclo=omstopapertura;
|
||||
break;
|
||||
case omapertura5:
|
||||
if(ramp(M1,FW,mrampstart[M1-1],m1pwmap,tramp,RAMPRUN)==DONE){
|
||||
rtCiclo=t2ap;
|
||||
stCiclo=omapertura6;
|
||||
}
|
||||
if(stPulsanti&P1STOP)stCiclo=omstopapertura;
|
||||
break;
|
||||
case omapertura6:
|
||||
if(rtCiclo==0){
|
||||
(void)ramp(M3,FW,mrampstart[M3-1],m3pwmap,tramp,RAMPINIT);
|
||||
stCiclo=omapertura7;
|
||||
}
|
||||
if(stPulsanti&P1STOP)stCiclo=omstopapertura;
|
||||
break;
|
||||
case omapertura7:
|
||||
if(ramp(M3,FW,mrampstart[M3-1],m3pwmap,tramp,RAMPRUN)==DONE){
|
||||
rtCiclo=t3ap;
|
||||
stCiclo=omapertura8;
|
||||
}
|
||||
if(stPulsanti&P1STOP)stCiclo=omstopapertura;
|
||||
break;
|
||||
case omapertura8:
|
||||
if(rtCiclo==0){
|
||||
(void)ramp(M3,FW,m3pwmap,0,tramp,RAMPINIT);
|
||||
(void)ramp(M1,FW,m1pwmap,0,tramp,RAMPINIT);
|
||||
stCiclo=omapertura9;
|
||||
}
|
||||
if(stPulsanti&P1STOP)stCiclo=omstopapertura;
|
||||
break;
|
||||
case omapertura9:
|
||||
if((ramp(M3,FW,m3pwmap,0,tramp,RAMPRUN)==DONE)&&(ramp(M1,FW,m1pwmap,0,tramp,RAMPRUN)==DONE)){
|
||||
rtCiclo=twap;
|
||||
stCiclo=omapertura10;
|
||||
}
|
||||
if(stPulsanti&P1STOP)stCiclo=omstopapertura;
|
||||
break;
|
||||
case omapertura10:
|
||||
if(rtCiclo==0){
|
||||
(void)ramp(M4,FW,mrampstart[M4-1],m4pwmap,tramp,RAMPINIT);
|
||||
stCiclo=omapertura11;
|
||||
}
|
||||
if(stPulsanti&P1STOP)stCiclo=omstopapertura;
|
||||
break;
|
||||
case omapertura11:
|
||||
if(ramp(M4,FW,mrampstart[M4-1],m4pwmap,tramp,RAMPRUN)==DONE){
|
||||
rtCiclo=t4ap;
|
||||
stCiclo=omapertura12;
|
||||
}
|
||||
if(stPulsanti&P1STOP)stCiclo=omstopapertura;
|
||||
break;
|
||||
case omapertura12:
|
||||
if(rtCiclo==0){
|
||||
(void)ramp(M4,FW,m4pwmap,0,tramp,RAMPINIT);
|
||||
stCiclo=omapertura13;
|
||||
}
|
||||
if(stPulsanti&P1STOP)stCiclo=omstopapertura;
|
||||
break;
|
||||
case omapertura13:
|
||||
if(ramp(M4,FW,m4pwmap,0,tramp,RAMPRUN)==DONE){
|
||||
rtCiclo=twap;
|
||||
stCiclo=omapertura14;
|
||||
}
|
||||
if(stPulsanti&P1STOP)stCiclo=omstopapertura;
|
||||
break;
|
||||
case omapertura14:
|
||||
if(rtCiclo==0){
|
||||
stBuz=bzoff;
|
||||
stCiclo=omaperto;
|
||||
}
|
||||
if(stPulsanti&P1STOP)stCiclo=omstopapertura;
|
||||
break;
|
||||
case omstopapertura:
|
||||
SetMotPerc(M1,FW,0);
|
||||
SetMotPerc(M2,FW,0);
|
||||
SetMotPerc(M3,FW,0);
|
||||
SetMotPerc(M4,FW,0);
|
||||
stBuz=bzoff;
|
||||
stCiclo=omchiuso;
|
||||
stPulsanti&=(~P1STOP);
|
||||
break;
|
||||
case omaperto:
|
||||
if(stPulsanti&P1START){
|
||||
stBuz=bzmoving;
|
||||
(void)ramp(M3,BW,mrampstart[M3-1],m3pwmch,tramp,RAMPINIT);
|
||||
(void)ramp(M1,BW,mrampstart[M1-1],m1pwmch,tramp,RAMPINIT);
|
||||
stCiclo=omchiusura1;
|
||||
}
|
||||
if(stPulsanti&P1STOP)stCiclo=omstopchiusura;
|
||||
break;
|
||||
case omchiusura1:
|
||||
if((ramp(M3,BW,mrampstart[M3-1],m3pwmch,tramp,RAMPRUN)==DONE)&&(ramp(M1,BW,mrampstart[M1-1],m1pwmch,tramp,RAMPRUN)==DONE)){
|
||||
rtCiclo=t1ch;
|
||||
stCiclo=omchiusura2;
|
||||
}
|
||||
if(stPulsanti&P1STOP)stCiclo=omstopchiusura;
|
||||
break;
|
||||
case omchiusura2:
|
||||
if(rtCiclo==0){
|
||||
(void)ramp(M3,BW,m3pwmch,0,tramp,RAMPINIT);
|
||||
(void)ramp(M1,BW,m1pwmch,0,tramp,RAMPINIT);
|
||||
stCiclo=omchiusura3;
|
||||
}
|
||||
if(stPulsanti&P1STOP)stCiclo=omstopchiusura;
|
||||
break;
|
||||
case omchiusura3:
|
||||
if((ramp(M3,BW,m3pwmch,0,tramp,RAMPRUN)==DONE)&&(ramp(M1,BW,m1pwmch,0,tramp,RAMPRUN)==DONE)){
|
||||
rtCiclo=twch;
|
||||
stCiclo=omchiusura4;
|
||||
}
|
||||
if(stPulsanti&P1STOP)stCiclo=omstopchiusura;
|
||||
break;
|
||||
case omchiusura4:
|
||||
if(rtCiclo==0){
|
||||
(void)ramp(M2,FW,mrampstart[M2-1],m2pwmch,tramp,RAMPINIT);
|
||||
stCiclo=omchiusura5;
|
||||
}
|
||||
if(stPulsanti&P1STOP)stCiclo=omstopchiusura;
|
||||
break;
|
||||
case omchiusura5:
|
||||
if(ramp(M2,FW,mrampstart[M2-1],m2pwmch,tramp,RAMPRUN)==DONE){
|
||||
rtCiclo=t2ch;
|
||||
stCiclo=omchiusura6;
|
||||
}
|
||||
if(stPulsanti&P1STOP)stCiclo=omstopchiusura;
|
||||
break;
|
||||
case omchiusura6:
|
||||
if(rtCiclo==0){
|
||||
(void)ramp(M2,FW,m2pwmch,0,tramp,RAMPINIT);
|
||||
stCiclo=omchiusura7;
|
||||
}
|
||||
if(stPulsanti&P1STOP)stCiclo=omstopchiusura;
|
||||
break;
|
||||
case omchiusura7:
|
||||
if(ramp(M2,FW,m2pwmch,0,tramp,RAMPRUN)==DONE){
|
||||
rtCiclo=twch;
|
||||
stCiclo=omchiusura8;
|
||||
}
|
||||
if(stPulsanti&P1STOP)stCiclo=omstopchiusura;
|
||||
break;
|
||||
case omchiusura8:
|
||||
if(rtCiclo==0){
|
||||
(void)ramp(M4,BW,mrampstart[M4-1],m4pwmch,tramp,RAMPINIT);
|
||||
stCiclo=omchiusura9;
|
||||
}
|
||||
if(stPulsanti&P1STOP)stCiclo=omstopchiusura;
|
||||
break;
|
||||
case omchiusura9:
|
||||
if(ramp(M4,BW,mrampstart[M4-1],m4pwmch,tramp,RAMPRUN)==DONE){
|
||||
rtCiclo=t3ch;
|
||||
stCiclo=omchiusura10;
|
||||
}
|
||||
if(stPulsanti&P1STOP)stCiclo=omstopchiusura;
|
||||
break;
|
||||
case omchiusura10:
|
||||
if(rtCiclo==0){
|
||||
(void)ramp(M4,BW,m4pwmch,0,tramp,RAMPINIT);
|
||||
stCiclo=omchiusura11;
|
||||
}
|
||||
if(stPulsanti&P1STOP)stCiclo=omstopchiusura;
|
||||
break;
|
||||
case omchiusura11:
|
||||
if(ramp(M4,BW,m4pwmch,0,tramp,RAMPRUN)==DONE){
|
||||
rtCiclo=twch;
|
||||
stCiclo=omchiusura12;
|
||||
}
|
||||
if(stPulsanti&P1STOP)stCiclo=omstopchiusura;
|
||||
break;
|
||||
case omchiusura12:
|
||||
if(rtCiclo==0){
|
||||
stBuz=bzoff;
|
||||
stCiclo=omchiuso;
|
||||
}
|
||||
if(stPulsanti&P1STOP)stCiclo=omstopchiusura;
|
||||
break;
|
||||
case omstopchiusura:
|
||||
SetMotPerc(M1,FW,0);
|
||||
SetMotPerc(M2,FW,0);
|
||||
SetMotPerc(M3,FW,0);
|
||||
SetMotPerc(M4,FW,0);
|
||||
stBuz=bzoff;
|
||||
stCiclo=omaperto;
|
||||
stPulsanti&=(~P1STOP);
|
||||
@@ -280,6 +457,7 @@ int main(void)
|
||||
if (EE_Init() != EE_OK){
|
||||
for(;;);//errore eeprom
|
||||
}
|
||||
loadEE();
|
||||
/* USER CODE END 2 */
|
||||
|
||||
/* Infinite loop */
|
||||
|
||||
@@ -14,7 +14,8 @@ extern TIM_HandleTypeDef htim1;
|
||||
extern TIM_HandleTypeDef htim2;
|
||||
extern TIM_HandleTypeDef htim3;
|
||||
extern TIM_HandleTypeDef htim4;
|
||||
|
||||
extern volatile uint8_t rtramp[4];
|
||||
extern uint8_t mrampstart[4];
|
||||
bool IsPwmRunning(TIM_HandleTypeDef *htim, uint32_t Channel)
|
||||
{
|
||||
HAL_TIM_ChannelStateTypeDef chState = HAL_TIM_GetChannelState(htim, Channel);
|
||||
@@ -242,3 +243,41 @@ void SetMotPerc(uint8_t mot,uint8_t dir,uint8_t perc){
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
uint8_t ramp(uint8_t mot,uint8_t dir,uint8_t percStart,uint8_t percEnd,uint8_t tr,uint8_t mode){
|
||||
static uint8_t memrtramp[4];
|
||||
uint16_t delta;
|
||||
switch(mode){
|
||||
case RAMPINIT:
|
||||
memrtramp[mot-1]=percStart=tr;
|
||||
SetMotPerc(mot,dir,mrampstart[mot-1]);
|
||||
return DONE;
|
||||
case RAMPRUN:
|
||||
if(memrtramp[mot-1]!=rtramp[mot-1]){
|
||||
memrtramp[mot-1]=rtramp[mot-1];
|
||||
if(rtramp[mot-1]){
|
||||
if(mrampstart[mot-1]>percEnd){
|
||||
delta=mrampstart[mot-1]-percEnd;
|
||||
delta=delta*(uint16_t)(tr-rtramp[mot-1]);
|
||||
delta=delta/tr;
|
||||
SetMotPerc(mot,dir,mrampstart[mot-1]-delta);
|
||||
return RUNNING;
|
||||
}else if(mrampstart[mot-1]<percEnd){
|
||||
delta=percEnd-mrampstart[mot-1];
|
||||
delta=delta*(uint16_t)(tr-rtramp[mot-1]);
|
||||
delta=delta/tr;
|
||||
SetMotPerc(mot,dir,mrampstart[mot-1]+delta);
|
||||
return RUNNING;
|
||||
}else{
|
||||
SetMotPerc(mot,dir,percEnd);
|
||||
return DONE;
|
||||
}
|
||||
}else{
|
||||
SetMotPerc(mot,dir,percEnd);
|
||||
return DONE;
|
||||
}
|
||||
}else return RUNNING;
|
||||
break;
|
||||
}
|
||||
return DONE;
|
||||
}
|
||||
|
||||
Binary file not shown.
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,4 +1,4 @@
|
||||
../Core/Src/eeprom.h:77:24:EEW_Read 1
|
||||
../Core/Src/eeprom.h:82:24:EEW_Write 1
|
||||
../Core/Src/cdc_int.c:24:6:toHex 17
|
||||
../Core/Src/cdc_int.c:60:6:manageCDC 70
|
||||
../Core/Src/eeprom.h:102:24:EEW_Read 1
|
||||
../Core/Src/eeprom.h:107:24:EEW_Write 1
|
||||
../Core/Src/cdc_int.c:27:6:toHex 17
|
||||
../Core/Src/cdc_int.c:63:6:manageCDC 71
|
||||
|
||||
Binary file not shown.
@@ -1,4 +1,4 @@
|
||||
../Core/Src/eeprom.h:77:24:EEW_Read 16 static
|
||||
../Core/Src/eeprom.h:82:24:EEW_Write 16 static
|
||||
../Core/Src/cdc_int.c:24:6:toHex 16 static
|
||||
../Core/Src/cdc_int.c:60:6:manageCDC 184 static
|
||||
../Core/Src/eeprom.h:102:24:EEW_Read 16 static
|
||||
../Core/Src/eeprom.h:107:24:EEW_Write 16 static
|
||||
../Core/Src/cdc_int.c:27:6:toHex 16 static
|
||||
../Core/Src/cdc_int.c:63:6:manageCDC 184 static
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
../Core/Src/eeprom.c:73:17:EE_GetPageStatus 1
|
||||
../Core/Src/eeprom.c:78:26:EE_FlashProgramHalfWord 1
|
||||
../Core/Src/eeprom.c:89:26:EE_FlashErasePage 1
|
||||
../Core/Src/eeprom.c:108:17:EE_FindFreeAddress 3
|
||||
../Core/Src/eeprom.c:130:18:EE_FindInPage 6
|
||||
../Core/Src/eeprom.c:170:18:EE_Format 4
|
||||
../Core/Src/eeprom.c:188:17:EE_GetOtherPageBase 2
|
||||
../Core/Src/eeprom.c:194:18:EE_PageTransfer 11
|
||||
../Core/Src/eeprom.c:267:10:EE_Init 7
|
||||
../Core/Src/eeprom.c:298:10:EE_ReadVariable 2
|
||||
../Core/Src/eeprom.c:315:10:EE_WriteVariable 4
|
||||
../Core/Src/eeprom.h:102:24:EEW_Read 1
|
||||
../Core/Src/eeprom.c:92:17:EE_GetPageStatus 1
|
||||
../Core/Src/eeprom.c:97:26:EE_FlashProgramHalfWord 1
|
||||
../Core/Src/eeprom.c:108:26:EE_FlashErasePage 1
|
||||
../Core/Src/eeprom.c:127:17:EE_FindFreeAddress 3
|
||||
../Core/Src/eeprom.c:149:18:EE_FindInPage 6
|
||||
../Core/Src/eeprom.c:189:18:EE_Format 4
|
||||
../Core/Src/eeprom.c:207:17:EE_GetOtherPageBase 2
|
||||
../Core/Src/eeprom.c:213:18:EE_PageTransfer 11
|
||||
../Core/Src/eeprom.c:286:10:EE_Init 7
|
||||
../Core/Src/eeprom.c:317:10:EE_ReadVariable 2
|
||||
../Core/Src/eeprom.c:334:10:EE_WriteVariable 4
|
||||
../Core/Src/eeprom.c:357:6:loadEE 1
|
||||
|
||||
Binary file not shown.
@@ -1,11 +1,13 @@
|
||||
../Core/Src/eeprom.c:73:17:EE_GetPageStatus 16 static
|
||||
../Core/Src/eeprom.c:78:26:EE_FlashProgramHalfWord 32 static
|
||||
../Core/Src/eeprom.c:89:26:EE_FlashErasePage 40 static
|
||||
../Core/Src/eeprom.c:108:17:EE_FindFreeAddress 32 static
|
||||
../Core/Src/eeprom.c:130:18:EE_FindInPage 40 static
|
||||
../Core/Src/eeprom.c:170:18:EE_Format 8 static
|
||||
../Core/Src/eeprom.c:188:17:EE_GetOtherPageBase 16 static
|
||||
../Core/Src/eeprom.c:194:18:EE_PageTransfer 40 static
|
||||
../Core/Src/eeprom.c:267:10:EE_Init 16 static
|
||||
../Core/Src/eeprom.c:298:10:EE_ReadVariable 24 static
|
||||
../Core/Src/eeprom.c:315:10:EE_WriteVariable 24 static
|
||||
../Core/Src/eeprom.h:102:24:EEW_Read 16 static
|
||||
../Core/Src/eeprom.c:92:17:EE_GetPageStatus 16 static
|
||||
../Core/Src/eeprom.c:97:26:EE_FlashProgramHalfWord 32 static
|
||||
../Core/Src/eeprom.c:108:26:EE_FlashErasePage 40 static
|
||||
../Core/Src/eeprom.c:127:17:EE_FindFreeAddress 32 static
|
||||
../Core/Src/eeprom.c:149:18:EE_FindInPage 40 static
|
||||
../Core/Src/eeprom.c:189:18:EE_Format 8 static
|
||||
../Core/Src/eeprom.c:207:17:EE_GetOtherPageBase 16 static
|
||||
../Core/Src/eeprom.c:213:18:EE_PageTransfer 40 static
|
||||
../Core/Src/eeprom.c:286:10:EE_Init 16 static
|
||||
../Core/Src/eeprom.c:317:10:EE_ReadVariable 24 static
|
||||
../Core/Src/eeprom.c:334:10:EE_WriteVariable 24 static
|
||||
../Core/Src/eeprom.c:357:6:loadEE 8 static
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
../Core/Src/main.c:113:6:HAL_SYSTICK_Callback 10
|
||||
../Core/Src/main.c:151:6:managePulsanti 9
|
||||
../Core/Src/main.c:170:6:manageCiclo 32
|
||||
../Core/Src/main.c:237:5:main 2
|
||||
../Core/Src/main.c:319:6:SystemClock_Config 4
|
||||
../Core/Src/main.c:367:13:MX_ADC1_Init 7
|
||||
../Core/Src/main.c:450:13:MX_TIM2_Init 9
|
||||
../Core/Src/main.c:526:13:MX_TIM4_Init 9
|
||||
../Core/Src/main.c:600:13:MX_USART1_UART_Init 2
|
||||
../Core/Src/main.c:631:13:MX_DMA_Init 1
|
||||
../Core/Src/main.c:649:13:MX_GPIO_Init 1
|
||||
../Core/Src/main.c:725:6:Error_Handler 1
|
||||
../Core/Src/main.c:122:6:HAL_SYSTICK_Callback 13
|
||||
../Core/Src/main.c:165:6:managePulsanti 9
|
||||
../Core/Src/main.c:184:6:manageCiclo 90
|
||||
../Core/Src/main.c:414:5:main 2
|
||||
../Core/Src/main.c:497:6:SystemClock_Config 4
|
||||
../Core/Src/main.c:545:13:MX_ADC1_Init 7
|
||||
../Core/Src/main.c:628:13:MX_TIM2_Init 9
|
||||
../Core/Src/main.c:704:13:MX_TIM4_Init 9
|
||||
../Core/Src/main.c:778:13:MX_USART1_UART_Init 2
|
||||
../Core/Src/main.c:809:13:MX_DMA_Init 1
|
||||
../Core/Src/main.c:827:13:MX_GPIO_Init 1
|
||||
../Core/Src/main.c:903:6:Error_Handler 1
|
||||
|
||||
Binary file not shown.
@@ -1,12 +1,12 @@
|
||||
../Core/Src/main.c:113:6:HAL_SYSTICK_Callback 8 static
|
||||
../Core/Src/main.c:151:6:managePulsanti 4 static
|
||||
../Core/Src/main.c:170:6:manageCiclo 4 static
|
||||
../Core/Src/main.c:237:5:main 8 static
|
||||
../Core/Src/main.c:319:6:SystemClock_Config 88 static
|
||||
../Core/Src/main.c:367:13:MX_ADC1_Init 24 static
|
||||
../Core/Src/main.c:450:13:MX_TIM2_Init 64 static
|
||||
../Core/Src/main.c:526:13:MX_TIM4_Init 64 static
|
||||
../Core/Src/main.c:600:13:MX_USART1_UART_Init 8 static
|
||||
../Core/Src/main.c:631:13:MX_DMA_Init 16 static
|
||||
../Core/Src/main.c:649:13:MX_GPIO_Init 40 static
|
||||
../Core/Src/main.c:725:6:Error_Handler 4 static,ignoring_inline_asm
|
||||
../Core/Src/main.c:122:6:HAL_SYSTICK_Callback 16 static
|
||||
../Core/Src/main.c:165:6:managePulsanti 4 static
|
||||
../Core/Src/main.c:184:6:manageCiclo 16 static
|
||||
../Core/Src/main.c:414:5:main 8 static
|
||||
../Core/Src/main.c:497:6:SystemClock_Config 88 static
|
||||
../Core/Src/main.c:545:13:MX_ADC1_Init 24 static
|
||||
../Core/Src/main.c:628:13:MX_TIM2_Init 64 static
|
||||
../Core/Src/main.c:704:13:MX_TIM4_Init 64 static
|
||||
../Core/Src/main.c:778:13:MX_USART1_UART_Init 8 static
|
||||
../Core/Src/main.c:809:13:MX_DMA_Init 16 static
|
||||
../Core/Src/main.c:827:13:MX_GPIO_Init 40 static
|
||||
../Core/Src/main.c:903:6:Error_Handler 4 static,ignoring_inline_asm
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
../Core/Src/pwm.c:18:6:IsPwmRunning 1
|
||||
../Core/Src/pwm.c:25:6:StopMot 1
|
||||
../Core/Src/pwm.c:29:6:StartMot 4
|
||||
../Core/Src/pwm.c:34:6:SetMotPwm 4
|
||||
../Core/Src/pwm.c:38:6:SetMot 25
|
||||
../Core/Src/pwm.c:139:6:SetMotPerc 25
|
||||
../Core/Src/pwm.c:19:6:IsPwmRunning 1
|
||||
../Core/Src/pwm.c:26:6:StopMot 1
|
||||
../Core/Src/pwm.c:30:6:StartMot 4
|
||||
../Core/Src/pwm.c:35:6:SetMotPwm 4
|
||||
../Core/Src/pwm.c:39:6:SetMot 25
|
||||
../Core/Src/pwm.c:140:6:SetMotPerc 25
|
||||
../Core/Src/pwm.c:247:9:ramp 7
|
||||
|
||||
Binary file not shown.
@@ -1,6 +1,7 @@
|
||||
../Core/Src/pwm.c:18:6:IsPwmRunning 24 static
|
||||
../Core/Src/pwm.c:25:6:StopMot 16 static
|
||||
../Core/Src/pwm.c:29:6:StartMot 24 static
|
||||
../Core/Src/pwm.c:34:6:SetMotPwm 24 static
|
||||
../Core/Src/pwm.c:38:6:SetMot 16 static
|
||||
../Core/Src/pwm.c:139:6:SetMotPerc 24 static
|
||||
../Core/Src/pwm.c:19:6:IsPwmRunning 24 static
|
||||
../Core/Src/pwm.c:26:6:StopMot 16 static
|
||||
../Core/Src/pwm.c:30:6:StartMot 24 static
|
||||
../Core/Src/pwm.c:35:6:SetMotPwm 24 static
|
||||
../Core/Src/pwm.c:39:6:SetMot 16 static
|
||||
../Core/Src/pwm.c:140:6:SetMotPerc 24 static
|
||||
../Core/Src/pwm.c:247:9:ramp 32 static
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user