Fork to see if I can get working

Dependencies:   BufferedSerial OneWire WinbondSPIFlash libxDot-dev-mbed5-deprecated

Fork of xDotBridge_update_test20180823 by Matt Briggs

Embed: (wiki syntax)

« Back to documentation index

BaseboardIO Class Reference

BaseboardIO Class Reference

This class abstracts utilizing the IO mostly found on the baseboard this includes IO which is implemented via portExpanders. More...

#include <BaseboardIO.h>

Public Member Functions

 BaseboardIO ()
 BaseboardIO constructor.
CmdResult init ()
 Initialize IO to current values.
void regCCInInt (Callback< void()> func)
 Register for contact closure interrupt.
void regTamperInt (Callback< void()> func)
 Register for tamper interrupt.
void regPairBtnInt (Callback< void()> func)
 Register for pair button interrupt.
CmdResult sampleUserSwitches ()
 samples current IO including port expanders
bool isPairBtn ()
 Returns the current state of the pair button.
bool isCCNO ()
 Returns the current state of the NO/NC switch.
bool isCCNC ()
 Returns the current state of the NO/NC switch.
bool isRx ()
 Returns the current state of the Rx/Tx switch.
bool isTx ()
 Returns the current state of the Rx/Tx switch.
bool isLoRaWANMode ()
 Returns the current state of the LoRaWAN switch.
bool isSerialEnabled ()
 Returns the current state of the serial switch.
uint8_t rotarySwitch1 ()
 Returns value of a rotary switch (TODO give board location)
uint8_t rotarySwitch2 ()
 Returns value of a rotary switch (TODO give board location)
CmdResult ledOn ()
 Turns LED on.
CmdResult ledOff ()
 Turns LED off.
CmdResult relayAlert ()
 Changes state of relay to alert.
CmdResult relayNormal ()
 Changes state of relay to normal.
CmdResult serialRx (bool enable)
 Enables/disables serial chip.
CmdResult serialTx (bool enable)
 Controls serial chip transmission.

Detailed Description

This class abstracts utilizing the IO mostly found on the baseboard this includes IO which is implemented via portExpanders.

This API currently does not implement interfaces for communications like UART or for memory like flash devices.

Definition at line 56 of file BaseboardIO.h.


Constructor & Destructor Documentation

BaseboardIO (  )

BaseboardIO constructor.

Note for interrupt within uC cannot use two pins with the same numeric suffix (e.g.

Just initialized internal variables does not configure devices. Should call init before other functions are called.

On Entry:

On Exit: Internal variables are set to a known state but futher initialziation is required

Returns:

cannot use both PA_0 and PB_0). Note 1, 6, 7, 8, and 13 are used by LoRa radio.

Definition at line 46 of file BaseboardIO.cpp.


Member Function Documentation

CmdResult init (  )

Initialize IO to current values.

Initialize IO to current state and ensure that class variables are updated to latest values. The following are initialized. 1. PortExpanders are setup are read 2. Relay is forced to known state 3. Interrupts are setup

On Entry:

On Exit: Either IO is configured or an error is returned

Returns:
CmdResult

Definition at line 98 of file BaseboardIO.h.

bool isCCNC (  )

Returns the current state of the NO/NC switch.

This just simply uses the last sample of the IO to return a bool. If the switch is in asserted position that the devices is normally closed (NC) therefore true is returned. Otherwise device is normally open (NO) and therefore returns false.

On Entry: IO should be sampled recently

On Exit:

Returns:
bool

Definition at line 224 of file BaseboardIO.h.

bool isCCNO (  )

Returns the current state of the NO/NC switch.

This just simply uses the last sample of the IO to return a bool. If the switch is in asserted position that the devices is normally closed (NC) therefore false is returned. Otherwise device is normally open (NO) and therefore returns true.

On Entry: IO should be sampled recently

On Exit:

Returns:
bool

Definition at line 207 of file BaseboardIO.cpp.

bool isLoRaWANMode (  )

Returns the current state of the LoRaWAN switch.

This just simply uses the last sample of the IO to return a bool. If the switch is in asserted position that the device is will report via LoRaWAN otherwise the device will use peer-to-peer mode.

On Entry: IO should be sampled recently

On Exit:

Returns:
bool

Definition at line 237 of file BaseboardIO.cpp.

bool isPairBtn (  )

Returns the current state of the pair button.

This just simply uses the last sample of the IO to return a bool. If the button is depressed than true is returned other wise false

On Entry: IO should be sampled recently

On Exit:

Returns:
bool

Definition at line 202 of file BaseboardIO.cpp.

bool isRx (  )

Returns the current state of the Rx/Tx switch.

This just simply uses the last sample of the IO to return a bool. If the switch is in asserted position that the devices is transmitter (Tx) therefore false is returned. Otherwise device is a receiver(Rx) and therefore returns true.

On Entry: IO should be sampled recently

On Exit:

Returns:
bool

Definition at line 222 of file BaseboardIO.cpp.

bool isSerialEnabled (  )

Returns the current state of the serial switch.

This just simply uses the last sample of the IO to return a bool. If enabled then the serial chip will be listening for traffic at least in the case of a TX.

On Entry: IO should be sampled recently

On Exit:

Returns:
bool

Definition at line 242 of file BaseboardIO.cpp.

bool isTx (  )

Returns the current state of the Rx/Tx switch.

This just simply uses the last sample of the IO to return a bool. If the switch is in asserted position that the devices is transmitter (Tx) therefore true is returned. Otherwise device is a receiver(Rx) and therefore returns false.

On Entry: IO should be sampled recently

On Exit:

Returns:
bool

Definition at line 262 of file BaseboardIO.h.

CmdResult ledOff (  )

Turns LED off.

Returns:
CmdResult

Definition at line 306 of file BaseboardIO.cpp.

CmdResult ledOn (  )

Turns LED on.

Returns:
CmdResult

Definition at line 298 of file BaseboardIO.cpp.

void regCCInInt ( Callback< void()>  func )

Register for contact closure interrupt.

Pass function pointer which will be called when interrupt occurs.

On Entry:

On Exit: Callback registered

Returns:

Definition at line 144 of file BaseboardIO.cpp.

void regPairBtnInt ( Callback< void()>  func )

Register for pair button interrupt.

Pass function pointer which will be called when interrupt occurs. Note there is a hardware switch which can prevent the tamper sensor from pulling the line down. If this switch deasserted there is no way in software to reconfigure this.

On Entry:

On Exit: Callback registered

Returns:

Definition at line 164 of file BaseboardIO.cpp.

void regTamperInt ( Callback< void()>  func )

Register for tamper interrupt.

Pass function pointer which will be called when interrupt occurs.

On Entry:

On Exit: Callback registered

Returns:

Definition at line 156 of file BaseboardIO.cpp.

CmdResult relayAlert (  )

Changes state of relay to alert.

If the configured as normally open then the relay closes and vice versa for normally closed.

Returns:
CmdResult

Definition at line 315 of file BaseboardIO.cpp.

CmdResult relayNormal (  )

Changes state of relay to normal.

If the configured as normally open then the relay opens and vice versa for normally closed.

Returns:
CmdResult

Definition at line 324 of file BaseboardIO.cpp.

uint8_t rotarySwitch1 (  )

Returns value of a rotary switch (TODO give board location)

On Entry: IO should be sampled recently

On Exit:

Returns:
uint8_t

Definition at line 247 of file BaseboardIO.cpp.

uint8_t rotarySwitch2 (  )

Returns value of a rotary switch (TODO give board location)

On Entry: IO should be sampled recently

On Exit:

Returns:
uint8_t

Definition at line 282 of file BaseboardIO.cpp.

CmdResult sampleUserSwitches (  )

samples current IO including port expanders

Samples values and stores them so that IO accessors can execute quicker.

Future: Add some detail about how robust the values displayed here are. It might be a good idea to add a timestamp for this IO

On Entry:

On Exit: Internal class variables are updated or error is returned.

Returns:
CmdResult

Definition at line 173 of file BaseboardIO.cpp.

CmdResult serialRx ( bool  enable )

Enables/disables serial chip.

This controls IO to ON/~OFF pin of RS232 chip. If transmitting ensure serialTx is called as well.

Returns:
CmdResult

Definition at line 335 of file BaseboardIO.cpp.

CmdResult serialTx ( bool  enable )

Controls serial chip transmission.

This controls IO to Tx_DIS pin of RS232 chip. Note calling this function will also enable serialRx.

Returns:
CmdResult

Definition at line 358 of file BaseboardIO.cpp.