-
Notifications
You must be signed in to change notification settings - Fork 12
/
datatypes.h
executable file
·101 lines (91 loc) · 1.84 KB
/
datatypes.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#ifndef _DATATYPES_H_
#define _DATATYPES_H_
#include "ch.h"
typedef enum
{
STOPPED,
RUNNING,
TONE,
INDUCTANCE_MEASURE
} ControllerState;
typedef enum
{
NONE,
CURRENT,
DUTY_CYCLE,
SPEED,
POWER
} ControllerMode;
typedef enum
{
NO_FAULT,
UNDERVOLTAGE,
OVERVOLTAGE,
OVERCURRENT,
TEMPERATURE
} ControllerFault;
typedef enum
{
AS5045B, // SSI, 12-bit angular, 10-bit incremental
AS5145B, // SSI, 12-bit angular, 12-bit incremental
AS5x47P, // SPI, 14-bit angular, 12-bit incremental
HALL,
SENSORLESS
} EncoderType;
typedef enum
{
CAN,
I2C,
UART,
PPM,
NUNCHUK,
NRF24,
NRF8001,
CUSTOM
} CommInterface;
typedef enum
{
SINUSOIDAL,
MIDPOINT_CLAMP,
TOP_CLAMP,
BOTTOM_CLAMP,
TOP_BOTTOM_CLAMP
} ZSMMode;
typedef struct
{
volatile uint8_t CANDeviceID;
volatile EncoderType encoderType;
volatile CommInterface commInterface;
volatile ZSMMode zsmMode;
volatile uint8_t polePairs;
volatile float encoderZero;
volatile bool encoderInverted;
volatile float pwmFrequency;
volatile float currentKp;
volatile float currentKi;
volatile float maxDuty;
volatile float maxCurrent;
volatile float pllKp;
volatile float pllKi;
volatile float speedKp;
volatile float speedKi;
volatile float speedKd;
volatile float motorResistance;
volatile float motorInductance;
volatile float motorFluxLinkage;
volatile float observerGain;
volatile bool forwardCAN;
volatile uint32_t CANStatusRate;
volatile bool sendStatusCAN;
} Config;
typedef enum
{
PACKET_CONNECT = 0x00,
PACKET_CONSOLE = 0x01,
PACKET_USB_OVERRIDE_START = 0x02,
PACKET_USB_OVERRIDE_END = 0x03,
PACKET_SET_DUTY_CYCLE = 0x04,
PACKET_SET_CURRENT = 0x05,
PACKET_GET_DATA = 0x06,
} PacketID;
#endif