Skip to content

Commit f029a06

Browse files
committed
moved the ISR for new data logic into the underlying interface comm object - in prep for enabling SPI - which needs the same logic as I2C; Also added logic for ESP32 and RP2* boards so the IRS callback takes a paramter -- which will enable the use of multiple devices - if needed
1 parent 625f6bf commit f029a06

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

src/sfTk/sfDevFPC2534IComm.h

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,28 @@
1818
class sfDevFPC2534IComm
1919
{
2020
public:
21+
sfDevFPC2534IComm() : _dataAvailable{false}, _usingISRParam{true} {};
2122
virtual bool dataAvailable(void) = 0;
2223
virtual void clearData(void) = 0;
2324
virtual uint16_t write(const uint8_t *data, size_t len) = 0;
2425
virtual uint16_t read(uint8_t *data, size_t len) = 0;
25-
};
26+
// On SPI writes, the CS line needs to remain low during writes (which have multiple blocks).
27+
// So add a normally no-op beginWrite and endWrite methods that can be overridden by SPI comm classes.
28+
virtual void beginWrite(void) {};
29+
virtual void endWrite(void) {};
30+
void setISRDataAvailable(void);
31+
32+
protected:
33+
// All communication protocols/types supported by the sensor use an interrupt to signal data availability.
34+
// This is required for i2c and SPI interfaces (UART is okay b/c of Arduino Serial buffer handling). So
35+
// we consolidate the core interrupt handling in this case. If needed, comm type specializations can use this.
36+
void initISRHandler(uint32_t interruptPin);
37+
bool isISRDataAvailable(void);
38+
39+
void clearISRDataAvailable(void);
40+
41+
private:
42+
volatile bool _dataAvailable;
43+
bool _usingISRParam;
44+
};
45+

0 commit comments

Comments
 (0)