From: Pavel Pisa Date: Tue, 12 May 2015 09:02:12 +0000 (+0200) Subject: RPi PXMC Test: adapt PWM position in SPI send data according to FPGA design update. X-Git-Url: http://rtime.felk.cvut.cz/gitweb/fpga/rpi-motor-control-pxmc.git/commitdiff_plain/cbfe6898e662f5f539eae7020bf3f4a497cfef2f RPi PXMC Test: adapt PWM position in SPI send data according to FPGA design update. Signed-off-by: Pavel Pisa --- diff --git a/src/app/rpi-pmsm-test1/rpi_spi.c b/src/app/rpi-pmsm-test1/rpi_spi.c index 1976449..084c361 100644 --- a/src/app/rpi-pmsm-test1/rpi_spi.c +++ b/src/app/rpi-pmsm-test1/rpi_spi.c @@ -37,7 +37,6 @@ int spimc_transfer(spimc_state_t *spimcst) uint8_t *tx = spimcst->tx_buf; uint8_t *rx = spimcst->rx_buf; int ret; - uint16_t tmp; uint32_t pwm1, pwm2, pwm3; memset(tx, 0, SPIMC_TRANSFER_SIZE); @@ -69,12 +68,9 @@ int spimc_transfer(spimc_state_t *spimcst) * bit 122 - shutdown2 * bit 121 - shutdown3 * . - * . - * . - * bits 66 .. 56 - match PWM1 - * bits 55 .. 45 - match PWM2 - * bit 11,12 - Unused - * bits 42 .. 32 - match PWM3 + * bits 47 .. 32 - match PWM1 + * bits 31 .. 16 - match PWM2 + * bits 15 .. 0 - match PWM3 */ pwm1 = spimcst->pwm[0]; @@ -105,18 +101,16 @@ int spimc_transfer(spimc_state_t *spimcst) if (pwm3 > 2047) pwm3 = 2047; /*pwm1*/ - tx[7]=(tx[7] & 0xF8) | (0x07 & ((uint8_t*)&pwm1)[1]); /*MSB*/ - tx[8]=((uint8_t*)&pwm1)[0]; /*LSB*/ + tx[10] = pwm1 >> 8; /*MSB*/ + tx[11] = pwm1 & 0xff; /*LSB*/ /*pwm2*/ - tmp=pwm2; - tmp<<=5; - tx[9]=((uint8_t*)&tmp)[1]; /*MSB*/ - tx[10]=(tx[10] & 0x1F) | (0xE0 & ((uint8_t*)&tmp)[0]); /*LSB*/ + tx[12] = pwm2 >> 8; /*MSB*/ + tx[13] = pwm2 & 0xff; /*LSB*/ /*pwm3*/ - tx[10]=(tx[10] & 0xF8) | (0x07 & ((uint8_t*)&pwm3)[1]); /*MSB*/ - tx[11]=((uint8_t*)&pwm3)[0]; /*LSB*/ + tx[14] = pwm3 >> 8; /*MSB*/ + tx[15] = pwm3 & 0xff; /*LSB*/ struct spi_ioc_transfer tr = { .tx_buf = (uintptr_t)tx,