unclear use of a function in spi tutorial (c synta


i understand in spi eeprom tutorial except use of spi_transfer(volatile char data) function:

spi_transfer((char)[/b](eeprom_address>>8));   //send msbyte address first
 spi_transfer((char)(eeprom_address));  

why (char) put there?  i have never seen syntax before.

in tutorial address 16bit number. spi_transfer() function expects 8bit numbers. char 8 bits wide. first call transfers high byte, second call low byte. char-cast throws away bits above 1-byte boundary. that's why in first call high byte shifted 8 bits right, "ordinary bytes" live, upper part tossed away , remaining data gets sent.


Arduino Forum > Forum 2005-2010 (read only) > Software > Syntax & Programs > unclear use of a function in spi tutorial (c synta


arduino

Comments

Popular posts from this blog

CAN'T INSTALL MAMBELFISH 1.5 FROM DIRECTORY - Joomla! Forum - community, help and support

error: expected initializer before 'void'

CPU load monitoring using GPIO and leds - Raspberry Pi Forums