]> rtime.felk.cvut.cz Git - fpga/rpi-motor-control-pxmc.git/blob - src/app/rpi-pmsm-test1/pxmc_spimc.h
RPi PXMC Test: adapt PWM position in SPI send data according to FPGA design update.
[fpga/rpi-motor-control-pxmc.git] / src / app / rpi-pmsm-test1 / pxmc_spimc.h
1 #ifndef _PXMC_SPIMC_H
2 #define _PXMC_SPIMC_H
3
4 #include <stdint.h>
5
6 #define SPIMC_TRANSFER_SIZE 16
7 #define SPIMC_CHAN_COUNT    3
8
9 #define SPIMC_PWM_VALUE_m   0x0ffff
10 #define SPIMC_PWM_ENABLE    0x10000
11 #define SPIMC_PWM_SHUTDOWN  0x20000
12
13 typedef struct spimc_state_t {
14   char     *spi_dev;
15   int      spi_fd;
16   uint32_t pwm[SPIMC_CHAN_COUNT];
17   uint32_t act_pos;
18   uint32_t index_pos;
19   uint32_t pos_offset;
20   int32_t  curadc_val[SPIMC_CHAN_COUNT];
21   int32_t  curadc_offs[SPIMC_CHAN_COUNT];
22   uint8_t  hal_sensors;
23   uint16_t curadc_sqn;
24   uint16_t curadc_sqn_last;
25   uint32_t curadc_cumsum[SPIMC_CHAN_COUNT];
26   uint32_t curadc_cumsum_last[SPIMC_CHAN_COUNT];
27   uint8_t tx_buf[SPIMC_TRANSFER_SIZE];
28   uint8_t rx_buf[SPIMC_TRANSFER_SIZE];
29 } spimc_state_t;
30
31 int spimc_init(spimc_state_t *spimcst);
32
33 int spimc_transfer(spimc_state_t *spimcst);
34
35 #endif /*_PXMC_SPIMC_H*/