Hello !
I've another question about merging 2 bytes. I was watching tutorials on youtube about STM32 and saw this part of the code :

The buffer was initially with uint8_t (uint8_t but[12]) that's how it was on the video. Although I don't understand how to read this part of the code ?
I can see that int16_t is only next to buf[0] and there is nothing next to buf[1]. And I know that there is arithmetic shift by 4 to left for buf[0] and by 4 to right for buf[1].
I know that's how arithmetic shift looks like this for 8 bit data :

So shifting by 4 to the right or left changes the data that was in 8 bits or does it magically change the size of buf ? I don't know how it looks like here exactly.
Also does the buffer at the end resets to uint8_t ? Or what ?
I've another question about merging 2 bytes. I was watching tutorials on youtube about STM32 and saw this part of the code :

The buffer was initially with uint8_t (uint8_t but[12]) that's how it was on the video. Although I don't understand how to read this part of the code ?
I can see that int16_t is only next to buf[0] and there is nothing next to buf[1]. And I know that there is arithmetic shift by 4 to left for buf[0] and by 4 to right for buf[1].
I know that's how arithmetic shift looks like this for 8 bit data :

So shifting by 4 to the right or left changes the data that was in 8 bits or does it magically change the size of buf ? I don't know how it looks like here exactly.
Also does the buffer at the end resets to uint8_t ? Or what ?





