- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
if (LD3_state == 0 || LD2_state == 0 || LD1_state == 0)
{
GPIO_SetBits(GPIOB, LED1); //RED ON
LD_Status = NO_LOCK;
}
else
{
LD_Status = LOCK_OK;
}
if (LD4_state == 0 && LD_Status == LOCK_OK)
{
GPIO_SetBits(GPIOB, LED1); //RED ON
}
else
{
GPIO_ResetBits(GPIOB, LED1); //RED OF
}
if (LD4_state == 0 && LD_Status == LOCK_OK)
{
GPIO_ResetBits(GPIOB, LED1); //RED OFF
}
/* Ну можно же было сделать по-человечески, а? */
/* Эквивалентный код: */
LD_Status = LD1_state && LD2_state && LD3_state && LD4_state;
if (LD_Status)
{
GPIO_ResetBits(GPIOB, LED1); //RED OFF
}
else
{
GPIO_SetBits(GPIOB, LED1); //RED ON
}