FastArduino v1.10
C++ library to build fast but small Arduino/AVR projects
|
Supporting class for the Wiegand 26 bits protocol (used by many access control devices). More...
#include <fastarduino/devices/wiegand.h>
Public Types | |
using | DATA_TYPE = uint32_t |
The data type used to return data read from the access control device. More... | |
Public Member Functions | |
Wiegand () | |
Construct a new Wiegand instance to be sued by an access control device. More... | |
void | reset () |
Reset current read state of this instance. More... | |
void | reset_ () |
Reset current read state of this instance. More... | |
bool | available_ () const |
Check if data is available, i.e. More... | |
bool | valid_ () const |
Check if current data is valid, i.e. More... | |
DATA_TYPE | get_data_ () const |
Get data read from access control device. More... | |
void | on_falling_data0 () |
Your device shall call this method whenever DATA0 line level is falling to 0 , which means a 0 bit must be added to read data. More... | |
void | on_falling_data1 () |
Your device shall call this method whenever DATA1 line level is falling to 0 , which means a 1 bit must be added to read data. More... | |
Static Public Attributes | |
static constexpr uint8_t | DATA_BITS = 24 |
The actual number of bits of data in DATA_TYPE . More... | |
Supporting class for the Wiegand 26 bits protocol (used by many access control devices).
To use Wiegand class, you just need to instantiate it in your own device class, ensure you call on_falling_data0()
and on_falling_data1()
when you detect (ISR preferred) that line DATA0 or DATA1 is falling to 0V.
Other API methods allow you to know the state of reading (finished, parity valid), get the read data (if available and valid) and reset the reading.
using devices::protocols::Wiegand::DATA_TYPE = uint32_t |
|
inline |
|
inline |
Reset current read state of this instance.
Any bits read will be lost. You should call this method after having read latest data with get_data_()
.
This method is synchronized, hence you can call it from an an interrupt-unsafe context; if you are sure you are in an interrupt-safe, you should use the not synchronized flavor reset_()
instead.
|
inline |
Reset current read state of this instance.
Any bits read will be lost. You should call this method after having read latest data with get_data_()
.
This method is not synchronized, hence you must ensure it is called from an interrupt-safe context; otherwise, you should use the synchronized flavor reset_()
instead.
|
inline |
Check if data is available, i.e.
all 26 bits have been received already.
valid_()
.This method is not synchronized, hence you must ensure it is called from an interrupt-safe context.
|
inline |
Check if current data is valid, i.e.
parity has been checked against both even and odd parity bits (as per Wiegand 26 bits standard).
available_()
.This method is not synchronized, hence you must ensure it is called from an interrupt-safe context.
|
inline |
Get data read from access control device.
available_()
and valid_()
before calling get_data_()
.This method is not synchronized, hence you must ensure it is called from an interrupt-safe context.
|
inline |
Your device shall call this method whenever DATA0 line level is falling to 0
, which means a 0
bit must be added to read data.
It is expected to work with interrupts (EXT or PCI) for connecting the access control device DATA0 and DATA1 pins.
|
inline |
Your device shall call this method whenever DATA1 line level is falling to 0
, which means a 1
bit must be added to read data.
It is expected to work with interrupts (EXT or PCI) for connecting the access control device DATA0 and DATA1 pins.
|
staticconstexpr |