#include <MockIoAbstraction.h>
Public Member Functions | |
MockedIoAbstraction (int numberOfCycles=6) | |
void | resetIo () |
void | pinDirection (pinid_t pin, uint8_t mode) override |
void | writeValue (pinid_t pin, uint8_t value) override |
uint8_t | readValue (pinid_t pin) override |
void | attachInterrupt (pinid_t pin, RawIntHandler interruptHandler, uint8_t mode) override |
bool | runLoop () override |
void | writePort (pinid_t pin, uint8_t portVal) override |
virtual uint8_t | readPort (pinid_t pin) |
int | getNumberOfRunLoops () |
uint16_t | getWrittenValuesForRunLoop (int runLoop) |
void | setValueForReading (int runLoopNo, uint16_t val) |
uint16_t | getWrittenValue (int runLoopNo) |
MockIoError | getErrorMode () |
void | clearError () |
RawIntHandler | getInterruptFunction () |
bool | isIntRegisteredAs (uint8_t pin, uint8_t mode) |
Public Member Functions inherited from BasicIoAbstraction | |
uint8_t | digitalRead (pinid_t p) |
void | digitalWrite (pinid_t p, uint8_t v) |
uint8_t | digitalReadS (pinid_t p) |
void | digitalWriteS (pinid_t p, uint8_t v) |
void | writePortS (pinid_t p, uint8_t v) |
uint8_t | readPortS (pinid_t p) |
void | pinMode (pinid_t pin, uint8_t mode) |
bool | sync () |
This class implements the IoAbstraction interface but does not do anything other than record the pinMode and write calls, it also allows the read values to be set upfront. There are up to 16 pins in this abstraction and each run loop cycles to another buffer. In the constructor you can set the number of storage slots (the point they will cycle back to slot 0).
It is very useful when trying to work with IoAbstraction in unit tests.
|
inline |
Resets this abstraction back to its initial state, ready for the next test.
|
inlineoverridevirtual |
sets the pin direction for a pin controlled by this abstraction - as per pinMode
pin | the pin to be changed |
mode | the new mode, as per pinMode (or on Mbed you can use PinMode enum values) |
Reimplemented from BasicIoAbstraction.
|
inlineoverridevirtual |
Writes a value to a pin on this abstraction, as per digitalWrite
. For serial devices, may need a sync first.
pin | the pin to be written to |
value | the new value such as HIGH / LOW |
Reimplemented from BasicIoAbstraction.
|
inlineoverridevirtual |
Reads a value from a pin for this abstraction as per digitalRead
. For serial devices may need a sync first.
pin | the pin to be read |
Reimplemented from BasicIoAbstraction.
|
inlineoverridevirtual |
Overrides the usual interrupt handler to just record the details of the interrupt requested
Reimplemented from BasicIoAbstraction.
|
inlineoverridevirtual |
This method is not needed on Arduino pins, but for most serial implementations it causes the device and abstraction to be synced. Returns true if the write call worked, normally true, false indicates error
Reimplemented from BasicIoAbstraction.
|
inlineoverridevirtual |
Writes out a whole port at once, on Arduino pins this is achieved by providing any pin within that port. On Arduino pins you should take care not to use ports that are providing core functions.
pin | the pin determines the hardware port to use. |
portVal | the 8 bit value to write to the port. Use with care. |
Reimplemented from BasicIoAbstraction.
|
inlinevirtual |
Reads a whole port at once, on Arduino pins this is achieved by providing any pin within that port. On Arduino pins you should take care not to use ports that are providing core functions.
pin | the pin determines the hardware port to use. |
Reimplemented from BasicIoAbstraction.
|
inline |
get the number of run loops that have been performed
|
inline |
get the data that's been written in a given run loop
|
inline |
set the value that will be used to return during read functions
|
inline |
get the value that was written using the write functions
|
inline |
get any error in usage of the class
|
inline |
clear down the error state
|
inline |
get the interrupt function registered using the attachInterrupt call
|
inline |
check if the registered interrupt pin and mode are right