write_spi(ROT_OUT);
//wait until we receive rot_out_value from SPI
uart_write(rot_out_value);
write_spi(YINCL_OUT);
//wait until we receive yincl_out_value from SPI
uart_write(yincl_out_value);
The sensor returns false values for ROT_OUT and YINCL_OUT commands. I started to dig into the problem and came to a conclusion that if we want to change the command (For example from ROT_OUT to YINCL_OUT), we must do like this :
//switch to ROT_OUT command
write_spi(ROT_OUT);
//small delay
delay_us(40);
write_spi(ROT_OUT);
//wait until we receive rot_out_value from SPI
uart_write(rot_out_value);
//switch to YINCL_OUT command
write_spi(YINCL_OUT);
//small delay
delay_us(40);
write_spi(YINCL_OUT);
//wait until we receive yincl_out_value from SPI
uart_write(yincl_out_value);
No comments:
Post a Comment