#if !defined(_SPI2Slave_T4_H_) #define _SPI2Slave_T4_H_ #include #include #include typedef enum SPI_BITS { SPI_8_BITS = 8, SPI_16_BITS = 16, SPI_32_BITS = 32, } SPI_BITS; typedef void (*_SPI_ptr)(); #define SPI2Slave_T4_CLASS template #define SPI2Slave_T4_FUNC template #define SPI2Slave_T4_OPT SPI2Slave_T4 extern SPIClass SPI; class SPI2Slave_T4_Base { public: virtual void SLAVE_ISR(); }; static SPI2Slave_T4_Base* _LPSPI1 = nullptr; SPI2Slave_T4_CLASS class SPI2Slave_T4 : public SPI2Slave_T4_Base { public: SPI2Slave_T4(); void begin(); uint32_t transmitErrors(); void onReceive(_SPI_ptr handler) { _spihandler = handler; } bool active(); bool available(); void pushr(uint32_t data); uint32_t popr(); private: _SPI_ptr _spihandler = nullptr; void SLAVE_ISR(); int _portnum = 0; uint32_t nvic_irq = 0; uint32_t transmit_errors = 0; }; #include "SPI2Slave_T4.tpp" #endif