#include <sys/ioctl.h>
#include <linux/types.h>
#include <linux/spi/spidev.h>
+#include <string.h>
#include "rp_spi.h" /*struct rpi_in */
.bits_per_word = bits,
};
+ memset(&in,0,sizeof(in));
+
ret = ioctl(fd, SPI_IOC_MESSAGE(1), &tr);
/*vypisovani prichozich dat */
*/
/*uprava endianity pozice*/
- uint8_p=(uint8_t*)&in.pozice;
+ uint8_p=(uint8_t*)&in.pozice_raw;
/* x86 je Little-Endian */
uint8_p[0]=rx[3]; /* LSB */
uint8_p[1]=rx[2];
uint8_p[2]=rx[1];
uint8_p[3]=rx[0]; /*MSB*/ /*with sign bit*/
- uint8_p[4]=uint8_p[5]=uint8_p[6]=uint8_p[7]=0;
/*halove sondy
* hal1 - bit95
in.hal2=!!(0x40 & rx[4]);
in.hal3=!!(0x20 & rx[4]);
- /*pwm enable
- * en1 - bit92
- * en2 - bit91
- * en2 - bit90
- */
- in.en1=!!(0x10 & rx[4]);
- in.en2=!!(0x08 & rx[4]);
- in.en3=!!(0x04 & rx[4]);
-
- /*shutdown
- * shdn1 - bit89
- * shdn2 - bit88
- * shdn3 - bit87
+ /* index position
+ * bits 92 downto 81
+ * 92..88 in rx[4] last 5 bits (from left)
+ * 87..81 in rx[5] first 7 bits (from left)
*/
- in.shdn1=!!(0x02 & rx[4]);
- in.shdn2=!!(0x01 & rx[4]);
- in.shdn3=!!(0x80 & rx[5]);
+ in.index_position=0x1F & rx[4];
+ in.index_position<<=8;
+ in.index_position|=0xFE & rx[5];
+ in.index_position>>=1;
/* current measurments count
* bits 80 downto 72