#include "ClearCore.h"
#define baudRate 9600
#define SerialPort ConnectorUsb
int main() {
SerialPort.Mode(Connector::USB_CDC);
SerialPort.Speed(baudRate);
uint32_t timeout = 5000;
SerialPort.PortOpen();
while (!SerialPort &&
Milliseconds() - startTime < timeout) {
continue;
}
while (true) {
SerialPort.SendLine("Status Register:");
SerialPort.Send("Vsupply over-voltage:\t\t");
if (statusReg.bit.VSupplyOverVoltage) {
SerialPort.SendLine('1');
}
else {
SerialPort.SendLine('0');
}
SerialPort.Send("Vsupply under-voltage:\t\t");
if (statusReg.bit.VSupplyUnderVoltage) {
SerialPort.SendLine('1');
}
else {
SerialPort.SendLine('0');
}
SerialPort.Send("H-Bridge output overloaded:\t");
if (statusReg.bit.HBridgeOverloaded) {
SerialPort.SendLine('1');
}
else {
SerialPort.SendLine('0');
}
SerialPort.Send("H-Bridge resetting:\t\t");
if (statusReg.bit.HBridgeReset) {
SerialPort.SendLine('1');
}
else {
SerialPort.SendLine('0');
}
SerialPort.Send("Offboard 5V overloaded:\t\t");
if (statusReg.bit.Overloaded5V) {
SerialPort.SendLine('1');
}
else {
SerialPort.SendLine('0');
}
SerialPort.Send("Output overloaded:\t\t");
if (statusReg.bit.OutputOverloaded) {
SerialPort.SendLine('1');
}
else {
SerialPort.SendLine('0');
}
SerialPort.Send("CCIO-8 output overloaded:\t");
if (statusReg.bit.CcioOverloaded) {
SerialPort.SendLine('1');
}
else {
SerialPort.SendLine('0');
}
SerialPort.Send("CCIO-8 link broken:\t\t");
if (statusReg.bit.CcioLinkBroken) {
SerialPort.SendLine('1');
}
else {
SerialPort.SendLine('0');
}
SerialPort.Send("ADC in timeout:\t\t\t");
if (statusReg.bit.AdcTimeout) {
SerialPort.SendLine('1');
}
else {
SerialPort.SendLine('0');
}
SerialPort.Send("Ethernet disconnect:\t\t");
if (statusReg.bit.EthernetDisconnect) {
SerialPort.SendLine('1');
}
else {
SerialPort.SendLine('0');
}
SerialPort.Send("Ethernet remote fault:\t\t");
if (statusReg.bit.EthernetRemoteFault) {
SerialPort.SendLine('1');
}
else {
SerialPort.SendLine('0');
}
SerialPort.Send("SD card error:\t\t\t");
if (statusReg.bit.SdCardError) {
SerialPort.SendLine('1');
}
else {
SerialPort.SendLine('0');
}
SerialPort.SendLine("------------------------");
}
}