Serial Wombat Arduino Library

Loading...
Searching...
No Matches
SerialWombat.h
Go to the documentation of this file.
1#ifndef SERIAL_WOMBAT_H__
2#define SERIAL_WOMBAT_H__
3
4/*
5 Copyright 2020-2025 Broadwell Consulting Inc.
6
7"Serial Wombat" is a registered trademark of Broadwell Consulting Inc. in
8 the United States. See SerialWombat.com for usage guidance.
9
10 Permission is hereby granted, free of charge, to any person obtaining a
11 * copy of this software and associated documentation files (the "Software"),
12 * to deal in the Software without restriction, including without limitation
13 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
14 * and/or sell copies of the Software, and to permit persons to whom the
15 * Software is furnished to do so, subject to the following conditions:
16
17 The above copyright notice and this permission notice shall be included in
18 * all copies or substantial portions of the Software.
19
20 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
23 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
24 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
25 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
26 * OTHER DEALINGS IN THE SOFTWARE.
27*/
28
29#include <stdint.h>
30#include "Stream.h"
31//#include "Serial.h" // Using "" rather than <> for compatibility with Visual C++ simulation project
32#include "Wire.h"// Using "" rather than <> for compatibility with Visual C++ simulation project
33#include "Arduino.h"
34#ifndef INPUT
35#define INPUT 0x0
36#endif
37
38
41
42
43#include "SerialWombatErrors.h"
44
46#define SW_LE16(_a) (uint8_t)((_a) & 0xFF), (uint8_t)((_a) >>8)
47
49#define SW_LE32(_a) (uint8_t)((_a) & 0xFF), (uint8_t)((_a) >>8) , (uint8_t)((_a) >>16), (uint8_t)((_a) >>24)
50
51#define ARRAY_UINT32(_array,_index) ((((uint32_t) _array[_index +3])<<24) + (((uint32_t) _array[_index +2])<<16) + (((uint32_t) _array[_index +1])<<8) + _array[_index])
52#define SW18AB_LATEST_FIRMWARE 222
53#define SW08B_LATEST_FIRMWARE 222
54#define SW4B_LATEST_FIRMWARE 203
55
56 typedef enum
57{
58 SW_LOW = 0,
59 SW_HIGH = 1,
60 SW_INPUT = 2,
61}SerialWombatPinState_t;
62
63
65 enum class SerialWombatDataSource{
66
67 SW_DATA_SOURCE_PIN_0 = 0,
68 SW_DATA_SOURCE_PIN_1 = 1,
69 SW_DATA_SOURCE_PIN_2 = 2,
70 SW_DATA_SOURCE_PIN_3 = 3,
71 SW_DATA_SOURCE_PIN_4 = 4,
72 SW_DATA_SOURCE_PIN_5 = 5,
73 SW_DATA_SOURCE_PIN_6 = 6,
74 SW_DATA_SOURCE_PIN_7 = 7,
75 SW_DATA_SOURCE_PIN_8 = 8,
76 SW_DATA_SOURCE_PIN_9 = 9,
77 SW_DATA_SOURCE_PIN_10 = 10,
78 SW_DATA_SOURCE_PIN_11 = 11,
79 SW_DATA_SOURCE_PIN_12 = 12,
80 SW_DATA_SOURCE_PIN_13 = 13,
81 SW_DATA_SOURCE_PIN_14 = 14,
82 SW_DATA_SOURCE_PIN_15 = 15,
83 SW_DATA_SOURCE_PIN_16 = 16,
84 SW_DATA_SOURCE_PIN_17 = 17,
85 SW_DATA_SOURCE_PIN_18 = 18,
86 SW_DATA_SOURCE_PIN_19 = 19,
87// SW_DATA_SOURCE_PIN_20 = 20,
88// SW_DATA_SOURCE_PIN_21 = 21,
89// SW_DATA_SOURCE_PIN_22 = 22,
90// SW_DATA_SOURCE_PIN_23 = 23,
91// SW_DATA_SOURCE_PIN_24 = 24,
92// SW_DATA_SOURCE_PIN_25 = 25,
93// SW_DATA_SOURCE_PIN_26 = 26,
94// SW_DATA_SOURCE_PIN_27 = 27,
95// SW_DATA_SOURCE_PIN_28 = 28,
96// SW_DATA_SOURCE_PIN_29 = 29,
97// SW_DATA_SOURCE_PIN_30 = 30,
98// SW_DATA_SOURCE_PIN_31 = 31,
99// SW_DATA_SOURCE_PIN_32 = 32,
100// SW_DATA_SOURCE_PIN_33 = 33,
101// SW_DATA_SOURCE_PIN_34 = 34,
102// SW_DATA_SOURCE_PIN_35 = 35,
103// SW_DATA_SOURCE_PIN_36 = 36,
104// SW_DATA_SOURCE_PIN_37 = 37,
105// SW_DATA_SOURCE_PIN_38 = 38,
106// SW_DATA_SOURCE_PIN_39 = 39,
107// SW_DATA_SOURCE_PIN_40 = 40,
108// SW_DATA_SOURCE_PIN_41 = 41,
109// SW_DATA_SOURCE_PIN_42 = 42,
110// SW_DATA_SOURCE_PIN_43 = 43,
111// SW_DATA_SOURCE_PIN_44 = 44,
112// SW_DATA_SOURCE_PIN_45 = 45,
113// SW_DATA_SOURCE_PIN_46 = 46,
114// SW_DATA_SOURCE_PIN_47 = 47,
115// SW_DATA_SOURCE_PIN_48 = 48,
116// SW_DATA_SOURCE_PIN_49 = 49,
117// SW_DATA_SOURCE_PIN_50 = 50,
118// SW_DATA_SOURCE_PIN_51 = 51,
119// SW_DATA_SOURCE_PIN_52 = 52,
120// SW_DATA_SOURCE_PIN_53 = 53,
121// SW_DATA_SOURCE_PIN_54 = 54,
122// SW_DATA_SOURCE_PIN_55 = 55,
123// SW_DATA_SOURCE_PIN_56 = 56,
124// SW_DATA_SOURCE_PIN_57 = 57,
125// SW_DATA_SOURCE_PIN_58 = 58,
126// SW_DATA_SOURCE_PIN_59 = 59,
127// SW_DATA_SOURCE_PIN_60 = 60,
128// SW_DATA_SOURCE_PIN_61 = 61,
129// SW_DATA_SOURCE_PIN_62 = 62,
130// SW_DATA_SOURCE_PIN_63 = 63,
131 SW_DATA_SOURCE_INCREMENTING_NUMBER = 65,
132 SW_DATA_SOURCE_1024mvCounts = 66 ,
133 SW_DATA_SOURCE_FRAMES_RUN_LSW = 67,
134 SW_DATA_SOURCE_FRAMES_RUN_MSW = 68,
135 SW_DATA_SOURCE_OVERRUN_FRAMES = 69,
136 SW_DATA_SOURCE_TEMPERATURE = 70,
137 SW_DATA_SOURCE_PACKETS_RECEIVED = 71,
138 SW_DATA_SOURCE_ERRORS = 72,
139 SW_DATA_SOURCE_DROPPED_FRAMES = 73,
140 SW_DATA_SOURCE_SYSTEM_UTILIZATION = 74,
141 SW_DATA_SOURCE_VCC_mVOLTS = 75,
142 SW_DATA_SOURCE_VBG_COUNTS_VS_VREF = 76,
143
144 SW_DATA_SOURCE_RESET_REGISTER = 77,
145 SW_DATA_SOURCE_LFSR = 78,
146 SW_DATA_COM_ADDRESS_LOW = 79,
147 SW_DATA_COM_ADDRESS_HIGH = 80,
148 SW_DATA_SOURCE_0x55 = 85,
149 SW_DATA_SOURCE_PIN_0_MV = 100,
150 SW_DATA_SOURCE_PIN_1_MV = 101,
151 SW_DATA_SOURCE_PIN_2_MV = 102,
152 SW_DATA_SOURCE_PIN_3_MV = 103,
153 SW_DATA_SOURCE_PIN_4_MV = 104,
154 //NOT ANALOG SW_DATA_SOURCE_PIN_5_MV = 105,
155 //NOT ANALOG SW_DATA_SOURCE_PIN_6_MV = 106,
156 //NOT ANALOG SW_DATA_SOURCE_PIN_7_MV = 107,
157 //NOT ANALOG SW_DATA_SOURCE_PIN_8_MV = 108,
158 //NOT ANALOG SW_DATA_SOURCE_PIN_9_MV = 109,
159 //NOT ANALOG SW_DATA_SOURCE_PIN_10_MV = 110,
160 //NOT ANALOG SW_DATA_SOURCE_PIN_11_MV = 111,
161 //NOT ANALOG SW_DATA_SOURCE_PIN_12_MV = 112,
162 //NOT ANALOG SW_DATA_SOURCE_PIN_13_MV = 113,
163 //NOT ANALOG SW_DATA_SOURCE_PIN_14_MV = 114,
164 //NOT ANALOG SW_DATA_SOURCE_PIN_15_MV = 115,
165 SW_DATA_SOURCE_PIN_16_MV = 116,
166 SW_DATA_SOURCE_PIN_17_MV = 117,
167 SW_DATA_SOURCE_PIN_18_MV = 118,
168 SW_DATA_SOURCE_PIN_19_MV = 119,
169 SW_DATA_SOURCE_2HZ_SQUARE = 164,
170 SW_DATA_SOURCE_2HZ_SAW = 165,
171// SW_DATA_SOURCE_2HZ_SIN = 166,
172 SW_DATA_SOURCE_1HZ_SQUARE = 167,
173 SW_DATA_SOURCE_1HZ_SAW = 168,
174// SW_DATA_SOURCE_1HZ_SIN = 169,
175 SW_DATA_SOURCE_2SEC_SQUARE = 170,
176 SW_DATA_SOURCE_2SEC_SAW = 171,
177// SW_DATA_SOURCE_2SEC_SIN = 172,
178 SW_DATA_SOURCE_8SEC_SQUARE = 173,
179 SW_DATA_SOURCE_8SEC_SAW = 174,
180// SW_DATA_SOURCE_8SEC_SIN = 175,
181 SW_DATA_SOURCE_65SEC_SQUARE = 176,
182 SW_DATA_SOURCE_65SEC_SAW = 177,
183// SW_DATA_SOURCE_65SEC_SIN = 178,
184 SW_DATA_SOURCE_NONE = 255,
185};
186
187#define ERROR_HOST_INCORRECT_NUMBER_BYTES_WRITTEN 0x10000
188#define ERROR_HOST_DATA_TOO_LONG 0x10001
189#define ERROR_HOST_NACK_ADDRESS 0x10002
190#define ERROR_HOST_NACK_DATA 0x10003
191#define ERROR_HOST_OTHER_I2C_ERROR 0x10004
192
193#define WOMBAT_MAXIMUM_PINS 20
194
195 enum class SerialWombatCommands
196{
197 CMD_ECHO ='!',
198 CMD_READ_BUFFER_ASCII = 'G',
199 CMD_ASCII_SET_PIN ='P',
200 CMD_RESET = 'R',
201 CMD_SET_BUFFER_ASCII = 'S',
202 CMD_RESYNC = 'U',
203 CMD_VERSION = 'V',
204 CMD_SUPPLYVOLTAGE = 'v',
205 COMMAND_BINARY_READ_PIN_BUFFFER = 0x81,
206 COMMAND_BINARY_SET_PIN_BUFFFER = 0x82,
207 COMMAND_BINARY_READ_USER_BUFFER = 0x83,
208 COMMAND_BINARY_WRITE_USER_BUFFER = 0x84,
209 COMMAND_BINARY_WRITE_USER_BUFFER_CONTINUE = 0x85,
210 COMMAND_BINARY_PIN_POLL_THRESHOLD = 0x8F,
211 COMMAND_BINARY_QUEUE_INITIALIZE = 0x90,
212 COMMAND_BINARY_QUEUE_ADD_BYTES = 0x91,
213 COMMAND_BINARY_QUEUE_ADD_7BYTES = 0x92,
214 COMMAND_BINARY_QUEUE_READ_BYTES = 0x93,
215 COMMAND_BINARY_QUEUE_INFORMATION = 0x94,
216 COMMAND_BINARY_QUEUE_CLONE = 0x95,
217 COMMAND_BINARY_CONFIG_DATALOGGER = 0x96,
218 COMMAND_BINARY_CONFIGURE = 0x9F,
219 COMMAND_BINARY_READ_RAM = 0xA0,
220 COMMAND_BINARY_READ_FLASH = 0xA1,
221 COMMAND_BINARY_READ_EEPROM = 0xA2,
222 COMMAND_BINARY_WRITE_RAM = 0xA3,
223 COMMAND_BINARY_WRITE_FLASH = 0xA4,
224 COMMAND_CALIBRATE_ANALOG = 0xA5,
225 COMMAND_ENABLE_2ND_UART = 0xA6,
226 COMMAND_READ_LAST_ERROR_PACKET = 0xA7,
227 COMMAND_UART0_TX_7BYTES = 0xB0,
228 COMMAND_UART0_RX_7BYTES = 0xB1,
229 COMMAND_UART1_TX_7BYTES = 0xB2,
230 COMMAND_UART1_RX_7BYTES = 0xB3,
231 COMMAND_BINARY_TEST_SEQUENCE = 0xB4,
232 COMMAND_BINARY_RW_PIN_MEMORY = 0xB5,
233 COMMAND_CAPTURE_STARTUP_SEQUENCE = 0xB6,
234 COMMAND_ADJUST_FREQUENCY = 0xB7,
235 COMMAND_SET_PIN_HW = 0xB8,
236 COMMAND_BINARY_SET_ADDRESS = 0xB9,
237 CONFIGURE_PIN_MODE0 = 200,
238 CONFIGURE_PIN_MODE1 = 201,
239 CONFIGURE_PIN_MODE2 = 202,
240 CONFIGURE_PIN_MODE3 = 203,
241 CONFIGURE_PIN_MODE4 = 204,
242 CONFIGURE_PIN_MODE5 = 205,
243 CONFIGURE_PIN_MODE6 = 206,
244 CONFIGURE_PIN_MODE7 = 207,
245 CONFIGURE_PIN_MODE8 = 208,
246 CONFIGURE_PIN_MODE9 = 209,
247 CONFIGURE_PIN_MODE10 = 210,
248 CONFIGURE_PIN_OUTPUTSCALE = 210,
249 CONFIGURE_PIN_MODE_DISABLE = 219,
250 CONFIGURE_PIN_INPUTPROCESS = 211,
251 CONFIGURE_CHANNEL_MODE_CHECK_MODE_SUPPORTED = 218,
252 CONFIGURE_PIN_MODE_HW_0 = 220,
253 CONFIGURE_CHANNEL_MODE_HW_1 = 221,
254 CONFIGURE_CHANNEL_MODE_HW_2 = 222,
255 CONFIGURE_CHANNEL_MODE_HW_3 = 223,
256
257};
258
259
260 typedef enum {
261 PIN_MODE_DIGITALIO = 0,
262 PIN_MODE_CONTROLLED = 1,
263 PIN_MODE_ANALOGINPUT = 2,
264 PIN_MODE_SERVO = 3,
265 PIN_MODE_THROUGHPUT_CONSUMER = 4,
266 PIN_MODE_QUADRATUREENCODER = 5,
267 PIN_MODE_HBRIDGE = 6,
268 PIN_MODE_WATCHDOG = 7,
269 PIN_MODE_PROTECTED_OUTPUT = 8,
270 PIN_MODE_DEBOUNCE = 10,
271 PIN_MODE_TM1637 = 11,
272 PIN_MODE_WS2812 = 12,
273 PIN_MODE_SW_UART = 13,
274 PIN_MODE_INPUT_PROCESSOR = 14,
275 PIN_MODE_MATRIX_KEYPAD = 15,
276 PIN_MODE_PWM = 16,
277 PIN_MODE_UART_RX_TX = 17,
278 PIN_MODE_PULSETIMER = 18,
279 PIN_MODE_FRAME_TIMER = 21,
280 PIN_MODE_SW18AB_CAPTOUCH = 22,
281 PIN_MODE_UART1_RX_TX = 23,
282 PIN_MODE_RESISTANCEINPUT = 24,
283 PIN_MODE_PULSE_ON_CHANGE = 25,
284 PIN_MODE_HS_SERVO = 26,
285 PIN_MODE_ULTRASONIC_DISTANCE = 27,
286 PIN_MODE_LIQUIDCRYSTAL = 28,
287 PIN_MODE_HS_CLOCK = 29,
288 PIN_MODE_HS_COUNTER = 30,
289 PIN_MODE_VGA = 31,
290 PIN_MODE_PS2KEYBOARD = 32,
291 PIN_MODE_I2C_CONTROLLER = 33,
292 PIN_MODE_QUEUED_PULSE_OUTPUT = 34,
293 PIN_MODE_FREQUENCY_OUTPUT = 36,
294 PIN_MODE_IRRX = 37,
295 PIN_MODE_BLINK = 40,
296 PIN_MODE_UNKNOWN = 255,
297}SerialWombatPinMode_t;
298
299 class SerialWombatChip;
300
301 typedef void (*SerialWombatErrorHandler_t) (uint16_t errorNumber, SerialWombatChip* sw);
302
312 class SerialWombatChip
313{
314 private:
315
316 char version[8] = { 0 };
317 HardwareSerial * Serial = NULL;
318 TwoWire* i2cInterface = NULL;
319 uint8_t _pinmode[WOMBAT_MAXIMUM_PINS]={}; // Includes Pullup
320 bool _pullDown[WOMBAT_MAXIMUM_PINS]={};
321 bool _openDrain[WOMBAT_MAXIMUM_PINS]={};
322 bool _highLow[WOMBAT_MAXIMUM_PINS] = {};
323 bool _asleep = false;
324 SerialWombatErrorHandler_t errorHandler = NULL;
325 bool _currentlyCommunicating = false;
326 public:
333 uint16_t _supplyVoltagemV = 0;
334
336 uint8_t model[4] = { 0 };
337
339 uint8_t fwVersion[4] = { 0 };
340
346 uint8_t uniqueIdentifier[16];
347
352 uint8_t uniqueIdentifierLength = 0;
353
358 uint16_t deviceIdentifier;
359
364 uint16_t deviceRevision;
366 uint16_t errorCount = 0;
367
369 bool inBoot = false;
370
372 int16_t lastErrorCode = 0;
373
382
383 void configureDigitalPin(uint8_t pin, uint8_t highLow)
384 {
385 uint8_t tx[8] = { 200,pin,0,0,0,0,0,0x55 };
386 uint8_t rx[8];
387 switch (_pinmode[pin])
388 {
389 case INPUT: // Arduino input
390 {
391 tx[3] = 2; //Input
392 }
393 break;
394 case OUTPUT:
395 {
396 if (highLow == LOW)
397 {
398 tx[3] = 0;
399 }
400 else if (highLow == HIGH)
401 {
402 tx[3] = 1;
403 }
404 else
405 {
406 return;
407 }
408 }
409 break;
410 case INPUT_PULLUP:
411 {
412 tx[3] = 2; //Input
413 tx[4] = 1; //Pullup on
414 }
415 break;
416 default:
417 {
418 return;
419 }
420 }
421 tx[6] = _openDrain[pin];
422 tx[5] = _pullDown[pin];
423 sendPacket(tx, rx, true);
424 }
425
429 uint32_t sendReadyTime = 0;
430
434 int16_t initialize()
435 {
436 lastErrorCode = 0;
437 readVersion();
438 readSupplyVoltage_mV();
439 readUniqueIdentifier();
440 readDeviceIdentifier();
441 return(lastErrorCode);
442 }
443
450 void readUniqueIdentifier()
451 {
452 uniqueIdentifierLength = 0;
453 if (version[0] == 'S' && version[1] == '0' && version[2] == '4')
454 { //16F15214
455 for (uint32_t address = 0x8100; address <= 0x8108; ++address)
456 {
457 uint32_t data = readFlashAddress(address);
458 uniqueIdentifier[uniqueIdentifierLength] = (uint8_t)data;
459 ++uniqueIdentifierLength;
460 /* Always zero... leave out
461 uniqueIdentifier[uniqueIdentifierLength] = (uint8_t)(data>>8);
462 ++uniqueIdentifierLength;
463 */
464 }
465 }
466 else if (isSW18())
467 {
468 for (uint32_t address = 0x801600; address <= 0x801608; address += 2)
469 {
470 uint32_t data = readFlashAddress(address);
471 uniqueIdentifier[uniqueIdentifierLength] = data;
472 ++uniqueIdentifierLength;
473 uniqueIdentifier[uniqueIdentifierLength] = data >> 8;
474 ++uniqueIdentifierLength;
475 uniqueIdentifier[uniqueIdentifierLength] = data >> 16;
476 ++uniqueIdentifierLength;
477 }
478 }
479 else if (isSW08())
480 {
481 //TODO
482 }
483
484 }
485
492
493 void readDeviceIdentifier()
494 {
495 if (version[0] == 'S' && version[1] == '0' && version[2] == '4')
496 { //16F15214
497
498 uint32_t data = readFlashAddress(0x8006);
499 deviceIdentifier = (uint16_t)data;
500 data = readFlashAddress(0x8005);
501 deviceRevision = (uint16_t)data;
502 }
503 else if (isSW18())
504 {
505 uint32_t data = readFlashAddress(0xFF0000);
506 deviceIdentifier = (uint16_t)data;
507 data = readFlashAddress(0xFF0002);
508 deviceRevision = (uint16_t)data & 0xF;
509 }
510 }
511
517 uint16_t returnErrorCode(uint8_t* rx)
518 {
519 uint16_t result = rx[1] - '0';
520 result *= 10;
521 result += rx[2] - '0';
522 result *= 10;
523 result += rx[3] - '0';
524 result *= 10;
525 result += rx[4] - '0';
526 result *= 10;
527 result += rx[5] - '0';
528 return(result);
529 }
530
531
532
533 public:
534 SerialWombatChip();
548 int16_t begin(HardwareSerial& serial, bool reset = true)
549 {
550 Serial = &serial;
551 Serial->begin(115200);
552 Serial->setTimeout(2);
553 Serial->write((uint8_t*)"UUUUUUUU", 8);
554 delay(5);
555 while (Serial->read() >= 0);
556 if (reset)
557 {
558 hardwareReset();
559 sendReadyTime = millis() + 1000;
560 return(1);
561 }
562 else
563 {
564 return initialize();
565 }
566
567
568 }
569
579 int16_t begin(uint8_t i2cAddress);
580
594 int16_t begin(TwoWire& wire, uint8_t i2cAddress, bool reset = true)
595 {
596 i2cInterface = &wire;
597 address = i2cAddress;
598
599 Wire.beginTransmission(i2cAddress);
600 int error = Wire.endTransmission();
601
602
603 if (error != 0)
604 {
605 return(-1);
606 }
607
608 if (reset)
609 {
610 hardwareReset();
611 sendReadyTime = millis() + 250;
612 return(1);
613 }
614 else
615 {
616 sendReadyTime = 0;
617 return initialize();
618
619 }
620 }
621
622 ~SerialWombatChip();
623
634 int sendPacket( uint8_t tx[], uint8_t rx[]);
635
645 int sendPacket(uint8_t tx[]);
646
660 int sendPacket(uint8_t tx[], uint8_t rx[], bool retryIfEchoDoesntMatch, uint8_t beginningBytesToMatch = 8, uint8_t endBytesToMatch = 0);
671 int sendPacket(uint8_t tx[], bool retryIfEchoDoesntMatch);
672
681
682 int sendPacketNoResponse(uint8_t tx[]);
683
692 char* readVersion(void)
693 {
694 uint8_t tx[] = { 'V',0x55,0x55,0x55,0x55,0x55,0x55,0x55 };
695 uint8_t rx[8];
696 sendPacket(tx, rx);
697 memcpy(version, &rx[1], 7);
698 version[7] = '\0';
699 memcpy(model, &rx[1], 3);
700 model[3] = '\0';
701 fwVersion[0] = rx[5];
702 fwVersion[1] = rx[6];
703 fwVersion[2] = rx[7];
704 return (version);
705 }
706
713 uint32_t readVersion_uint32(void)
714 {
715 readVersion();
716 return (
717 ((uint32_t)fwVersion[0] - '0') * 100 +
718 ((uint32_t)fwVersion[1] - '0') * 10 +
719 (uint32_t)fwVersion[2] - '0');
720 }
721
726 bool isLatestFirmware(void)
727 {
728 uint32_t v = readVersion_uint32();
729 if (isSW18())
730 {
731 return (v == SW18AB_LATEST_FIRMWARE);
732 }
733 else if (isSW08())
734 {
735 return (v == SW08B_LATEST_FIRMWARE);
736 }
737 else
738 {
739 return (v == SW4B_LATEST_FIRMWARE);
740
741 }
742 }
743
753 uint16_t readPublicData(uint8_t pin)
754 {
755 uint8_t tx[] = { 0x81,pin,255,255,0x55,0x55,0x55,0x55 };
756 uint8_t rx[8];
757 sendPacket(tx, rx);
758 return(rx[2] + (uint16_t)rx[3] * 256);
759 }
760
770 uint16_t readPublicData(SerialWombatDataSource dataSource)
771 {
772 return (readPublicData((uint8_t)dataSource));
773 }
774
780 uint16_t writePublicData(uint8_t pin, uint16_t value)
781 {
782 uint8_t tx[] = { 0x82,pin,(uint8_t)(value & 0xFF),(uint8_t)(value >> 8) ,255,0x55,0x55,0x55 };
783 uint8_t rx[8];
784 sendPacket(tx, rx);
785 return (rx[2] + rx[3] * 256);
786 }
787
788 uint32_t comparePublicDataToThreshold(uint16_t threshold = 0)
789 {
790 uint8_t tx[] = { (uint8_t) SerialWombatCommands::COMMAND_BINARY_PIN_POLL_THRESHOLD,SW_LE16(threshold) ,0x55, 0x55,0x55,0x55,0x55 };
791 uint8_t rx[8];
792 sendPacket(tx, rx);
793 return (ARRAY_UINT32(rx,1));
794 }
795
805
806 uint16_t readSupplyVoltage_mV(void)
807 {
808 if (isSW18() || isSW08())
809 {
810 _supplyVoltagemV = readPublicData(SerialWombatDataSource::SW_DATA_SOURCE_VCC_mVOLTS);
811 }
812 else
813 {
814 int32_t counts = readPublicData(66); // Get FVR counts (1.024 v)
815 if (counts > 0)
816 {
817 uint32_t mv = 1024 * 65536 / counts;
818 _supplyVoltagemV = (uint16_t)mv;
819 }
820 else
821 {
822 _supplyVoltagemV = 0;
823 }
824 }
825 return(_supplyVoltagemV);
826 }
827
828
839 int16_t readTemperature_100thsDegC(void)
840 {
841 if (isSW18())
842 {
843 int32_t result = readPublicData(70);
844 if (result >= 32768)
845 {
846 result = result - 65536;
847 }
848 return ((int16_t)result);
849 }
850 else
851 {
852 return 2500;
853 }
854 }
855
862 void hardwareReset()
863 {
864 uint8_t tx[9] = "ReSeT!#*";
865 sendPacketNoResponse(tx);
866 }
867
876 void pinMode(uint8_t pin, uint8_t mode, bool pullDown = false, bool openDrain = false)
877 {
878 if (pin >= WOMBAT_MAXIMUM_PINS)
879 {
880 return;
881 }
882 _pullDown[pin] = pullDown;
883 _openDrain[pin] = openDrain;
884 _pinmode[pin] = mode;
885 configureDigitalPin(pin, mode);
886 }
887
895 void digitalWrite(uint8_t pin, uint8_t val)
896 {
897 configureDigitalPin(pin, val);
898 }
899
905 int digitalRead(uint8_t pin)
906 {
907 if (readPublicData(pin) > 0)
908 {
909 return (HIGH);
910 }
911 else
912 {
913 return (LOW);
914 }
915 }
916
926 int analogRead(uint8_t pin)
927 {
928 uint8_t tx[] = { 200,pin,PIN_MODE_ANALOGINPUT,0,0,0,0,0 };
929 uint8_t rx[8];
930 sendPacket(tx, rx);
931 return (readPublicData(pin) >> 6); // Scale from 16 bit value to 10 bit value.
932 }
933
945 void analogWrite(uint8_t pin, int val)
946 {
947 uint8_t dutyCycleLow = 0;
948 if (val == 255)
949 {
950 dutyCycleLow = 255;
951 }
952 uint8_t tx[] = { (uint8_t)SerialWombatCommands::CONFIGURE_PIN_MODE0,pin,PIN_MODE_PWM,pin,dutyCycleLow,(uint8_t) val,false,0x55 };
953 uint8_t rx[8];
954 sendPacket(tx, rx);
955 }
956
967 bool queryVersion()
968 {
969 uint8_t tx[8] = { 'V',0x55,0x55,0x55,0x55,0x55,0x55,0x55 };
970 uint8_t rx[8];
971 sendPacket(tx, rx);
972 if (rx[0] == 'V' && (rx[1] == 'S' || rx[1] == 'B'))
973 {
974 model[0] = rx[1];
975 model[1] = rx[2];
976 model[2] = rx[3];
977 model[3] = 0;
978 fwVersion[0] = rx[5];
979 fwVersion[1] = rx[6];
980 fwVersion[2] = rx[7];
981 fwVersion[3] = 0;
982
983 inBoot = (rx[1] == 'B');
984 return (true);
985 }
986 return (false);
987 }
988
995 uint32_t readFramesExecuted()
996 {
997 uint8_t tx[8] = { 0x81,67,68,0x55,0x55,0x55,0x55,0x55 };
998 uint8_t rx[8];
999 sendPacket(tx, rx);
1000 uint32_t returnval = rx[2] + (((uint32_t)rx[3]) << 8) + (((uint32_t)rx[4]) << 16) + (((uint32_t)rx[5]) << 24);
1001 return (returnval);
1002 }
1003
1011
1012 uint16_t readOverflowFrames()
1013 {
1014 return readPublicData(69);
1015 }
1016
1026 void jumpToBoot()
1027 {
1028 uint8_t tx[] = "BoOtLoAd";
1029 sendPacket(tx);
1030 }
1031
1052 uint8_t readRamAddress(uint16_t address)
1053 {
1054 uint8_t tx[8] = { 0xA0,SW_LE16(address),0x55,0x55,0x55,0x55,0x55 };
1055 uint8_t rx[8];
1056 sendPacket(tx, rx);
1057 return(rx[3]);
1058 }
1059
1079
1080 int16_t writeRamAddress(uint16_t address, uint8_t value)
1081 {
1082 uint8_t tx[8] = { 0xA3,SW_LE16(address),0,0,value,0x55,0x55};
1083 return sendPacket(tx);
1084 }
1085
1100
1101 uint32_t readFlashAddress(uint32_t address)
1102 {
1103 uint8_t tx[8] = { 0xA1,SW_LE32(address),0x55,0x55,0x55 };
1104 uint8_t rx[8];
1105 sendPacket(tx, rx);
1106 return(((uint32_t)rx[4]) + (((uint32_t)rx[5]) <<8) + (((uint32_t)rx[6]) <<16) + (((uint32_t)rx[7]) <<24));
1107 }
1108
1120 int16_t readUserBuffer(uint16_t index, uint8_t* buffer, uint16_t count)
1121 {
1122 uint16_t bytesRead = 0;
1123 while (bytesRead < count)
1124 {
1125 byte tx[] = {(byte)SerialWombatCommands::COMMAND_BINARY_READ_USER_BUFFER, (byte)(index & 0xFF), (byte)(index >> 8), 0x55, 0x55, 0x55, 0x55, 0x55};
1126 byte rx[8];
1127 int16_t result = sendPacket(tx, rx);
1128 if (result >= 0)
1129 {
1130 for (int i = 1; i < 8; ++i)
1131 {
1132 buffer[bytesRead] = rx[i];
1133 ++bytesRead;
1134 ++index;
1135 if (bytesRead >= count)
1136 {
1137 break;
1138 }
1139 }
1140 }
1141 else
1142 {
1143 return (bytesRead);
1144 }
1145 }
1146 return (bytesRead);
1147 }
1148
1158 void sleep()
1159 {
1160 uint8_t tx[8] = { 'S','l','E','e','P','!','#','*'};
1161 sendPacket(tx);
1162 _asleep = true;
1163 }
1164
1166 void wake()
1167 {
1168 uint8_t tx[8] = { '!','!','!','!','!','!','!','!' };
1169 sendPacket(tx);
1170 }
1171
1173 bool isSW04()
1174 {
1175 return ( model[1] == '0' && model[2] == '4');
1176 }
1177
1178
1180 bool isSW18()
1181 {
1182 return ( model[1] == '1' && model[2] == '8');
1183 }
1184
1185 bool isSW08()
1186 {
1187 return ( model[1] == '0' && model[2] == '8');
1188 }
1189
1195 bool isPinModeSupported(int pinMode)
1196 {
1197 return isPinModeSupported((SerialWombatPinMode_t)pinMode);
1198 }
1199
1204 bool isPinModeSupported(SerialWombatPinMode_t pinMode)
1205 {
1206 if (isSW04())
1207 {
1208 switch (pinMode)
1209 {
1210 case PIN_MODE_DIGITALIO:
1211 case PIN_MODE_ANALOGINPUT:
1212 case PIN_MODE_CONTROLLED:
1213 case PIN_MODE_SERVO:
1214 case PIN_MODE_PWM:
1215 case PIN_MODE_DEBOUNCE:
1216 case PIN_MODE_QUADRATUREENCODER:
1217 case PIN_MODE_WATCHDOG:
1218 case PIN_MODE_PULSETIMER:
1219 case PIN_MODE_PROTECTED_OUTPUT:
1220 return true;
1221
1222 default:
1223 return false;
1224 }
1225 }
1226
1227 uint8_t tx[8] = {(uint8_t)SerialWombatCommands::CONFIGURE_CHANNEL_MODE_CHECK_MODE_SUPPORTED, 1, (uint8_t)pinMode, 0x55, 0x55, 0x55, 0x55, 0x55};
1228 int16_t returnVal = sendPacket(tx);
1229 returnVal *= -1;
1230 return (returnVal != SW_ERROR_UNKNOWN_PIN_MODE);
1231 }
1232
1233
1234
1235
1237 int16_t eraseFlashPage(uint32_t address)
1238 {
1239 uint8_t tx[8] = { (uint8_t)SerialWombatCommands::COMMAND_BINARY_WRITE_FLASH,
1240 0, //Erase Page
1241 SW_LE32(address),
1242 0x55,0x55 };
1243 return sendPacket(tx);
1244 }
1245
1246
1248 int16_t writeFlashRow(uint32_t address)
1249 {
1250 uint8_t tx[8] = { (uint8_t)SerialWombatCommands::COMMAND_BINARY_WRITE_FLASH,
1251 1, // Write entire row
1252 SW_LE32(address),0x55,0x55 };
1253 return sendPacket(tx);
1254 }
1255
1256
1257
1258
1268 int16_t setThroughputPin(uint8_t pin)
1269 {
1270 uint8_t tx[8] = { (uint8_t)SerialWombatCommands::CONFIGURE_PIN_MODE0,pin,PIN_MODE_FRAME_TIMER,0x55,0x55,0x55,0x55,0x55 };
1271 return sendPacket(tx);
1272 }
1273
1287 int16_t setThroughputPin(uint32_t address)
1288 {
1289 uint8_t tx[8] = { (uint8_t)SerialWombatCommands::COMMAND_BINARY_SET_ADDRESS,SW_LE32(address),0x55,0x55,0x55 };
1290 return sendPacket(tx);
1291 }
1292
1300 int writeUserBuffer(uint16_t index, uint8_t* buffer, uint16_t count)
1301 {
1302 uint16_t bytesSent = 0;
1303 if (count == 0)
1304 {
1305 return 0;
1306 }
1307
1308 { // Send first packet of up to 4 bytes
1309 uint8_t bytesToSend = 4;
1310 if (count < 4)
1311 {
1312 bytesToSend = (uint8_t)count;
1313 count = 0;
1314 }
1315 else
1316 {
1317 count -= 4;
1318 }
1319
1320 uint8_t tx[8] = { 0x84,SW_LE16(index), bytesToSend,0x55,0x55,0x55,0x55 };
1321 uint8_t rx[8];
1322
1323 uint8_t i;
1324 for (i = 0; i < bytesToSend; ++i)
1325 {
1326 tx[4 + i] = buffer[i];
1327 }
1328 int result = sendPacket(tx, rx);
1329 if (rx[0] == 'E')
1330 {
1331 return (result);
1332 }
1333 bytesSent = bytesToSend;
1334 }
1335 while (count >= 7) // Continue sending
1336 {
1337
1338 count -= 7;
1339 uint8_t tx[8] = { 0x85,0x55,0x55,0x55,0x55,0x55,0x55,0x55 };
1340 uint8_t rx[8];
1341 uint8_t i;
1342 for (i = 0; i < 7; ++i)
1343 {
1344 tx[1 + i] = buffer[bytesSent + i];
1345 }
1346 int result = sendPacket(tx, rx);
1347 if (rx[0] == 'E')
1348 {
1349 return (result);
1350 }
1351 bytesSent += 7;
1352 }
1353 while (count > 0)
1354 {
1355
1356 { // Send first packet of up to 4 bytes
1357 uint8_t bytesToSend = 4;
1358 if (count < 4)
1359 {
1360 bytesToSend = (uint8_t)count;
1361 count = 0;
1362 }
1363 else
1364 {
1365 count -= 4;
1366 }
1367
1368 uint8_t tx[8] = { 0x84,SW_LE16(index + bytesSent), bytesToSend,0x55,0x55,0x55,0x55 };
1369 uint8_t rx[8];
1370
1371 uint8_t i;
1372 for (i = 0; i < bytesToSend; ++i)
1373 {
1374 tx[4 + i] = buffer[i + bytesSent];
1375 }
1376 int result = sendPacket(tx, rx);
1377 if (rx[0] == 'E')
1378 {
1379 return (result);
1380 }
1381 bytesSent += bytesToSend;
1382 }
1383 }
1384 return(bytesSent);
1385
1386
1387 }
1388
1395 int writeUserBuffer(uint16_t index, char* s)
1396 {
1397 return writeUserBuffer(index, (uint8_t*)s, (uint16_t)strlen(s));
1398 }
1399
1406 int writeUserBuffer(uint16_t index, const char s[])
1407 {
1408 return writeUserBuffer(index, (uint8_t*)s, (uint16_t)strlen(s));
1409 }
1410
1411
1412
1424 int16_t writeFrameTimerPin(uint8_t pin)
1425{
1426 uint8_t tx[] = { 0xC8 ,pin,(uint8_t)PIN_MODE_FRAME_TIMER,0x55,0x55,0x55,0x55,0x55 };
1427 return sendPacket(tx);
1428}
1429
1430
1438 static uint8_t find(bool keepTrying = false)
1439 {
1440 do
1441 {
1442 for (int i2cAddress = 0x60; i2cAddress <= 0x6F; ++i2cAddress)
1443 {
1444 Wire.beginTransmission(i2cAddress);
1445 int error = Wire.endTransmission();
1446
1447
1448 if (error == 0)
1449 {
1450 uint8_t tx[8] = { 'V',0x55,0x55,0x55,0x55,0x55,0x55,0x55 };
1451 uint8_t rx[8];
1452 Wire.beginTransmission(i2cAddress);
1453 Wire.write(tx, 8);
1454 Wire.endTransmission();
1455 Wire.requestFrom((uint8_t)i2cAddress, (uint8_t)8);
1456
1457 int count = 0;
1458 while (Wire.available() && count < 8)
1459 {
1460 rx[count] = Wire.read();
1461 ++count;
1462 }
1463 if (count == 8)
1464 {
1465 if (rx[0] == 'V' && (rx[1] == 'S' || rx[1]=='B'))
1466 {
1467 return(i2cAddress); // Found one.
1468 }
1469 }
1470 }
1471 }
1472 delay(0);
1473 }while (keepTrying);
1474 return(0); // Didn't find one.
1475 }
1476
1477
1484 int16_t readLastErrorCommand(uint8_t* cmd)
1485{
1486
1487 uint8_t tx[8] = { (uint8_t)SerialWombatCommands::COMMAND_READ_LAST_ERROR_PACKET, 0,0x55,0x55,0x55,0x55,0x55,0x55 };
1488 uint8_t rx[8];
1489 if (sendPacket(tx, rx) >= 0)
1490 {
1491 for (int i = 1; i < 8; ++i)
1492 {
1493 cmd[i - 1] = rx[i];
1494 }
1495 }
1496 else
1497 {
1498 return (lastErrorCode);
1499 }
1500 tx[1] = 7;
1501 if (sendPacket(tx, rx) >= 0)
1502 {
1503 cmd[7] = rx[1];
1504 }
1505 return(lastErrorCode);
1506}
1507
1512 void registerErrorHandler(SerialWombatErrorHandler_t handler)
1513 {
1514 errorHandler = handler;
1515 }
1516
1518 uint8_t address = 0;
1519
1521 uint8_t communicationErrorRetries = 5;
1522
1529 int16_t echo(uint8_t data[], uint8_t count = 7)
1530 {
1531 uint8_t tx[] = "!UUUUUUU";
1532 for (int i = 0; i < 7 && i < count; ++i)
1533 {
1534 tx[i + 1] = (uint8_t)data[i];
1535 }
1536 return sendPacket(tx);
1537 }
1538
1544
1545 int16_t echo(char* data)
1546 {
1547 int length = strlen(data);
1548 uint8_t tx[] = "!UUUUUUU";
1549 for (int i = 0; i < 7 && i < length; ++i)
1550 {
1551 tx[i + 1] = (uint8_t)data[i];
1552 }
1553 return sendPacket(tx);
1554 }
1555
1560 uint32_t readBirthday()
1561 {
1562 if (isSW18())
1563 {
1564 uint32_t birthday = (readFlashAddress(0x2A00C) >> 8) & 0xFF;
1565 birthday *= 100;
1566 birthday += (readFlashAddress(0x2A00C)) & 0xFF;
1567 birthday *= 100;
1568 birthday += readFlashAddress(0x2A00E) & 0xFF;
1569 birthday *= 100;
1570 birthday += readFlashAddress(0x2A010) & 0xFF;
1571 return (birthday);
1572 }
1573 return 0;
1574 }
1575
1580 int16_t readBrand(char* data)
1581 {
1582 uint8_t length = 0;
1583 if (isSW18())
1584 {
1585 for (int i = 0; i < 32; ++i)
1586 {
1587 uint32_t val = readFlashAddress(0x2A020 + i * 2) ;
1588 if ((val & 0xFF) != 0xFF)
1589 {
1590 data[i ] = (char)(val & 0xFF);
1591 ++length;
1592 }
1593 else
1594 {
1595 data[length] = 0;
1596 return (length);
1597 }
1598 }
1599 data[length] = 0;
1600 return (length);
1601 }
1602
1603 data[0] = 0;
1604 return 0 ;
1605 }
1606
1607};
1608
1622 class SerialWombat18ABOscillatorTuner
1623{
1624 private:
1625 SerialWombatChip& _sw;
1626 uint32_t lastMillis = 0;
1627 uint32_t lastFrames = 0;
1628 public:
1633 SerialWombat18ABOscillatorTuner(SerialWombatChip& serialWombatChip) : _sw(serialWombatChip) { }
1634
1638 void update() {
1639 uint32_t m = millis();
1640 if (lastMillis == 0)
1641 {
1642 lastMillis = m;
1643 uint32_t frames = _sw.readPublicData(SerialWombatDataSource::SW_DATA_SOURCE_FRAMES_RUN_MSW);
1644 uint16_t frameslsb = _sw.readPublicData(SerialWombatDataSource::SW_DATA_SOURCE_FRAMES_RUN_LSW);
1645 if (frames != _sw.readPublicData(SerialWombatDataSource::SW_DATA_SOURCE_FRAMES_RUN_MSW))
1646 {
1647 frameslsb = _sw.readPublicData(SerialWombatDataSource::SW_DATA_SOURCE_FRAMES_RUN_LSW);
1648 frames = _sw.readPublicData(SerialWombatDataSource::SW_DATA_SOURCE_FRAMES_RUN_MSW);
1649 }
1650 frames <<= 16;
1651 frames += frameslsb;
1652 lastFrames = frames;
1653
1654 }
1655 else if ((m - lastMillis) < 10000)
1656 {
1657 //Do nothing
1658 }
1659 else if (m < lastMillis)
1660 {
1661 //Has it been 47 days already?
1662 lastMillis = 0;
1663 }
1664 else
1665 {
1666 uint32_t diff = m - lastMillis;
1667
1668 uint32_t frames = _sw.readPublicData(SerialWombatDataSource::SW_DATA_SOURCE_FRAMES_RUN_MSW);
1669 uint16_t frameslsb = _sw.readPublicData(SerialWombatDataSource::SW_DATA_SOURCE_FRAMES_RUN_LSW);
1670
1671 if (frames != _sw.readPublicData(SerialWombatDataSource::SW_DATA_SOURCE_FRAMES_RUN_MSW))
1672 {
1673 frameslsb = _sw.readPublicData(SerialWombatDataSource::SW_DATA_SOURCE_FRAMES_RUN_LSW);
1674 frames = _sw.readPublicData(SerialWombatDataSource::SW_DATA_SOURCE_FRAMES_RUN_MSW);
1675 }
1676 frames <<= 16;
1677 frames += frameslsb;
1678 uint32_t framesDif = frames - lastFrames;
1679
1680 if (diff > framesDif )
1681 {
1682 // Running slow
1683 uint8_t tx[] = { (uint8_t)SerialWombatCommands::COMMAND_ADJUST_FREQUENCY,
1684 SW_LE16(1),//Counts to increment
1685 SW_LE16(0), // Counts to decrement
1686 0x55,0x55,0x55};
1687 _sw.sendPacket(tx);
1688 }
1689 else if (diff < framesDif)
1690 {
1691 // Running mfast
1692 uint8_t tx[] = { (uint8_t)SerialWombatCommands::COMMAND_ADJUST_FREQUENCY,
1693 SW_LE16(0),//Counts to increment
1694 SW_LE16(1), // Counts to decrement
1695 0x55,0x55,0x55 };
1696 _sw.sendPacket(tx);
1697
1698 }
1699
1700 lastMillis = m;
1701 lastFrames = frames;
1702
1703 }
1704
1705 }
1706
1707};
1708
1709/*
1710 End of cross platform code synchronization. Random string to help the compare tool sync lines:
1711 asdkj38vjn1nasdnvuwlamafdjiivnowalskive
1712*/
1713
1715 class SerialWombat : public SerialWombatChip {};
1716
1717
1718
1719
1720
1728 void SerialWombatSerialErrorHandlerBrief(uint16_t error, SerialWombatChip* sw);
1729
1737 void SerialWombatSerialErrorHandlerVerbose(uint16_t error, SerialWombatChip* sw);
1738
1739#include "SerialWombatPin.h"
1740#include "SerialWombatQueue.h"
1741#include "SerialWombat18ABDataLogger.h"
1742#include "SerialWombatAbstractButton.h"
1743#include "SerialWombatAbstractProcessedInput.h"
1744#include "SerialWombatAbstractScaledOutput.h"
1745#include "SerialWombatBlink.h"
1746#include "SerialWombat18CapTouch.h"
1747#include "SerialWombat18ABVGA.h"
1748#include "SerialWombatAnalogInput.h"
1749#include "SerialWombatDebouncedInput.h"
1750#include "SerialWombatFrequencyOutput.h"
1751#include "SerialWombatHBridge.h"
1752#include "SerialWombatHSClock.h"
1753#include "SerialWombatHSCounter.h"
1754#include "SerialWombatIRRx.h"
1755#include "SerialWombatLiquidCrystal.h"
1756#include "SerialWombatMatrixKeypad.h"
1757#include "SerialWombatProcessedInputPin.h"
1758#include "SerialWombatProtectedOutput.h"
1759#include "SerialWombatPS2Keyboard.h"
1760#include "SerialWombatPulseOnChange.h"
1761#include "SerialWombatPulseTimer.h"
1762#include "SerialWombatPWM.h"
1763#include "SerialWombatQuadEnc.h"
1764#include "SerialWombatQueuedPulseOutput.h"
1765#include "SerialWombatResistanceInput.h"
1766#include "SerialWombatServo.h"
1767#include "SerialWombatTM1637.h"
1768#include "SerialWombatUART.h"
1769#include "SerialWombatUltrasonicDistanceSensor.h"
1770#include "SerialWombatWatchdog.h"
1771#include "SerialWombatWS2812.h"
1772#include "SerialWombatThroughputConsumer.h"
1773#include "PCB0030_Bridge.h"
1774#include "PCB0031_Grip.h"
1775
1776#endif
PCB0030_Bridge.h
PCB0031_Grip.h
SerialWombat18ABDataLogger.h
SerialWombat18ABVGA.h
SerialWombat18CapTouch.h
INPUT
#define INPUT
Definition SerialWombat.h:35
SW18AB_LATEST_FIRMWARE
#define SW18AB_LATEST_FIRMWARE
Definition SerialWombat.h:52
WOMBAT_MAXIMUM_PINS
#define WOMBAT_MAXIMUM_PINS
Definition SerialWombat.h:193
SerialWombatSerialErrorHandlerBrief
void SerialWombatSerialErrorHandlerBrief(uint16_t error, SerialWombatChip *sw)
a sample error handler that can be registered with registerErrorHandler to report protocol errors on ...
Definition SerialWombat.cpp:340
SW_LE16
#define SW_LE16(_a)
Convert a uint16_t to two bytes in little endian format for array initialization.
Definition SerialWombat.h:46
SerialWombatCommands
SerialWombatCommands
Definition SerialWombat.h:196
SerialWombatCommands::COMMAND_CAPTURE_STARTUP_SEQUENCE
@ COMMAND_CAPTURE_STARTUP_SEQUENCE
(0xB6)
Definition SerialWombat.h:233
SerialWombatCommands::COMMAND_BINARY_WRITE_FLASH
@ COMMAND_BINARY_WRITE_FLASH
(0xA4)
Definition SerialWombat.h:223
SerialWombatCommands::COMMAND_BINARY_READ_USER_BUFFER
@ COMMAND_BINARY_READ_USER_BUFFER
(0x83)
Definition SerialWombat.h:207
SerialWombatCommands::COMMAND_BINARY_QUEUE_INFORMATION
@ COMMAND_BINARY_QUEUE_INFORMATION
(0x94)
Definition SerialWombat.h:215
SerialWombatCommands::CONFIGURE_PIN_MODE0
@ CONFIGURE_PIN_MODE0
(200)
Definition SerialWombat.h:237
SerialWombatCommands::COMMAND_BINARY_QUEUE_INITIALIZE
@ COMMAND_BINARY_QUEUE_INITIALIZE
(0x90)
Definition SerialWombat.h:211
SerialWombatCommands::COMMAND_BINARY_SET_PIN_BUFFFER
@ COMMAND_BINARY_SET_PIN_BUFFFER
(0x82)
Definition SerialWombat.h:206
SerialWombatCommands::COMMAND_ENABLE_2ND_UART
@ COMMAND_ENABLE_2ND_UART
(0xA6)
Definition SerialWombat.h:225
SerialWombatCommands::COMMAND_UART1_RX_7BYTES
@ COMMAND_UART1_RX_7BYTES
(0xB3)
Definition SerialWombat.h:230
SerialWombatCommands::COMMAND_ADJUST_FREQUENCY
@ COMMAND_ADJUST_FREQUENCY
(0xB7)
Definition SerialWombat.h:234
SerialWombatCommands::COMMAND_BINARY_WRITE_USER_BUFFER
@ COMMAND_BINARY_WRITE_USER_BUFFER
(0x84)
Definition SerialWombat.h:208
SerialWombatCommands::CONFIGURE_PIN_MODE3
@ CONFIGURE_PIN_MODE3
(203)
Definition SerialWombat.h:240
SerialWombatCommands::CMD_RESET
@ CMD_RESET
('R')
Definition SerialWombat.h:200
SerialWombatCommands::CONFIGURE_PIN_MODE4
@ CONFIGURE_PIN_MODE4
(204)
Definition SerialWombat.h:241
SerialWombatCommands::CONFIGURE_PIN_MODE_DISABLE
@ CONFIGURE_PIN_MODE_DISABLE
(219)
Definition SerialWombat.h:249
SerialWombatCommands::CMD_READ_BUFFER_ASCII
@ CMD_READ_BUFFER_ASCII
('G')
Definition SerialWombat.h:198
SerialWombatCommands::COMMAND_BINARY_QUEUE_CLONE
@ COMMAND_BINARY_QUEUE_CLONE
(0x95)
Definition SerialWombat.h:216
SerialWombatCommands::COMMAND_BINARY_QUEUE_ADD_BYTES
@ COMMAND_BINARY_QUEUE_ADD_BYTES
(0x91)
Definition SerialWombat.h:212
SerialWombatCommands::CMD_RESYNC
@ CMD_RESYNC
('U')
Definition SerialWombat.h:202
SerialWombatCommands::COMMAND_BINARY_READ_EEPROM
@ COMMAND_BINARY_READ_EEPROM
(0xA2)
Definition SerialWombat.h:221
SerialWombatCommands::CMD_SUPPLYVOLTAGE
@ CMD_SUPPLYVOLTAGE
('v')
Definition SerialWombat.h:204
SerialWombatCommands::CONFIGURE_PIN_MODE5
@ CONFIGURE_PIN_MODE5
(205)
Definition SerialWombat.h:242
SerialWombatCommands::COMMAND_BINARY_QUEUE_ADD_7BYTES
@ COMMAND_BINARY_QUEUE_ADD_7BYTES
(0x92)
Definition SerialWombat.h:213
SerialWombatCommands::CONFIGURE_PIN_MODE8
@ CONFIGURE_PIN_MODE8
(208)
Definition SerialWombat.h:245
SerialWombatCommands::CONFIGURE_PIN_MODE_HW_0
@ CONFIGURE_PIN_MODE_HW_0
(220)
Definition SerialWombat.h:252
SerialWombatCommands::CONFIGURE_PIN_MODE6
@ CONFIGURE_PIN_MODE6
(206)
Definition SerialWombat.h:243
SerialWombatCommands::CMD_SET_BUFFER_ASCII
@ CMD_SET_BUFFER_ASCII
('S')
Definition SerialWombat.h:201
SerialWombatCommands::CONFIGURE_PIN_MODE2
@ CONFIGURE_PIN_MODE2
(202)
Definition SerialWombat.h:239
SerialWombatCommands::COMMAND_UART0_TX_7BYTES
@ COMMAND_UART0_TX_7BYTES
(0xB0)
Definition SerialWombat.h:227
SerialWombatCommands::COMMAND_BINARY_QUEUE_READ_BYTES
@ COMMAND_BINARY_QUEUE_READ_BYTES
(0x93)
Definition SerialWombat.h:214
SerialWombatCommands::COMMAND_BINARY_SET_ADDRESS
@ COMMAND_BINARY_SET_ADDRESS
(0xB9)
Definition SerialWombat.h:236
SerialWombatCommands::CONFIGURE_PIN_INPUTPROCESS
@ CONFIGURE_PIN_INPUTPROCESS
(211)
Definition SerialWombat.h:250
SerialWombatCommands::CONFIGURE_CHANNEL_MODE_CHECK_MODE_SUPPORTED
@ CONFIGURE_CHANNEL_MODE_CHECK_MODE_SUPPORTED
(218)
Definition SerialWombat.h:251
SerialWombatCommands::CMD_VERSION
@ CMD_VERSION
('V')
Definition SerialWombat.h:203
SerialWombatCommands::CMD_ASCII_SET_PIN
@ CMD_ASCII_SET_PIN
('P')
Definition SerialWombat.h:199
SerialWombatCommands::CONFIGURE_PIN_MODE10
@ CONFIGURE_PIN_MODE10
(210)
Definition SerialWombat.h:247
SerialWombatCommands::COMMAND_BINARY_WRITE_USER_BUFFER_CONTINUE
@ COMMAND_BINARY_WRITE_USER_BUFFER_CONTINUE
(0x85)
Definition SerialWombat.h:209
SerialWombatCommands::COMMAND_BINARY_CONFIG_DATALOGGER
@ COMMAND_BINARY_CONFIG_DATALOGGER
(0x96)
Definition SerialWombat.h:217
SerialWombatCommands::CONFIGURE_PIN_MODE9
@ CONFIGURE_PIN_MODE9
(209)
Definition SerialWombat.h:246
SerialWombatCommands::COMMAND_UART1_TX_7BYTES
@ COMMAND_UART1_TX_7BYTES
(0xB2)
Definition SerialWombat.h:229
SerialWombatCommands::COMMAND_UART0_RX_7BYTES
@ COMMAND_UART0_RX_7BYTES
(0xB1)
Definition SerialWombat.h:228
SerialWombatCommands::COMMAND_BINARY_RW_PIN_MEMORY
@ COMMAND_BINARY_RW_PIN_MEMORY
(0xB5)
Definition SerialWombat.h:232
SerialWombatCommands::COMMAND_READ_LAST_ERROR_PACKET
@ COMMAND_READ_LAST_ERROR_PACKET
(0xA7)
Definition SerialWombat.h:226
SerialWombatCommands::COMMAND_BINARY_WRITE_RAM
@ COMMAND_BINARY_WRITE_RAM
(0xA3)
Definition SerialWombat.h:222
SerialWombatCommands::COMMAND_BINARY_READ_RAM
@ COMMAND_BINARY_READ_RAM
(0xA0)
Definition SerialWombat.h:219
SerialWombatCommands::COMMAND_BINARY_TEST_SEQUENCE
@ COMMAND_BINARY_TEST_SEQUENCE
(0xB4)
Definition SerialWombat.h:231
SerialWombatCommands::CONFIGURE_CHANNEL_MODE_HW_2
@ CONFIGURE_CHANNEL_MODE_HW_2
(222)
Definition SerialWombat.h:254
SerialWombatCommands::COMMAND_BINARY_READ_PIN_BUFFFER
@ COMMAND_BINARY_READ_PIN_BUFFFER
(0x81)
Definition SerialWombat.h:205
SerialWombatCommands::CONFIGURE_CHANNEL_MODE_HW_1
@ CONFIGURE_CHANNEL_MODE_HW_1
(221)
Definition SerialWombat.h:253
SerialWombatCommands::COMMAND_BINARY_READ_FLASH
@ COMMAND_BINARY_READ_FLASH
(0xA1)
Definition SerialWombat.h:220
SerialWombatCommands::CONFIGURE_CHANNEL_MODE_HW_3
@ CONFIGURE_CHANNEL_MODE_HW_3
(223)
Definition SerialWombat.h:255
SerialWombatCommands::COMMAND_SET_PIN_HW
@ COMMAND_SET_PIN_HW
(0xB8)
Definition SerialWombat.h:235
SerialWombatCommands::COMMAND_CALIBRATE_ANALOG
@ COMMAND_CALIBRATE_ANALOG
(0xA5)
Definition SerialWombat.h:224
SerialWombatCommands::CMD_ECHO
@ CMD_ECHO
('!')
Definition SerialWombat.h:197
SerialWombatCommands::CONFIGURE_PIN_MODE7
@ CONFIGURE_PIN_MODE7
(207)
Definition SerialWombat.h:244
SerialWombatCommands::CONFIGURE_PIN_MODE1
@ CONFIGURE_PIN_MODE1
(201)
Definition SerialWombat.h:238
SerialWombatCommands::COMMAND_BINARY_PIN_POLL_THRESHOLD
@ COMMAND_BINARY_PIN_POLL_THRESHOLD
(0x8F)
Definition SerialWombat.h:210
SerialWombatCommands::CONFIGURE_PIN_OUTPUTSCALE
@ CONFIGURE_PIN_OUTPUTSCALE
(210)
Definition SerialWombat.h:248
SerialWombatCommands::COMMAND_BINARY_CONFIGURE
@ COMMAND_BINARY_CONFIGURE
(0x9F)
Definition SerialWombat.h:218
SW08B_LATEST_FIRMWARE
#define SW08B_LATEST_FIRMWARE
Definition SerialWombat.h:53
SW_LE32
#define SW_LE32(_a)
Convert a uint32_t to four bytes in little endian format for array initialization.
Definition SerialWombat.h:49
SW4B_LATEST_FIRMWARE
#define SW4B_LATEST_FIRMWARE
Definition SerialWombat.h:54
SerialWombatPinMode_t
SerialWombatPinMode_t
Definition SerialWombat.h:260
PIN_MODE_PULSE_ON_CHANGE
@ PIN_MODE_PULSE_ON_CHANGE
(25)
Definition SerialWombat.h:283
PIN_MODE_FRAME_TIMER
@ PIN_MODE_FRAME_TIMER
(21)
Definition SerialWombat.h:279
PIN_MODE_UNKNOWN
@ PIN_MODE_UNKNOWN
(0xFF)
Definition SerialWombat.h:296
PIN_MODE_TM1637
@ PIN_MODE_TM1637
(11)
Definition SerialWombat.h:271
PIN_MODE_PULSETIMER
@ PIN_MODE_PULSETIMER
(18)
Definition SerialWombat.h:278
PIN_MODE_PS2KEYBOARD
@ PIN_MODE_PS2KEYBOARD
(32)
Definition SerialWombat.h:290
PIN_MODE_FREQUENCY_OUTPUT
@ PIN_MODE_FREQUENCY_OUTPUT
(36)
Definition SerialWombat.h:293
PIN_MODE_HS_SERVO
@ PIN_MODE_HS_SERVO
(26)
Definition SerialWombat.h:284
PIN_MODE_CONTROLLED
@ PIN_MODE_CONTROLLED
(1)
Definition SerialWombat.h:262
PIN_MODE_QUEUED_PULSE_OUTPUT
@ PIN_MODE_QUEUED_PULSE_OUTPUT
(34)
Definition SerialWombat.h:292
PIN_MODE_HBRIDGE
@ PIN_MODE_HBRIDGE
(6)
Definition SerialWombat.h:267
PIN_MODE_SW18AB_CAPTOUCH
@ PIN_MODE_SW18AB_CAPTOUCH
(22)
Definition SerialWombat.h:280
PIN_MODE_LIQUIDCRYSTAL
@ PIN_MODE_LIQUIDCRYSTAL
(28)
Definition SerialWombat.h:286
PIN_MODE_IRRX
@ PIN_MODE_IRRX
(37)
Definition SerialWombat.h:294
PIN_MODE_QUADRATUREENCODER
@ PIN_MODE_QUADRATUREENCODER
(5)
Definition SerialWombat.h:266
PIN_MODE_UART_RX_TX
@ PIN_MODE_UART_RX_TX
(17)
Definition SerialWombat.h:277
PIN_MODE_WATCHDOG
@ PIN_MODE_WATCHDOG
(7)
Definition SerialWombat.h:268
PIN_MODE_HS_COUNTER
@ PIN_MODE_HS_COUNTER
< (29)
Definition SerialWombat.h:288
PIN_MODE_PROTECTED_OUTPUT
@ PIN_MODE_PROTECTED_OUTPUT
(8)
Definition SerialWombat.h:269
PIN_MODE_ANALOGINPUT
@ PIN_MODE_ANALOGINPUT
(2)
Definition SerialWombat.h:263
PIN_MODE_UART1_RX_TX
@ PIN_MODE_UART1_RX_TX
(23)
Definition SerialWombat.h:281
PIN_MODE_I2C_CONTROLLER
@ PIN_MODE_I2C_CONTROLLER
(33)
Definition SerialWombat.h:291
PIN_MODE_PWM
@ PIN_MODE_PWM
(16)
Definition SerialWombat.h:276
PIN_MODE_RESISTANCEINPUT
@ PIN_MODE_RESISTANCEINPUT
(24)
Definition SerialWombat.h:282
PIN_MODE_DEBOUNCE
@ PIN_MODE_DEBOUNCE
(10)
Definition SerialWombat.h:270
PIN_MODE_BLINK
@ PIN_MODE_BLINK
(40)
Definition SerialWombat.h:295
PIN_MODE_INPUT_PROCESSOR
@ PIN_MODE_INPUT_PROCESSOR
(14)
Definition SerialWombat.h:274
PIN_MODE_ULTRASONIC_DISTANCE
@ PIN_MODE_ULTRASONIC_DISTANCE
(27)
Definition SerialWombat.h:285
PIN_MODE_HS_CLOCK
@ PIN_MODE_HS_CLOCK
Definition SerialWombat.h:287
PIN_MODE_SERVO
@ PIN_MODE_SERVO
(3)
Definition SerialWombat.h:264
PIN_MODE_DIGITALIO
@ PIN_MODE_DIGITALIO
(0)
Definition SerialWombat.h:261
PIN_MODE_THROUGHPUT_CONSUMER
@ PIN_MODE_THROUGHPUT_CONSUMER
(4)
Definition SerialWombat.h:265
PIN_MODE_MATRIX_KEYPAD
@ PIN_MODE_MATRIX_KEYPAD
(15)
Definition SerialWombat.h:275
PIN_MODE_SW_UART
@ PIN_MODE_SW_UART
(13)
Definition SerialWombat.h:273
PIN_MODE_VGA
@ PIN_MODE_VGA
(31)
Definition SerialWombat.h:289
PIN_MODE_WS2812
@ PIN_MODE_WS2812
(12)
Definition SerialWombat.h:272
SerialWombatSerialErrorHandlerVerbose
void SerialWombatSerialErrorHandlerVerbose(uint16_t error, SerialWombatChip *sw)
a sample error handler that can be registered with registerErrorHandler to report protocol errors on ...
SerialWombatDataSource
SerialWombatDataSource
A list of Serial Wombat public data sources.
Definition SerialWombat.h:65
SerialWombatDataSource::SW_DATA_SOURCE_PIN_10
@ SW_DATA_SOURCE_PIN_10
(10) 16 bit public data provided by Pin 10
Definition SerialWombat.h:77
SerialWombatDataSource::SW_DATA_SOURCE_VBG_COUNTS_VS_VREF
@ SW_DATA_SOURCE_VBG_COUNTS_VS_VREF
(76) A/D conversion of VBG against VRef . Used for mfg calibration
Definition SerialWombat.h:142
SerialWombatDataSource::SW_DATA_SOURCE_PIN_5
@ SW_DATA_SOURCE_PIN_5
(5) 16 bit public data provided by Pin 5
Definition SerialWombat.h:72
SerialWombatDataSource::SW_DATA_SOURCE_PIN_14
@ SW_DATA_SOURCE_PIN_14
(14) 16 bit public data provided by Pin 14
Definition SerialWombat.h:81
SerialWombatDataSource::SW_DATA_SOURCE_PIN_13
@ SW_DATA_SOURCE_PIN_13
(13) 16 bit public data provided by Pin 13
Definition SerialWombat.h:80
SerialWombatDataSource::SW_DATA_SOURCE_1024mvCounts
@ SW_DATA_SOURCE_1024mvCounts
(66) The number of ADC counts that result from a 1.024V reading
Definition SerialWombat.h:132
SerialWombatDataSource::SW_DATA_SOURCE_TEMPERATURE
@ SW_DATA_SOURCE_TEMPERATURE
(70)The internal core temperature expressed in 100ths deg C
Definition SerialWombat.h:136
SerialWombatDataSource::SW_DATA_SOURCE_PIN_1
@ SW_DATA_SOURCE_PIN_1
(1) 16 bit public data provided by Pin 1
Definition SerialWombat.h:68
SerialWombatDataSource::SW_DATA_SOURCE_FRAMES_RUN_LSW
@ SW_DATA_SOURCE_FRAMES_RUN_LSW
(67) The number of frames run since reset, least significant 16 bits
Definition SerialWombat.h:133
SerialWombatDataSource::SW_DATA_SOURCE_VCC_mVOLTS
@ SW_DATA_SOURCE_VCC_mVOLTS
(75) The system source voltage in mV
Definition SerialWombat.h:141
SerialWombatDataSource::SW_DATA_SOURCE_PIN_11
@ SW_DATA_SOURCE_PIN_11
(11) 16 bit public data provided by Pin 11
Definition SerialWombat.h:78
SerialWombatDataSource::SW_DATA_SOURCE_8SEC_SAW
@ SW_DATA_SOURCE_8SEC_SAW
(174)Sawtooth wave that goes from 0 to 65535 to 0 every 8192 frames
Definition SerialWombat.h:179
SerialWombatDataSource::SW_DATA_SOURCE_PIN_4_MV
@ SW_DATA_SOURCE_PIN_4_MV
(104) Pin 4 public output expressed in mV (for analog modes only)
Definition SerialWombat.h:153
SerialWombatDataSource::SW_DATA_SOURCE_PIN_6
@ SW_DATA_SOURCE_PIN_6
(6) 16 bit public data provided by Pin 6
Definition SerialWombat.h:73
SerialWombatDataSource::SW_DATA_SOURCE_PIN_15
@ SW_DATA_SOURCE_PIN_15
(15) 16 bit public data provided by Pin 15
Definition SerialWombat.h:82
SerialWombatDataSource::SW_DATA_SOURCE_LFSR
@ SW_DATA_SOURCE_LFSR
A Linear FeedBack Shift register (32,7,5,3,2,1) based pseudo-random number generator.
Definition SerialWombat.h:145
SerialWombatDataSource::SW_DATA_SOURCE_OVERRUN_FRAMES
@ SW_DATA_SOURCE_OVERRUN_FRAMES
(69) The number of frames that ran more than 1mS
Definition SerialWombat.h:135
SerialWombatDataSource::SW_DATA_SOURCE_PIN_9
@ SW_DATA_SOURCE_PIN_9
(9) 16 bit public data provided by Pin 9
Definition SerialWombat.h:76
SerialWombatDataSource::SW_DATA_SOURCE_PIN_12
@ SW_DATA_SOURCE_PIN_12
(12) 16 bit public data provided by Pin 12
Definition SerialWombat.h:79
SerialWombatDataSource::SW_DATA_SOURCE_PIN_3_MV
@ SW_DATA_SOURCE_PIN_3_MV
(103) Pin 3 public output expressed in mV (for analog modes only)
Definition SerialWombat.h:152
SerialWombatDataSource::SW_DATA_SOURCE_PIN_8
@ SW_DATA_SOURCE_PIN_8
(8) 16 bit public data provided by Pin 8
Definition SerialWombat.h:75
SerialWombatDataSource::SW_DATA_SOURCE_PIN_18
@ SW_DATA_SOURCE_PIN_18
(18) 16 bit public data provided by Pin 18
Definition SerialWombat.h:85
SerialWombatDataSource::SW_DATA_SOURCE_8SEC_SQUARE
@ SW_DATA_SOURCE_8SEC_SQUARE
(173)Square wave that alternates between 0 and 65535 every 4096 frames
Definition SerialWombat.h:178
SerialWombatDataSource::SW_DATA_SOURCE_0x55
@ SW_DATA_SOURCE_0x55
(85) 0x55 is a reserved value for resyncing. Returns 0x55 0x55
Definition SerialWombat.h:148
SerialWombatDataSource::SW_DATA_SOURCE_RESET_REGISTER
@ SW_DATA_SOURCE_RESET_REGISTER
Hardware dependent reset reason register contents.
Definition SerialWombat.h:144
SerialWombatDataSource::SW_DATA_SOURCE_2SEC_SQUARE
@ SW_DATA_SOURCE_2SEC_SQUARE
(170)Square wave that alternates between 0 and 65535 every 1024 frames
Definition SerialWombat.h:175
SerialWombatDataSource::SW_DATA_COM_ADDRESS_LOW
@ SW_DATA_COM_ADDRESS_LOW
The Communications Address of the Device (Lower 16 bits)
Definition SerialWombat.h:146
SerialWombatDataSource::SW_DATA_SOURCE_PIN_18_MV
@ SW_DATA_SOURCE_PIN_18_MV
(118) Pin 18 public output expressed in mV (for analog modes only)
Definition SerialWombat.h:167
SerialWombatDataSource::SW_DATA_COM_ADDRESS_HIGH
@ SW_DATA_COM_ADDRESS_HIGH
The Communications Address of the Device (HIGHER 16 bits) Anticipated for CAN ID.
Definition SerialWombat.h:147
SerialWombatDataSource::SW_DATA_SOURCE_ERRORS
@ SW_DATA_SOURCE_ERRORS
(72)The number of incoming packets that have caused errors since reset (rolls over at 65535)
Definition SerialWombat.h:138
SerialWombatDataSource::SW_DATA_SOURCE_PIN_0_MV
@ SW_DATA_SOURCE_PIN_0_MV
(100) Pin 0 public output expressed in mV (for analog modes only)
Definition SerialWombat.h:149
SerialWombatDataSource::SW_DATA_SOURCE_PIN_4
@ SW_DATA_SOURCE_PIN_4
(4) 16 bit public data provided by Pin 4
Definition SerialWombat.h:71
SerialWombatDataSource::SW_DATA_SOURCE_SYSTEM_UTILIZATION
@ SW_DATA_SOURCE_SYSTEM_UTILIZATION
(74) A number between 0 and 65535 that scales to the average length of pin processing frames between ...
Definition SerialWombat.h:140
SerialWombatDataSource::SW_DATA_SOURCE_PACKETS_RECEIVED
@ SW_DATA_SOURCE_PACKETS_RECEIVED
(71) The nubmer of incoming command packets that have been processed since reset (rolls over at 65535...
Definition SerialWombat.h:137
SerialWombatDataSource::SW_DATA_SOURCE_1HZ_SQUARE
@ SW_DATA_SOURCE_1HZ_SQUARE
(167) Square wave that alternates between 0 and 65535 every 512 frames
Definition SerialWombat.h:172
SerialWombatDataSource::SW_DATA_SOURCE_2SEC_SAW
@ SW_DATA_SOURCE_2SEC_SAW
(171)Sawtooth wave that goes from 0 to 65535 to 0 every 2048 frames
Definition SerialWombat.h:176
SerialWombatDataSource::SW_DATA_SOURCE_PIN_17_MV
@ SW_DATA_SOURCE_PIN_17_MV
(117) Pin 17 public output expressed in mV (for analog modes only)
Definition SerialWombat.h:166
SerialWombatDataSource::SW_DATA_SOURCE_PIN_1_MV
@ SW_DATA_SOURCE_PIN_1_MV
(101) Pin 1 public output expressed in mV (for analog modes only)
Definition SerialWombat.h:150
SerialWombatDataSource::SW_DATA_SOURCE_DROPPED_FRAMES
@ SW_DATA_SOURCE_DROPPED_FRAMES
(73) The number of times since reset that a frame ran so far behind that it crossed two subsequent 1m...
Definition SerialWombat.h:139
SerialWombatDataSource::SW_DATA_SOURCE_PIN_16_MV
@ SW_DATA_SOURCE_PIN_16_MV
(116) Pin 16 public output expressed in mV (for analog modes only)
Definition SerialWombat.h:165
SerialWombatDataSource::SW_DATA_SOURCE_PIN_0
@ SW_DATA_SOURCE_PIN_0
(0) 16 bit public data provided by Pin 0
Definition SerialWombat.h:67
SerialWombatDataSource::SW_DATA_SOURCE_PIN_2
@ SW_DATA_SOURCE_PIN_2
(2) 16 bit public data provided by Pin 2
Definition SerialWombat.h:69
SerialWombatDataSource::SW_DATA_SOURCE_PIN_2_MV
@ SW_DATA_SOURCE_PIN_2_MV
(102) Pin 2 public output expressed in mV (for analog modes only)
Definition SerialWombat.h:151
SerialWombatDataSource::SW_DATA_SOURCE_PIN_16
@ SW_DATA_SOURCE_PIN_16
(16) 16 bit public data provided by Pin 16
Definition SerialWombat.h:83
SerialWombatDataSource::SW_DATA_SOURCE_1HZ_SAW
@ SW_DATA_SOURCE_1HZ_SAW
(168) Sawtooth wave that goes from 0 to 65535 to 0 every 1024 frames
Definition SerialWombat.h:173
SerialWombatDataSource::SW_DATA_SOURCE_PIN_19_MV
@ SW_DATA_SOURCE_PIN_19_MV
(119) Pin 19 public output expressed in mV (for analog modes only)
Definition SerialWombat.h:168
SerialWombatDataSource::SW_DATA_SOURCE_PIN_7
@ SW_DATA_SOURCE_PIN_7
(7) 16 bit public data provided by Pin 7
Definition SerialWombat.h:74
SerialWombatDataSource::SW_DATA_SOURCE_FRAMES_RUN_MSW
@ SW_DATA_SOURCE_FRAMES_RUN_MSW
(68) The number of frames run since reset, most significant 16 bits
Definition SerialWombat.h:134
SerialWombatDataSource::SW_DATA_SOURCE_INCREMENTING_NUMBER
@ SW_DATA_SOURCE_INCREMENTING_NUMBER
(65) An number that increments each time it is accessed.
Definition SerialWombat.h:131
SerialWombatDataSource::SW_DATA_SOURCE_PIN_19
@ SW_DATA_SOURCE_PIN_19
(19) 16 bit public data provided by Pin 19
Definition SerialWombat.h:86
SerialWombatDataSource::SW_DATA_SOURCE_2HZ_SAW
@ SW_DATA_SOURCE_2HZ_SAW
(165) Sawtooth wave that goes from 0 to 65535 to 0 every 512 frames
Definition SerialWombat.h:170
SerialWombatDataSource::SW_DATA_SOURCE_PIN_17
@ SW_DATA_SOURCE_PIN_17
(17) 16 bit public data provided by Pin 17
Definition SerialWombat.h:84
SerialWombatDataSource::SW_DATA_SOURCE_PIN_3
@ SW_DATA_SOURCE_PIN_3
(3) 16 bit public data provided by Pin 3
Definition SerialWombat.h:70
SerialWombatDataSource::SW_DATA_SOURCE_65SEC_SAW
@ SW_DATA_SOURCE_65SEC_SAW
(177 )Sawtooth wave that goes from 0 to 65535 to 0 every 65536 frames
Definition SerialWombat.h:182
SerialWombatDataSource::SW_DATA_SOURCE_NONE
@ SW_DATA_SOURCE_NONE
(255 ) Used to mean "No Source Selected"
Definition SerialWombat.h:184
SerialWombatDataSource::SW_DATA_SOURCE_2HZ_SQUARE
@ SW_DATA_SOURCE_2HZ_SQUARE
(164) Square wave that alternates between 0 and 65535 every 256 frames
Definition SerialWombat.h:169
SerialWombatDataSource::SW_DATA_SOURCE_65SEC_SQUARE
@ SW_DATA_SOURCE_65SEC_SQUARE
(176) Square wave that alternates between 0 and 65535 every 32768 frames
Definition SerialWombat.h:181
ARRAY_UINT32
#define ARRAY_UINT32(_array, _index)
Definition SerialWombat.h:51
SerialWombatErrorHandler_t
void(* SerialWombatErrorHandler_t)(uint16_t errorNumber, SerialWombatChip *sw)
Definition SerialWombat.h:301
SerialWombatPinState_t
SerialWombatPinState_t
Definition SerialWombat.h:57
SW_INPUT
@ SW_INPUT
Definition SerialWombat.h:60
SW_HIGH
@ SW_HIGH
Definition SerialWombat.h:59
SW_LOW
@ SW_LOW
Definition SerialWombat.h:58
SerialWombatAbstractButton.h
SerialWombatAbstractProcessedInput.h
SerialWombatAbstractScaledOutput.h
SerialWombatAnalogInput.h
SerialWombatBlink.h
SerialWombatDebouncedInput.h
SerialWombatErrors.h
SW_ERROR_UNKNOWN_PIN_MODE
@ SW_ERROR_UNKNOWN_PIN_MODE
(#3) A Pin mode was indicated that is not avaialble on this model or version of Serial Wombat chip
Definition SerialWombatErrors.h:28
SerialWombatFrequencyOutput.h
SerialWombatHBridge.h
SerialWombatHSClock.h
SerialWombatHSCounter.h
SerialWombatIRRx.h
SerialWombatLiquidCrystal.h
SerialWombatMatrixKeypad.h
SerialWombatPS2Keyboard.h
SerialWombatPWM.h
SerialWombatPin.h
SerialWombatProcessedInputPin.h
SerialWombatProtectedOutput.h
SerialWombatPulseOnChange.h
SerialWombatPulseTimer.h
SerialWombatQuadEnc.h
SerialWombatQueue.h
SerialWombatQueuedPulseOutput.h
SerialWombatResistanceInput.h
SerialWombatServo.h
SerialWombatTM1637.h
SerialWombatThroughputConsumer.h
SerialWombatUART.h
SerialWombatUltrasonicDistanceSensor.h
SerialWombatWS2812.h
SerialWombatWatchdog.h
SerialWombat18ABOscillatorTuner::SerialWombat18ABOscillatorTuner
SerialWombat18ABOscillatorTuner(SerialWombatChip &serialWombatChip)
Class constructor for SerialWombat18OscillatorTuner.
Definition SerialWombat.h:1633
SerialWombat18ABOscillatorTuner::update
void update()
Call periodically to tune the SW18AB oscillator to reported millis.
Definition SerialWombat.h:1638
SerialWombatChip
Class for a Serial Wombat chip. Each Serial Wombat chip on a project should have its own instance.
Definition SerialWombat.h:313
SerialWombatChip::setThroughputPin
int16_t setThroughputPin(uint32_t address)
Set this chip Address (SW8B only)
Definition SerialWombat.h:1287
SerialWombatChip::uniqueIdentifier
uint8_t uniqueIdentifier[16]
Definition SerialWombat.h:346
SerialWombatChip::isLatestFirmware
bool isLatestFirmware(void)
Check if the firmware is the latest version (or more precisely, if the firmware matches this verison ...
Definition SerialWombat.h:726
SerialWombatChip::address
uint8_t address
The I2C address of the SerialWombatChip instance.
Definition SerialWombat.h:1518
SerialWombatChip::deviceRevision
uint16_t deviceRevision
Definition SerialWombat.h:364
SerialWombatChip::wake
void wake()
Called to send a dummy packet to the Serial Wombat chip to wake it from sleep and ready it for other ...
Definition SerialWombat.h:1166
SerialWombatChip::SerialWombatChip
SerialWombatChip()
Definition SerialWombat.cpp:31
SerialWombatChip::sendReadyTime
uint32_t sendReadyTime
Used as a countdown after a reset command is issued.
Definition SerialWombat.h:429
SerialWombatChip::uniqueIdentifierLength
uint8_t uniqueIdentifierLength
Definition SerialWombat.h:352
SerialWombatChip::isSW04
bool isSW04()
Returns true if the instance received a model number corresponding to the Serial Wombat 18 series of ...
Definition SerialWombat.h:1173
SerialWombatChip::comparePublicDataToThreshold
uint32_t comparePublicDataToThreshold(uint16_t threshold=0)
Definition SerialWombat.h:788
SerialWombatChip::echo
int16_t echo(uint8_t data[], uint8_t count=7)
Echo a byte array back to the host. Used for testing and debugging.
Definition SerialWombat.h:1529
SerialWombatChip::digitalWrite
void digitalWrite(uint8_t pin, uint8_t val)
Set an output pin High or Low.
Definition SerialWombat.h:895
SerialWombatChip::readFlashAddress
uint32_t readFlashAddress(uint32_t address)
Read Address from Flash based on 32 bit address.
Definition SerialWombat.h:1101
SerialWombatChip::inBoot
bool inBoot
Set to true if boot mode is indicated by a version query.
Definition SerialWombat.h:369
SerialWombatChip::isPinModeSupported
bool isPinModeSupported(int pinMode)
Check if a specific pin mode is supported by the firmware in the Serial Wombat chip....
Definition SerialWombat.h:1195
SerialWombatChip::isPinModeSupported
bool isPinModeSupported(SerialWombatPinMode_t pinMode)
Check if a specific pin mode is supported by the firmware in the Serial Wombat chip....
Definition SerialWombat.h:1204
SerialWombatChip::isSW08
bool isSW08()
Returns true if the instance received a model number corresponding to the Serial Wombat 08 series of ...
Definition SerialWombat.h:1185
SerialWombatChip::readUniqueIdentifier
void readUniqueIdentifier()
Read the unique identifier from the Serial Wombat chip and store it in uniqueIdentifier.
Definition SerialWombat.h:450
SerialWombatChip::readVersion
char * readVersion(void)
Request version string (combined model and firmware) and return pointer to it.
Definition SerialWombat.h:692
SerialWombatChip::configureDigitalPin
void configureDigitalPin(uint8_t pin, uint8_t highLow)
Configure a pin to a digital state with the same parameters as Arduino's digitalWrite() function.
Definition SerialWombat.h:383
SerialWombatChip::readPublicData
uint16_t readPublicData(uint8_t pin)
Read the 16 Bit public data associated with a Serial Wombat Pin Mode.
Definition SerialWombat.h:753
SerialWombatChip::fwVersion
uint8_t fwVersion[4]
Contains the last firmware Version retreived by queryVersion() as a zero-terminated string.
Definition SerialWombat.h:339
SerialWombatChip::readBirthday
uint32_t readBirthday()
Read the birthday of the Serial Wombat 18AB chip.
Definition SerialWombat.h:1560
SerialWombatChip::communicationErrorRetries
uint8_t communicationErrorRetries
How many times to retry a packet if communcation bus (such as I2C) error.
Definition SerialWombat.h:1521
SerialWombatChip::echo
int16_t echo(char *data)
Echo a byte array back to the host. Used for testing and debugging.
Definition SerialWombat.h:1545
SerialWombatChip::readOverflowFrames
uint16_t readOverflowFrames()
Get the number of times an overflow Frame has occured.
Definition SerialWombat.h:1012
SerialWombatChip::find
static uint8_t find(bool keepTrying=false)
Search the I2C Bus addresses 0x68 to 0x6F for I2C devices, and test to see if they respond to Serial ...
Definition SerialWombat.h:1438
SerialWombatChip::readDeviceIdentifier
void readDeviceIdentifier()
Read the device identifier from the Serial Wombat chip and store it in deviceIdentifier.
Definition SerialWombat.h:493
SerialWombatChip::writeUserBuffer
int writeUserBuffer(uint16_t index, uint8_t *buffer, uint16_t count)
Write bytes to the User Memory Buffer in the Serial Wombat chip.
Definition SerialWombat.h:1300
SerialWombatChip::readTemperature_100thsDegC
int16_t readTemperature_100thsDegC(void)
Measure the Serial Wombat chip's internal temperature.
Definition SerialWombat.h:839
SerialWombatChip::sendPacketNoResponse
int sendPacketNoResponse(uint8_t tx[])
Send an 8 byte packet to the Serial Wombat chip, don't wait for a response.
Definition SerialWombat.cpp:280
SerialWombatChip::~SerialWombatChip
~SerialWombatChip()
Definition SerialWombat.cpp:37
SerialWombatChip::readRamAddress
uint8_t readRamAddress(uint16_t address)
Read Address from RAM based on 16 bit address.
Definition SerialWombat.h:1052
SerialWombatChip::readUserBuffer
int16_t readUserBuffer(uint16_t index, uint8_t *buffer, uint16_t count)
Read data from the Serial Wombat 18AB's internal RAM buffer.
Definition SerialWombat.h:1120
SerialWombatChip::isSW18
bool isSW18()
Returns true if the instance received a model number corresponding to the Serial Wombat 18 series of ...
Definition SerialWombat.h:1180
SerialWombatChip::lastErrorCode
int16_t lastErrorCode
The last error code returned as part of a protocol error message expressed as a positive integer.
Definition SerialWombat.h:372
SerialWombatChip::readBrand
int16_t readBrand(char *data)
Read the brand of the Serial Wombat 18AB chip.
Definition SerialWombat.h:1580
SerialWombatChip::pinMode
void pinMode(uint8_t pin, uint8_t mode, bool pullDown=false, bool openDrain=false)
Set a pin to INPUT or OUTPUT, with options for pull Ups and open Drain settings.
Definition SerialWombat.h:876
SerialWombatChip::setThroughputPin
int16_t setThroughputPin(uint8_t pin)
Set a pin to be a throughput monitoring pin.
Definition SerialWombat.h:1268
SerialWombatChip::begin
int16_t begin(HardwareSerial &serial, bool reset=true)
initialize a Serial Wombat chip to use a Serial Interface.
Definition SerialWombat.h:548
SerialWombatChip::sendPacket
int sendPacket(uint8_t tx[], uint8_t rx[])
Send an 8 byte packet to the Serial Wombat chip and wait for 8 bytes back.
Definition SerialWombat.cpp:115
SerialWombatChip::readVersion_uint32
uint32_t readVersion_uint32(void)
Request version as a uint32.
Definition SerialWombat.h:713
SerialWombatChip::writePublicData
uint16_t writePublicData(uint8_t pin, uint16_t value)
Write a 16 bit value to a Serial Wombat pin Mode.
Definition SerialWombat.h:780
SerialWombatChip::readSupplyVoltage_mV
uint16_t readSupplyVoltage_mV(void)
Measure the Serial Wombat chip's Supply voltage.
Definition SerialWombat.h:806
SerialWombatChip::writeFlashRow
int16_t writeFlashRow(uint32_t address)
Writes a row in flash. Intended for use with the Bootloader, not by end users outside of bootloading ...
Definition SerialWombat.h:1248
SerialWombatChip::writeUserBuffer
int writeUserBuffer(uint16_t index, char *s)
Write bytes to the User Memory Buffer in the Serial Wombat chip.
Definition SerialWombat.h:1395
SerialWombatChip::eraseFlashPage
int16_t eraseFlashPage(uint32_t address)
Erases a page in flash. Intended for use with the Bootloader, not by end users outside of bootloading...
Definition SerialWombat.h:1237
SerialWombatChip::returnErrorCode
uint16_t returnErrorCode(uint8_t *rx)
Convert an ASCII Error code from a received packet into an integer error code.
Definition SerialWombat.h:517
SerialWombatChip::deviceIdentifier
uint16_t deviceIdentifier
Definition SerialWombat.h:358
SerialWombatChip::writeRamAddress
int16_t writeRamAddress(uint16_t address, uint8_t value)
Write byte to Address in RAM based on 16 bit address.
Definition SerialWombat.h:1080
SerialWombatChip::initialize
int16_t initialize()
An internal function used to set up the Serial Wombat chip and this class. Call begin() instead of th...
Definition SerialWombat.h:434
SerialWombatChip::writeFrameTimerPin
int16_t writeFrameTimerPin(uint8_t pin)
Set a pin to be a frame timer for system utilization (SW18AB Only)
Definition SerialWombat.h:1424
SerialWombatChip::_supplyVoltagemV
uint16_t _supplyVoltagemV
Definition SerialWombat.h:333
SerialWombatChip::registerErrorHandler
void registerErrorHandler(SerialWombatErrorHandler_t handler)
Registers an error handler that is called by the SerialWombatChip sendPacket() command when a protoco...
Definition SerialWombat.h:1512
SerialWombatChip::begin
int16_t begin(TwoWire &wire, uint8_t i2cAddress, bool reset=true)
initialize a Serial Wombat chip to use a specified I2C Interface and address.
Definition SerialWombat.h:594
SerialWombatChip::analogWrite
void analogWrite(uint8_t pin, int val)
Set a pin to PWM output.
Definition SerialWombat.h:945
SerialWombatChip::errorCount
uint16_t errorCount
Incremented every time a communication or command error is detected.
Definition SerialWombat.h:366
SerialWombatChip::writeUserBuffer
int writeUserBuffer(uint16_t index, const char s[])
Write bytes to the User Memory Buffer in the Serial Wombat chip.
Definition SerialWombat.h:1406
SerialWombatChip::analogRead
int analogRead(uint8_t pin)
Configures pin as analog input and does an immediate A/D conversion.
Definition SerialWombat.h:926
SerialWombatChip::readPublicData
uint16_t readPublicData(SerialWombatDataSource dataSource)
Read the 16 Bit public data associated with a Serial Wombat Pin Mode.
Definition SerialWombat.h:770
SerialWombatChip::queryVersion
bool queryVersion()
Send a version request to the Serial Wombat chip.
Definition SerialWombat.h:967
SerialWombatChip::jumpToBoot
void jumpToBoot()
Jump to Bootloader and wait for a UART download of new firmware.
Definition SerialWombat.h:1026
SerialWombatChip::digitalRead
int digitalRead(uint8_t pin)
Reads the state of a Pin.
Definition SerialWombat.h:905
SerialWombatChip::hardwareReset
void hardwareReset()
Send a reset command to the Serial Wombat chip.
Definition SerialWombat.h:862
SerialWombatChip::model
uint8_t model[4]
Contains the last model retreived by queryVersion() as a zero-terminated string.
Definition SerialWombat.h:336
SerialWombatChip::readFramesExecuted
uint32_t readFramesExecuted()
Get the number of 1mS frames that have been executed since Serial Wombat chip reset.
Definition SerialWombat.h:995
SerialWombatChip::readLastErrorCommand
int16_t readLastErrorCommand(uint8_t *cmd)
Returns the last Serial Wombat command that produced a protocol error.
Definition SerialWombat.h:1484
SerialWombatChip::sleep
void sleep()
Shuts down most functions of the Serial Wombat chip reducing power consumption.
Definition SerialWombat.h:1158
SerialWombat
This class name is depricated. Do not use for new development. Use SerialWombatChip instead.
Definition SerialWombat.h:1715