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>>
); //send msbyte address first
spi_transfer((char)(eeprom_address));
why (char) put there? i have never seen syntax before.
spi_transfer((char)[/b](eeprom_address>>
); //send msbyte address firstspi_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
Post a Comment