Serial Wombat Arduino Library

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

Describes a Serial Wombat Pin. Is base class for other pin modes. More...

`#include <SerialWombatPin.h>`

Inheritance diagram for SerialWombatPin:
[legend]
Collaboration diagram for SerialWombatPin:
[legend]

## Public Member Functions
| SerialWombatPin (SerialWombatChip &serialWombatChip)
| Instantiates a Serial Wombat Pin.
| SerialWombatPin (SerialWombatChip &serialWombatChip, uint8_t pin)
| Instantiates a Serial Wombat Pin.
uint16_t | readPublicData ()
| Read the 16 Bit public data associated with this pin.
void | pinMode (uint8_t mode, bool pullDown=false, bool openDrain=false)
| Set pin to INPUT or OUTPUT, with options for pull Ups and open Drain settings.
void | digitalWrite (uint8_t val)
| Set output pin High or Low.
int | digitalRead ()
| Reads the state of the Pin.
uint16_t | writePublicData (uint16_t value)
| Write a 16 bit value to this pin.
uint8_t | pin ()
| Returns the current SW pin number. Used primarily for virtual calls by derived classes.
uint8_t | swPinModeNumber ()
| Returns the Mode number. Used primarily by derived classes to populate packet data.
int16_t | initPacketNoResponse (uint8_t packetNumber, uint8_t param0=0x55, uint8_t param1=0x55, uint8_t param2=0x55, uint8_t param3=0x55, uint8_t param4=0x55)
int16_t | initPacketNoResponse (uint8_t packetNumber, uint16_t param0=0x55, uint8_t param1=0x55, uint8_t param2=0x55, uint8_t param3=0x55)
int16_t | initPacketNoResponse (uint8_t packetNumber, uint16_t param0, uint16_t param1, uint8_t param2=0x55)
int16_t | disable ()
| Disables the pin mode (if applicable)
int16_t | enablePullup (bool enabled)
| Enables the weak pull up on a pin. Implemented on SW18AB only.
int16_t | enablePullDown (bool enabled)
| Enables the weak pull down on a pin. Implemented on SW18AB only.
int16_t | enableOpenDrain (bool enabled)
| Enables open drain mode on a pin. Implemented on SW18AB only.

## Protected Attributes
uint8_t | _pin = 255
SerialWombatChip & | _sw
uint8_t | _pinMode = 0

## Detailed Description

Describes a Serial Wombat Pin. Is base class for other pin modes.

This class describes a Serial Wombat Pin on a Serial Wombat Chip. This class can be used to control a pin as a simple Digital I/O pin. This class is used as a base class for many other pin mode classes.

Digital I/O related members such as digitalWrite or pinMode should not be called against derived classes as this may have unpredicable effects on the state machines run by those derived classes.

Definition at line 38 of file SerialWombatPin.h.

## Constructor & Destructor Documentation

## ◆ SerialWombatPin() [1/2]

SerialWombatPin::SerialWombatPin | ( | SerialWombatChip & | serialWombatChip | ) |
| inline

Instantiates a Serial Wombat Pin.

Parameters

  serialWombatChip | The chip on which the Serial Wombat Pin exists

Definition at line 45 of file SerialWombatPin.h.

## ◆ SerialWombatPin() [2/2]

SerialWombatPin::SerialWombatPin | ( | SerialWombatChip & | serialWombatChip,
|  | uint8_t | pin )
| inline

Instantiates a Serial Wombat Pin.

Parameters

  serialWombatChip | The chip on which the Serial Wombat Pin exists
  pin | The pin number of the pin (WP number, not package pin number) of the pin

Definition at line 54 of file SerialWombatPin.h.

## Member Function Documentation

## ◆ digitalRead()

int SerialWombatPin::digitalRead | ( |  | ) |
| inline

Reads the state of the Pin.

This function is based on the pin's public data, not a raw reading.

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 104 of file SerialWombatPin.h.

## ◆ digitalWrite()

void SerialWombatPin::digitalWrite | ( | uint8_t | val | ) |
| inline

Set 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 92 of file SerialWombatPin.h.

## ◆ disable()

int16_t SerialWombatPin::disable | ( |  | ) |
| inline

Disables the pin mode (if applicable)

Definition at line 150 of file SerialWombatPin.h.

## ◆ enableOpenDrain()

int16_t SerialWombatPin::enableOpenDrain | ( | bool | enabled | ) |
| inline

Enables open drain mode on a pin. Implemented on SW18AB only.

Returns
  Returns a negative error code, or positive number if successful

Parameters

  enabled | Boolean indicating if open drain mode should be enabled or disabled

Definition at line 187 of file SerialWombatPin.h.

## ◆ enablePullDown()

int16_t SerialWombatPin::enablePullDown | ( | bool | enabled | ) |
| inline

Enables the weak pull down on a pin. Implemented on SW18AB only.

Returns
  Returns a negative error code, or positive number if successful

Parameters

  enabled | Boolean indicating if weak pull down should be enabled or disabled

Definition at line 177 of file SerialWombatPin.h.

## ◆ enablePullup()

int16_t SerialWombatPin::enablePullup | ( | bool | enabled | ) |
| inline

Enables the weak pull up on a pin. Implemented on SW18AB only.

Returns
  Returns a negative error code, or positive number if successful

Parameters

  enabled | Boolean indicating if weak pull up should be enabled or disabled

Definition at line 167 of file SerialWombatPin.h.

## ◆ initPacketNoResponse() [1/3]

int16_t SerialWombatPin::initPacketNoResponse | ( | uint8_t | packetNumber,
|  | uint16_t | param0,
|  | uint16_t | param1,
|  | uint8_t | param2 = 0x55 )
| inline

Definition at line 142 of file SerialWombatPin.h.

## ◆ initPacketNoResponse() [2/3]

int16_t SerialWombatPin::initPacketNoResponse | ( | uint8_t | packetNumber,
|  | uint16_t | param0 = 0x55,
|  | uint8_t | param1 = 0x55,
|  | uint8_t | param2 = 0x55,
|  | uint8_t | param3 = 0x55 )
| inline

Definition at line 137 of file SerialWombatPin.h.

## ◆ initPacketNoResponse() [3/3]

int16_t SerialWombatPin::initPacketNoResponse | ( | uint8_t | packetNumber,
|  | uint8_t | param0 = 0x55,
|  | uint8_t | param1 = 0x55,
|  | uint8_t | param2 = 0x55,
|  | uint8_t | param3 = 0x55,
|  | uint8_t | param4 = 0x55 )
| inline

Definition at line 131 of file SerialWombatPin.h.

## ◆ pin()

uint8_t SerialWombatPin::pin | ( |  | ) |
| inline

Returns the current SW pin number. Used primarily for virtual calls by derived classes.

Returns
  Returns the current SW pin number.

Definition at line 121 of file SerialWombatPin.h.

## ◆ pinMode()

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

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

Parameters

  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 79 of file SerialWombatPin.h.

## ◆ readPublicData()

uint16_t SerialWombatPin::readPublicData | ( |  | ) |
| inline

Read the 16 Bit public data associated with this pin.

Reads and returns the 16 bit value associated with this pin.

Returns
  16 bit public data for this pin.

Definition at line 65 of file SerialWombatPin.h.

## ◆ swPinModeNumber()

uint8_t SerialWombatPin::swPinModeNumber | ( |  | ) |
| inline

Returns the Mode number. Used primarily by derived classes to populate packet data.

Returns
  Returns the pin mode number

Definition at line 127 of file SerialWombatPin.h.

## ◆ writePublicData()

uint16_t SerialWombatPin::writePublicData | ( | uint16_t | value | ) |
| inline

Write a 16 bit value to this pin.

Parameters

  value | The 16 bit value to write

Definition at line 114 of file SerialWombatPin.h.

## Member Data Documentation

## ◆ _pin

uint8_t SerialWombatPin::_pin = 255
| protected

Definition at line 193 of file SerialWombatPin.h.

## ◆ _pinMode

uint8_t SerialWombatPin::_pinMode = 0
| protected

Definition at line 195 of file SerialWombatPin.h.

## ◆ _sw

SerialWombatChip& SerialWombatPin::_sw
| protected

Definition at line 194 of file SerialWombatPin.h.