Serial Wombat Arduino Library

Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
SerialWombatChip Class Reference

Class for a Serial Wombat chip. Each Serial Wombat chip on a project should have its own instance. More...

`#include <SerialWombat.h>`

Inheritance diagram for SerialWombatChip:
[legend]

## Public Member Functions
void | configureDigitalPin (uint8_t pin, uint8_t highLow)
| Configure a pin to a digital state with the same parameters as Arduino's digitalWrite() function.
int16_t | initialize ()
| An internal function used to set up the Serial Wombat chip and this class. Call begin() instead of this function.
void | readUniqueIdentifier ()
| Read the unique identifier from the Serial Wombat chip and store it in uniqueIdentifier.
void | readDeviceIdentifier ()
| Read the device identifier from the Serial Wombat chip and store it in deviceIdentifier.
uint16_t | returnErrorCode (uint8_t *rx)
| Convert an ASCII Error code from a received packet into an integer error code.
| SerialWombatChip ()
int16_t | begin (HardwareSerial &serial, bool reset=true)
| initialize a Serial Wombat chip to use a Serial Interface.
int16_t | begin (uint8_t i2cAddress)
| initialize a Serial Wombat chip to use the default Wire I2C Interface and specified address.
int16_t | begin (TwoWire &wire, uint8_t i2cAddress, bool reset=true)
| initialize a Serial Wombat chip to use a specified I2C Interface and address.
| ~SerialWombatChip ()
int | sendPacket (uint8_t tx[], uint8_t rx[])
| Send an 8 byte packet to the Serial Wombat chip and wait for 8 bytes back.
int | sendPacket (uint8_t tx[])
| Send an 8 byte packet to the Serial Wombat chip.
int | sendPacket (uint8_t tx[], uint8_t rx[], bool retryIfEchoDoesntMatch, uint8_t beginningBytesToMatch=8, uint8_t endBytesToMatch=0)
| Send an 8 byte packet to the Serial Wombat chip and wait for 8 bytes back.
int | sendPacket (uint8_t tx[], bool retryIfEchoDoesntMatch)
| Send an 8 byte packet to the Serial Wombat chip.
int | sendPacketNoResponse (uint8_t tx[])
| Send an 8 byte packet to the Serial Wombat chip, don't wait for a response.
char * | readVersion (void)
| Request version string (combined model and firmware) and return pointer to it.
uint32_t | readVersion_uint32 (void)
| Request version as a uint32.
bool | isLatestFirmware (void)
| Check if the firmware is the latest version (or more precisely, if the firmware matches this verison of the Library)
uint16_t | readPublicData (uint8_t pin)
| Read the 16 Bit public data associated with a Serial Wombat Pin Mode.
uint16_t | readPublicData (SerialWombatDataSource dataSource)
| Read the 16 Bit public data associated with a Serial Wombat Pin Mode.
uint16_t | writePublicData (uint8_t pin, uint16_t value)
| Write a 16 bit value to a Serial Wombat pin Mode.
uint32_t | comparePublicDataToThreshold (uint16_t threshold=0)
uint16_t | readSupplyVoltage_mV (void)
| Measure the Serial Wombat chip's Supply voltage.
int16_t | readTemperature_100thsDegC (void)
| Measure the Serial Wombat chip's internal temperature.
void | hardwareReset ()
| Send a reset command to the Serial Wombat 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.
void | digitalWrite (uint8_t pin, uint8_t val)
| Set an output pin High or Low.
int | digitalRead (uint8_t pin)
| Reads the state of a Pin.
int | analogRead (uint8_t pin)
| Configures pin as analog input and does an immediate A/D conversion.
void | analogWrite (uint8_t pin, int val)
| Set a pin to PWM output.
bool | queryVersion ()
| Send a version request to the Serial Wombat chip.
uint32_t | readFramesExecuted ()
| Get the number of 1mS frames that have been executed since Serial Wombat chip reset.
uint16_t | readOverflowFrames ()
| Get the number of times an overflow Frame has occured.
void | jumpToBoot ()
| Jump to Bootloader and wait for a UART download of new firmware.
uint8_t | readRamAddress (uint16_t address)
| Read Address from RAM based on 16 bit address.
int16_t | writeRamAddress (uint16_t address, uint8_t value)
| Write byte to Address in RAM based on 16 bit address.
uint32_t | readFlashAddress (uint32_t address)
| Read Address from Flash based on 32 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.
void | sleep4B ()
| Shuts down most functions of the Serial Wombat 4B chip reducing power consumption.
void | sleep8B (uint16_t delay)
| Shuts down the Serial Wombat 8B chip reducing power consumption as low as 10uA.
void | wake ()
| Called to send a dummy packet to the Serial Wombat 8B chip to wake it from sleep and ready it for other commands.
bool | isSW04 ()
| Returns true if the instance received a model number corresponding to the Serial Wombat 18 series of chips at begin.
bool | isSW18 ()
| Returns true if the instance received a model number corresponding to the Serial Wombat 18 series of chips at begin.
bool | isSW08 ()
| Returns true if the instance received a model number corresponding to the Serial Wombat 08 series of chips at begin.
bool | isPinModeSupported (int pinMode)
| Check if a specific pin mode is supported by the firmware in the Serial Wombat chip. (8B and 18AB only)
bool | isPinModeSupported (SerialWombatPinMode_t pinMode)
| Check if a specific pin mode is supported by the firmware in the Serial Wombat chip. (8B and 18AB only)
int16_t | eraseFlashPage (uint32_t address)
| Erases a page in flash. Intended for use with the Bootloader, not by end users outside of bootloading sketch.
int16_t | writeFlashRow (uint32_t address)
| Writes a row in flash. Intended for use with the Bootloader, not by end users outside of bootloading sketc.
int16_t | setThroughputPin (uint8_t pin)
| Set a pin to be a throughput monitoring pin.
int16_t | setThroughputPin (uint32_t address)
| Set this chip Address (SW8B only)
int | writeUserBuffer (uint16_t index, uint8_t *buffer, uint16_t count)
| Write bytes to the User Memory Buffer in the Serial Wombat chip.
int | writeUserBuffer (uint16_t index, char *s)
| Write bytes to the User Memory Buffer in the Serial Wombat chip.
int | writeUserBuffer (uint16_t index, const char s[])
| Write bytes to the User Memory Buffer in the Serial Wombat chip.
int16_t | writeFrameTimerPin (uint8_t pin)
| Set a pin to be a frame timer for system utilization (SW18AB Only)
int16_t | readLastErrorCommand (uint8_t *cmd)
| Returns the last Serial Wombat command that produced a protocol error.
void | registerErrorHandler (SerialWombatErrorHandler_t handler)
| Registers an error handler that is called by the SerialWombatChip sendPacket() command when a protocol error is returned by the Serial Wombat.
int16_t | echo (uint8_t data[], uint8_t count=7)
| Echo a byte array back to the host. Used for testing and debugging.
int16_t | echo (char *data)
| Echo a byte array back to the host. Used for testing and debugging.
uint32_t | readBirthday ()
| Read the birthday of the Serial Wombat 18AB chip.
int16_t | readBrand (char *data)
| Read the brand of the Serial Wombat 18AB chip.

## Static Public Member Functions
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 Wombat version commands. Returns first address that responds properly or 0 if none found.

## Public Attributes
uint16_t | _supplyVoltagemV = 0
uint8_t | model [4] = { 0 }
| Contains the last model retreived by queryVersion() as a zero-terminated string.
uint8_t | fwVersion [4] = { 0 }
| Contains the last firmware Version retreived by queryVersion() as a zero-terminated string.
uint8_t | uniqueIdentifier [16]
uint8_t | uniqueIdentifierLength = 0
uint16_t | deviceIdentifier
uint16_t | deviceRevision
uint16_t | errorCount = 0
| Incremented every time a communication or command error is detected.
bool | inBoot = false
| Set to true if boot mode is indicated by a version query.
int16_t | lastErrorCode = 0
| The last error code returned as part of a protocol error message expressed as a positive integer.
uint32_t | sendReadyTime = 0
| Used as a countdown after a reset command is issued.
uint8_t | address = 0
| The I2C address of the SerialWombatChip instance.
uint8_t | communicationErrorRetries = 5
| How many times to retry a packet if communcation bus (such as I2C) error.

## Detailed Description

Class for a Serial Wombat chip. Each Serial Wombat chip on a project should have its own instance.

This class describes the capabilties of a Serial Wombat Chip that are not Pin Mode functionalities. This class is used for all variety of Serial Wombat chips and is the parent class for Serial Wombat Boards such as PCB0030, PCB0031, etc.

Certain features may not be available on all models of Serial Wombat chips.

Definition at line 314 of file SerialWombat.h.

## Constructor & Destructor Documentation

## ◆ SerialWombatChip()

SerialWombatChip::SerialWombatChip | ( |  | ) |

Definition at line 31 of file SerialWombat.cpp.

## ◆ ~SerialWombatChip()

SerialWombatChip::~SerialWombatChip | ( |  | ) |

Definition at line 37 of file SerialWombat.cpp.

## Member Function Documentation

## ◆ analogRead()

int SerialWombatChip::analogRead | ( | uint8_t | pin | ) |
| inline

Configures pin as analog input and does an immediate A/D conversion.

This function is compatible with the Arduino Uno analogRead function.
It does not make use of advanced Serial Wombat chip's functionality such as averaging and filtering. Consider declaring a SerialWombatAnalogInput instead.

Parameters

  pin | The Serial Wombat pin to set. Valid values for SW4A: 0-3 SW4B: 1-3

Returns
  An Analog to Digital conversion ranging from 0 to 1023 (10-bit)

Definition at line 928 of file SerialWombat.h.

## ◆ analogWrite()

void SerialWombatChip::analogWrite | ( | uint8_t | pin,
|  | int | val )
| inline

Set a pin to PWM output.

This function is compatible with the Arduino Uno analogWrite function, but will output a PWM with a different frequency. Consider declaring a SerialWombatPWM instead. It has higher resolution and the ability to choose frequency.

Parameters

  pin | The Serial Wombat pin to set. Valid values for SW4A: 0-3 SW4B: 1-3
  val | A value from 0 (always low) to 255(always high) for the PWM duty cycle

Definition at line 947 of file SerialWombat.h.

## ◆ begin() [1/3]

int16_t SerialWombatChip::begin | ( | HardwareSerial & | serial,
|  | bool | reset = true )
| inline

initialize a Serial Wombat chip to use a Serial Interface.

The reset parameter determines if the Serial Wombat chip is reset prior to other initialization operations. If false, then any prior pin modes and configurations may still be in place. The Serial Wombat chips's source voltage is then read as well as its version.

Parameters

  serial | Serial Interface to be used by the Serial Wombat library
  reset | Whether or not to reset the Serial Wombat chip via command as the first initialization operation

Definition at line 550 of file SerialWombat.h.

## ◆ begin() [2/3]

int16_t SerialWombatChip::begin | ( | TwoWire & | wire,
|  | uint8_t | i2cAddress,
|  | bool | reset = true )
| inline

initialize a Serial Wombat chip to use a specified I2C Interface and address.

This call causes the Serial Wombat chip to optionally reset through its reset command as the first operation. The Serial Wombat chip's source voltage is then read as well as its version.

Parameters

  wire | I2C interface to be used by the Serial Wombat Library
  i2cAddress | I2C Follower address of the Serial Wombat chip commanded by this instance
  reset | Whether or not to reset the Serial Wombat chip via command as the first initialization operation. If false, then any prior pin modes and configurations may still be in place.

Definition at line 596 of file SerialWombat.h.

## ◆ begin() [3/3]

int16_t SerialWombatChip::begin | ( | uint8_t | i2cAddress | ) |

initialize a Serial Wombat chip to use the default Wire I2C Interface and specified address.

This call causes the Serial Wombat chip to be reset through its reset command as the first operation. The Serial Wombat chip's source voltage is then read as well as its version.

Parameters

  i2cAddress | I2C Follower address of the Serial Wombat chip commanded by this instance

Definition at line 45 of file SerialWombat.cpp.

## ◆ comparePublicDataToThreshold()

uint32_t SerialWombatChip::comparePublicDataToThreshold | ( | uint16_t | threshold = 0 | ) |
| inline

Definition at line 790 of file SerialWombat.h.

## ◆ configureDigitalPin()

void SerialWombatChip::configureDigitalPin | ( | uint8_t | pin,
|  | uint8_t | highLow )
| inline

Configure a pin to a digital state with the same parameters as Arduino's digitalWrite() function.

This function is convenient if not using SerialWombatPin class which provides additonal funcitonalities.

Parameters

  pin | The pin number to configure
  highLow | The desired state of the pin. INPUT, LOW or HIGH or INPUT_PULLUP

Definition at line 385 of file SerialWombat.h.

## ◆ digitalRead()

int SerialWombatChip::digitalRead | ( | uint8_t | pin | ) |
| inline

Reads the state of a Pin.

Returns
  Returns LOW if pin is low or public data is 0. Returns HIGH if pin is high or public data is > 0

Definition at line 907 of file SerialWombat.h.

## ◆ digitalWrite()

void SerialWombatChip::digitalWrite | ( | uint8_t | pin,
|  | uint8_t | val )
| inline

Set an output pin High or Low.

Before calling this function, the pin should be configured as an input or output with pinMode()

Parameters

  pin | The Serial Wombat pin to set. Valid values for SW4A: 0-3 SW4B: 1-3
  val | Valid values are HIGH or LOW not use SW_INPUT, SW_HIGH or SW_LOW here, as these have different meanings

Definition at line 897 of file SerialWombat.h.

## ◆ echo() [1/2]

int16_t SerialWombatChip::echo | ( | char * | data | ) |
| inline

Echo a byte array back to the host. Used for testing and debugging.

Parameters

  data | The 7 byte array to echo back to the host

Returns
  0 for success or negative error code. Success is successful transmit, not echo verification.

Definition at line 1575 of file SerialWombat.h.

## ◆ echo() [2/2]

int16_t SerialWombatChip::echo | ( | uint8_t | data[],
|  | uint8_t | count = 7 )
| inline

Echo a byte array back to the host. Used for testing and debugging.

Parameters

  data | The byte array to echo back to the host
  count | The number of bytes to echo. Default is 7 bytes. Maximum is 7 bytes.

Returns
  0 for success or negative error code. Success is successful transmit, not echo verification.

Definition at line 1559 of file SerialWombat.h.

## ◆ eraseFlashPage()

int16_t SerialWombatChip::eraseFlashPage | ( | uint32_t | address | ) |
| inline

Erases a page in flash. Intended for use with the Bootloader, not by end users outside of bootloading sketch.

Definition at line 1267 of file SerialWombat.h.

## ◆ find()

static uint8_t SerialWombatChip::find | ( | bool | keepTrying = false | ) |
| inline static

Search the I2C Bus addresses 0x68 to 0x6F for I2C devices, and test to see if they respond to Serial Wombat version commands. Returns first address that responds properly or 0 if none found.

Parameters

  keepTrying | if True, go into a loop and do not exit until a Serial Wombat Chip is found

Returns
  I2C address of first found Seirla Wombat chip or 0 if none found

Definition at line 1468 of file SerialWombat.h.

## ◆ hardwareReset()

void SerialWombatChip::hardwareReset | ( |  | ) |
| inline

Send a reset command to the Serial Wombat chip.

Sends a reset command to the Serial Wombat chip. The calling function should wait 500mS before sending additional commands.

Definition at line 864 of file SerialWombat.h.

## ◆ initialize()

int16_t SerialWombatChip::initialize | ( |  | ) |
| inline

An internal function used to set up the Serial Wombat chip and this class. Call begin() instead of this function.

Definition at line 436 of file SerialWombat.h.

## ◆ isLatestFirmware()

bool SerialWombatChip::isLatestFirmware | ( | void |  | ) |
| inline

Check if the firmware is the latest version (or more precisely, if the firmware matches this verison of the Library)

Returns
  true if the firmware matches the library. False if the firmware is newer or older than the library

Definition at line 728 of file SerialWombat.h.

## ◆ isPinModeSupported() [1/2]

bool SerialWombatChip::isPinModeSupported | ( | int | pinMode | ) |
| inline

Check if a specific pin mode is supported by the firmware in the Serial Wombat chip. (8B and 18AB only)

Parameters

  pinMode | The pin mode to check

Returns
  true if the pin mode is supported, false otherwise.

Definition at line 1225 of file SerialWombat.h.

## ◆ isPinModeSupported() [2/2]

bool SerialWombatChip::isPinModeSupported | ( | SerialWombatPinMode_t | pinMode | ) |
| inline

Check if a specific pin mode is supported by the firmware in the Serial Wombat chip. (8B and 18AB only)

Parameters

  pinMode | The pin mode to check

Returns
  true if the pin mode is supported, false otherwise.

Definition at line 1234 of file SerialWombat.h.

## ◆ isSW04()

bool SerialWombatChip::isSW04 | ( |  | ) |
| inline

Returns true if the instance received a model number corresponding to the Serial Wombat 18 series of chips at begin.

Definition at line 1203 of file SerialWombat.h.

## ◆ isSW08()

bool SerialWombatChip::isSW08 | ( |  | ) |
| inline

Returns true if the instance received a model number corresponding to the Serial Wombat 08 series of chips at begin.

Definition at line 1215 of file SerialWombat.h.

## ◆ isSW18()

bool SerialWombatChip::isSW18 | ( |  | ) |
| inline

Returns true if the instance received a model number corresponding to the Serial Wombat 18 series of chips at begin.

Definition at line 1210 of file SerialWombat.h.

## ◆ jumpToBoot()

void SerialWombatChip::jumpToBoot | ( |  | ) |
| inline

Jump to Bootloader and wait for a UART download of new firmware.

This function causes a reset of the Serial Wombat chip and causes it to remain in the bootloader until a power-cycle occurs. This allows loading new firmware via a UART connection to the bottom two pins (DIP pins 4 (RX) and 5(TX)) on the SW4A/SW4B. When jumping to boot the TX pin will go high. All other communication or functional pins will become inputs (i.e. PWMS, etc will stop).

Definition at line 1028 of file SerialWombat.h.

## ◆ pinMode()

void SerialWombatChip::pinMode | ( | uint8_t | pin,
|  | uint8_t | mode,
|  | bool | pullDown = false,
|  | bool | openDrain = false )
| inline

Set a pin to INPUT or OUTPUT, with options for pull Ups and open Drain settings.

Parameters

  pin | The Serial Wombat pin to set
  mode | Valid values are INPUT, OUTPUT or INPUT_PULLUP as defined by arduino. Do not use SW_INPUT, SW_HIGH or SW_LOW here, as these have different meanings
  pullDown | If True, a weak pull down will be enabled on this pin (No effect on SW4A/SW4B)
  openDrain | If True, output becomes openDrain output rather than push / pull

Definition at line 878 of file SerialWombat.h.

## ◆ queryVersion()

bool SerialWombatChip::queryVersion | ( |  | ) |
| inline

Send a version request to the Serial Wombat chip.

This function queries the Serial Wombat chip for its model and version and stores the result in the public members model and fwVersion as zero terminated strings. Returns true if the response is likely a proper version response and false otherwise.

Returns
  TRUE if response was likely a valid version, FALSE otherwise

Definition at line 969 of file SerialWombat.h.

## ◆ readBirthday()

uint32_t SerialWombatChip::readBirthday | ( |  | ) |
| inline

Read the birthday of the Serial Wombat 18AB chip.

Returns
  The birthday as a 32 bit value, or 0 if not a SW18AB chip

Definition at line 1590 of file SerialWombat.h.

## ◆ readBrand()

int16_t SerialWombatChip::readBrand | ( | char * | data | ) |
| inline

Read the brand of the Serial Wombat 18AB chip.

Returns
  The brand as a string, or empty string if not a SW18AB chip

Definition at line 1610 of file SerialWombat.h.

## ◆ readDeviceIdentifier()

void SerialWombatChip::readDeviceIdentifier | ( |  | ) |
| inline

Read the device identifier from the Serial Wombat chip and store it in deviceIdentifier.

This function makes various chip identification (such as mask revision) available to the user. See the datasheet for the specific Serial Wombat chip's microcontroller for details on what this identifier means.

Definition at line 495 of file SerialWombat.h.

## ◆ readFlashAddress()

uint32_t SerialWombatChip::readFlashAddress | ( | uint32_t | address | ) |
| inline

Read Address from Flash based on 32 bit address.

Most Arduino users should not need this command.

This command can be used to read flash locations within the Serial Wombat Chip

Addresses are not validated to be available in a given chip's address range.

Parameters

  address | A 32-bit address pointing to a location in the Serial Wombat Chip's memory map

Returns
  An 32 bit value returned from the Serial Wombat chip. 32 bits are used to accomodate different chips. The SW18 series has a 24 bit flash word, whereas the SW4A and SW4B have a 14 bit word.

Definition at line 1103 of file SerialWombat.h.

## ◆ readFramesExecuted()

uint32_t SerialWombatChip::readFramesExecuted | ( |  | ) |
| inline

Get the number of 1mS frames that have been executed since Serial Wombat chip reset.

This value should be roughly equal to the mS since reset. It will vary based on the Serial Wombat chip's internal oscillator variation, and may run slow if Overflow frames are occuring.

Definition at line 997 of file SerialWombat.h.

## ◆ readLastErrorCommand()

int16_t SerialWombatChip::readLastErrorCommand | ( | uint8_t * | cmd | ) |
| inline

Returns the last Serial Wombat command that produced a protocol error.

Returns
  Returns the error code associated with the command

Parameters

  cmd | pointer to a uint8_t [8] array into which the error command will be copied

Definition at line 1514 of file SerialWombat.h.

## ◆ readOverflowFrames()

uint16_t SerialWombatChip::readOverflowFrames | ( |  | ) |
| inline

Get the number of times an overflow Frame has occured.

This value increments each time the Serial Wombat firmware determines it is time to start a new 1 mS frame, but the previous frame is still executing. Indicates processor loading over 100% of real-time. Overflows back to 0 when incremented from 65535.

Definition at line 1014 of file SerialWombat.h.

## ◆ readPublicData() [1/2]

uint16_t SerialWombatChip::readPublicData | ( | SerialWombatDataSource | dataSource | ) |
| inline

Read the 16 Bit public data associated with a Serial Wombat Pin Mode.

Reads and returns the 16 bit value associated with a Serial Wombat Pin Mode. Additionally, values of 65 and higher have special meanings. See Serial Wombat firmware documentation for details.

Returns
  16 bit public data for pin specified

Parameters

  dataSource | The pin (or special meaning value) for which to retreive data

Definition at line 772 of file SerialWombat.h.

## ◆ readPublicData() [2/2]

uint16_t SerialWombatChip::readPublicData | ( | uint8_t | pin | ) |
| inline

Read the 16 Bit public data associated with a Serial Wombat Pin Mode.

Reads and returns the 16 bit value associated with a Serial Wombat Pin Mode. Additionally, values of 65 and higher have special meanings. See Serial Wombat firmware documentation for details.

Returns
  16 bit public data for pin specified

Parameters

  pin | The pin (or special meaning value) for which to retreive data

Definition at line 755 of file SerialWombat.h.

## ◆ readRamAddress()

uint8_t SerialWombatChip::readRamAddress | ( | uint16_t | address | ) |
| inline

Read Address from RAM based on 16 bit address.

Most Arduino users should not need this command.

This command can be used to read variables and registers within the Serial Wombat Chip Note that reading registers may have unintended side effects. See the microcontroller datasheet for details.

Note that Note that the PIC16F15214 used in the SW4A and SW4B chips is a Microchip Enhanced Mid-Range chip with both a banked RAM area and a Linear RAM area at an offset address. See the datasheet for details. It's wierd to people who are unfamilliar with it. The same location can have two different addresses.

Addresses are not validated to be available in a given chip's address range.

Parameters

  address | A 16-bit address pointing to a location in the Serial Wombat Chip's memory map

Returns
  An 8 bit value returned from the Serial Wombat chip.

Definition at line 1054 of file SerialWombat.h.

## ◆ readSupplyVoltage_mV()

uint16_t SerialWombatChip::readSupplyVoltage_mV | ( | void |  | ) |
| inline

Measure the Serial Wombat chip's Supply voltage.

Causes the Serial Wombat chip to measure the counts for the internal reference voltage. The Arduino library then converts these counts to a Source votlage in mV

Returns
  The Serial Wombat chip's source voltage in mV

Definition at line 808 of file SerialWombat.h.

## ◆ readTemperature_100thsDegC()

int16_t SerialWombatChip::readTemperature_100thsDegC | ( | void |  | ) |
| inline

Measure the Serial Wombat chip's internal temperature.

This command is only supported by the SerialWombat 18 Series. The Arduino library will return 25 deg. C for other models

This value is low accuracy unless a calibration has been performed

Returns
  The Serial Wombat chip's temperature in 100ths deg C

Definition at line 841 of file SerialWombat.h.

## ◆ readUniqueIdentifier()

void SerialWombatChip::readUniqueIdentifier | ( |  | ) |
| inline

Read the unique identifier from the Serial Wombat chip and store it in uniqueIdentifier.

Each Serial Wombat Chip has a unique identifier stored in its flash memory at manufacturing. The length of this identifier varies by model. See the public value uniqueIdentifierLength to determine the length of the identifier.

Definition at line 452 of file SerialWombat.h.

## ◆ readUserBuffer()

int16_t SerialWombatChip::readUserBuffer | ( | uint16_t | index,
|  | uint8_t * | buffer,
|  | uint16_t | count )
| inline

Read data from the Serial Wombat 18AB's internal RAM buffer.

Parameters

  index | A 16-bit index into the Serial Wombat Chip's User RAM Buffer
  buffer | a pointer to an array into which bytes will be written
  count | Number of bytes to read

Returns
  Number of bytes read, or negative error code

Definition at line 1122 of file SerialWombat.h.

## ◆ readVersion()

char * SerialWombatChip::readVersion | ( | void |  | ) |
| inline

Request version string (combined model and firmware) and return pointer to it.

This queries the Serial Wombat chip for the 7 characters: product line (1 character) Model (3 characters) and firmware version (3 characters) This is stored in a string in the Serial Wombat object. A pointer to this string is returned.

Definition at line 694 of file SerialWombat.h.

## ◆ readVersion_uint32()

uint32_t SerialWombatChip::readVersion_uint32 | ( | void |  | ) |
| inline

Request version as a uint32.

This queries the Serial Wombat chip for its version information, and returns the firmware version as a uint32 0x0XYZ where X,Y,and Z represent firmwre version X.Y.Z

Definition at line 715 of file SerialWombat.h.

## ◆ registerErrorHandler()

void SerialWombatChip::registerErrorHandler | ( | SerialWombatErrorHandler_t | handler | ) |
| inline

Registers an error handler that is called by the SerialWombatChip sendPacket() command when a protocol error is returned by the Serial Wombat.

Parameters

  handler | A function pointer to a function of SerialWombatErrorHandler_t type.

Definition at line 1542 of file SerialWombat.h.

## ◆ returnErrorCode()

uint16_t SerialWombatChip::returnErrorCode | ( | uint8_t * | rx | ) |
| inline

Convert an ASCII Error code from a received packet into an integer error code.

Parameters

  rx | The received packet

Returns
  The integer error code

Definition at line 519 of file SerialWombat.h.

## ◆ sendPacket() [1/4]

int SerialWombatChip::sendPacket | ( | uint8_t | tx[] | ) |

Send an 8 byte packet to the Serial Wombat chip.

This method sends 8 bytes and processes the response to check for errors.

Parameters

  tx | address of an array of 8 bytes to send

Returns
  The number of bytes received as a response, or a negative value if an error was returned from the Serial Wombat chip

Definition at line 299 of file SerialWombat.cpp.

## ◆ sendPacket() [2/4]

int SerialWombatChip::sendPacket | ( | uint8_t | tx[],
|  | bool | retryIfEchoDoesntMatch )

Send an 8 byte packet to the Serial Wombat chip.

This method sends 8 bytes and processes the response to check for errors.

Parameters

  tx | address of an array of 8 bytes to send
  retryIfEchoDoesntMatch | If true, the packet will be retried if the echo doesn't match

Returns
  The number of bytes received as a response, or a negative value if an error was returned from the Serial Wombat chip

Definition at line 52 of file SerialWombat.cpp.

## ◆ sendPacket() [3/4]

int SerialWombatChip::sendPacket | ( | uint8_t | tx[],
|  | uint8_t | rx[] )

Send an 8 byte packet to the Serial Wombat chip and wait for 8 bytes back.

This method sends 8 bytes via I2C or Serial and blocks until 8 bytes are receieved back

Parameters

  tx | address of an array of 8 bytes to send
  rx | address of an array of 8 bytes into which to put response.

Returns
  The number of bytes received as a response, or a negative value if an error was returned from the Serial Wombat chip

Definition at line 115 of file SerialWombat.cpp.

## ◆ sendPacket() [4/4]

int SerialWombatChip::sendPacket | ( | uint8_t | tx[],
|  | uint8_t | rx[],
|  | bool | retryIfEchoDoesntMatch,
|  | uint8_t | beginningBytesToMatch = 8,
|  | uint8_t | endBytesToMatch = 0 )

Send an 8 byte packet to the Serial Wombat chip and wait for 8 bytes back.

This method sends 8 bytes via I2C or Serial and blocks until 8 bytes are receieved back

Parameters

  tx | address of an array of 8 bytes to send
  rx | address of an array of 8 bytes into which to put response.
  retryIfEchoDoesntMatch | If true, the packet will be retried if the echo doesn't match
  beginningBytesToMatch | The number of bytes at the beginning of the packet to check for a match
  endBytesToMatch | The number of bytes at the end of the packet to check for a match

Returns
  The number of bytes received as a response, or a negative value if an error was returned from the Serial Wombat chip

Definition at line 58 of file SerialWombat.cpp.

## ◆ sendPacketNoResponse()

int SerialWombatChip::sendPacketNoResponse | ( | uint8_t | tx[] | ) |

Send an 8 byte packet to the Serial Wombat chip, don't wait for a response.

This method sends 8 bytes. Used for resetting the chip prior to bootloading

Parameters

  tx | address of an array of 8 bytes to send

Returns
  returns a non-error 0 or higher

Definition at line 280 of file SerialWombat.cpp.

## ◆ setThroughputPin() [1/2]

int16_t SerialWombatChip::setThroughputPin | ( | uint32_t | address | ) |
| inline

Set this chip Address (SW8B only)

Sets the i2c or other address of the chip. This value is stored in flash and applies to both bootloader and application. Persistent across application bootloads. Causes address selection pins to be ignored. Set to 0xFF to restore address pins. Requires reset after calling to change I2C address.

Parameters

  address | to set. 7 Bit value for I2C, defined as 32 bit for future applications like CAN

Returns
  Number of bytes written or error code.

Definition at line 1317 of file SerialWombat.h.

## ◆ setThroughputPin() [2/2]

int16_t SerialWombatChip::setThroughputPin | ( | uint8_t | pin | ) |
| inline

Set a pin to be a throughput monitoring pin.

This pin goes high when pin processing begins in each 1mS frame, and goes low after pin processing is complete. This allows the CPU utilization of the Serial Wombat chip to be measured using a logic analyzer. This function can only be applied to one pin, and is only disabled by resetting the chip. This function is supported on the SW18AB chip. It is not supported on the SW4 series of chips.

Definition at line 1298 of file SerialWombat.h.

## ◆ sleep4B()

void SerialWombatChip::sleep4B | ( |  | ) |
| inline

Shuts down most functions of the Serial Wombat 4B chip reducing power consumption.

This command stops the Serial Wombat chip's internal clock, greatly reducing power consumption. The host is responsible for configuring outputs to a safe state prior to calling sleep.

Sending an I2C Packet to the Serial Wombat 4B chip will wake it up.

Warning
  This command does not cause any sort of shutdown routine to run. The chip just stops. Outputs, including PWM, Servo and Protected Outputs, may retain their logic levels at the moment the sleep command is processed. In other words, they may stay high or low as long as the chip is in sleep.

Definition at line 1162 of file SerialWombat.h.

## ◆ sleep8B()

void SerialWombatChip::sleep8B | ( | uint16_t | delay | ) |
| inline

Shuts down the Serial Wombat 8B chip reducing power consumption as low as 10uA.

This command stops the Serial Wombat chip's internal clock, greatly reducing power consumption. The host is responsible for configuring outputs to a safe state prior to calling sleep. Inputs should not be left floating as this will greatly increase sleep current.

The chip will stay asleep until the next high-to-low SCL transition for any device after the specified delay time. The chip resets after waking up. Appropriate pin mode begin calls must be made to reconfigure the Serial Wombat 8B chip as if it were a power-up reset.

Parameters

  delay | Number of mS after call to go to sleep. This allows other chips to be configured over I2C after this call without waking up this chip.

Warning
  This command does not cause any sort of shutdown routine to run. The chip just stops. Outputs, including PWM, Servo and Protected Outputs, may retain their logic levels at the moment the sleep command is processed. In other words, they may stay high or low as long as the chip is in sleep.

Definition at line 1187 of file SerialWombat.h.

## ◆ wake()

void SerialWombatChip::wake | ( |  | ) |
| inline

Called to send a dummy packet to the Serial Wombat 8B chip to wake it from sleep and ready it for other commands.

Definition at line 1196 of file SerialWombat.h.

## ◆ writeFlashRow()

int16_t SerialWombatChip::writeFlashRow | ( | uint32_t | address | ) |
| inline

Writes a row in flash. Intended for use with the Bootloader, not by end users outside of bootloading sketc.

Definition at line 1278 of file SerialWombat.h.

## ◆ writeFrameTimerPin()

int16_t SerialWombatChip::writeFrameTimerPin | ( | uint8_t | pin | ) |
| inline

Set a pin to be a frame timer for system utilization (SW18AB Only)

Returns
  0 or positive for success or negative error code

This command configures a Serial Wombat 18AB Pin to be a frame timer. This frame goes high at the beginning of pin processing, and low after all pins have been serviced. The duty cycle of this pin is an indicator of the Serial Wombat Chip's CPU utilization. This pin has a frequency of 1kHz corresponding to the 1000 frames per second executive. Most multimeters will filter this pin to a voltage, so the CPU utilization can be seen as a fraction of the system voltage. Only one pin can be the Frame Timer pin at a time.

Definition at line 1454 of file SerialWombat.h.

## ◆ writePublicData()

uint16_t SerialWombatChip::writePublicData | ( | uint8_t | pin,
|  | uint16_t | value )
| inline

Write a 16 bit value to a Serial Wombat pin Mode.

Parameters

  pin | The pin number to which to write
  value | The 16 bit value to write

Definition at line 782 of file SerialWombat.h.

## ◆ writeRamAddress()

int16_t SerialWombatChip::writeRamAddress | ( | uint16_t | address,
|  | uint8_t | value )
| inline

Write byte to Address in RAM based on 16 bit address.

Most Arduino users should not need this command.

This command can be used to write variables and registers within the Serial Wombat Chip Note that write registers may have unintended side effects. See the microcontroller datasheet for details.

Note that Note that the PIC16F15214 used in the SW4A and SW4B chips is a Microchip Enhanced Mid-Range chip with both a banked RAM area and a Linear RAM area at an offset address. See the datasheet for details. It's wierd to people who are unfamilliar with it. The same location can have two different addresses.

Addresses are not validated to be available in a given chip's address range.

Parameters

  address | A 16-bit address pointing to a location in the Serial Wombat Chip's memory map
  value | An 8 bit value to be written to RAM

Definition at line 1082 of file SerialWombat.h.

## ◆ writeUserBuffer() [1/3]

int SerialWombatChip::writeUserBuffer | ( | uint16_t | index,
|  | char * | s )
| inline

Write bytes to the User Memory Buffer in the Serial Wombat chip.

Parameters

  index | The index into the User Buffer array of bytes where the data should be loaded
  s | string to convert to Ascii bytes and load

Returns
  Number of bytes written or error code.

Definition at line 1425 of file SerialWombat.h.

## ◆ writeUserBuffer() [2/3]

int SerialWombatChip::writeUserBuffer | ( | uint16_t | index,
|  | const char | s[] )
| inline

Write bytes to the User Memory Buffer in the Serial Wombat chip.

Parameters

  index | The index into the User Buffer array of bytes where the data should be loaded
  s | string to convert to Ascii bytes and load

Returns
  Number of bytes written or error code.

Definition at line 1436 of file SerialWombat.h.

## ◆ writeUserBuffer() [3/3]

int SerialWombatChip::writeUserBuffer | ( | uint16_t | index,
|  | uint8_t * | buffer,
|  | uint16_t | count )
| inline

Write bytes to the User Memory Buffer in the Serial Wombat chip.

Parameters

  index | The index into the User Buffer array of bytes where the data should be loaded
  buffer | a pointer to an array of bytes to be loaded into the User Buffer array
  count | number of bytes to load

Returns
  Number of bytes written or error code.

Definition at line 1330 of file SerialWombat.h.

## Member Data Documentation

## ◆ _supplyVoltagemV

uint16_t SerialWombatChip::_supplyVoltagemV = 0

Stores the last value retreived by readSupplyVoltage_mV(). Used by SerialWombatAnalogInput class to calculate mV outputs from retreived A/D counts. Don't access this member, as it may become private and SerialWombatAnalog input be made a friend of SerialWombat in the future. Call readSupplyVoltage_mV instead.

Definition at line 335 of file SerialWombat.h.

## ◆ address

uint8_t SerialWombatChip::address = 0

The I2C address of the SerialWombatChip instance.

Definition at line 1548 of file SerialWombat.h.

## ◆ communicationErrorRetries

uint8_t SerialWombatChip::communicationErrorRetries = 5

How many times to retry a packet if communcation bus (such as I2C) error.

Definition at line 1551 of file SerialWombat.h.

## ◆ deviceIdentifier

uint16_t SerialWombatChip::deviceIdentifier

Contains a Microchip device identifier for Microchip based Serial Wombat Models. Call queryVersion() to populate this value.

Definition at line 360 of file SerialWombat.h.

## ◆ deviceRevision

uint16_t SerialWombatChip::deviceRevision

Contains a Microchip device revision for Microchip based Serial Wombat Models. Call queryVersion() to populate this value.

Definition at line 366 of file SerialWombat.h.

## ◆ errorCount

uint16_t SerialWombatChip::errorCount = 0

Incremented every time a communication or command error is detected.

Definition at line 368 of file SerialWombat.h.

## ◆ fwVersion

uint8_t SerialWombatChip::fwVersion[4] = { 0 }

Contains the last firmware Version retreived by queryVersion() as a zero-terminated string.

Definition at line 341 of file SerialWombat.h.

## ◆ inBoot

bool SerialWombatChip::inBoot = false

Set to true if boot mode is indicated by a version query.

Definition at line 371 of file SerialWombat.h.

## ◆ lastErrorCode

int16_t SerialWombatChip::lastErrorCode = 0

The last error code returned as part of a protocol error message expressed as a positive integer.

Definition at line 374 of file SerialWombat.h.

## ◆ model

uint8_t SerialWombatChip::model[4] = { 0 }

Contains the last model retreived by queryVersion() as a zero-terminated string.

Definition at line 338 of file SerialWombat.h.

## ◆ sendReadyTime

uint32_t SerialWombatChip::sendReadyTime = 0

Used as a countdown after a reset command is issued.

Definition at line 431 of file SerialWombat.h.

## ◆ uniqueIdentifier

uint8_t SerialWombatChip::uniqueIdentifier[16]

Contains the unique identifier stored in microcontroller at its manufacturing.
Length and format vary by model. uniqueIdentifier holds the length in bytes.
Call queryVersion() to populate this value.

Definition at line 348 of file SerialWombat.h.

## ◆ uniqueIdentifierLength

uint8_t SerialWombatChip::uniqueIdentifierLength = 0

Contains the unique identifier length in bytes. This value varies by model. Call queryVersion() to populate this value.

Definition at line 354 of file SerialWombat.h.