-
Notifications
You must be signed in to change notification settings - Fork 1
/
stm32-protocol_txt.txt
153 lines (127 loc) · 4.56 KB
/
stm32-protocol_txt.txt
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
remarks:
u16, etc.: MSB first
a bool|b bool: 000000ab
commands:
VERSION_REQ u8
--> VERSION_REP u8, uc_id u96, hw_version u8, sw_version u8
(asynchronous)
--> SHUTDOWN u8
(asynchronous)
--> EMERGENCY_STOP u8
EMERGENCY_ACTION u8, activate bool
--> (status codes)
EMERGENCY_REQ u8
--> EMERGENCY_REP u8, active bool
IO_CONFIG u8, port u8, on bool|pulldown bool|pullup bool|output bool
--> (status codes)
ANALOG_REQ u8, port u8
--> ANALOG_REP u8, port u8, value u16
--> (error codes)
IMU_RATE_REQ u8
--> IMU_RATE_REP u8, x s16, y s16, z s16
IMU_ACCEL_REQ u8
--> IMU_ACCEL_REP u8, x s16, y s16, z s16
IMU_POSE_REQ u8
--> IMU_POSE_REP u8, x s16, y s16, z s16
DIGITAL_REQ u8, port u8
--> DIGITAL_REP u8, port u8, value bool
--> (error codes)
MOTOR u8, port u8, mode u8, amount s16
--> (status codes)
MOTOR_POSITIONAL u8, port u8, mode u8, amount s16, relative bool|done_mode u7, position s32
--> (status codes)
MOTOR_SERVO u8, port u8, max_velocity u16, relative bool, position s32
--> (status codes)
MOTOR_CONFIG_DC u8, port u8
--> (status codes)
MOTOR_CONFIG_ENCODER u8, port u8, encoder_a_port u8, encoder_b_port u8
--> (status codes)
MOTOR_CONFIG_STEPPER u8, port u8
--> (status codes)
(asynchronous)
--> MOTOR_DONE_UPDATE u8, port u8
SERVO u8, port u8, active bool|value u15
--> (status codes)
UART u8, length u8, data u8{length}
--> (status codes)
(asynchronous)
--> UART_UPDATE u8, length u8, data u8{length}
SPEAKER u8, frequency u16
--> (status codes)
status codes:
OK u8
UNKNOWN_OPCODE u8
- the opcode is unknown and the connection needs to be reset
INVALID_OPCODE u8
- the opcode is known and is decoded properly, but can't be handled
INVALID_PORT u8
- port out of range
- invalid port for stepper motor mode: only even port n is valid, odd port n+1 is affected as well
INVALID_CONFIG u8
- POWER(with value!=0)/BRAKE command for stepper motor
- VELOCITY command for DC motor
- IO_STATE command for encoder io port
- motor command for auxiliary stepper motor port
INVALID_MODE u8
- mode is not POWER, BRAKE, VELOCITY
INVALID_FLAGS u8
- (io_flags & ~0x1F) != 0x00
- invalid combination: OUTPUT & PULLUP/PULLDOWN; INPUT & ON; PULLUP & PULLDOWN
INVALID_VALUE u8
- MOTOR/SERVO value out of range
codes:
command opcodes:
VERSION_REQ 0x01
EMERGENCY_ACTION 0x05
EMERGENCY_REQ 0x06
IO_CONFIG 0x10
ANALOG_REQ 0x20
IMU_RATE_REQ 0x22
IMU_ACCEL_REQ 0x23
IMU_POSE_REQ 0x24
DIGITAL_REQ 0x30
MOTOR 0x40
MOTOR_POSITIONAL 0x41
MOTOR_SERVO 0x42
MOTOR_CONFIG_DC 0x48
MOTOR_CONFIG_ENCODER 0x49
MOTOR_CONFIG_STEPPER 0x4A
SERVO 0x50
UART 0x60
SPEAKER 0x70
reply opcodes:
VERSION_REP 0x02
EMERGENCY_REP 0x07
OK 0x80
UNKNOWN_OPCODE 0x81
INVALID_OPCODE 0x82
INVALID_PORT 0x83
INVALID_CONFIG 0x84
INVALID_MODE 0x85
INVALID_FLAGS 0x86
INVALID_VALUE 0x87
FAIL_EMERG_ACT 0x88
ANALOG_REP 0xA1
IMU_RATE_REP 0xA2
IMU_ACCEL_REP 0xA3
IMU_POSE_REP 0xA4
DIGITAL_REP 0xB1
update opcodes:
SHUTDOWN 0x03
EMERGENCY_STOP 0x04
MOTOR_DONE_UPDATE 0xC3
UART_UPDATE 0xE1
number analog and digital ports together, servo and motor ports separately
special analog ports:
BATTERY_VOLTAGE 0x80
special digital ports (output only):
LED0 0x90
LED1 0x91
motor & motor_positional modes:
POWER 0x00
BRAKE 0x01
VELOCITY 0x02
motor_positional done_modes:
OFF 0x00
BRAKE 0x01
ACTIVE_BRAKE 0x02