Hi,
Did you read the documentation for both HAL functions?
I did not .... but from a first view I don't think you use them correctly.
For reading a pin you usually need:
* to tell the port
* to tell which pin of the port
* a variable where to store the result ..... this is what I miss
All three of them need to match the function description
***
All in all I don't understand your concept.
I guess you did not draw a flow chart. If you did: show it. If you did not: then do it now, and show it. No need to be fancy, paper and pencil will do.
What your code does:
* Read a pins state .... but immediately dismiss the result
* in best case it sends out some random characters via UART. (Here you try to send something before you received it)
* you write a pin with the random contents of a variable... before you filled the variable with meaningful content. I'm not sure whether you use the right type of variable.
* next you try to receive data from the UART into a variable. The same variable that you used before to send to the output port.
"You try" ... because you used the non blocking "...RECEIVE_IT" function. It immediatly comes back and does not wait for a character to be received.
* next you initialise a variable ... no idea why
* then you (busy) wait 100 ms. ... no idea why
* then you do all the above in a loop
It all makes no sense.
Variables/values.
* a pin has two states: HIGH or LOW (TRUE/ FALSE), thus it makes sense to use a "BOOLEAN" type variable
* a UART character usually is a byte, it has 256 states. It makes sense to use a CHAR type variable.
(technically both variable may be stored in a byte ... but you need to be aware of their according states, the range and the meaning)
* usually when sending a BOOL variable over UART, you should translate (or cast) it into the CHAR variable (or array of chars)
* HOW you need to translate depends on what you want to receive at the other end of the UART. Please tell us.
Klaus