This code:
- while (1)
-
{
-
if (SerialKeyPressed((char*)&key)) break;
-
}
-
is an infinite loop tht will continue until the call to SerialKeyPressed returns true. That is returns something not a zero. key is an argument so &key would be the address of the key. Therefore, (char*)&key tells the compiler to use the address of the key as a char*. I suspect the function needs a char* argument and key is not a char making &key not a char*. Normally, this situation will blow you build but the cast tells the compiler to accept the address against the rules.
(TIM3->SR1 & TIM3_FLAG_CC1) is an expression. Expressions are either true (not 0) or false (0), Here the expression is compared to TIM3_FLAG_CC1. If the expression is not equal to TIM3_FLAG_CC1 you stay in the loop.
TIM3->SR1 & TIM3_FLAG_CC1 uses a bitwise AND. Here you may want to look up bitwise operations to see what this means. In an AND if corresponding bits are true (1) then the AND is true (1). Otherwise, the AND is false. So TIM3->SR1 & TIM3_FLAG_CC will be true if any corresponding true bits (1) in TIM3->SR1 and TIM3_FLAG_C are true. If none of the bits match, the expression is false (0).
101
110
---AND
100 result is true (not 0)