#define input1PinCheck ((GPIOB->IDR & GPIO_PIN_0) == 0)
#define input2PinCheck ((GPIOB->IDR & GPIO_PIN_14) == 0)
void countSMD (void)
{
int32_t c1 = 0; // что насчитали
uint32_t flags = 0, flagsUp = 0, flagsDown = 0;
while (1)
{
__watchdog_reset();
if (input1PinCheck && input2PinCheck)
{
if (flagsDown && (flags == 1)) c1++;
if (flagsUp && (flags == 2)) c1--;
flags = 0;
flagsUp = 0;
flagsDown = 0;
}
if (!input1PinCheck && input2PinCheck)
{
if (flags == 0) flagsUp++;
flags = 1;
}
if (input1PinCheck && !input2PinCheck)
{
if (flags == 0) flagsDown++;
flags = 2;
}
}
}