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
43#define SW_LE16(_a) (uint8_t)((_a) & 0xFF), (uint8_t)((_a) >>8)
44
46#define SW_LE32(_a) (uint8_t)((_a) & 0xFF), (uint8_t)((_a) >>8) , (uint8_t)((_a) >>16), (uint8_t)((_a) >>24)
47
48#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])
49#define SW18AB_LATEST_FIRMWARE 221
50#define SW08B_LATEST_FIRMWARE 221
51#define SW4B_LATEST_FIRMWARE 203
52
53 typedef enum
54{
55 SW_LOW = 0,
56 SW_HIGH = 1,
57 SW_INPUT = 2,
58}SerialWombatPinState_t;
59
60
62 enum class SerialWombatDataSource{
63
64 SW_DATA_SOURCE_PIN_0 = 0,
65 SW_DATA_SOURCE_PIN_1 = 1,
66 SW_DATA_SOURCE_PIN_2 = 2,
67 SW_DATA_SOURCE_PIN_3 = 3,
68 SW_DATA_SOURCE_PIN_4 = 4,
69 SW_DATA_SOURCE_PIN_5 = 5,
70 SW_DATA_SOURCE_PIN_6 = 6,
71 SW_DATA_SOURCE_PIN_7 = 7,
72 SW_DATA_SOURCE_PIN_8 = 8,
73 SW_DATA_SOURCE_PIN_9 = 9,
74 SW_DATA_SOURCE_PIN_10 = 10,
75 SW_DATA_SOURCE_PIN_11 = 11,
76 SW_DATA_SOURCE_PIN_12 = 12,
77 SW_DATA_SOURCE_PIN_13 = 13,
78 SW_DATA_SOURCE_PIN_14 = 14,
79 SW_DATA_SOURCE_PIN_15 = 15,
80 SW_DATA_SOURCE_PIN_16 = 16,
81 SW_DATA_SOURCE_PIN_17 = 17,
82 SW_DATA_SOURCE_PIN_18 = 18,
83 SW_DATA_SOURCE_PIN_19 = 19,
84// SW_DATA_SOURCE_PIN_20 = 20,
85// SW_DATA_SOURCE_PIN_21 = 21,
86// SW_DATA_SOURCE_PIN_22 = 22,
87// SW_DATA_SOURCE_PIN_23 = 23,
88// SW_DATA_SOURCE_PIN_24 = 24,
89// SW_DATA_SOURCE_PIN_25 = 25,
90// SW_DATA_SOURCE_PIN_26 = 26,
91// SW_DATA_SOURCE_PIN_27 = 27,
92// SW_DATA_SOURCE_PIN_28 = 28,
93// SW_DATA_SOURCE_PIN_29 = 29,
94// SW_DATA_SOURCE_PIN_30 = 30,
95// SW_DATA_SOURCE_PIN_31 = 31,
96// SW_DATA_SOURCE_PIN_32 = 32,
97// SW_DATA_SOURCE_PIN_33 = 33,
98// SW_DATA_SOURCE_PIN_34 = 34,
99// SW_DATA_SOURCE_PIN_35 = 35,
100// SW_DATA_SOURCE_PIN_36 = 36,
101// SW_DATA_SOURCE_PIN_37 = 37,
102// SW_DATA_SOURCE_PIN_38 = 38,
103// SW_DATA_SOURCE_PIN_39 = 39,
104// SW_DATA_SOURCE_PIN_40 = 40,
105// SW_DATA_SOURCE_PIN_41 = 41,
106// SW_DATA_SOURCE_PIN_42 = 42,
107// SW_DATA_SOURCE_PIN_43 = 43,
108// SW_DATA_SOURCE_PIN_44 = 44,
109// SW_DATA_SOURCE_PIN_45 = 45,
110// SW_DATA_SOURCE_PIN_46 = 46,
111// SW_DATA_SOURCE_PIN_47 = 47,
112// SW_DATA_SOURCE_PIN_48 = 48,
113// SW_DATA_SOURCE_PIN_49 = 49,
114// SW_DATA_SOURCE_PIN_50 = 50,
115// SW_DATA_SOURCE_PIN_51 = 51,
116// SW_DATA_SOURCE_PIN_52 = 52,
117// SW_DATA_SOURCE_PIN_53 = 53,
118// SW_DATA_SOURCE_PIN_54 = 54,
119// SW_DATA_SOURCE_PIN_55 = 55,
120// SW_DATA_SOURCE_PIN_56 = 56,
121// SW_DATA_SOURCE_PIN_57 = 57,
122// SW_DATA_SOURCE_PIN_58 = 58,
123// SW_DATA_SOURCE_PIN_59 = 59,
124// SW_DATA_SOURCE_PIN_60 = 60,
125// SW_DATA_SOURCE_PIN_61 = 61,
126// SW_DATA_SOURCE_PIN_62 = 62,
127// SW_DATA_SOURCE_PIN_63 = 63,
128 SW_DATA_SOURCE_INCREMENTING_NUMBER = 65,
129 SW_DATA_SOURCE_1024mvCounts = 66 ,
130 SW_DATA_SOURCE_FRAMES_RUN_LSW = 67,
131 SW_DATA_SOURCE_FRAMES_RUN_MSW = 68,
132 SW_DATA_SOURCE_OVERRUN_FRAMES = 69,
133 SW_DATA_SOURCE_TEMPERATURE = 70,
134 SW_DATA_SOURCE_PACKETS_RECEIVED = 71,
135 SW_DATA_SOURCE_ERRORS = 72,
136 SW_DATA_SOURCE_DROPPED_FRAMES = 73,
137 SW_DATA_SOURCE_SYSTEM_UTILIZATION = 74,
138 SW_DATA_SOURCE_VCC_mVOLTS = 75,
139 SW_DATA_SOURCE_VBG_COUNTS_VS_VREF = 76,
140 SW_DATA_SOURCE_LFSR = 78,
141 SW_DATA_SOURCE_0x55 = 85,
142 SW_DATA_SOURCE_PIN_0_MV = 100,
143 SW_DATA_SOURCE_PIN_1_MV = 101,
144 SW_DATA_SOURCE_PIN_2_MV = 102,
145 SW_DATA_SOURCE_PIN_3_MV = 103,
146 SW_DATA_SOURCE_PIN_4_MV = 104,
147 //NOT ANALOG SW_DATA_SOURCE_PIN_5_MV = 105,
148 //NOT ANALOG SW_DATA_SOURCE_PIN_6_MV = 106,
149 //NOT ANALOG SW_DATA_SOURCE_PIN_7_MV = 107,
150 //NOT ANALOG SW_DATA_SOURCE_PIN_8_MV = 108,
151 //NOT ANALOG SW_DATA_SOURCE_PIN_9_MV = 109,
152 //NOT ANALOG SW_DATA_SOURCE_PIN_10_MV = 110,
153 //NOT ANALOG SW_DATA_SOURCE_PIN_11_MV = 111,
154 //NOT ANALOG SW_DATA_SOURCE_PIN_12_MV = 112,
155 //NOT ANALOG SW_DATA_SOURCE_PIN_13_MV = 113,
156 //NOT ANALOG SW_DATA_SOURCE_PIN_14_MV = 114,
157 //NOT ANALOG SW_DATA_SOURCE_PIN_15_MV = 115,
158 SW_DATA_SOURCE_PIN_16_MV = 116,
159 SW_DATA_SOURCE_PIN_17_MV = 117,
160 SW_DATA_SOURCE_PIN_18_MV = 118,
161 SW_DATA_SOURCE_PIN_19_MV = 119,
162 SW_DATA_SOURCE_2HZ_SQUARE = 164,
163 SW_DATA_SOURCE_2HZ_SAW = 165,
164// SW_DATA_SOURCE_2HZ_SIN = 166,
165 SW_DATA_SOURCE_1HZ_SQUARE = 167,
166 SW_DATA_SOURCE_1HZ_SAW = 168,
167// SW_DATA_SOURCE_1HZ_SIN = 169,
168 SW_DATA_SOURCE_2SEC_SQUARE = 170,
169 SW_DATA_SOURCE_2SEC_SAW = 171,
170// SW_DATA_SOURCE_2SEC_SIN = 172,
171 SW_DATA_SOURCE_8SEC_SQUARE = 173,
172 SW_DATA_SOURCE_8SEC_SAW = 174,
173// SW_DATA_SOURCE_8SEC_SIN = 175,
174 SW_DATA_SOURCE_65SEC_SQUARE = 176,
175 SW_DATA_SOURCE_65SEC_SAW = 177,
176// SW_DATA_SOURCE_65SEC_SIN = 178,
177 SW_DATA_SOURCE_NONE = 255,
178};
179
180#define ERROR_HOST_INCORRECT_NUMBER_BYTES_WRITTEN 0x10000
181#define ERROR_HOST_DATA_TOO_LONG 0x10001
182#define ERROR_HOST_NACK_ADDRESS 0x10002
183#define ERROR_HOST_NACK_DATA 0x10003
184#define ERROR_HOST_OTHER_I2C_ERROR 0x10004
185
186#define WOMBAT_MAXIMUM_PINS 20
187
188 enum class SerialWombatCommands
189{
190 CMD_ECHO ='!',
191 CMD_READ_BUFFER_ASCII = 'G',
192 CMD_ASCII_SET_PIN ='P',
193 CMD_RESET = 'R',
194 CMD_SET_BUFFER_ASCII = 'S',
195 CMD_RESYNC = 'U',
196 CMD_VERSION = 'V',
197 CMD_SUPPLYVOLTAGE = 'v',
198 COMMAND_BINARY_READ_PIN_BUFFFER = 0x81,
199 COMMAND_BINARY_SET_PIN_BUFFFER = 0x82,
200 COMMAND_BINARY_READ_USER_BUFFER = 0x83,
201 COMMAND_BINARY_WRITE_USER_BUFFER = 0x84,
202 COMMAND_BINARY_WRITE_USER_BUFFER_CONTINUE = 0x85,
203 COMMAND_BINARY_PIN_POLL_THRESHOLD = 0x8F,
204 COMMAND_BINARY_QUEUE_INITIALIZE = 0x90,
205 COMMAND_BINARY_QUEUE_ADD_BYTES = 0x91,
206 COMMAND_BINARY_QUEUE_ADD_7BYTES = 0x92,
207 COMMAND_BINARY_QUEUE_READ_BYTES = 0x93,
208 COMMAND_BINARY_QUEUE_INFORMATION = 0x94,
209 COMMAND_BINARY_QUEUE_CLONE = 0x95,
210 COMMAND_BINARY_CONFIG_DATALOGGER = 0x96,
211 COMMAND_BINARY_CONFIGURE = 0x9F,
212 COMMAND_BINARY_READ_RAM = 0xA0,
213 COMMAND_BINARY_READ_FLASH = 0xA1,
214 COMMAND_BINARY_READ_EEPROM = 0xA2,
215 COMMAND_BINARY_WRITE_RAM = 0xA3,
216 COMMAND_BINARY_WRITE_FLASH = 0xA4,
217 COMMAND_CALIBRATE_ANALOG = 0xA5,
218 COMMAND_ENABLE_2ND_UART = 0xA6,
219 COMMAND_READ_LAST_ERROR_PACKET = 0xA7,
220 COMMAND_UART0_TX_7BYTES = 0xB0,
221 COMMAND_UART0_RX_7BYTES = 0xB1,
222 COMMAND_UART1_TX_7BYTES = 0xB2,
223 COMMAND_UART1_RX_7BYTES = 0xB3,
224 COMMAND_BINARY_TEST_SEQUENCE = 0xB4,
225 COMMAND_BINARY_RW_PIN_MEMORY = 0xB5,
226 COMMAND_CAPTURE_STARTUP_SEQUENCE = 0xB6,
227 COMMAND_ADJUST_FREQUENCY = 0xB7,
228 COMMAND_SET_PIN_HW = 0xB8,
229 COMMAND_BINARY_SET_ADDRESS = 0xB9,
230 CONFIGURE_PIN_MODE0 = 200,
231 CONFIGURE_PIN_MODE1 = 201,
232 CONFIGURE_PIN_MODE2 = 202,
233 CONFIGURE_PIN_MODE3 = 203,
234 CONFIGURE_PIN_MODE4 = 204,
235 CONFIGURE_PIN_MODE5 = 205,
236 CONFIGURE_PIN_MODE6 = 206,
237 CONFIGURE_PIN_MODE7 = 207,
238 CONFIGURE_PIN_MODE8 = 208,
239 CONFIGURE_PIN_MODE9 = 209,
240 CONFIGURE_PIN_MODE10 = 210,
241 CONFIGURE_PIN_OUTPUTSCALE = 210,
242 CONFIGURE_PIN_MODE_DISABLE = 219,
243 CONFIGURE_PIN_INPUTPROCESS = 211,
244 CONFIGURE_PIN_MODE_HW_0 = 220,
245 CONFIGURE_CHANNEL_MODE_HW_1 = 221,
246 CONFIGURE_CHANNEL_MODE_HW_2 = 222,
247 CONFIGURE_CHANNEL_MODE_HW_3 = 223,
248
249};
250
251
252 typedef enum {
253 PIN_MODE_DIGITALIO = 0,
254 PIN_MODE_CONTROLLED = 1,
255 PIN_MODE_ANALOGINPUT = 2,
256 PIN_MODE_SERVO = 3,
257 PIN_MODE_THROUGHPUT_CONSUMER = 4,
258 PIN_MODE_QUADRATUREENCODER = 5,
259 PIN_MODE_HBRIDGE = 6,
260 PIN_MODE_WATCHDOG = 7,
261 PIN_MODE_PROTECTED_OUTPUT = 8,
262 PIN_MODE_DEBOUNCE = 10,
263 PIN_MODE_TM1637 = 11,
264 PIN_MODE_WS2812 = 12,
265 PIN_MODE_SW_UART = 13,
266 PIN_MODE_INPUT_PROCESSOR = 14,
267 PIN_MODE_MATRIX_KEYPAD = 15,
268 PIN_MODE_PWM = 16,
269 PIN_MODE_UART_RX_TX = 17,
270 PIN_MODE_PULSETIMER = 18,
271 PIN_MODE_FRAME_TIMER = 21,
272 PIN_MODE_SW18AB_CAPTOUCH = 22,
273 PIN_MODE_UART1_RX_TX = 23,
274 PIN_MODE_RESISTANCEINPUT = 24,
275 PIN_MODE_PULSE_ON_CHANGE = 25,
276 PIN_MODE_HS_SERVO = 26,
277 PIN_MODE_ULTRASONIC_DISTANCE = 27,
278 PIN_MODE_LIQUIDCRYSTAL = 28,
279 PIN_MODE_HS_CLOCK = 29,
280 PIN_MODE_HS_COUNTER = 30,
281 PIN_MODE_VGA = 31,
282 PIN_MODE_PS2KEYBOARD = 32,
283 PIN_MODE_I2C_CONTROLLER = 33,
284 PIN_MODE_QUEUED_PULSE_OUTPUT = 34,
285 PIN_MODE_FREQUENCY_OUTPUT = 36,
286 PIN_MODE_IRRX = 37,
287 PIN_MODE_UNKNOWN = 255,
288}SerialWombatPinMode_t;
289
290 class SerialWombatChip;
291
292 typedef void (*SerialWombatErrorHandler_t) (uint16_t errorNumber, SerialWombatChip* sw);
293
299 class SerialWombatChip
300{
301 private:
302
303 char version[8] = { 0 };
304 HardwareSerial * Serial = NULL;
305 TwoWire* i2cInterface = NULL;
306 uint8_t _pinmode[WOMBAT_MAXIMUM_PINS]={}; // Includes Pullup
307 bool _pullDown[WOMBAT_MAXIMUM_PINS]={};
308 bool _openDrain[WOMBAT_MAXIMUM_PINS]={};
309 bool _highLow[WOMBAT_MAXIMUM_PINS] = {};
310 bool _asleep = false;
311 SerialWombatErrorHandler_t errorHandler = NULL;
312 bool _currentlyCommunicating = false;
313 public:
320 uint16_t _supplyVoltagemV = 0;
321
323 uint8_t model[4] = { 0 };
324
326 uint8_t fwVersion[4] = { 0 };
327
333 uint8_t uniqueIdentifier[16];
334
339 uint8_t uniqueIdentifierLength = 0;
340
345 uint16_t deviceIdentifier;
346
351 uint16_t deviceRevision;
353 uint16_t errorCount = 0;
354
356 bool inBoot = false;
357
359 int16_t lastErrorCode = 0;
360
361 void configureDigitalPin(uint8_t pin, uint8_t highLow)
362 {
363 uint8_t tx[8] = { 200,pin,0,0,0,0,0,0x55 };
364 uint8_t rx[8];
365 switch (_pinmode[pin])
366 {
367 case INPUT: // Arduino input
368 {
369 tx[3] = 2; //Input
370 }
371 break;
372 case OUTPUT:
373 {
374 if (highLow == LOW)
375 {
376 tx[3] = 0;
377 }
378 else if (highLow == HIGH)
379 {
380 tx[3] = 1;
381 }
382 else
383 {
384 return;
385 }
386 }
387 break;
388 case INPUT_PULLUP:
389 {
390 tx[3] = 2; //Input
391 tx[4] = 1; //Pullup on
392 }
393 break;
394 default:
395 {
396 return;
397 }
398 }
399 tx[6] = _openDrain[pin];
400 tx[5] = _pullDown[pin];
401 sendPacket(tx, rx, true);
402 }
403 uint32_t sendReadyTime = 0;
404 int16_t initialize()
405 {
406 lastErrorCode = 0;
407 readVersion();
408 readSupplyVoltage_mV();
409 readUniqueIdentifier();
410 readDeviceIdentifier();
411 return(lastErrorCode);
412 }
413
414 void readUniqueIdentifier()
415 {
416 uniqueIdentifierLength = 0;
417 if (version[0] == 'S' && version[1] == '0' && version[2] == '4')
418 { //16F15214
419 for (uint32_t address = 0x8100; address <= 0x8108; ++address)
420 {
421 uint32_t data = readFlashAddress(address);
422 uniqueIdentifier[uniqueIdentifierLength] = (uint8_t)data;
423 ++uniqueIdentifierLength;
424 /* Always zero... leave out
425 uniqueIdentifier[uniqueIdentifierLength] = (uint8_t)(data>>8);
426 ++uniqueIdentifierLength;
427 */
428 }
429 }
430 else if (isSW18())
431 {
432 for (uint32_t address = 0x801600; address <= 0x801608; address += 2)
433 {
434 uint32_t data = readFlashAddress(address);
435 uniqueIdentifier[uniqueIdentifierLength] = data;
436 ++uniqueIdentifierLength;
437 uniqueIdentifier[uniqueIdentifierLength] = data >> 8;
438 ++uniqueIdentifierLength;
439 uniqueIdentifier[uniqueIdentifierLength] = data >> 16;
440 ++uniqueIdentifierLength;
441 }
442 }
443 }
444
445 void readDeviceIdentifier()
446 {
447 if (version[0] == 'S' && version[1] == '0' && version[2] == '4')
448 { //16F15214
449
450 uint32_t data = readFlashAddress(0x8006);
451 deviceIdentifier = (uint16_t)data;
452 data = readFlashAddress(0x8005);
453 deviceRevision = (uint16_t)data;
454 }
455 else if (isSW18())
456 {
457 uint32_t data = readFlashAddress(0xFF0000);
458 deviceIdentifier = (uint16_t)data;
459 data = readFlashAddress(0xFF0002);
460 deviceRevision = (uint16_t)data & 0xF;
461 }
462 }
463
464 uint16_t returnErrorCode(uint8_t* rx)
465 {
466 uint16_t result = rx[1] - '0';
467 result *= 10;
468 result += rx[2] - '0';
469 result *= 10;
470 result += rx[3] - '0';
471 result *= 10;
472 result += rx[4] - '0';
473 result *= 10;
474 result += rx[5] - '0';
475 return(result);
476 }
477
478
479
480 public:
481 SerialWombatChip();
495 int16_t begin(HardwareSerial& serial, bool reset = true)
496 {
497 Serial = &serial;
498 Serial->begin(115200);
499 Serial->setTimeout(2);
500 Serial->write((uint8_t*)"UUUUUUUU", 8);
501 delay(5);
502 while (Serial->read() >= 0);
503 if (reset)
504 {
505 hardwareReset();
506 sendReadyTime = millis() + 1000;
507 return(1);
508 }
509 else
510 {
511 return initialize();
512 }
513
514
515 }
516
526 int16_t begin(uint8_t i2cAddress);
527
541 int16_t begin(TwoWire& wire, uint8_t i2cAddress, bool reset = true)
542 {
543 i2cInterface = &wire;
544 address = i2cAddress;
545
546 Wire.beginTransmission(i2cAddress);
547 int error = Wire.endTransmission();
548
549
550 if (error != 0)
551 {
552 return(-1);
553 }
554
555 if (reset)
556 {
557 hardwareReset();
558 sendReadyTime = millis() + 250;
559 return(1);
560 }
561 else
562 {
563 sendReadyTime = 0;
564 return initialize();
565
566 }
567 }
568
569 ~SerialWombatChip();
570
581 int sendPacket( uint8_t tx[], uint8_t rx[]);
582
592 int sendPacket(uint8_t tx[]);
593
604 int sendPacket(uint8_t tx[], uint8_t rx[], bool retryIfEchoDoesntMatch, uint8_t beginningBytesToMatch = 8, uint8_t endBytesToMatch = 0);
614 int sendPacket(uint8_t tx[], bool retryIfEchoDoesntMatch);
615
624
625 int sendPacketNoResponse(uint8_t tx[]);
626
635 char* readVersion(void)
636 {
637 uint8_t tx[] = { 'V',0x55,0x55,0x55,0x55,0x55,0x55,0x55 };
638 uint8_t rx[8];
639 sendPacket(tx, rx);
640 memcpy(version, &rx[1], 7);
641 version[7] = '\0';
642 memcpy(model, &rx[1], 3);
643 model[3] = '\0';
644 fwVersion[0] = rx[5];
645 fwVersion[1] = rx[6];
646 fwVersion[2] = rx[7];
647 return (version);
648 }
649
656 uint32_t readVersion_uint32(void)
657 {
658 readVersion();
659 return (
660 ((uint32_t)fwVersion[0] - '0') * 100 +
661 ((uint32_t)fwVersion[1] - '0') * 10 +
662 (uint32_t)fwVersion[2] - '0');
663 }
664
665 bool isLatestFirmware(void)
666 {
667 uint32_t v = readVersion_uint32();
668 if (isSW18())
669 {
670 return (v == SW18AB_LATEST_FIRMWARE);
671 }
672 else if (isSW08())
673 {
674 return (v == SW08B_LATEST_FIRMWARE);
675 }
676 else
677 {
678 return (v == SW4B_LATEST_FIRMWARE);
679
680 }
681 }
682
692 uint16_t readPublicData(uint8_t pin)
693 {
694 uint8_t tx[] = { 0x81,pin,255,255,0x55,0x55,0x55,0x55 };
695 uint8_t rx[8];
696 sendPacket(tx, rx);
697 return(rx[2] + (uint16_t)rx[3] * 256);
698 }
699
709 uint16_t readPublicData(SerialWombatDataSource dataSource)
710 {
711 return (readPublicData((uint8_t)dataSource));
712 }
713
719 uint16_t writePublicData(uint8_t pin, uint16_t value)
720 {
721 uint8_t tx[] = { 0x82,pin,(uint8_t)(value & 0xFF),(uint8_t)(value >> 8) ,255,0x55,0x55,0x55 };
722 uint8_t rx[8];
723 sendPacket(tx, rx);
724 return (rx[2] + rx[3] * 256);
725 }
726
727 uint32_t comparePublicDataToThreshold(uint16_t threshold = 0)
728 {
729 uint8_t tx[] = { (uint8_t) SerialWombatCommands::COMMAND_BINARY_PIN_POLL_THRESHOLD,SW_LE16(threshold) ,0x55, 0x55,0x55,0x55,0x55 };
730 uint8_t rx[8];
731 sendPacket(tx, rx);
732 return (ARRAY_UINT32(rx,1));
733 }
734
744
745 uint16_t readSupplyVoltage_mV(void)
746 {
747 if (isSW18() || isSW08())
748 {
749 _supplyVoltagemV = readPublicData(SerialWombatDataSource::SW_DATA_SOURCE_VCC_mVOLTS);
750 }
751 else
752 {
753 int32_t counts = readPublicData(66); // Get FVR counts (1.024 v)
754 if (counts > 0)
755 {
756 uint32_t mv = 1024 * 65536 / counts;
757 _supplyVoltagemV = (uint16_t)mv;
758 }
759 else
760 {
761 _supplyVoltagemV = 0;
762 }
763 }
764 return(_supplyVoltagemV);
765 }
766
767
778 int16_t readTemperature_100thsDegC(void)
779 {
780 if (isSW18())
781 {
782 int32_t result = readPublicData(70);
783 if (result >= 32768)
784 {
785 result = result - 65536;
786 }
787 return ((int16_t)result);
788 }
789 else
790 {
791 return 2500;
792 }
793 }
794
801 void hardwareReset()
802 {
803 uint8_t tx[9] = "ReSeT!#*";
804 sendPacketNoResponse(tx);
805 }
806
815 void pinMode(uint8_t pin, uint8_t mode, bool pullDown = false, bool openDrain = false)
816 {
817 if (pin >= WOMBAT_MAXIMUM_PINS)
818 {
819 return;
820 }
821 _pullDown[pin] = pullDown;
822 _openDrain[pin] = openDrain;
823 _pinmode[pin] = mode;
824 configureDigitalPin(pin, mode);
825 }
826
834 void digitalWrite(uint8_t pin, uint8_t val)
835 {
836 configureDigitalPin(pin, val);
837 }
838
844 int digitalRead(uint8_t pin)
845 {
846 if (readPublicData(pin) > 0)
847 {
848 return (HIGH);
849 }
850 else
851 {
852 return (LOW);
853 }
854 }
855
865 int analogRead(uint8_t pin)
866 {
867 uint8_t tx[] = { 200,pin,PIN_MODE_ANALOGINPUT,0,0,0,0,0 };
868 uint8_t rx[8];
869 sendPacket(tx, rx);
870 return (readPublicData(pin) >> 6); // Scale from 16 bit value to 10 bit value.
871 }
872
884 void analogWrite(uint8_t pin, int val)
885 {
886 uint8_t dutyCycleLow = 0;
887 if (val == 255)
888 {
889 dutyCycleLow = 255;
890 }
891 uint8_t tx[] = { (uint8_t)SerialWombatCommands::CONFIGURE_PIN_MODE0,pin,PIN_MODE_PWM,pin,dutyCycleLow,(uint8_t) val,false,0x55 };
892 uint8_t rx[8];
893 sendPacket(tx, rx);
894 }
895
906 bool queryVersion()
907 {
908 uint8_t tx[8] = { 'V',0x55,0x55,0x55,0x55,0x55,0x55,0x55 };
909 uint8_t rx[8];
910 sendPacket(tx, rx);
911 if (rx[0] == 'V' && (rx[1] == 'S' || rx[1] == 'B'))
912 {
913 model[0] = rx[1];
914 model[1] = rx[2];
915 model[2] = rx[3];
916 model[3] = 0;
917 fwVersion[0] = rx[5];
918 fwVersion[1] = rx[6];
919 fwVersion[2] = rx[7];
920 fwVersion[3] = 0;
921
922 inBoot = (rx[1] == 'B');
923 return (true);
924 }
925 return (false);
926 }
927
934 uint32_t readFramesExecuted()
935 {
936 uint8_t tx[8] = { 0x81,67,68,0x55,0x55,0x55,0x55,0x55 };
937 uint8_t rx[8];
938 sendPacket(tx, rx);
939 uint32_t returnval = rx[2] + (((uint32_t)rx[3]) << 8) + (((uint32_t)rx[4]) << 16) + (((uint32_t)rx[5]) << 24);
940 return (returnval);
941 }
942
950
951 uint16_t readOverflowFrames()
952 {
953 return readPublicData(69);
954 }
955
965 void jumpToBoot()
966 {
967 uint8_t tx[] = "BoOtLoAd";
968 sendPacket(tx);
969 }
970
991 uint8_t readRamAddress(uint16_t address)
992 {
993 uint8_t tx[8] = { 0xA0,SW_LE16(address),0x55,0x55,0x55,0x55,0x55 };
994 uint8_t rx[8];
995 sendPacket(tx, rx);
996 return(rx[3]);
997 }
998
1018
1019 int16_t writeRamAddress(uint16_t address, uint8_t value)
1020 {
1021 uint8_t tx[8] = { 0xA3,SW_LE16(address),0,0,value,0x55,0x55};
1022 return sendPacket(tx);
1023 }
1024
1039
1040 uint32_t readFlashAddress(uint32_t address)
1041 {
1042 uint8_t tx[8] = { 0xA1,SW_LE32(address),0x55,0x55,0x55 };
1043 uint8_t rx[8];
1044 sendPacket(tx, rx);
1045 return(((uint32_t)rx[4]) + (((uint32_t)rx[5]) <<8) + (((uint32_t)rx[6]) <<16) + (((uint32_t)rx[7]) <<24));
1046 }
1047
1059 int16_t readUserBuffer(uint16_t index, uint8_t* buffer, uint16_t count)
1060 {
1061 uint16_t bytesRead = 0;
1062 while (bytesRead < count)
1063 {
1064 byte tx[] = {(byte)SerialWombatCommands::COMMAND_BINARY_READ_USER_BUFFER, (byte)(index & 0xFF), (byte)(index >> 8), 0x55, 0x55, 0x55, 0x55, 0x55};
1065 byte rx[8];
1066 int16_t result = sendPacket(tx, rx);
1067 if (result >= 0)
1068 {
1069 for (int i = 1; i < 8; ++i)
1070 {
1071 buffer[bytesRead] = rx[i];
1072 ++bytesRead;
1073 ++index;
1074 if (bytesRead >= count)
1075 {
1076 break;
1077 }
1078 }
1079 }
1080 else
1081 {
1082 return (bytesRead);
1083 }
1084 }
1085 return (bytesRead);
1086 }
1087
1097 void sleep()
1098 {
1099 uint8_t tx[8] = { 'S','l','E','e','P','!','#','*'};
1100 sendPacket(tx);
1101 _asleep = true;
1102 }
1103
1105 void wake()
1106 {
1107 uint8_t tx[8] = { '!','!','!','!','!','!','!','!' };
1108 sendPacket(tx);
1109 }
1110
1112 bool isSW18()
1113 {
1114 return ( model[1] == '1' && model[2] == '8');
1115 }
1116
1117 bool isSW08()
1118 {
1119 return ( model[1] == '0' && model[2] == '8');
1120 }
1121
1123 int16_t eraseFlashPage(uint32_t address)
1124 {
1125 uint8_t tx[8] = { (uint8_t)SerialWombatCommands::COMMAND_BINARY_WRITE_FLASH,
1126 0, //Erase Page
1127 SW_LE32(address),
1128 0x55,0x55 };
1129 return sendPacket(tx);
1130 }
1131
1132
1134 int16_t writeFlashRow(uint32_t address)
1135 {
1136 uint8_t tx[8] = { (uint8_t)SerialWombatCommands::COMMAND_BINARY_WRITE_FLASH,
1137 1, // Write entire row
1138 SW_LE32(address),0x55,0x55 };
1139 return sendPacket(tx);
1140 }
1141
1142
1143
1144
1154 int16_t setThroughputPin(uint8_t pin)
1155 {
1156 uint8_t tx[8] = { (uint8_t)SerialWombatCommands::CONFIGURE_PIN_MODE0,pin,PIN_MODE_FRAME_TIMER,0x55,0x55,0x55,0x55,0x55 };
1157 return sendPacket(tx);
1158 }
1159
1173 int16_t setThroughputPin(uint32_t address)
1174 {
1175 uint8_t tx[8] = { (uint8_t)SerialWombatCommands::COMMAND_BINARY_SET_ADDRESS,SW_LE32(address),0x55,0x55,0x55 };
1176 return sendPacket(tx);
1177 }
1178
1186 int writeUserBuffer(uint16_t index, uint8_t* buffer, uint16_t count)
1187 {
1188 uint16_t bytesSent = 0;
1189 if (count == 0)
1190 {
1191 return 0;
1192 }
1193
1194 { // Send first packet of up to 4 bytes
1195 uint8_t bytesToSend = 4;
1196 if (count < 4)
1197 {
1198 bytesToSend = (uint8_t)count;
1199 count = 0;
1200 }
1201 else
1202 {
1203 count -= 4;
1204 }
1205
1206 uint8_t tx[8] = { 0x84,SW_LE16(index), bytesToSend,0x55,0x55,0x55,0x55 };
1207 uint8_t rx[8];
1208
1209 uint8_t i;
1210 for (i = 0; i < bytesToSend; ++i)
1211 {
1212 tx[4 + i] = buffer[i];
1213 }
1214 int result = sendPacket(tx, rx);
1215 if (rx[0] == 'E')
1216 {
1217 return (result);
1218 }
1219 bytesSent = bytesToSend;
1220 }
1221 while (count >= 7) // Continue sending
1222 {
1223
1224 count -= 7;
1225 uint8_t tx[8] = { 0x85,0x55,0x55,0x55,0x55,0x55,0x55,0x55 };
1226 uint8_t rx[8];
1227 uint8_t i;
1228 for (i = 0; i < 7; ++i)
1229 {
1230 tx[1 + i] = buffer[bytesSent + i];
1231 }
1232 int result = sendPacket(tx, rx);
1233 if (rx[0] == 'E')
1234 {
1235 return (result);
1236 }
1237 bytesSent += 7;
1238 }
1239 while (count > 0)
1240 {
1241
1242 { // Send first packet of up to 4 bytes
1243 uint8_t bytesToSend = 4;
1244 if (count < 4)
1245 {
1246 bytesToSend = (uint8_t)count;
1247 count = 0;
1248 }
1249 else
1250 {
1251 count -= 4;
1252 }
1253
1254 uint8_t tx[8] = { 0x84,SW_LE16(index + bytesSent), bytesToSend,0x55,0x55,0x55,0x55 };
1255 uint8_t rx[8];
1256
1257 uint8_t i;
1258 for (i = 0; i < bytesToSend; ++i)
1259 {
1260 tx[4 + i] = buffer[i + bytesSent];
1261 }
1262 int result = sendPacket(tx, rx);
1263 if (rx[0] == 'E')
1264 {
1265 return (result);
1266 }
1267 bytesSent += bytesToSend;
1268 }
1269 }
1270 return(bytesSent);
1271
1272
1273 }
1274
1282 int writeUserBuffer(uint16_t index, char* s)
1283 {
1284 return writeUserBuffer(index, (uint8_t*)s, (uint16_t)strlen(s));
1285 }
1286
1294 int writeUserBuffer(uint16_t index, const char s[])
1295 {
1296 return writeUserBuffer(index, (uint8_t*)s, (uint16_t)strlen(s));
1297 }
1298
1299
1300
1312 int16_t writeFrameTimerPin(uint8_t pin)
1313{
1314 uint8_t tx[] = { 0xC8 ,pin,(uint8_t)PIN_MODE_FRAME_TIMER,0x55,0x55,0x55,0x55,0x55 };
1315 return sendPacket(tx);
1316}
1317
1318
1326 static uint8_t find(bool keepTrying = false)
1327 {
1328 do
1329 {
1330 for (int i2cAddress = 0x60; i2cAddress <= 0x6F; ++i2cAddress)
1331 {
1332 Wire.beginTransmission(i2cAddress);
1333 int error = Wire.endTransmission();
1334
1335
1336 if (error == 0)
1337 {
1338 uint8_t tx[8] = { 'V',0x55,0x55,0x55,0x55,0x55,0x55,0x55 };
1339 uint8_t rx[8];
1340 Wire.beginTransmission(i2cAddress);
1341 Wire.write(tx, 8);
1342 Wire.endTransmission();
1343 Wire.requestFrom((uint8_t)i2cAddress, (uint8_t)8);
1344
1345 int count = 0;
1346 while (Wire.available() && count < 8)
1347 {
1348 rx[count] = Wire.read();
1349 ++count;
1350 }
1351 if (count == 8)
1352 {
1353 if (rx[0] == 'V' && (rx[1] == 'S' || rx[1]=='B'))
1354 {
1355 return(i2cAddress); // Found one.
1356 }
1357 }
1358 }
1359 }
1360 delay(0);
1361 }while (keepTrying);
1362 return(0); // Didn't find one.
1363 }
1364
1365
1372 int16_t readLastErrorCommand(uint8_t* cmd)
1373{
1374 //TODO this doen't look like it returns the error
1375 uint8_t tx[8] = { (uint8_t)SerialWombatCommands::COMMAND_READ_LAST_ERROR_PACKET, 0,0x55,0x55,0x55,0x55,0x55,0x55 };
1376 uint8_t rx[8];
1377 if (sendPacket(tx, rx) >= 0)
1378 {
1379 for (int i = 1; i < 8; ++i)
1380 {
1381 cmd[i - 1] = rx[i];
1382 }
1383 }
1384 else
1385 {
1386 return (lastErrorCode);
1387 }
1388 tx[1] = 7;
1389 if (sendPacket(tx, rx) >= 0)
1390 {
1391 cmd[7] = rx[1];
1392 }
1393 return(lastErrorCode);
1394}
1395
1400 void registerErrorHandler(SerialWombatErrorHandler_t handler)
1401 {
1402 errorHandler = handler;
1403 }
1404
1406 uint8_t address = 0;
1407
1409 uint8_t communicationErrorRetries = 5;
1410
1411 int16_t echo(uint8_t data[], uint8_t count = 7)
1412 {
1413 uint8_t tx[] = "!UUUUUUU";
1414 for (int i = 0; i < 7 && i < count; ++i)
1415 {
1416 tx[i + 1] = (uint8_t)data[i];
1417 }
1418 return sendPacket(tx);
1419 }
1420
1421
1422 int16_t echo(char* data)
1423 {
1424 int length = strlen(data);
1425 uint8_t tx[] = "!UUUUUUU";
1426 for (int i = 0; i < 7 && i < length; ++i)
1427 {
1428 tx[i + 1] = (uint8_t)data[i];
1429 }
1430 return sendPacket(tx);
1431 }
1432
1433 uint32_t readBirthday()
1434 {
1435 if (isSW18())
1436 {
1437 uint32_t birthday = (readFlashAddress(0x2A00C) >> 8) & 0xFF;
1438 birthday *= 100;
1439 birthday += (readFlashAddress(0x2A00C)) & 0xFF;
1440 birthday *= 100;
1441 birthday += readFlashAddress(0x2A00E) & 0xFF;
1442 birthday *= 100;
1443 birthday += readFlashAddress(0x2A010) & 0xFF;
1444 return (birthday);
1445 }
1446 return 0;
1447 }
1448
1449 int16_t readBrand(char* data)
1450 {
1451 uint8_t length = 0;
1452 if (isSW18())
1453 {
1454 for (int i = 0; i < 32; ++i)
1455 {
1456 uint32_t val = readFlashAddress(0x2A020 + i * 2) ;
1457 if ((val & 0xFF) != 0xFF)
1458 {
1459 data[i ] = (char)(val & 0xFF);
1460 ++length;
1461 }
1462 else
1463 {
1464 data[length] = 0;
1465 return (length);
1466 }
1467 }
1468 data[length] = 0;
1469 return (length);
1470 }
1471
1472 data[0] = 0;
1473 return 0 ;
1474 }
1475
1476};
1477
1491 class SerialWombat18ABOscillatorTuner
1492{
1493 private:
1494 SerialWombatChip& _sw;
1495 uint32_t lastMillis = 0;
1496 uint32_t lastFrames = 0;
1497 public:
1502 SerialWombat18ABOscillatorTuner(SerialWombatChip& serialWombatChip) : _sw(serialWombatChip) { }
1503
1507 void update() {
1508 uint32_t m = millis();
1509 if (lastMillis == 0)
1510 {
1511 lastMillis = m;
1512 uint32_t frames = _sw.readPublicData(SerialWombatDataSource::SW_DATA_SOURCE_FRAMES_RUN_MSW);
1513 uint16_t frameslsb = _sw.readPublicData(SerialWombatDataSource::SW_DATA_SOURCE_FRAMES_RUN_LSW);
1514 if (frames != _sw.readPublicData(SerialWombatDataSource::SW_DATA_SOURCE_FRAMES_RUN_MSW))
1515 {
1516 frameslsb = _sw.readPublicData(SerialWombatDataSource::SW_DATA_SOURCE_FRAMES_RUN_LSW);
1517 frames = _sw.readPublicData(SerialWombatDataSource::SW_DATA_SOURCE_FRAMES_RUN_MSW);
1518 }
1519 frames <<= 16;
1520 frames += frameslsb;
1521 lastFrames = frames;
1522
1523 }
1524 else if ((m - lastMillis) < 10000)
1525 {
1526 //Do nothing
1527 }
1528 else if (m < lastMillis)
1529 {
1530 //Has it been 47 days already?
1531 lastMillis = 0;
1532 }
1533 else
1534 {
1535 uint32_t diff = m - lastMillis;
1536
1537 uint32_t frames = _sw.readPublicData(SerialWombatDataSource::SW_DATA_SOURCE_FRAMES_RUN_MSW);
1538 uint16_t frameslsb = _sw.readPublicData(SerialWombatDataSource::SW_DATA_SOURCE_FRAMES_RUN_LSW);
1539
1540 if (frames != _sw.readPublicData(SerialWombatDataSource::SW_DATA_SOURCE_FRAMES_RUN_MSW))
1541 {
1542 frameslsb = _sw.readPublicData(SerialWombatDataSource::SW_DATA_SOURCE_FRAMES_RUN_LSW);
1543 frames = _sw.readPublicData(SerialWombatDataSource::SW_DATA_SOURCE_FRAMES_RUN_MSW);
1544 }
1545 frames <<= 16;
1546 frames += frameslsb;
1547 uint32_t framesDif = frames - lastFrames;
1548
1549 if (diff > framesDif )
1550 {
1551 // Running slow
1552 uint8_t tx[] = { (uint8_t)SerialWombatCommands::COMMAND_ADJUST_FREQUENCY,
1553 SW_LE16(1),//Counts to increment
1554 SW_LE16(0), // Counts to decrement
1555 0x55,0x55,0x55};
1556 _sw.sendPacket(tx);
1557 }
1558 else if (diff < framesDif)
1559 {
1560 // Running mfast
1561 uint8_t tx[] = { (uint8_t)SerialWombatCommands::COMMAND_ADJUST_FREQUENCY,
1562 SW_LE16(0),//Counts to increment
1563 SW_LE16(1), // Counts to decrement
1564 0x55,0x55,0x55 };
1565 _sw.sendPacket(tx);
1566
1567 }
1568
1569 lastMillis = m;
1570 lastFrames = frames;
1571
1572 }
1573
1574 }
1575
1576};
1577
1578/*
1579 End of cross platform code synchronization. Random string to help the compare tool sync lines:
1580 asdkj38vjn1nasdnvuwlamafdjiivnowalskive
1581*/
1582
1584 class SerialWombat : public SerialWombatChip {};
1585
1586
1587
1588
1589
1597 void SerialWombatSerialErrorHandlerBrief(uint16_t error, SerialWombatChip* sw);
1598 void SerialWombatSerialErrorHandlerVerbose(uint16_t error, SerialWombatChip* sw);
1599
1600#include "SerialWombatPin.h"
1601#include "SerialWombatErrors.h"
1602#include "SerialWombatQueue.h"
1603#include "SerialWombat18ABDataLogger.h"
1604#include "SerialWombatAbstractButton.h"
1605#include "SerialWombatAbstractProcessedInput.h"
1606#include "SerialWombatAbstractScaledOutput.h"
1607#include "SerialWombat18CapTouch.h"
1608#include "SerialWombat18ABVGA.h"
1609#include "SerialWombatAnalogInput.h"
1610#include "SerialWombatDebouncedInput.h"
1611#include "SerialWombatFrequencyOutput.h"
1612#include "SerialWombatHBridge.h"
1613#include "SerialWombatHSClock.h"
1614#include "SerialWombatHSCounter.h"
1615#include "SerialWombatIRRx.h"
1616#include "SerialWombatLiquidCrystal.h"
1617#include "SerialWombatMatrixKeypad.h"
1618#include "SerialWombatProcessedInputPin.h"
1619#include "SerialWombatProtectedOutput.h"
1620#include "SerialWombatPS2Keyboard.h"
1621#include "SerialWombatPulseOnChange.h"
1622#include "SerialWombatPulseTimer.h"
1623#include "SerialWombatPWM.h"
1624#include "SerialWombatQuadEnc.h"
1625#include "SerialWombatQueuedPulseOutput.h"
1626#include "SerialWombatResistanceInput.h"
1627#include "SerialWombatServo.h"
1628#include "SerialWombatTM1637.h"
1629#include "SerialWombatUART.h"
1630#include "SerialWombatUltrasonicDistanceSensor.h"
1631#include "SerialWombatWatchdog.h"
1632#include "SerialWombatWS2812.h"
1633#include "SerialWombatThroughputConsumer.h"
1634#include "PCB0031_Grip.h"
1635
1636#endif
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:49
WOMBAT_MAXIMUM_PINS
#define WOMBAT_MAXIMUM_PINS
Definition SerialWombat.h:186
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:43
SerialWombatCommands
SerialWombatCommands
Definition SerialWombat.h:189
SerialWombatCommands::COMMAND_CAPTURE_STARTUP_SEQUENCE
@ COMMAND_CAPTURE_STARTUP_SEQUENCE
(0xB6)
Definition SerialWombat.h:226
SerialWombatCommands::COMMAND_BINARY_WRITE_FLASH
@ COMMAND_BINARY_WRITE_FLASH
(0xA4)
Definition SerialWombat.h:216
SerialWombatCommands::COMMAND_BINARY_READ_USER_BUFFER
@ COMMAND_BINARY_READ_USER_BUFFER
(0x83)
Definition SerialWombat.h:200
SerialWombatCommands::COMMAND_BINARY_QUEUE_INFORMATION
@ COMMAND_BINARY_QUEUE_INFORMATION
(0x94)
Definition SerialWombat.h:208
SerialWombatCommands::CONFIGURE_PIN_MODE0
@ CONFIGURE_PIN_MODE0
(200)
Definition SerialWombat.h:230
SerialWombatCommands::COMMAND_BINARY_QUEUE_INITIALIZE
@ COMMAND_BINARY_QUEUE_INITIALIZE
(0x90)
Definition SerialWombat.h:204
SerialWombatCommands::COMMAND_BINARY_SET_PIN_BUFFFER
@ COMMAND_BINARY_SET_PIN_BUFFFER
(0x82)
Definition SerialWombat.h:199
SerialWombatCommands::COMMAND_ENABLE_2ND_UART
@ COMMAND_ENABLE_2ND_UART
(0xA6)
Definition SerialWombat.h:218
SerialWombatCommands::COMMAND_UART1_RX_7BYTES
@ COMMAND_UART1_RX_7BYTES
(0xB3)
Definition SerialWombat.h:223
SerialWombatCommands::COMMAND_ADJUST_FREQUENCY
@ COMMAND_ADJUST_FREQUENCY
(0xB7)
Definition SerialWombat.h:227
SerialWombatCommands::COMMAND_BINARY_WRITE_USER_BUFFER
@ COMMAND_BINARY_WRITE_USER_BUFFER
(0x84)
Definition SerialWombat.h:201
SerialWombatCommands::CONFIGURE_PIN_MODE3
@ CONFIGURE_PIN_MODE3
(203)
Definition SerialWombat.h:233
SerialWombatCommands::CMD_RESET
@ CMD_RESET
('R')
Definition SerialWombat.h:193
SerialWombatCommands::CONFIGURE_PIN_MODE4
@ CONFIGURE_PIN_MODE4
(204)
Definition SerialWombat.h:234
SerialWombatCommands::CONFIGURE_PIN_MODE_DISABLE
@ CONFIGURE_PIN_MODE_DISABLE
(219)
Definition SerialWombat.h:242
SerialWombatCommands::CMD_READ_BUFFER_ASCII
@ CMD_READ_BUFFER_ASCII
('G')
Definition SerialWombat.h:191
SerialWombatCommands::COMMAND_BINARY_QUEUE_CLONE
@ COMMAND_BINARY_QUEUE_CLONE
(0x95)
Definition SerialWombat.h:209
SerialWombatCommands::COMMAND_BINARY_QUEUE_ADD_BYTES
@ COMMAND_BINARY_QUEUE_ADD_BYTES
(0x91)
Definition SerialWombat.h:205
SerialWombatCommands::CMD_RESYNC
@ CMD_RESYNC
('U')
Definition SerialWombat.h:195
SerialWombatCommands::COMMAND_BINARY_READ_EEPROM
@ COMMAND_BINARY_READ_EEPROM
(0xA2)
Definition SerialWombat.h:214
SerialWombatCommands::CMD_SUPPLYVOLTAGE
@ CMD_SUPPLYVOLTAGE
('v')
Definition SerialWombat.h:197
SerialWombatCommands::CONFIGURE_PIN_MODE5
@ CONFIGURE_PIN_MODE5
(205)
Definition SerialWombat.h:235
SerialWombatCommands::COMMAND_BINARY_QUEUE_ADD_7BYTES
@ COMMAND_BINARY_QUEUE_ADD_7BYTES
(0x92)
Definition SerialWombat.h:206
SerialWombatCommands::CONFIGURE_PIN_MODE8
@ CONFIGURE_PIN_MODE8
(208)
Definition SerialWombat.h:238
SerialWombatCommands::CONFIGURE_PIN_MODE_HW_0
@ CONFIGURE_PIN_MODE_HW_0
(220)
Definition SerialWombat.h:244
SerialWombatCommands::CONFIGURE_PIN_MODE6
@ CONFIGURE_PIN_MODE6
(206)
Definition SerialWombat.h:236
SerialWombatCommands::CMD_SET_BUFFER_ASCII
@ CMD_SET_BUFFER_ASCII
('S')
Definition SerialWombat.h:194
SerialWombatCommands::CONFIGURE_PIN_MODE2
@ CONFIGURE_PIN_MODE2
(202)
Definition SerialWombat.h:232
SerialWombatCommands::COMMAND_UART0_TX_7BYTES
@ COMMAND_UART0_TX_7BYTES
(0xB0)
Definition SerialWombat.h:220
SerialWombatCommands::COMMAND_BINARY_QUEUE_READ_BYTES
@ COMMAND_BINARY_QUEUE_READ_BYTES
(0x93)
Definition SerialWombat.h:207
SerialWombatCommands::COMMAND_BINARY_SET_ADDRESS
@ COMMAND_BINARY_SET_ADDRESS
(0xB9)
Definition SerialWombat.h:229
SerialWombatCommands::CONFIGURE_PIN_INPUTPROCESS
@ CONFIGURE_PIN_INPUTPROCESS
(211)
Definition SerialWombat.h:243
SerialWombatCommands::CMD_VERSION
@ CMD_VERSION
('V')
Definition SerialWombat.h:196
SerialWombatCommands::CMD_ASCII_SET_PIN
@ CMD_ASCII_SET_PIN
('P')
Definition SerialWombat.h:192
SerialWombatCommands::CONFIGURE_PIN_MODE10
@ CONFIGURE_PIN_MODE10
(210)
Definition SerialWombat.h:240
SerialWombatCommands::COMMAND_BINARY_WRITE_USER_BUFFER_CONTINUE
@ COMMAND_BINARY_WRITE_USER_BUFFER_CONTINUE
(0x85)
Definition SerialWombat.h:202
SerialWombatCommands::COMMAND_BINARY_CONFIG_DATALOGGER
@ COMMAND_BINARY_CONFIG_DATALOGGER
(0x96)
Definition SerialWombat.h:210
SerialWombatCommands::CONFIGURE_PIN_MODE9
@ CONFIGURE_PIN_MODE9
(209)
Definition SerialWombat.h:239
SerialWombatCommands::COMMAND_UART1_TX_7BYTES
@ COMMAND_UART1_TX_7BYTES
(0xB2)
Definition SerialWombat.h:222
SerialWombatCommands::COMMAND_UART0_RX_7BYTES
@ COMMAND_UART0_RX_7BYTES
(0xB1)
Definition SerialWombat.h:221
SerialWombatCommands::COMMAND_BINARY_RW_PIN_MEMORY
@ COMMAND_BINARY_RW_PIN_MEMORY
(0xB5)
Definition SerialWombat.h:225
SerialWombatCommands::COMMAND_READ_LAST_ERROR_PACKET
@ COMMAND_READ_LAST_ERROR_PACKET
(0xA7)
Definition SerialWombat.h:219
SerialWombatCommands::COMMAND_BINARY_WRITE_RAM
@ COMMAND_BINARY_WRITE_RAM
(0xA3)
Definition SerialWombat.h:215
SerialWombatCommands::COMMAND_BINARY_READ_RAM
@ COMMAND_BINARY_READ_RAM
(0xA0)
Definition SerialWombat.h:212
SerialWombatCommands::COMMAND_BINARY_TEST_SEQUENCE
@ COMMAND_BINARY_TEST_SEQUENCE
(0xB4)
Definition SerialWombat.h:224
SerialWombatCommands::CONFIGURE_CHANNEL_MODE_HW_2
@ CONFIGURE_CHANNEL_MODE_HW_2
(222)
Definition SerialWombat.h:246
SerialWombatCommands::COMMAND_BINARY_READ_PIN_BUFFFER
@ COMMAND_BINARY_READ_PIN_BUFFFER
(0x81)
Definition SerialWombat.h:198
SerialWombatCommands::CONFIGURE_CHANNEL_MODE_HW_1
@ CONFIGURE_CHANNEL_MODE_HW_1
(221)
Definition SerialWombat.h:245
SerialWombatCommands::COMMAND_BINARY_READ_FLASH
@ COMMAND_BINARY_READ_FLASH
(0xA1)
Definition SerialWombat.h:213
SerialWombatCommands::CONFIGURE_CHANNEL_MODE_HW_3
@ CONFIGURE_CHANNEL_MODE_HW_3
(223)
Definition SerialWombat.h:247
SerialWombatCommands::COMMAND_SET_PIN_HW
@ COMMAND_SET_PIN_HW
(0xB8)
Definition SerialWombat.h:228
SerialWombatCommands::COMMAND_CALIBRATE_ANALOG
@ COMMAND_CALIBRATE_ANALOG
(0xA5)
Definition SerialWombat.h:217
SerialWombatCommands::CMD_ECHO
@ CMD_ECHO
('!')
Definition SerialWombat.h:190
SerialWombatCommands::CONFIGURE_PIN_MODE7
@ CONFIGURE_PIN_MODE7
(207)
Definition SerialWombat.h:237
SerialWombatCommands::CONFIGURE_PIN_MODE1
@ CONFIGURE_PIN_MODE1
(201)
Definition SerialWombat.h:231
SerialWombatCommands::COMMAND_BINARY_PIN_POLL_THRESHOLD
@ COMMAND_BINARY_PIN_POLL_THRESHOLD
(0x8F)
Definition SerialWombat.h:203
SerialWombatCommands::CONFIGURE_PIN_OUTPUTSCALE
@ CONFIGURE_PIN_OUTPUTSCALE
(210)
Definition SerialWombat.h:241
SerialWombatCommands::COMMAND_BINARY_CONFIGURE
@ COMMAND_BINARY_CONFIGURE
(0x9F)
Definition SerialWombat.h:211
SW08B_LATEST_FIRMWARE
#define SW08B_LATEST_FIRMWARE
Definition SerialWombat.h:50
SW_LE32
#define SW_LE32(_a)
Convert a uint32_t to four bytes in little endian format for array initialization.
Definition SerialWombat.h:46
SW4B_LATEST_FIRMWARE
#define SW4B_LATEST_FIRMWARE
Definition SerialWombat.h:51
SerialWombatPinMode_t
SerialWombatPinMode_t
Definition SerialWombat.h:252
PIN_MODE_PULSE_ON_CHANGE
@ PIN_MODE_PULSE_ON_CHANGE
(25)
Definition SerialWombat.h:275
PIN_MODE_FRAME_TIMER
@ PIN_MODE_FRAME_TIMER
(21)
Definition SerialWombat.h:271
PIN_MODE_UNKNOWN
@ PIN_MODE_UNKNOWN
(0xFF)
Definition SerialWombat.h:287
PIN_MODE_TM1637
@ PIN_MODE_TM1637
(11)
Definition SerialWombat.h:263
PIN_MODE_PULSETIMER
@ PIN_MODE_PULSETIMER
(18)
Definition SerialWombat.h:270
PIN_MODE_PS2KEYBOARD
@ PIN_MODE_PS2KEYBOARD
(32)
Definition SerialWombat.h:282
PIN_MODE_FREQUENCY_OUTPUT
@ PIN_MODE_FREQUENCY_OUTPUT
(36)
Definition SerialWombat.h:285
PIN_MODE_HS_SERVO
@ PIN_MODE_HS_SERVO
(26)
Definition SerialWombat.h:276
PIN_MODE_CONTROLLED
@ PIN_MODE_CONTROLLED
(1)
Definition SerialWombat.h:254
PIN_MODE_QUEUED_PULSE_OUTPUT
@ PIN_MODE_QUEUED_PULSE_OUTPUT
(34)
Definition SerialWombat.h:284
PIN_MODE_HBRIDGE
@ PIN_MODE_HBRIDGE
(6)
Definition SerialWombat.h:259
PIN_MODE_SW18AB_CAPTOUCH
@ PIN_MODE_SW18AB_CAPTOUCH
(22)
Definition SerialWombat.h:272
PIN_MODE_LIQUIDCRYSTAL
@ PIN_MODE_LIQUIDCRYSTAL
(28)
Definition SerialWombat.h:278
PIN_MODE_IRRX
@ PIN_MODE_IRRX
(37)
Definition SerialWombat.h:286
PIN_MODE_QUADRATUREENCODER
@ PIN_MODE_QUADRATUREENCODER
(5)
Definition SerialWombat.h:258
PIN_MODE_UART_RX_TX
@ PIN_MODE_UART_RX_TX
(17)
Definition SerialWombat.h:269
PIN_MODE_WATCHDOG
@ PIN_MODE_WATCHDOG
(7)
Definition SerialWombat.h:260
PIN_MODE_HS_COUNTER
@ PIN_MODE_HS_COUNTER
< (29)
Definition SerialWombat.h:280
PIN_MODE_PROTECTED_OUTPUT
@ PIN_MODE_PROTECTED_OUTPUT
(8)
Definition SerialWombat.h:261
PIN_MODE_ANALOGINPUT
@ PIN_MODE_ANALOGINPUT
(2)
Definition SerialWombat.h:255
PIN_MODE_UART1_RX_TX
@ PIN_MODE_UART1_RX_TX
(23)
Definition SerialWombat.h:273
PIN_MODE_I2C_CONTROLLER
@ PIN_MODE_I2C_CONTROLLER
(33)
Definition SerialWombat.h:283
PIN_MODE_PWM
@ PIN_MODE_PWM
(16)
Definition SerialWombat.h:268
PIN_MODE_RESISTANCEINPUT
@ PIN_MODE_RESISTANCEINPUT
(24)
Definition SerialWombat.h:274
PIN_MODE_DEBOUNCE
@ PIN_MODE_DEBOUNCE
(10)
Definition SerialWombat.h:262
PIN_MODE_INPUT_PROCESSOR
@ PIN_MODE_INPUT_PROCESSOR
(14)
Definition SerialWombat.h:266
PIN_MODE_ULTRASONIC_DISTANCE
@ PIN_MODE_ULTRASONIC_DISTANCE
(27)
Definition SerialWombat.h:277
PIN_MODE_HS_CLOCK
@ PIN_MODE_HS_CLOCK
Definition SerialWombat.h:279
PIN_MODE_SERVO
@ PIN_MODE_SERVO
(3)
Definition SerialWombat.h:256
PIN_MODE_DIGITALIO
@ PIN_MODE_DIGITALIO
(0)
Definition SerialWombat.h:253
PIN_MODE_THROUGHPUT_CONSUMER
@ PIN_MODE_THROUGHPUT_CONSUMER
(4)
Definition SerialWombat.h:257
PIN_MODE_MATRIX_KEYPAD
@ PIN_MODE_MATRIX_KEYPAD
(15)
Definition SerialWombat.h:267
PIN_MODE_SW_UART
@ PIN_MODE_SW_UART
(13)
Definition SerialWombat.h:265
PIN_MODE_VGA
@ PIN_MODE_VGA
(31)
Definition SerialWombat.h:281
PIN_MODE_WS2812
@ PIN_MODE_WS2812
(12)
Definition SerialWombat.h:264
SerialWombatSerialErrorHandlerVerbose
void SerialWombatSerialErrorHandlerVerbose(uint16_t error, SerialWombatChip *sw)
SerialWombatDataSource
SerialWombatDataSource
A list of Serial Wombat public data sources.
Definition SerialWombat.h:62
SerialWombatDataSource::SW_DATA_SOURCE_PIN_10
@ SW_DATA_SOURCE_PIN_10
(10) 16 bit public data provided by Pin 10
Definition SerialWombat.h:74
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:139
SerialWombatDataSource::SW_DATA_SOURCE_PIN_5
@ SW_DATA_SOURCE_PIN_5
(5) 16 bit public data provided by Pin 5
Definition SerialWombat.h:69
SerialWombatDataSource::SW_DATA_SOURCE_PIN_14
@ SW_DATA_SOURCE_PIN_14
(14) 16 bit public data provided by Pin 14
Definition SerialWombat.h:78
SerialWombatDataSource::SW_DATA_SOURCE_PIN_13
@ SW_DATA_SOURCE_PIN_13
(13) 16 bit public data provided by Pin 13
Definition SerialWombat.h:77
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:129
SerialWombatDataSource::SW_DATA_SOURCE_TEMPERATURE
@ SW_DATA_SOURCE_TEMPERATURE
(70)The internal core temperature expressed in 100ths deg C
Definition SerialWombat.h:133
SerialWombatDataSource::SW_DATA_SOURCE_PIN_1
@ SW_DATA_SOURCE_PIN_1
(1) 16 bit public data provided by Pin 1
Definition SerialWombat.h:65
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:130
SerialWombatDataSource::SW_DATA_SOURCE_VCC_mVOLTS
@ SW_DATA_SOURCE_VCC_mVOLTS
(75) The system source voltage in mV
Definition SerialWombat.h:138
SerialWombatDataSource::SW_DATA_SOURCE_PIN_11
@ SW_DATA_SOURCE_PIN_11
(11) 16 bit public data provided by Pin 11
Definition SerialWombat.h:75
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:172
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:146
SerialWombatDataSource::SW_DATA_SOURCE_PIN_6
@ SW_DATA_SOURCE_PIN_6
(6) 16 bit public data provided by Pin 6
Definition SerialWombat.h:70
SerialWombatDataSource::SW_DATA_SOURCE_PIN_15
@ SW_DATA_SOURCE_PIN_15
(15) 16 bit public data provided by Pin 15
Definition SerialWombat.h:79
SerialWombatDataSource::SW_DATA_SOURCE_LFSR
@ SW_DATA_SOURCE_LFSR
(78) A Linear Feedback Shift Register that produces a Pseudo random sequence of 16 bit values
Definition SerialWombat.h:140
SerialWombatDataSource::SW_DATA_SOURCE_OVERRUN_FRAMES
@ SW_DATA_SOURCE_OVERRUN_FRAMES
(69) The number of frames that ran more than 1mS
Definition SerialWombat.h:132
SerialWombatDataSource::SW_DATA_SOURCE_PIN_9
@ SW_DATA_SOURCE_PIN_9
(9) 16 bit public data provided by Pin 9
Definition SerialWombat.h:73
SerialWombatDataSource::SW_DATA_SOURCE_PIN_12
@ SW_DATA_SOURCE_PIN_12
(12) 16 bit public data provided by Pin 12
Definition SerialWombat.h:76
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:145
SerialWombatDataSource::SW_DATA_SOURCE_PIN_8
@ SW_DATA_SOURCE_PIN_8
(8) 16 bit public data provided by Pin 8
Definition SerialWombat.h:72
SerialWombatDataSource::SW_DATA_SOURCE_PIN_18
@ SW_DATA_SOURCE_PIN_18
(18) 16 bit public data provided by Pin 18
Definition SerialWombat.h:82
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:171
SerialWombatDataSource::SW_DATA_SOURCE_0x55
@ SW_DATA_SOURCE_0x55
(85) 0x55 is a reserved value for resyncing. Returns 0x55 0x55
Definition SerialWombat.h:141
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:168
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:160
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:135
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:142
SerialWombatDataSource::SW_DATA_SOURCE_PIN_4
@ SW_DATA_SOURCE_PIN_4
(4) 16 bit public data provided by Pin 4
Definition SerialWombat.h:68
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:137
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:134
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:165
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:169
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:159
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:143
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:136
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:158
SerialWombatDataSource::SW_DATA_SOURCE_PIN_0
@ SW_DATA_SOURCE_PIN_0
(0) 16 bit public data provided by Pin 0
Definition SerialWombat.h:64
SerialWombatDataSource::SW_DATA_SOURCE_PIN_2
@ SW_DATA_SOURCE_PIN_2
(2) 16 bit public data provided by Pin 2
Definition SerialWombat.h:66
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:144
SerialWombatDataSource::SW_DATA_SOURCE_PIN_16
@ SW_DATA_SOURCE_PIN_16
(16) 16 bit public data provided by Pin 16
Definition SerialWombat.h:80
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:166
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:161
SerialWombatDataSource::SW_DATA_SOURCE_PIN_7
@ SW_DATA_SOURCE_PIN_7
(7) 16 bit public data provided by Pin 7
Definition SerialWombat.h:71
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:131
SerialWombatDataSource::SW_DATA_SOURCE_INCREMENTING_NUMBER
@ SW_DATA_SOURCE_INCREMENTING_NUMBER
(65) An number that increments each time it is accessed.
Definition SerialWombat.h:128
SerialWombatDataSource::SW_DATA_SOURCE_PIN_19
@ SW_DATA_SOURCE_PIN_19
(19) 16 bit public data provided by Pin 19
Definition SerialWombat.h:83
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:163
SerialWombatDataSource::SW_DATA_SOURCE_PIN_17
@ SW_DATA_SOURCE_PIN_17
(17) 16 bit public data provided by Pin 17
Definition SerialWombat.h:81
SerialWombatDataSource::SW_DATA_SOURCE_PIN_3
@ SW_DATA_SOURCE_PIN_3
(3) 16 bit public data provided by Pin 3
Definition SerialWombat.h:67
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:175
SerialWombatDataSource::SW_DATA_SOURCE_NONE
@ SW_DATA_SOURCE_NONE
(255 ) Used to mean "No Source Selected"
Definition SerialWombat.h:177
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:162
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:174
ARRAY_UINT32
#define ARRAY_UINT32(_array, _index)
Definition SerialWombat.h:48
SerialWombatErrorHandler_t
void(* SerialWombatErrorHandler_t)(uint16_t errorNumber, SerialWombatChip *sw)
Definition SerialWombat.h:292
SerialWombatPinState_t
SerialWombatPinState_t
Definition SerialWombat.h:54
SW_INPUT
@ SW_INPUT
Definition SerialWombat.h:57
SW_HIGH
@ SW_HIGH
Definition SerialWombat.h:56
SW_LOW
@ SW_LOW
Definition SerialWombat.h:55
SerialWombatAbstractButton.h
SerialWombatAbstractProcessedInput.h
SerialWombatAbstractScaledOutput.h
SerialWombatAnalogInput.h
SerialWombatDebouncedInput.h
SerialWombatErrors.h
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:1502
SerialWombat18ABOscillatorTuner::update
void update()
Call periodically to tune the SW18AB oscillator to reported millis.
Definition SerialWombat.h:1507
SerialWombatChip
Class for a Serial Wombat chip. Each Serial Wombat chip on a project should have its own instance.
Definition SerialWombat.h:300
SerialWombatChip::setThroughputPin
int16_t setThroughputPin(uint32_t address)
Set this chip Address (SW8B only)
Definition SerialWombat.h:1173
SerialWombatChip::uniqueIdentifier
uint8_t uniqueIdentifier[16]
Definition SerialWombat.h:333
SerialWombatChip::isLatestFirmware
bool isLatestFirmware(void)
Definition SerialWombat.h:665
SerialWombatChip::address
uint8_t address
The I2C address of the SerialWombatChip instance.
Definition SerialWombat.h:1406
SerialWombatChip::deviceRevision
uint16_t deviceRevision
Definition SerialWombat.h:351
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:1105
SerialWombatChip::SerialWombatChip
SerialWombatChip()
Definition SerialWombat.cpp:31
SerialWombatChip::sendReadyTime
uint32_t sendReadyTime
Definition SerialWombat.h:403
SerialWombatChip::uniqueIdentifierLength
uint8_t uniqueIdentifierLength
Definition SerialWombat.h:339
SerialWombatChip::comparePublicDataToThreshold
uint32_t comparePublicDataToThreshold(uint16_t threshold=0)
Definition SerialWombat.h:727
SerialWombatChip::echo
int16_t echo(uint8_t data[], uint8_t count=7)
Definition SerialWombat.h:1411
SerialWombatChip::digitalWrite
void digitalWrite(uint8_t pin, uint8_t val)
Set an output pin High or Low.
Definition SerialWombat.h:834
SerialWombatChip::readFlashAddress
uint32_t readFlashAddress(uint32_t address)
Read Address from Flash based on 32 bit address.
Definition SerialWombat.h:1040
SerialWombatChip::inBoot
bool inBoot
Set to true if boot mode is indicated by a version query.
Definition SerialWombat.h:356
SerialWombatChip::isSW08
bool isSW08()
Returns true if the instance received a model number corresponding to the Serial Wombat 08 series of ...
Definition SerialWombat.h:1117
SerialWombatChip::readUniqueIdentifier
void readUniqueIdentifier()
Definition SerialWombat.h:414
SerialWombatChip::readVersion
char * readVersion(void)
Request version string (combined model and firmware) and return pointer to it.
Definition SerialWombat.h:635
SerialWombatChip::configureDigitalPin
void configureDigitalPin(uint8_t pin, uint8_t highLow)
Definition SerialWombat.h:361
SerialWombatChip::readPublicData
uint16_t readPublicData(uint8_t pin)
Read the 16 Bit public data associated with a Serial Wombat Pin Mode.
Definition SerialWombat.h:692
SerialWombatChip::fwVersion
uint8_t fwVersion[4]
Contains the last firmware Version retreived by queryVersion() as a zero-terminated string.
Definition SerialWombat.h:326
SerialWombatChip::readBirthday
uint32_t readBirthday()
Definition SerialWombat.h:1433
SerialWombatChip::communicationErrorRetries
uint8_t communicationErrorRetries
How many times to retry a packet if communcation bus (such as I2C) error.
Definition SerialWombat.h:1409
SerialWombatChip::echo
int16_t echo(char *data)
Definition SerialWombat.h:1422
SerialWombatChip::readOverflowFrames
uint16_t readOverflowFrames()
Get the number of times an overflow Frame has occured.
Definition SerialWombat.h:951
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:1326
SerialWombatChip::readDeviceIdentifier
void readDeviceIdentifier()
Definition SerialWombat.h:445
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:1186
SerialWombatChip::readTemperature_100thsDegC
int16_t readTemperature_100thsDegC(void)
Measure the Serial Wombat chip's internal temperature.
Definition SerialWombat.h:778
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:991
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:1059
SerialWombatChip::isSW18
bool isSW18()
Returns true if the instance received a model number corresponding to the Serial Wombat 18 series of ...
Definition SerialWombat.h:1112
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:359
SerialWombatChip::readBrand
int16_t readBrand(char *data)
Definition SerialWombat.h:1449
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:815
SerialWombatChip::setThroughputPin
int16_t setThroughputPin(uint8_t pin)
Set a pin to be a throughput monitoring pin.
Definition SerialWombat.h:1154
SerialWombatChip::begin
int16_t begin(HardwareSerial &serial, bool reset=true)
initialize a Serial Wombat chip to use a Serial Interface.
Definition SerialWombat.h:495
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:656
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:719
SerialWombatChip::readSupplyVoltage_mV
uint16_t readSupplyVoltage_mV(void)
Measure the Serial Wombat chip's Supply voltage.
Definition SerialWombat.h:745
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:1134
SerialWombatChip::writeUserBuffer
int writeUserBuffer(uint16_t index, char *s)
Write bytes to the User Memory Buffer in the Serial Wombat chip.
Definition SerialWombat.h:1282
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:1123
SerialWombatChip::returnErrorCode
uint16_t returnErrorCode(uint8_t *rx)
Definition SerialWombat.h:464
SerialWombatChip::deviceIdentifier
uint16_t deviceIdentifier
Definition SerialWombat.h:345
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:1019
SerialWombatChip::initialize
int16_t initialize()
Definition SerialWombat.h:404
SerialWombatChip::writeFrameTimerPin
int16_t writeFrameTimerPin(uint8_t pin)
Set a pin to be a frame timer for system utilization (SW18AB Only)
Definition SerialWombat.h:1312
SerialWombatChip::_supplyVoltagemV
uint16_t _supplyVoltagemV
Definition SerialWombat.h:320
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:1400
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:541
SerialWombatChip::analogWrite
void analogWrite(uint8_t pin, int val)
Set a pin to PWM output.
Definition SerialWombat.h:884
SerialWombatChip::errorCount
uint16_t errorCount
Incremented every time a communication or command error is detected.
Definition SerialWombat.h:353
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:1294
SerialWombatChip::analogRead
int analogRead(uint8_t pin)
Configures pin as analog input and does an immediate A/D conversion.
Definition SerialWombat.h:865
SerialWombatChip::readPublicData
uint16_t readPublicData(SerialWombatDataSource dataSource)
Read the 16 Bit public data associated with a Serial Wombat Pin Mode.
Definition SerialWombat.h:709
SerialWombatChip::queryVersion
bool queryVersion()
Send a version request to the Serial Wombat chip.
Definition SerialWombat.h:906
SerialWombatChip::jumpToBoot
void jumpToBoot()
Jump to Bootloader and wait for a UART download of new firmware.
Definition SerialWombat.h:965
SerialWombatChip::digitalRead
int digitalRead(uint8_t pin)
Reads the state of a Pin.
Definition SerialWombat.h:844
SerialWombatChip::hardwareReset
void hardwareReset()
Send a reset command to the Serial Wombat chip.
Definition SerialWombat.h:801
SerialWombatChip::model
uint8_t model[4]
Contains the last model retreived by queryVersion() as a zero-terminated string.
Definition SerialWombat.h:323
SerialWombatChip::readFramesExecuted
uint32_t readFramesExecuted()
Get the number of 1mS frames that have been executed since Serial Wombat chip reset.
Definition SerialWombat.h:934
SerialWombatChip::readLastErrorCommand
int16_t readLastErrorCommand(uint8_t *cmd)
Returns the last Serial Wombat command that produced a protocol error.
Definition SerialWombat.h:1372
SerialWombatChip::sleep
void sleep()
Shuts down most functions of the Serial Wombat chip reducing power consumption.
Definition SerialWombat.h:1097
SerialWombat
This class name is depricated. Do not use for new development. Use SerialWombatChip instead.
Definition SerialWombat.h:1584