From 06b1a193c87d7055643e48b1bd56f59c8e7fa519 Mon Sep 17 00:00:00 2001 From: Martin Prudek Date: Wed, 15 Apr 2015 20:31:58 +0200 Subject: [PATCH] Bit positioning description changed after switching to 128-bit SPI. --- pmsm-control/test_sw/rp_spi.c | 57 +++++++++++++++-------------------- 1 file changed, 25 insertions(+), 32 deletions(-) diff --git a/pmsm-control/test_sw/rp_spi.c b/pmsm-control/test_sw/rp_spi.c index a1de3ce..57a2122 100644 --- a/pmsm-control/test_sw/rp_spi.c +++ b/pmsm-control/test_sw/rp_spi.c @@ -97,18 +97,22 @@ struct rpi_in spi_read(uint8_t * tx) /*/ /*prichozi data: - * rx[0] - bity 95 downto 88 - bits, that come first - * rx[1] - bity 87 downto 80 - * rx[2] - bity 79 downto 72 - * rx[3] - bity 71 downto 64 - * rx[4] - bity 63 downto 56 - * rx[5] - bity 55 downto 48 - * rx[6] - bity 47 downto 40 - * rx[7] - bity 39 downto 32 - * rx[8] - bity 31 downto 24 - * rx[9] - bity 23 downto 16 - * rx[10] - bity 15 downto 8 - * rx[11] - bity 7 downto 0 + * rx[0] - bity 127 downto 120 + * rx[1] - bity 119 downto 112 + * rx[2] - bity 111 downto 104 + * rx[3] - bity 103 downto 96 + * rx[4] - bity 95 downto 88 + * rx[5] - bity 87 downto 80 + * rx[6] - bity 79 downto 72 + * rx[7] - bity 71 downto 64 + * rx[8] - bity 63 downto 56 + * rx[9] - bity 55 downto 48 + * rx[10] - bity 47 downto 40 + * rx[11] - bity 39 downto 32 + * rx[12] - bity 31 downto 24 + * rx[13] - bity 23 downto 16 + * rx[14] - bity 15 downto 8 + * rx[15] - bity 7 downto 0 */ /*uprava endianity pozice*/ @@ -121,27 +125,27 @@ struct rpi_in spi_read(uint8_t * tx) uint8_p[4]=uint8_p[5]=uint8_p[6]=uint8_p[7]=0; /*halove sondy - * hal1 - bit63 - * hal2 - bit62 - * hal3 - bit61 + * hal1 - bit95 + * hal2 - bit94 + * hal3 - bit93 */ in.hal1=!!(0x80 & rx[4]); in.hal2=!!(0x40 & rx[4]); in.hal3=!!(0x20 & rx[4]); /*pwm enable - * en1 - bit60 - * en2 - bit59 - * en2 - bit58 + * en1 - bit92 + * en2 - bit91 + * en2 - bit90 */ in.en1=!!(0x10 & rx[4]); in.en2=!!(0x08 & rx[4]); in.en3=!!(0x04 & rx[4]); /*shutdown - * shdn1 - bit57 - * shdn2 - bit56 - * shdn3 - bit55 + * shdn1 - bit89 + * shdn2 - bit88 + * shdn3 - bit87 */ in.shdn1=!!(0x02 & rx[4]); in.shdn2=!!(0x01 & rx[4]); @@ -170,17 +174,6 @@ struct rpi_in spi_read(uint8_t * tx) in.b37=!!(0x20 & rx[7]); in.b36=!!(0x10 & rx[7]); - /** currents - * ch0 - bits 35 downto 24 - * 35..32 in rx[7] - last 4 - * 31..24 in rx[8] - all bytte - * ch1 - bits 23 downto 12 - * 23..16 in rx[9] - all byte - * 15..12 in rx[10] - first 4 - * ch2 - bits 11 downto 0 - * 11..8 in rx[10] - last 4 - * 7..0 in rx[11] - all byte - */ in.ch0=0x0F & rx[7]; in.ch0<<=8; -- 2.39.2