Added reading of irc_index position.
[fpga/rpi-motor-control.git] / pmsm-control / test_sw / rp_spi.c
index 056cb5d..bbe8225 100644 (file)
@@ -120,7 +120,6 @@ struct rpi_in spi_read(uint8_t * tx)
        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
@@ -131,23 +130,15 @@ struct rpi_in spi_read(uint8_t * tx)
        in.hal2=!!(0x40 & rx[4]);
        in.hal3=!!(0x20 & rx[4]);
 
-       /*pwm enable
-        * en1 - bit92
-        * en2 - bit91
-        * en2 - bit90
+       /* 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.en1=!!(0x10 & rx[4]);
-       in.en2=!!(0x08 & rx[4]);
-       in.en3=!!(0x04 & rx[4]);
-
-       /*shutdown
-        * shdn1 - bit89
-        * shdn2 - bit88
-        * shdn3 - bit87
-        */
-       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