|
|
|
|
@@ -219,14 +219,14 @@ void HAL_SYSTICK_Callback(void) {
|
|
|
|
|
}
|
|
|
|
|
} else if (stBuz == bzwarning) {
|
|
|
|
|
if (nobuz) {
|
|
|
|
|
if (c1s & 2)
|
|
|
|
|
if (c1s & 1)
|
|
|
|
|
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)
|
|
|
|
|
if (c1s & 1)
|
|
|
|
|
HAL_GPIO_WritePin(GPIOA, BUZ_Pin, GPIO_PIN_RESET);
|
|
|
|
|
else
|
|
|
|
|
HAL_GPIO_WritePin(GPIOA, BUZ_Pin, GPIO_PIN_SET);
|
|
|
|
|
@@ -253,6 +253,7 @@ void managePulsanti(void) {
|
|
|
|
|
} else {
|
|
|
|
|
if (stPulsanti & P1START) {
|
|
|
|
|
stPulsanti &= (~P1START);
|
|
|
|
|
stPulsanti|=P1RELEASED;
|
|
|
|
|
HAL_GPIO_WritePin(LED2_GPIO_Port, LED2_Pin, GPIO_PIN_RESET);
|
|
|
|
|
} else if (rtP1 <= 190) {
|
|
|
|
|
stPulsanti |= P1STOP;
|
|
|
|
|
@@ -270,7 +271,7 @@ void managePulsanti(void) {
|
|
|
|
|
stPulsanti |= P2STOP;
|
|
|
|
|
rtP2 = 200;
|
|
|
|
|
}
|
|
|
|
|
stPulsanti &= (P1START | P1STOP | P2START | P2STOP);
|
|
|
|
|
stPulsanti &= (P1START | P1STOP | P2START | P2STOP |P1RELEASED);
|
|
|
|
|
if (stPulsanti == 0) {
|
|
|
|
|
switch (pulsanti & 0x3c) {
|
|
|
|
|
case 0x00:
|
|
|
|
|
@@ -313,6 +314,7 @@ void manageCiclo(void) {
|
|
|
|
|
motMov_st m1, m2, m3, m4;
|
|
|
|
|
switch (stCiclo) {
|
|
|
|
|
case omchiuso:
|
|
|
|
|
stPulsanti &= (~P1RELEASED);
|
|
|
|
|
if (stPulsanti & P1START) {
|
|
|
|
|
stBuz = bzwarning;
|
|
|
|
|
rtCiclo = 0;
|
|
|
|
|
@@ -329,8 +331,9 @@ void manageCiclo(void) {
|
|
|
|
|
if ((ch8 > thanem) && (fchiuso == false)) {
|
|
|
|
|
HAL_GPIO_WritePin(LED1_GPIO_Port, LED1_Pin, GPIO_PIN_SET);
|
|
|
|
|
if (rtAnem == 0) {
|
|
|
|
|
rtCiclo=0;
|
|
|
|
|
stBuz = bzmoving;
|
|
|
|
|
stCiclo = omchiusura1;
|
|
|
|
|
stCiclo = omemergenza1;
|
|
|
|
|
(void) m1ch();
|
|
|
|
|
(void) m2ch();
|
|
|
|
|
(void) m3ch();
|
|
|
|
|
@@ -482,10 +485,10 @@ void manageCiclo(void) {
|
|
|
|
|
}
|
|
|
|
|
if (stPulsanti & P1STOP)
|
|
|
|
|
stCiclo = omstopapertura;
|
|
|
|
|
// if (stPulsanti & P1START) {
|
|
|
|
|
// stCiclo = omstoprestartchiusura;
|
|
|
|
|
// rtCiclo = 0;
|
|
|
|
|
// }
|
|
|
|
|
if ((stPulsanti & P1START)&&(stPulsanti & P1RELEASED)) {
|
|
|
|
|
stCiclo = omstoprestartchiusura;
|
|
|
|
|
rtCiclo = 0;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case omstopapertura:
|
|
|
|
|
SetMotPerc(M1, FW, 0);
|
|
|
|
|
@@ -511,10 +514,12 @@ void manageCiclo(void) {
|
|
|
|
|
SetMotPerc(M2, BW, 0);
|
|
|
|
|
SetMotPerc(M3, BW, 0);
|
|
|
|
|
SetMotPerc(M4, BW, 0);
|
|
|
|
|
stBuz = bzoff;
|
|
|
|
|
if (rtCiclo >= 20)
|
|
|
|
|
stCiclo = omaperto;
|
|
|
|
|
break;
|
|
|
|
|
case omaperto:
|
|
|
|
|
stPulsanti &= (~P1RELEASED);
|
|
|
|
|
rtCiclo = 0;
|
|
|
|
|
if (stPulsanti & P1START) {
|
|
|
|
|
stBuz = bzmoving;
|
|
|
|
|
@@ -529,7 +534,7 @@ void manageCiclo(void) {
|
|
|
|
|
HAL_GPIO_WritePin(LED1_GPIO_Port, LED1_Pin, GPIO_PIN_SET);
|
|
|
|
|
if (rtAnem == 0) {
|
|
|
|
|
stBuz = bzmoving;
|
|
|
|
|
stCiclo = omchiusura1;
|
|
|
|
|
stCiclo = omemergenza1;
|
|
|
|
|
(void) m1ch();
|
|
|
|
|
(void) m2ch();
|
|
|
|
|
(void) m3ch();
|
|
|
|
|
@@ -599,10 +604,25 @@ void manageCiclo(void) {
|
|
|
|
|
}
|
|
|
|
|
if (stPulsanti & P1STOP)
|
|
|
|
|
stCiclo = omstopchiusura;
|
|
|
|
|
// if (stPulsanti & P1START) {
|
|
|
|
|
// stCiclo = omstoprestartapertura;
|
|
|
|
|
// rtCiclo = 0;
|
|
|
|
|
// }
|
|
|
|
|
if ((stPulsanti & P1START)&&(stPulsanti & P1RELEASED)) {
|
|
|
|
|
stCiclo = omstoprestartapertura;
|
|
|
|
|
rtCiclo = 0;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case omemergenza1:
|
|
|
|
|
if (rtCiclo >= 10) { //doppo 1 secondi
|
|
|
|
|
m1 = m1ch();
|
|
|
|
|
m2 = m2ch();
|
|
|
|
|
m3 = m3ch();
|
|
|
|
|
m4 = m4ch();
|
|
|
|
|
if ((m1 == motStop) && (m2 == motStop) && (m3 == motStop)
|
|
|
|
|
&& (m4 == motStop)) {
|
|
|
|
|
stBuz = bzoff;
|
|
|
|
|
stCiclo = omchiuso;
|
|
|
|
|
fchiuso = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
case omstoprestartapertura:
|
|
|
|
|
SetMotPerc(M1, FW, 0);
|
|
|
|
|
@@ -613,6 +633,7 @@ void manageCiclo(void) {
|
|
|
|
|
SetMotPerc(M2, BW, 0);
|
|
|
|
|
SetMotPerc(M3, BW, 0);
|
|
|
|
|
SetMotPerc(M4, BW, 0);
|
|
|
|
|
stBuz = bzoff;
|
|
|
|
|
if (rtCiclo >= 20)
|
|
|
|
|
stCiclo = omchiuso;
|
|
|
|
|
break;
|
|
|
|
|
@@ -688,8 +709,10 @@ int main(void) {
|
|
|
|
|
}
|
|
|
|
|
loadEE();
|
|
|
|
|
if (flagPar != VERSIONE) {
|
|
|
|
|
HAL_GPIO_WritePin(GPIOA, BUZ_Pin, GPIO_PIN_SET);
|
|
|
|
|
loadDefault();
|
|
|
|
|
loadEE();
|
|
|
|
|
HAL_GPIO_WritePin(GPIOA, BUZ_Pin, GPIO_PIN_RESET);
|
|
|
|
|
}
|
|
|
|
|
/* USER CODE END 2 */
|
|
|
|
|
|
|
|
|
|
|