31#define SerialPort ConnectorUsb
36MotorDriver *motorConnectors[] = {&ConnectorM0, &ConnectorM1,
37 &ConnectorM2, &ConnectorM3
39char motorConnectorNames[][4] = {
"M-0",
"M-1",
"M-2",
"M-3" };
40uint8_t motorConnectorCount = 4;
46char *ReadyStateString(MotorDriver::MotorReadyStates readyState);
53 SerialPort.Mode(Connector::USB_CDC);
54 SerialPort.Speed(baudRate);
55 uint32_t timeout = 5000;
57 SerialPort.PortOpen();
58 while (!SerialPort &&
Milliseconds() - startTime < timeout) {
64 for (uint8_t i = 0; i < motorConnectorCount; i++) {
65 MotorDriver *motor = motorConnectors[i];
66 volatile const MotorDriver::StatusRegMotor &statusReg = motor->StatusReg();
67 volatile const MotorDriver::AlertRegMotor &alertReg = motor->AlertReg();
69 SerialPort.Send(
"Motor status register for motor M");
71 SerialPort.Send(
": ");
72 SerialPort.SendLine(statusReg.reg, 2);
74 SerialPort.Send(
"AtTargetPosition: ");
75 SerialPort.SendLine(statusReg.bit.AtTargetPosition);
77 SerialPort.Send(
"StepsActive: ");
78 SerialPort.SendLine(statusReg.bit.StepsActive);
80 SerialPort.Send(
"AtTargetVelocity: ");
81 SerialPort.SendLine(statusReg.bit.AtTargetVelocity);
83 SerialPort.Send(
"MoveDirection: ");
84 SerialPort.SendLine(statusReg.bit.MoveDirection);
86 SerialPort.Send(
"MotorInFault: ");
87 SerialPort.SendLine(statusReg.bit.MotorInFault);
89 SerialPort.Send(
"Enabled: ");
90 SerialPort.SendLine(statusReg.bit.Enabled);
92 SerialPort.Send(
"PositionalMove: ");
93 SerialPort.SendLine(statusReg.bit.PositionalMove);
95 SerialPort.Send(
"HLFB State: ");
96 switch (statusReg.bit.HlfbState) {
98 SerialPort.SendLine(
"HLFB_DEASSERTED");
101 SerialPort.SendLine(
"HLFB_ASSERTED");
104 SerialPort.SendLine(
"HLFB_HAS_MEASUREMENT");
107 SerialPort.SendLine(
"HLFB_UNKNOWN");
111 SerialPort.SendLine(
"???");
114 SerialPort.Send(
"AlertsPresent: ");
115 SerialPort.SendLine(statusReg.bit.AlertsPresent);
117 SerialPort.Send(
"Ready state: ");
118 switch (statusReg.bit.ReadyState) {
119 case MotorDriver::MOTOR_DISABLED:
120 SerialPort.SendLine(
"Disabled");
122 case MotorDriver::MOTOR_ENABLING:
123 SerialPort.SendLine(
"Enabling");
125 case MotorDriver::MOTOR_FAULTED:
126 SerialPort.SendLine(
"Faulted");
128 case MotorDriver::MOTOR_READY:
129 SerialPort.SendLine(
"Ready");
131 case MotorDriver::MOTOR_MOVING:
132 SerialPort.SendLine(
"Moving");
136 SerialPort.SendLine(
"???");
139 SerialPort.Send(
"Triggering: ");
140 SerialPort.SendLine(statusReg.bit.Triggering);
142 SerialPort.Send(
"InPositiveLimit: ");
143 SerialPort.SendLine(statusReg.bit.InPositiveLimit);
145 SerialPort.Send(
"InNegativeLimit: ");
146 SerialPort.SendLine(statusReg.bit.InNegativeLimit);
148 SerialPort.Send(
"InEStopSensor: ");
149 SerialPort.SendLine(statusReg.bit.InEStopSensor);
151 SerialPort.SendLine(
"--------------------------------");
154 if (statusReg.bit.AlertsPresent){
155 SerialPort.Send(
"Alert register: ");
156 SerialPort.SendLine(alertReg.reg, 2);
158 SerialPort.Send(
"MotionCanceledInAlert: ");
159 SerialPort.SendLine(alertReg.bit.MotionCanceledInAlert);
161 SerialPort.Send(
"MotionCanceledPositiveLimit: ");
162 SerialPort.SendLine(alertReg.bit.MotionCanceledPositiveLimit);
164 SerialPort.Send(
"MotionCanceledNegativeLimit: ");
165 SerialPort.SendLine(alertReg.bit.MotionCanceledNegativeLimit);
167 SerialPort.Send(
"MotionCanceledSensorEStop: ");
168 SerialPort.SendLine(alertReg.bit.MotionCanceledSensorEStop);
170 SerialPort.Send(
"MotionCanceledMotorDisabled: ");
171 SerialPort.SendLine(alertReg.bit.MotionCanceledMotorDisabled);
173 SerialPort.Send(
"MotorFaulted: ");
174 SerialPort.SendLine(alertReg.bit.MotorFaulted);
176 SerialPort.SendLine(
"--------------------------------");
196char *ReadyStateString(MotorDriver::MotorReadyStates readyState) {
197 switch (readyState) {
198 case MotorDriver::MOTOR_DISABLED:
199 return (
char *)
"Disabled";
200 case MotorDriver::MOTOR_ENABLING:
201 return (
char *)
"Enabling";
202 case MotorDriver::MOTOR_FAULTED:
203 return (
char *)
"Faulted";
204 case MotorDriver::MOTOR_READY:
205 return (
char *)
"Ready";
206 case MotorDriver::MOTOR_MOVING:
207 return (
char *)
"Moving";
210 return (
char *)
"???";
void Delay_ms(uint32_t ms)
Blocks operations for ms milliseconds.
Definition SysTiming.h:287
uint32_t Milliseconds(void)
Number of milliseconds since the ClearCore was initialized.