wip
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
#include "stm32f1xx_hal.h"
|
||||
#include "eeprom.h"
|
||||
#include "pwm.h"
|
||||
#include <stdbool.h>
|
||||
|
||||
extern TIM_HandleTypeDef htim1;
|
||||
extern TIM_HandleTypeDef htim2;
|
||||
@@ -19,10 +20,11 @@ extern uint16_t ch5 ;
|
||||
extern uint16_t ch6 ;
|
||||
extern uint16_t ch7 ;
|
||||
extern uint16_t ch8 ;
|
||||
extern const uint8_t deftab[];
|
||||
extern const uint16_t deftab[];
|
||||
extern omCiclo_st stCiclo;
|
||||
extern omCiclo_st memstCiclo;
|
||||
extern uint8_t stPulsanti;
|
||||
extern bool nobuz;
|
||||
|
||||
bool toHex(char c1,char c2,char c3,char c4,uint16_t* retval){
|
||||
if((c1>='0')&&(c1<='9')){
|
||||
@@ -97,6 +99,21 @@ void manageCDC(void){
|
||||
sprintf((char*)s,"\nID000000");
|
||||
while (CDC_Transmit_FS(s, 9) == USBD_BUSY);
|
||||
break;
|
||||
case 'b':
|
||||
if(rxidx==2){
|
||||
if(rxbuf[1]=='0'){
|
||||
nobuz=false;
|
||||
}else if(rxbuf[1]=='1'){
|
||||
nobuz=true;
|
||||
}else{
|
||||
sprintf((char*)s,"\nb0|1");
|
||||
while (CDC_Transmit_FS(s, 5) == USBD_BUSY);
|
||||
}
|
||||
}else{
|
||||
sprintf((char*)s,"\nb0|1");
|
||||
while (CDC_Transmit_FS(s, 5) == USBD_BUSY);
|
||||
}
|
||||
break;
|
||||
case 'm':
|
||||
if(rxidx==8){
|
||||
if((rxbuf[1]>='1')&&(rxbuf[1]<='4')){
|
||||
@@ -194,9 +211,9 @@ void manageCDC(void){
|
||||
}
|
||||
}else if(rxbuf[1]=='x'){
|
||||
if(rxidx==2){
|
||||
for(i=0;i<32;i++){
|
||||
for(i=0;i<EE_NUM_VIRTUAL_ADDR;i++){
|
||||
st=EEW_Write(i,deftab[i]);
|
||||
if (st == EE_OK)sprintf((char*)s,"\ndone 0x%02x=0x%04x",i,deftab[i]);
|
||||
if (st == EE_OK)sprintf((char*)s,"\ndone %d=%d",i,deftab[i]);
|
||||
else sprintf((char*)s,"\nee write error %d", st);
|
||||
while (CDC_Transmit_FS(s, strlen((char*)s)) == USBD_BUSY);
|
||||
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
#include "adc.h"
|
||||
#include "debug.h"
|
||||
#include "mot.h"
|
||||
#include <stdbool.h>
|
||||
/* USER CODE END Includes */
|
||||
|
||||
/* Private typedef -----------------------------------------------------------*/
|
||||
@@ -127,6 +128,7 @@ uint16_t stPulsanti=0;
|
||||
omCiclo_st stCiclo=omchiuso;
|
||||
omCiclo_st memstCiclo=omchiuso;
|
||||
volatile stBuz_st stBuz=bzoff;
|
||||
bool nobuz=false;
|
||||
/* USER CODE END PV */
|
||||
|
||||
/* Private function prototypes -----------------------------------------------*/
|
||||
@@ -179,16 +181,24 @@ void HAL_SYSTICK_Callback(void){
|
||||
|
||||
//**** 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);
|
||||
if(nobuz){
|
||||
if(c1s>=5)HAL_GPIO_WritePin(LED2_GPIO_Port, LED2_Pin, GPIO_PIN_RESET);else HAL_GPIO_WritePin(LED2_GPIO_Port, LED2_Pin, GPIO_PIN_SET);
|
||||
}else{
|
||||
if(c1s>=5)HAL_GPIO_WritePin(GPIOA, BUZ_Pin, GPIO_PIN_RESET);else HAL_GPIO_WritePin(GPIOA, BUZ_Pin, GPIO_PIN_SET);
|
||||
}
|
||||
}else if(stBuz==bzwarning){
|
||||
if(c1s&2)HAL_GPIO_WritePin(GPIOA, BUZ_Pin, GPIO_PIN_RESET);else HAL_GPIO_WritePin(GPIOA, BUZ_Pin, GPIO_PIN_SET);
|
||||
if(nobuz){
|
||||
if(c1s&2)HAL_GPIO_WritePin(LED2_GPIO_Port, LED2_Pin, GPIO_PIN_RESET);else HAL_GPIO_WritePin(LED2_GPIO_Port, LED2_Pin, GPIO_PIN_SET);
|
||||
}else{
|
||||
if(c1s&2)HAL_GPIO_WritePin(GPIOA, BUZ_Pin, GPIO_PIN_RESET);else HAL_GPIO_WritePin(GPIOA, BUZ_Pin, GPIO_PIN_SET);
|
||||
}
|
||||
}else{//bzoff
|
||||
HAL_GPIO_WritePin(GPIOA, BUZ_Pin, GPIO_PIN_RESET);
|
||||
}
|
||||
//**************************************************************************************************
|
||||
if (++c1s >= 10) { // 1 s
|
||||
c1s = 0;
|
||||
HAL_GPIO_TogglePin(LED2_GPIO_Port, LED2_Pin);
|
||||
//HAL_GPIO_TogglePin(LED2_GPIO_Port, LED2_Pin);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -197,10 +207,16 @@ void HAL_SYSTICK_Callback(void){
|
||||
void managePulsanti(void){
|
||||
if(pulsanti&INP1){
|
||||
if(rtP1==0)stPulsanti|=P1START;
|
||||
else{
|
||||
HAL_GPIO_WritePin(LED2_GPIO_Port,LED2_Pin, GPIO_PIN_SET);
|
||||
}
|
||||
}else{
|
||||
if(stPulsanti&P1START)stPulsanti&=(~P1START);
|
||||
else if(rtP1<=190){
|
||||
if(stPulsanti&P1START){
|
||||
stPulsanti&=(~P1START);
|
||||
HAL_GPIO_WritePin(LED2_GPIO_Port,LED2_Pin, GPIO_PIN_RESET);
|
||||
}else if(rtP1<=190){
|
||||
stPulsanti|=P1STOP;
|
||||
HAL_GPIO_WritePin(LED2_GPIO_Port,LED2_Pin, GPIO_PIN_RESET);
|
||||
}
|
||||
rtP1=200;
|
||||
}
|
||||
@@ -375,7 +391,7 @@ void manageCiclo(void){
|
||||
rtCiclo=0;
|
||||
if(stPulsanti&P1START){
|
||||
stBuz=bzmoving;
|
||||
(void)ramp(M1,BW,mrampstart[M1-1],m1pwmch,tramp,RAMPINIT);
|
||||
//(void)ramp(M1,BW,mrampstart[M1-1],m1pwmch,tramp,RAMPINIT);
|
||||
stCiclo=omchiusura1;
|
||||
(void)m1ch();(void)m2ch();(void)m3ch();(void)m4ch();
|
||||
}
|
||||
@@ -416,7 +432,8 @@ void manageCiclo(void){
|
||||
break;
|
||||
case omchiusura1:
|
||||
if(rtCiclo>=10){//doppo 1 secondi
|
||||
if((m1ch()==motStop)&&(m2ch()==motStop)&&(m3ch()==motStop)&&(m4ch()==motStop)){
|
||||
m1=m1ch();m2=m2ch();m3=m3ch();m4=m4ch();
|
||||
if((m1==motStop)&&(m2==motStop)&&(m3==motStop)&&(m4==motStop)){
|
||||
stBuz=bzoff;
|
||||
stCiclo=omchiuso;
|
||||
}
|
||||
|
||||
@@ -382,7 +382,7 @@ motMov_st m4ch(void){
|
||||
}
|
||||
break;
|
||||
case motStopRamp:
|
||||
if(ramp(43,FW,m4pwmch,0,tramp,RAMPRUN)==DONE){
|
||||
if(ramp(M4,FW,m4pwmch,0,tramp,RAMPRUN)==DONE){
|
||||
m4st=motStop;
|
||||
}
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user