36#define CcioPort ConnectorCOM0
39#define SerialPort ConnectorUsb
43const bool inputMode =
true;
45uint8_t ccioBoardCount;
53char msg[MAX_MSG_LEN + 1];
57 SerialPort.Mode(Connector::USB_CDC);
58 SerialPort.Speed(baudRate);
59 uint32_t timeout = 5000;
61 SerialPort.PortOpen();
62 while (!SerialPort &&
Milliseconds() - startTime < timeout) {
67 CcioPort.Mode(Connector::CCIO);
77 snprintf(msg, MAX_MSG_LEN,
"Discovered %d CCIO-8 board", ccioBoardCount);
80 if (ccioBoardCount != 1) {
83 SerialPort.SendLine(
"...");
84 SerialPort.SendLine();
89 for (uint8_t ccioPinIndex = 0; ccioPinIndex < ccioPinCount; ccioPinIndex++) {
91 ccioPinIndex))->
Mode(Connector::OUTPUT_DIGITAL);
99 SerialPort.SendLine(
"The CCIO-8 link is broken!");
103 SerialPort.SendLine(
"The CCIO-8 link is still broken!");
107 SerialPort.SendLine(
"The CCIO-8 link is online again!");
112 uint8_t newBoardCount = CcioMgr.
CcioCount();
113 if (ccioBoardCount != newBoardCount) {
114 snprintf(msg, MAX_MSG_LEN,
"CCIO-8 board count changed from %d to %d.",
115 ccioBoardCount, newBoardCount);
116 SerialPort.SendLine(msg);
118 ccioBoardCount = newBoardCount;
131 snprintf(msg, MAX_MSG_LEN,
"CCIO-A%d: ", ccioPinIndex);
132 SerialPort.Send(msg);
135 SerialPort.SendLine(
"ON");
138 SerialPort.SendLine(
"OFF");
145 snprintf(msg, MAX_MSG_LEN,
"All CCIO-8 Inputs: 0x%0*llX",
147 SerialPort.SendLine(msg);
151 snprintf(msg, MAX_MSG_LEN,
"CCIO-8 Input Rise: 0x%0*llX",
153 SerialPort.SendLine(msg);
154 snprintf(msg, MAX_MSG_LEN,
"CCIO-8 Input Fall: 0x%0*llX",
156 SerialPort.SendLine(msg);
158 SerialPort.SendLine(
"---------------------");
165 SerialPort.SendLine(
"Writing digital HIGH to each CCIO-8 connector...");
167 for (uint8_t ccioPinIndex = 0; ccioPinIndex < ccioPinCount; ccioPinIndex++) {
173 SerialPort.SendLine(
"Writing digital LOW to each CCIO-8 connector...");
175 for (int8_t ccioPinIndex = ccioPinCount - 1; ccioPinIndex >= 0; ccioPinIndex--) {
#define CCIO_PINS_PER_BOARD
Definition CcioBoardManager.h:46
ClearCorePins
ClearCore PIN definitions.
Definition SysConnectors.h:54
@ CLEARCORE_PIN_CCIOA0
CCIO-8 board 1, connector 0.
Definition SysConnectors.h:89
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.
uint64_t InputsRisen(uint64_t mask=UINT64_MAX)
Clear on read accessor for rising input edges.
CcioPin * PinByIndex(ClearCorePins connectorIndex)
Accessor for the individual CCIO-8 pin connectors.
volatile const uint8_t & CcioCount()
Accessor for the number of CCIO-8 boards connected to the ClearCore.
Definition CcioBoardManager.h:246
volatile const uint64_t & InputState()
Accessor for all the CCIO-8 pins' filtered input states.
Definition CcioBoardManager.h:349
uint64_t InputsFallen(uint64_t mask=UINT64_MAX)
Clear on read accessor for falling input edges.
volatile const bool & LinkBroken()
Accessor for the CCIO-8 link status.
Definition CcioBoardManager.h:261
int16_t State() override
In input mode, get the connector's last filtered sampled value. In output mode, get the connector's o...
virtual ConnectorModes Mode() override
Get the connector's operational mode.
Definition CcioPin.h:71