]> rtime.felk.cvut.cz Git - fpga/lx-cpu1/lx-rocon.git/blob - hw/lx-rocon_firmware/pxmcc_types.h
RoCoN and TUMBL firmware: reimplemented control of stepper motor without feedback.
[fpga/lx-cpu1/lx-rocon.git] / hw / lx-rocon_firmware / pxmcc_types.h
1 /*******************************************************************
2   Components for embedded applications builded for
3   laboratory and medical instruments firmware
4
5   pxmcc_types.h - multi axis motion controller coprocessor
6         for FPGA tumble CPU of lx-rocon system - data types
7
8   (C) 2001-2014 by Pavel Pisa pisa@cmp.felk.cvut.cz
9   (C) 2002-2014 by PiKRON Ltd. http://www.pikron.com
10
11   This file can be used and copied according to next
12   license alternatives
13    - GPL - GNU Public License
14    - other license provided by project originators
15
16  *******************************************************************/
17
18 #ifndef _PXMCC_TYPES_H_
19 #define _PXMCC_TYPES_H_
20
21 #include <stdint.h>
22
23 #define PXMCC_FWVERSION       0xACCE0001
24 #define PXMCC_AXIS_COUNT      4
25 #define PXMCC_CURADC_CHANNELS 16
26
27 #define PXMCC_MODE_IDLE              2
28 #define PXMCC_MODE_BLDC              0
29 #define PXMCC_MODE_STEPPER_WITH_IRC  1
30 #define PXMCC_MODE_STEPPER           3
31
32 typedef struct pxmcc_common_data_t {
33   uint32_t  fwversion;
34   uint32_t  pwm_cycle;
35   uint32_t  act_idle;
36   uint32_t  min_idle;
37   uint32_t  rx_done_sqn;
38   uint32_t  irc_base;
39 } pxmcc_common_data_t;
40
41 typedef struct pxmcc_axis_data_t {
42   uint32_t  ccflg;
43   uint32_t  mode;
44   uint32_t  pwm_dq;     /* D and Q components of PWM (pwm_d << 16) | (pwm_q) & 0xffff */
45   uint32_t  cur_dq;     /* D and Q components current (cur_d << 16) | (cur_q) & 0xffff */
46   uint32_t  ptindx;     /* index into phase table / irc in the cycle */
47   uint32_t  ptirc;      /* IRC count per phase table */
48   uint32_t  ptreci;     /* Reciprocal value of ptirc * 63356  */
49   uint32_t  ptofs;      /* offset between table and IRC counter */
50   int32_t   ptsin;
51   int32_t   ptcos;
52   uint32_t  ptphs;
53   uint32_t  cur_d_cum;
54   uint32_t  cur_q_cum;
55   uint32_t  inp_info;   /* which irc to use */
56   uint32_t  out_info;   /* output index */
57   uint32_t  pwmtx_info; /* offsets of pwm1 .. pwm4 from FPGA_LX_MASTER_TX */
58   uint32_t  pwm_prew[4];
59   uint32_t  steps_inc;  /* increments for selfgenerated stepper motor */
60   uint32_t  steps_pos;  /* self generated position for stepper motor */
61   uint32_t  steps_sqn_next; /* when to apply steps_inc_next */
62   uint32_t  steps_inc_next; /* increment to apply at steps_sqn_next */
63   uint32_t  steps_pos_next; /* base position to apply at steps_sqn_next */
64 } pxmcc_axis_data_t;
65
66 typedef struct pxmcc_curadc_data_t {
67   int32_t   cur_val;
68   int32_t   siroladc_offs;
69   uint32_t  siroladc_last;
70 } pxmcc_curadc_data_t;
71
72 typedef struct pxmcc_data_t {
73   pxmcc_common_data_t common;
74   pxmcc_axis_data_t   axis[PXMCC_AXIS_COUNT];
75   pxmcc_curadc_data_t curadc[PXMCC_CURADC_CHANNELS];
76 } pxmcc_data_t;
77
78 #endif /*_PXMCC_TYPES_H_*/