Hello, for my EFM32LG controller i have a line shown bellow.From the reference table shown in the end we see the sub properties of STATUS
also i know that <<6 mean multiply by 2^6
What is the logic of this line?
Thanks.
if(USART1->STATUS & (1 << 7)) { // if RX buffer contains valid data
rx_char = USART1->RXDATA; // store the data
}
if(rx_char) { // if we have a valid character
if(USART1->STATUS & (1 << 6)) { // check if TX buffer is empty
USART1->TXDATA = rx_char; // echo received char
rx_char = 0; // reset temp variable
}
}
It means what USART1 is pointing to, presumably the address of a register in the MCU, is logic ANDed with the value 0b00100000.
The (1 <<6) notation is rather pointless, it just means a number where a '1' has been shifted six places to the left. It is more normally used like (1 << BitName) so the program is more understandable. For example, using the table in your post you could write (1 << TXBL).