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 and SW8B only.
int16_t | enablePulldown (bool enabled)
| Enables the weak pull down on a pin. Implemented on SW18AB and SW8B only.
int16_t | enableOpenDrain (bool enabled)
| Enables open drain mode on a pin. Implemented on SW18AB and SW8B only.
int16_t | forceDMA (bool enabled)
| Forces use of DMA instead of hardware timing resources on SW18AB.
void | setPinNumberForTesting (uint8_t pin)
| A function designed for testing only. May have unpredictable results if used in real time. Not intended for general use.

## 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 103 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

  val | Valid values are HIGH or LOW, as defined by arduino. do not use SW_INPUT, SW_HIGH or SW_LOW here, as these have different meanings

Definition at line 91 of file SerialWombatPin.h.

## ◆ disable()

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

Disables the pin mode (if applicable)

Definition at line 149 of file SerialWombatPin.h.

## ◆ enableOpenDrain()

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

Enables open drain mode on a pin. Implemented on SW18AB and SW8B 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 186 of file SerialWombatPin.h.

## ◆ enablePulldown()

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

Enables the weak pull down on a pin. Implemented on SW18AB and SW8B 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 176 of file SerialWombatPin.h.

## ◆ enablePullup()

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

Enables the weak pull up on a pin. Implemented on SW18AB and SW8B 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 166 of file SerialWombatPin.h.

## ◆ forceDMA()

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

Forces use of DMA instead of hardware timing resources on SW18AB.

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

Parameters

  enabled | Boolean indicating if DMA forcing should be enabled or disabled

Definition at line 197 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 141 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 136 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 130 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 120 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.

## ◆ setPinNumberForTesting()

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

A function designed for testing only. May have unpredictable results if used in real time. Not intended for general use.

Definition at line 207 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 126 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 113 of file SerialWombatPin.h.

## Member Data Documentation

## ◆ _pin

uint8_t SerialWombatPin::_pin = 255
| protected

Definition at line 213 of file SerialWombatPin.h.

## ◆ _pinMode

uint8_t SerialWombatPin::_pinMode = 0
| protected

Definition at line 215 of file SerialWombatPin.h.

## ◆ _sw

SerialWombatChip& SerialWombatPin::_sw
| protected

Definition at line 214 of file SerialWombatPin.h.