1#ifndef SERIAL_WOMBAT_H__
2#define SERIAL_WOMBAT_H__
46#define SW_LE16(_a) (uint8_t)((_a) & 0xFF), (uint8_t)((_a) >>8)
49#define SW_LE32(_a) (uint8_t)((_a) & 0xFF), (uint8_t)((_a) >>8) , (uint8_t)((_a) >>16), (uint8_t)((_a) >>24)
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 225
53#define SW08B_LATEST_FIRMWARE 225
54#define SW4B_LATEST_FIRMWARE 203
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
193#define WOMBAT_MAXIMUM_PINS 20
320 char version[8] = { 0 };
321 HardwareSerial * Serial = NULL;
322 TwoWire* i2cInterface = NULL;
327 bool _asleep =
false;
329 bool _currentlyCommunicating =
false;
389 uint8_t tx[8] = { 200,pin,0,0,0,0,0,0x55 };
391 switch (_pinmode[pin])
404 else if (highLow == HIGH)
425 tx[6] = _openDrain[pin];
426 tx[5] = _pullDown[pin];
457 if (version[0] ==
'S' && version[1] ==
'0' && version[2] ==
'4')
510 if (version[0] ==
'S' && version[1] ==
'0' && version[2] ==
'4')
534 uint16_t result = rx[1] -
'0';
536 result += rx[2] -
'0';
538 result += rx[3] -
'0';
540 result += rx[4] -
'0';
542 result += rx[5] -
'0';
563 int16_t
begin(HardwareSerial& serial,
bool reset =
true)
566 Serial->begin(115200);
567 Serial->setTimeout(2);
568 Serial->write((uint8_t*)
"UUUUUUUU", 8);
570 while (Serial->read() >= 0);
594 int16_t
begin(uint8_t i2cAddress);
609 int16_t
begin(TwoWire& wire, uint8_t i2cAddress,
bool reset =
true)
611 i2cInterface = &wire;
614 Wire.beginTransmission(i2cAddress);
615 int error = Wire.endTransmission();
675 int sendPacket(uint8_t tx[], uint8_t rx[],
bool retryIfEchoDoesntMatch, uint8_t beginningBytesToMatch = 8, uint8_t endBytesToMatch = 0);
686 int sendPacket(uint8_t tx[],
bool retryIfEchoDoesntMatch);
709 uint8_t tx[] = {
'V',0x55,0x55,0x55,0x55,0x55,0x55,0x55 };
712 memcpy(version, &rx[1], 7);
714 memcpy(
model, &rx[1], 3);
772 uint8_t tx[] = { 0x81,pin,255,255,0x55,0x55,0x55,0x55 };
775 return(rx[2] + (uint16_t)rx[3] * 256);
799 uint8_t tx[] = { 0x82,pin,(uint8_t)(value & 0xFF),(uint8_t)(value >> 8) ,255,0x55,0x55,0x55 };
802 return (rx[2] + rx[3] * 256);
810 uint16_t
writePublicData(uint8_t firstPin, uint16_t firstValue, uint8_t secondPin,uint16_t secondValue)
812 uint8_t tx[] = { 0x82,firstPin,(uint8_t)(firstValue & 0xFF),(uint8_t)(firstValue >> 8) ,secondPin,(uint8_t)(secondValue & 0xFF),(uint8_t)(secondValue >> 8) ,0x55 };
815 return (rx[2] + rx[3] * 256);
847 uint32_t mv = 1024 * 65536 / counts;
876 result = result - 65536;
878 return ((int16_t)result);
894 uint8_t tx[9] =
"ReSeT!#*";
906 void pinMode(uint8_t pin, uint8_t mode,
bool pullDown =
false,
bool openDrain =
false)
912 _pullDown[pin] = pullDown;
913 _openDrain[pin] = openDrain;
914 _pinmode[pin] = mode;
977 uint8_t dutyCycleLow = 0;
999 uint8_t tx[8] = {
'V',0x55,0x55,0x55,0x55,0x55,0x55,0x55 };
1002 if (rx[0] ==
'V' && (rx[1] ==
'S' || rx[1] ==
'B'))
1027 uint8_t tx[8] = { 0x81,67,68,0x55,0x55,0x55,0x55,0x55 };
1030 uint32_t returnval = rx[2] + (((uint32_t)rx[3]) << 8) + (((uint32_t)rx[4]) << 16) + (((uint32_t)rx[5]) << 24);
1058 uint8_t tx[] =
"BoOtLoAd";
1084 uint8_t tx[8] = { 0xA0,
SW_LE16(
address),0x55,0x55,0x55,0x55,0x55 };
1136 return(((uint32_t)rx[4]) + (((uint32_t)rx[5]) <<8) + (((uint32_t)rx[6]) <<16) + (((uint32_t)rx[7]) <<24));
1152 uint16_t bytesRead = 0;
1153 while (bytesRead < count)
1160 for (
int i = 1; i < 8; ++i)
1162 buffer[bytesRead] = rx[i];
1165 if (bytesRead >= count)
1192 uint8_t tx[8] = {
'S',
'l',
'E',
'e',
'P',
'!',
'#',
'*'};
1217 uint8_t tx[8] = {
'S',
'l',
'E',
'e',
'P',
'!',
SW_LE16(delay)};
1226 uint8_t tx[8] = {
'!',
'!',
'!',
'!',
'!',
'!',
'!',
'!' };
1233 return (
model[1] ==
'0' &&
model[2] ==
'4');
1240 return (
model[1] ==
'1' &&
model[2] ==
'8');
1245 return (
model[1] ==
'0' &&
model[2] ==
'8');
1366 uint16_t bytesSent = 0;
1373 uint8_t bytesToSend = 4;
1376 bytesToSend = (uint8_t)count;
1384 uint8_t tx[8] = { 0x84,
SW_LE16(index), bytesToSend,0x55,0x55,0x55,0x55 };
1388 for (i = 0; i < bytesToSend; ++i)
1390 tx[4 + i] = buffer[i];
1397 bytesSent = bytesToSend;
1403 uint8_t tx[8] = { 0x85,0x55,0x55,0x55,0x55,0x55,0x55,0x55 };
1406 for (i = 0; i < 7; ++i)
1408 tx[1 + i] = buffer[bytesSent + i];
1421 uint8_t bytesToSend = 4;
1424 bytesToSend = (uint8_t)count;
1432 uint8_t tx[8] = { 0x84,
SW_LE16(index + bytesSent), bytesToSend,0x55,0x55,0x55,0x55 };
1436 for (i = 0; i < bytesToSend; ++i)
1438 tx[4 + i] = buffer[i + bytesSent];
1445 bytesSent += bytesToSend;
1502 static uint8_t
find(
bool keepTrying =
false)
1506 for (
int i2cAddress = 0x60; i2cAddress <= 0x6F; ++i2cAddress)
1508 Wire.beginTransmission(i2cAddress);
1509 int error = Wire.endTransmission();
1514 uint8_t tx[8] = {
'V',0x55,0x55,0x55,0x55,0x55,0x55,0x55 };
1516 Wire.beginTransmission(i2cAddress);
1518 Wire.endTransmission();
1519 Wire.requestFrom((uint8_t)i2cAddress, (uint8_t)8);
1522 while (Wire.available() && count < 8)
1524 rx[count] = Wire.read();
1529 if (rx[0] ==
'V' && (rx[1] ==
'S' || rx[1]==
'B'))
1537 }
while (keepTrying);
1555 for (
int i = 1; i < 8; ++i)
1578 errorHandler = handler;
1593 int16_t
echo(uint8_t data[], uint8_t count = 7)
1595 uint8_t tx[] =
"!UUUUUUU";
1596 for (
int i = 0; i < 7 && i < count; ++i)
1598 tx[i + 1] = (uint8_t)data[i];
1611 int length = strlen(data);
1612 uint8_t tx[] =
"!UUUUUUU";
1613 for (
int i = 0; i < 7 && i < length; ++i)
1615 tx[i + 1] = (uint8_t)data[i];
1649 for (
int i = 0; i < 32; ++i)
1652 if ((val & 0xFF) != 0xFF)
1654 data[i ] = (char)(val & 0xFF);
1690 uint32_t lastMillis = 0;
1691 uint32_t lastFrames = 0;
1703 uint32_t m = millis();
1704 if (lastMillis == 0)
1715 frames += frameslsb;
1716 lastFrames = frames;
1719 else if ((m - lastMillis) < 10000)
1723 else if (m < lastMillis)
1730 uint32_t diff = m - lastMillis;
1741 frames += frameslsb;
1742 uint32_t framesDif = frames - lastFrames;
1744 if (diff > framesDif )
1753 else if (diff < framesDif)
1765 lastFrames = frames;
1790 uint32_t lastMillis = 0;
1791 uint32_t lastFrames = 0;
1795 static const uint16_t CH32V003_RCC_CTLR_LOW = 0x1000;
1796 static const uint8_t CH32V003_HSITRIM_MASK = 0xF8;
1797 static const uint8_t CH32V003_HSITRIM_SHIFT = 3;
1801 return ((_sw.readRamAddress(CH32V003_RCC_CTLR_LOW) & CH32V003_HSITRIM_MASK) >> CH32V003_HSITRIM_SHIFT);
1804 void writeTrim(uint8_t trim)
1807 rccCtlrLow &= ~CH32V003_HSITRIM_MASK;
1808 rccCtlrLow |= (uint8_t)((trim & 0x1F) << CH32V003_HSITRIM_SHIFT);
1809 _sw.writeRamAddress(CH32V003_RCC_CTLR_LOW, rccCtlrLow);
1823 uint32_t m = millis();
1824 if (lastMillis == 0)
1835 frames += frameslsb;
1836 lastFrames = frames;
1839 else if ((m - lastMillis) < 10000)
1843 else if (m < lastMillis)
1850 uint32_t diff = m - lastMillis;
1861 frames += frameslsb;
1862 uint32_t framesDif = frames - lastFrames;
1864 if (diff > framesDif )
1867 uint8_t trim = readTrim();
1870 writeTrim(trim + 1);
1873 else if (diff < framesDif)
1876 uint8_t trim = readTrim();
1879 writeTrim(trim - 1);
1885 lastFrames = frames;
#define SW18AB_LATEST_FIRMWARE
#define WOMBAT_MAXIMUM_PINS
void SerialWombatSerialErrorHandlerBrief(uint16_t error, SerialWombatChip *sw)
a sample error handler that can be registered with registerErrorHandler to report protocol errors on ...
#define SW_LE16(_a)
Convert a uint16_t to two bytes in little endian format for array initialization.
@ COMMAND_CAPTURE_STARTUP_SEQUENCE
(0xB6)
@ COMMAND_BINARY_WRITE_FLASH
(0xA4)
@ COMMAND_BINARY_READ_USER_BUFFER
(0x83)
@ COMMAND_BINARY_QUEUE_INFORMATION
(0x94)
@ CONFIGURE_PIN_MODE0
(200)
@ COMMAND_BINARY_QUEUE_INITIALIZE
(0x90)
@ COMMAND_BINARY_SET_PIN_BUFFFER
(0x82)
@ COMMAND_ENABLE_2ND_UART
(0xA6)
@ COMMAND_UART1_RX_7BYTES
(0xB3)
@ COMMAND_ADJUST_FREQUENCY
(0xB7)
@ COMMAND_BINARY_WRITE_USER_BUFFER
(0x84)
@ CONFIGURE_PIN_MODE3
(203)
@ CONFIGURE_PIN_MODE4
(204)
@ CONFIGURE_PIN_MODE_DISABLE
(219)
@ CMD_READ_BUFFER_ASCII
('G')
@ COMMAND_BINARY_QUEUE_CLONE
(0x95)
@ COMMAND_BINARY_QUEUE_ADD_BYTES
(0x91)
@ COMMAND_BINARY_READ_EEPROM
(0xA2)
@ CONFIGURE_PIN_MODE5
(205)
@ COMMAND_BINARY_QUEUE_ADD_7BYTES
(0x92)
@ CONFIGURE_PIN_MODE8
(208)
@ CONFIGURE_PIN_MODE_HW_0
(220)
@ CONFIGURE_PIN_MODE6
(206)
@ CMD_SET_BUFFER_ASCII
('S')
@ CONFIGURE_PIN_MODE2
(202)
@ COMMAND_UART0_TX_7BYTES
(0xB0)
@ COMMAND_BINARY_QUEUE_READ_BYTES
(0x93)
@ COMMAND_BINARY_SET_ADDRESS
(0xB9)
@ CONFIGURE_PIN_INPUTPROCESS
(211)
@ CONFIGURE_CHANNEL_MODE_CHECK_MODE_SUPPORTED
(218)
@ CONFIGURE_PIN_MODE10
(210)
@ COMMAND_BINARY_WRITE_USER_BUFFER_CONTINUE
(0x85)
@ COMMAND_BINARY_CONFIG_DATALOGGER
(0x96)
@ CONFIGURE_PIN_MODE9
(209)
@ COMMAND_UART1_TX_7BYTES
(0xB2)
@ COMMAND_UART0_RX_7BYTES
(0xB1)
@ COMMAND_BINARY_RW_PIN_MEMORY
(0xB5)
@ COMMAND_READ_LAST_ERROR_PACKET
(0xA7)
@ COMMAND_BINARY_WRITE_RAM
(0xA3)
@ COMMAND_BINARY_READ_RAM
(0xA0)
@ COMMAND_BINARY_TEST_SEQUENCE
(0xB4)
@ CONFIGURE_CHANNEL_MODE_HW_2
(222)
@ COMMAND_BINARY_READ_PIN_BUFFFER
(0x81)
@ CONFIGURE_CHANNEL_MODE_HW_1
(221)
@ COMMAND_BINARY_READ_FLASH
(0xA1)
@ CONFIGURE_CHANNEL_MODE_HW_3
(223)
@ COMMAND_SET_PIN_HW
(0xB8)
@ COMMAND_CALIBRATE_ANALOG
(0xA5)
@ CONFIGURE_PIN_MODE7
(207)
@ CONFIGURE_PIN_MODE1
(201)
@ COMMAND_BINARY_PIN_POLL_THRESHOLD
(0x8F)
@ CONFIGURE_PIN_OUTPUTSCALE
(210)
@ COMMAND_BINARY_CONFIGURE
(0x9F)
#define SW08B_LATEST_FIRMWARE
#define SW_LE32(_a)
Convert a uint32_t to four bytes in little endian format for array initialization.
#define SW4B_LATEST_FIRMWARE
@ PIN_MODE_PULSE_ON_CHANGE
(25)
@ PIN_MODE_CHARLIEPLEX
(43)
@ PIN_MODE_FRAME_TIMER
(21)
@ PIN_MODE_PULSETIMER
(18)
@ PIN_MODE_PS2KEYBOARD
(32)
@ PIN_MODE_FREQUENCY_OUTPUT
(36)
@ PIN_MODE_RANDOMBLINK
(42)
@ PIN_MODE_QUEUED_PULSE_OUTPUT
(34)
@ PIN_MODE_SW18AB_CAPTOUCH
(22)
@ PIN_MODE_LIQUIDCRYSTAL
(28)
@ PIN_MODE_QUADRATUREENCODER
(5)
@ PIN_MODE_UART_RX_TX
(17)
@ PIN_MODE_HS_COUNTER
< (29)
@ PIN_MODE_PROTECTED_OUTPUT
(8)
@ PIN_MODE_ANALOGINPUT
(2)
@ PIN_MODE_UART1_RX_TX
(23)
@ PIN_MODE_I2C_CONTROLLER
(33)
@ PIN_MODE_RESISTANCEINPUT
(24)
@ PIN_MODE_INPUT_PROCESSOR
(14)
@ PIN_MODE_ULTRASONIC_DISTANCE
(27)
@ PIN_MODE_THROUGHPUT_CONSUMER
(4)
@ PIN_MODE_MATRIX_KEYPAD
(15)
void SerialWombatSerialErrorHandlerVerbose(uint16_t error, SerialWombatChip *sw)
a sample error handler that can be registered with registerErrorHandler to report protocol errors on ...
SerialWombatDataSource
A list of Serial Wombat public data sources.
@ SW_DATA_SOURCE_PIN_10
(10) 16 bit public data provided by Pin 10
@ SW_DATA_SOURCE_VBG_COUNTS_VS_VREF
(76) A/D conversion of VBG against VRef . Used for mfg calibration
@ SW_DATA_SOURCE_PIN_5
(5) 16 bit public data provided by Pin 5
@ SW_DATA_SOURCE_PIN_14
(14) 16 bit public data provided by Pin 14
@ SW_DATA_SOURCE_PIN_13
(13) 16 bit public data provided by Pin 13
@ SW_DATA_SOURCE_1024mvCounts
(66) The number of ADC counts that result from a 1.024V reading
@ SW_DATA_SOURCE_TEMPERATURE
(70)The internal core temperature expressed in 100ths deg C
@ SW_DATA_SOURCE_PIN_1
(1) 16 bit public data provided by Pin 1
@ SW_DATA_SOURCE_FRAMES_RUN_LSW
(67) The number of frames run since reset, least significant 16 bits
@ SW_DATA_SOURCE_VCC_mVOLTS
(75) The system source voltage in mV
@ SW_DATA_SOURCE_PIN_11
(11) 16 bit public data provided by Pin 11
@ SW_DATA_SOURCE_8SEC_SAW
(174)Sawtooth wave that goes from 0 to 65535 to 0 every 8192 frames
@ SW_DATA_SOURCE_PIN_4_MV
(104) Pin 4 public output expressed in mV (for analog modes only)
@ SW_DATA_SOURCE_PIN_6
(6) 16 bit public data provided by Pin 6
@ SW_DATA_SOURCE_PIN_15
(15) 16 bit public data provided by Pin 15
@ SW_DATA_SOURCE_LFSR
A Linear FeedBack Shift register (32,7,5,3,2,1) based pseudo-random number generator.
@ SW_DATA_SOURCE_OVERRUN_FRAMES
(69) The number of frames that ran more than 1mS
@ SW_DATA_SOURCE_PIN_9
(9) 16 bit public data provided by Pin 9
@ SW_DATA_SOURCE_PIN_12
(12) 16 bit public data provided by Pin 12
@ SW_DATA_SOURCE_PIN_3_MV
(103) Pin 3 public output expressed in mV (for analog modes only)
@ SW_DATA_SOURCE_PIN_8
(8) 16 bit public data provided by Pin 8
@ SW_DATA_SOURCE_PIN_18
(18) 16 bit public data provided by Pin 18
@ SW_DATA_SOURCE_8SEC_SQUARE
(173)Square wave that alternates between 0 and 65535 every 4096 frames
@ SW_DATA_SOURCE_0x55
(85) 0x55 is a reserved value for resyncing. Returns 0x55 0x55
@ SW_DATA_SOURCE_RESET_REGISTER
Hardware dependent reset reason register contents.
@ SW_DATA_SOURCE_2SEC_SQUARE
(170)Square wave that alternates between 0 and 65535 every 1024 frames
@ SW_DATA_COM_ADDRESS_LOW
The Communications Address of the Device (Lower 16 bits)
@ SW_DATA_SOURCE_PIN_18_MV
(118) Pin 18 public output expressed in mV (for analog modes only)
@ SW_DATA_COM_ADDRESS_HIGH
The Communications Address of the Device (HIGHER 16 bits) Anticipated for CAN ID.
@ SW_DATA_SOURCE_ERRORS
(72)The number of incoming packets that have caused errors since reset (rolls over at 65535)
@ SW_DATA_SOURCE_PIN_0_MV
(100) Pin 0 public output expressed in mV (for analog modes only)
@ SW_DATA_SOURCE_PIN_4
(4) 16 bit public data provided by Pin 4
@ SW_DATA_SOURCE_SYSTEM_UTILIZATION
(74) A number between 0 and 65535 that scales to the average length of pin processing frames between ...
@ SW_DATA_SOURCE_PACKETS_RECEIVED
(71) The nubmer of incoming command packets that have been processed since reset (rolls over at 65535...
@ SW_DATA_SOURCE_1HZ_SQUARE
(167) Square wave that alternates between 0 and 65535 every 512 frames
@ SW_DATA_SOURCE_2SEC_SAW
(171)Sawtooth wave that goes from 0 to 65535 to 0 every 2048 frames
@ SW_DATA_SOURCE_PIN_17_MV
(117) Pin 17 public output expressed in mV (for analog modes only)
@ SW_DATA_SOURCE_PIN_1_MV
(101) Pin 1 public output expressed in mV (for analog modes only)
@ 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...
@ SW_DATA_SOURCE_PIN_16_MV
(116) Pin 16 public output expressed in mV (for analog modes only)
@ SW_DATA_SOURCE_PIN_0
(0) 16 bit public data provided by Pin 0
@ SW_DATA_SOURCE_PIN_2
(2) 16 bit public data provided by Pin 2
@ SW_DATA_SOURCE_PIN_2_MV
(102) Pin 2 public output expressed in mV (for analog modes only)
@ SW_DATA_SOURCE_PIN_16
(16) 16 bit public data provided by Pin 16
@ SW_DATA_SOURCE_1HZ_SAW
(168) Sawtooth wave that goes from 0 to 65535 to 0 every 1024 frames
@ SW_DATA_SOURCE_PIN_19_MV
(119) Pin 19 public output expressed in mV (for analog modes only)
@ SW_DATA_SOURCE_PIN_7
(7) 16 bit public data provided by Pin 7
@ SW_DATA_SOURCE_FRAMES_RUN_MSW
(68) The number of frames run since reset, most significant 16 bits
@ SW_DATA_SOURCE_INCREMENTING_NUMBER
(65) An number that increments each time it is accessed.
@ SW_DATA_SOURCE_PIN_19
(19) 16 bit public data provided by Pin 19
@ SW_DATA_SOURCE_2HZ_SAW
(165) Sawtooth wave that goes from 0 to 65535 to 0 every 512 frames
@ SW_DATA_SOURCE_PIN_17
(17) 16 bit public data provided by Pin 17
@ SW_DATA_SOURCE_PIN_3
(3) 16 bit public data provided by Pin 3
@ SW_DATA_SOURCE_65SEC_SAW
(177 )Sawtooth wave that goes from 0 to 65535 to 0 every 65536 frames
@ SW_DATA_SOURCE_NONE
(255 ) Used to mean "No Source Selected"
@ SW_DATA_SOURCE_2HZ_SQUARE
(164) Square wave that alternates between 0 and 65535 every 256 frames
@ SW_DATA_SOURCE_65SEC_SQUARE
(176) Square wave that alternates between 0 and 65535 every 32768 frames
#define ARRAY_UINT32(_array, _index)
void(* SerialWombatErrorHandler_t)(uint16_t errorNumber, SerialWombatChip *sw)
@ SW_ERROR_UNKNOWN_PIN_MODE
(#3) A Pin mode was indicated that is not avaialble on this model or version of Serial Wombat chip
SerialWombat18ABOscillatorTuner(SerialWombatChip &serialWombatChip)
Class constructor for SerialWombat18OscillatorTuner.
void update()
Call periodically to tune the SW18AB oscillator to reported millis.
void update()
Call periodically to tune the SW8B oscillator to reported millis.
SerialWombat8BOscillatorTuner(SerialWombatChip &serialWombatChip)
Class constructor for SerialWombat8BOscillatorTuner.
Class for a Serial Wombat chip. Each Serial Wombat chip on a project should have its own instance.
int16_t setThroughputPin(uint32_t address)
Set this chip Address (SW8B only)
uint8_t uniqueIdentifier[16]
bool isLatestFirmware(void)
Check if the firmware is the latest version (or more precisely, if the firmware matches this verison ...
uint8_t address
The I2C address of the SerialWombatChip instance.
void wake()
Called to send a dummy packet to the Serial Wombat 8B chip to wake it from sleep and ready it for oth...
uint32_t sendReadyTime
Used as a countdown after a reset command is issued.
uint8_t uniqueIdentifierLength
bool isSW04()
Returns true if the instance received a model number corresponding to the Serial Wombat 18 series of ...
uint32_t comparePublicDataToThreshold(uint16_t threshold=0)
int16_t echo(uint8_t data[], uint8_t count=7)
Echo a byte array back to the host. Used for testing and debugging.
void digitalWrite(uint8_t pin, uint8_t val)
Set an output pin High or Low.
uint32_t readFlashAddress(uint32_t address)
Read Address from Flash based on 32 bit address.
bool inBoot
Set to true if boot mode is indicated by a version query.
bool isPinModeSupported(int pinMode)
Check if a specific pin mode is supported by the firmware in the Serial Wombat chip....
bool isPinModeSupported(SerialWombatPinMode_t pinMode)
Check if a specific pin mode is supported by the firmware in the Serial Wombat chip....
bool isSW08()
Returns true if the instance received a model number corresponding to the Serial Wombat 08 series of ...
void readUniqueIdentifier()
Read the unique identifier from the Serial Wombat chip and store it in uniqueIdentifier.
char * readVersion(void)
Request version string (combined model and firmware) and return pointer to it.
void configureDigitalPin(uint8_t pin, uint8_t highLow)
Configure a pin to a digital state with the same parameters as Arduino's digitalWrite() function.
uint16_t readPublicData(uint8_t pin)
Read the 16 Bit public data associated with a Serial Wombat Pin Mode.
uint8_t fwVersion[4]
Contains the last firmware Version retreived by queryVersion() as a zero-terminated string.
uint32_t readBirthday()
Read the birthday of the Serial Wombat 18AB chip.
uint8_t communicationErrorRetries
How many times to retry a packet if communcation bus (such as I2C) error.
int16_t echo(char *data)
Echo a byte array back to the host. Used for testing and debugging.
uint16_t readOverflowFrames()
Get the number of times an overflow Frame has occured.
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 ...
uint16_t writePublicData(uint8_t firstPin, uint16_t firstValue, uint8_t secondPin, uint16_t secondValue)
Write a 16 bit value to a Serial Wombat pin Mode.
void readDeviceIdentifier()
Read the device identifier from the Serial Wombat chip and store it in deviceIdentifier.
int writeUserBuffer(uint16_t index, uint8_t *buffer, uint16_t count)
Write bytes to the User Memory Buffer in the Serial Wombat chip.
int16_t readTemperature_100thsDegC(void)
Measure the Serial Wombat chip's internal temperature.
int sendPacketNoResponse(uint8_t tx[])
Send an 8 byte packet to the Serial Wombat chip, don't wait for a response.
uint8_t readRamAddress(uint16_t address)
Read Address from RAM based on 16 bit address.
int16_t readUserBuffer(uint16_t index, uint8_t *buffer, uint16_t count)
Read data from the Serial Wombat 18AB's internal RAM buffer.
bool isSW18()
Returns true if the instance received a model number corresponding to the Serial Wombat 18 series of ...
int16_t lastErrorCode
The last error code returned as part of a protocol error message expressed as a positive integer.
int16_t readBrand(char *data)
Read the brand of the Serial Wombat 18AB chip.
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.
int16_t setThroughputPin(uint8_t pin)
Set a pin to be a throughput monitoring pin.
int16_t begin(HardwareSerial &serial, bool reset=true)
initialize a Serial Wombat chip to use a Serial Interface.
int sendPacket(uint8_t tx[], uint8_t rx[])
Send an 8 byte packet to the Serial Wombat chip and wait for 8 bytes back.
void sleep4B()
Shuts down most functions of the Serial Wombat 4B chip reducing power consumption.
uint32_t readVersion_uint32(void)
Request version as a uint32.
uint16_t writePublicData(uint8_t pin, uint16_t value)
Write a 16 bit value to a Serial Wombat pin Mode.
uint16_t readSupplyVoltage_mV(void)
Measure the Serial Wombat chip's Supply voltage.
int16_t writeFlashRow(uint32_t address)
Writes a row in flash. Intended for use with the Bootloader, not by end users outside of bootloading ...
int writeUserBuffer(uint16_t index, char *s)
Write bytes to the User Memory Buffer in the Serial Wombat chip.
int16_t eraseFlashPage(uint32_t address)
Erases a page in flash. Intended for use with the Bootloader, not by end users outside of bootloading...
uint16_t returnErrorCode(uint8_t *rx)
Convert an ASCII Error code from a received packet into an integer error code.
uint16_t deviceIdentifier
int16_t writeRamAddress(uint16_t address, uint8_t value)
Write byte to Address in RAM based on 16 bit address.
int16_t initialize()
An internal function used to set up the Serial Wombat chip and this class. Call begin() instead of th...
int16_t writeFrameTimerPin(uint8_t pin)
Set a pin to be a frame timer for system utilization (SW18AB Only)
uint16_t _supplyVoltagemV
void registerErrorHandler(SerialWombatErrorHandler_t handler)
Registers an error handler that is called by the SerialWombatChip sendPacket() command when a protoco...
int16_t begin(TwoWire &wire, uint8_t i2cAddress, bool reset=true)
initialize a Serial Wombat chip to use a specified I2C Interface and address.
void analogWrite(uint8_t pin, int val)
Set a pin to PWM output.
void sleep8B(uint16_t delay)
Shuts down the Serial Wombat 8B chip reducing power consumption as low as 10uA.
uint16_t errorCount
Incremented every time a communication or command error is detected.
int writeUserBuffer(uint16_t index, const char s[])
Write bytes to the User Memory Buffer in the Serial Wombat chip.
int analogRead(uint8_t pin)
Configures pin as analog input and does an immediate A/D conversion.
uint16_t readPublicData(SerialWombatDataSource dataSource)
Read the 16 Bit public data associated with a Serial Wombat Pin Mode.
bool queryVersion()
Send a version request to the Serial Wombat chip.
void jumpToBoot()
Jump to Bootloader and wait for a UART download of new firmware.
int digitalRead(uint8_t pin)
Reads the state of a Pin.
void hardwareReset()
Send a reset command to the Serial Wombat chip.
uint8_t model[4]
Contains the last model retreived by queryVersion() as a zero-terminated string.
uint32_t readFramesExecuted()
Get the number of 1mS frames that have been executed since Serial Wombat chip reset.
int16_t readLastErrorCommand(uint8_t *cmd)
Returns the last Serial Wombat command that produced a protocol error.
This class name is depricated. Do not use for new development. Use SerialWombatChip instead.