wip
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user