Serial Wombat Arduino Library

Loading...
Searching...
No Matches
Public Member Functions | List of all members
SerialWombatHSClock Class Reference

A Class which outputs a high speed clock signal suitable for clocking other devices. More...

`#include <SerialWombatHSClock.h>`

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

## Public Member Functions
| SerialWombatHSClock (SerialWombatChip &serialWombatChip)
| Class constructor for SerialWombatHSClock pin mode.
int32_t | begin (uint8_t pin, uint32_t frequency_Hz)
| Begin outputing a clock at a frequency on a specified pin /.
Public Member Functions inherited from SerialWombatPin
| 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.

## Additional Inherited Members
Protected Attributes inherited from SerialWombatPin
uint8_t | _pin = 255
SerialWombatChip & | _sw
uint8_t | _pinMode = 0

## Detailed Description

A Class which outputs a high speed clock signal suitable for clocking other devices.

This pin mode provides a high speed clock (in the case of the SW18AB Chip up to 32 MHZ). The number of pins that support this mode and the resolution and frequency options will vary by base microcontroller.

In the case of the SW18AB chip only one pin may be configured to this pin mode, as the mode uses the hardware Reference Clock Output, and there is only one reference clock available on the PIC24FJ256GA702. The selected pin must be an enhanced digital capability pin.

The pin mode takes a 32 bit unsigned integer and outputs that frequency (or the chip's best approximation of it).

In the case of the SW18AB chip, the output frequency is determined by a hardware clock divider that either outputs 32MHZ or 32Mhz / 2 * an integer. So 32MHz and 16MHz are possible, but 24MHz (for example) is not. The divisor can range from 1 *2 to 32767 * 2, so the minimum output frequency is 32000000 / 32767 / 2 = 488 Hz

Warning
  The SW18AB uses an internal oscillator which has an accuracy of +/- 2 percent. So the accuracy of the output frequency can vary with the accuarcy of the internal oscillator.

If assigning a new pin mode to a pin in HS Clock mode, call the disable method first.

A video Tutorial on this pin mode is available:

//TODO - Video coming soon

TODO https://youtu.be/

Definition at line 61 of file SerialWombatHSClock.h.

## Constructor & Destructor Documentation

## ◆ SerialWombatHSClock()

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

Class constructor for SerialWombatHSClock pin mode.

Parameters

  serialWombatChip | The Serial Wombat chip on which the SerialWombatLiquidCrystal pin mode will run SerialWombatHSClock(SerialWombatChip& serialWombat);

Definition at line 68 of file SerialWombatHSClock.h.

## Member Function Documentation

## ◆ begin()

int32_t SerialWombatHSClock::begin | ( | uint8_t | pin,
|  | uint32_t | frequency_Hz )
| inline

Begin outputing a clock at a frequency on a specified pin /.

/

Parameters

  pin | The pin used to output the High Speed Clock. On the Serial Wombat 18AB chip this must be an enhanced digital capability pin. /
  frequency_Hz | The frequency in Hz of the output. The hardware may not be able to exactly produce the commanded frequency /

Returns
  The frequency that is output based on the chip's hardware capabilities, or a negative number if an error occured.

Definition at line 76 of file SerialWombatHSClock.h.