SparkFun Fingerprint Sensor - FPC2534 Pro  v0.9.9-3-g5d0d172
Library for the SparkFun Fingerprint Sensor - FPC2534 Pro
Loading...
Searching...
No Matches
sfDevFPC2534IComm.h
Go to the documentation of this file.
1/*
2 *---------------------------------------------------------------------------------
3 *
4 * Copyright (c) 2025, SparkFun Electronics Inc.
5 *
6 * SPDX-License-Identifier: MIT
7 *
8 *---------------------------------------------------------------------------------
9 */
10
11#pragma once
12
13#include <stddef.h>
14#include <stdint.h>
15
16// Define the communication interface for the FPC2534 fingerprint sensor library
17
19{
20 public:
21 sfDevFPC2534IComm() : _dataAvailable{false}, _usingISRParam{true} {};
22 virtual bool dataAvailable(void) = 0;
23 virtual void clearData(void) = 0;
24 virtual uint16_t write(const uint8_t *data, size_t len) = 0;
25 virtual uint16_t read(uint8_t *data, size_t len) = 0;
26
27 // On SPI writes, the CS line needs to remain low during writes (which have multiple blocks).
28 // So add a normally no-op beginWrite and endWrite methods that can be overridden by SPI comm classes.
29 virtual void beginWrite(void) {};
30 virtual void endWrite(void) {};
31
32 // For SPI read, multiple reads for the same transaction need to be bracketed with the Arduino transaction
33 // calls and the CS pin needs to remain low. So again, we add normally no-op beginRead and endRead methods
34 // that can be overridden by SPI comm classes. This keeps the main library code clean and simple.
35 virtual void beginRead(void) {};
36 virtual void endRead(void) {};
37
38 // public method -- for the ISR handler to set the data available flag for the specific object
39 // representing the IRS callback parameter.
40 void setISRDataAvailable(void);
41
42 protected:
43 // All communication protocols/types supported by the sensor use an interrupt to signal data availability.
44 // This is required for i2c and SPI interfaces (UART is okay b/c of Arduino Serial buffer handling). So
45 // we consolidate the core interrupt handling in this case. If needed, comm type specializations can use this.
46 void initISRHandler(uint32_t interruptPin);
47 bool isISRDataAvailable(void);
48
49 void clearISRDataAvailable(void);
50
51 private:
52 volatile bool _dataAvailable;
53 bool _usingISRParam;
54};
Definition: sfDevFPC2534IComm.h:19
void clearISRDataAvailable(void)
Definition: sfDevFPC2534IComm.cpp:81
virtual void beginWrite(void)
Definition: sfDevFPC2534IComm.h:29
virtual void clearData(void)=0
virtual void endRead(void)
Definition: sfDevFPC2534IComm.h:36
virtual bool dataAvailable(void)=0
virtual void beginRead(void)
Definition: sfDevFPC2534IComm.h:35
virtual uint16_t write(const uint8_t *data, size_t len)=0
void setISRDataAvailable(void)
Definition: sfDevFPC2534IComm.cpp:75
bool isISRDataAvailable(void)
Definition: sfDevFPC2534IComm.cpp:92
virtual void endWrite(void)
Definition: sfDevFPC2534IComm.h:30
void initISRHandler(uint32_t interruptPin)
Definition: sfDevFPC2534IComm.cpp:47
virtual uint16_t read(uint8_t *data, size_t len)=0
sfDevFPC2534IComm()
Definition: sfDevFPC2534IComm.h:21