SPI-Brigde (capseld), for polling interrupt, it is neccessary to adapt the constructor and the function getInt()

Revision:
2:cb90c271c412
Parent:
1:2a7edc2be6df
Child:
3:9cf83f16c17d
--- a/SC18IS602.h	Fri Feb 01 15:46:53 2019 +0000
+++ b/SC18IS602.h	Mon Feb 18 16:03:44 2019 +0000
@@ -9,27 +9,32 @@
 class SC18IS602
 {
     public:    
-    
-        static const int BUFFER_SIZE       = 200;// Byte
-        static const bool ACK              = false;
-        static const bool NACK             = true;
-        static const bool INTERRUPT        = false;
         
+        static const int BUFFER_SIZE        = 200;// Byte
+        static const bool ACK               = true;
+        static const bool NACK              = false;
+        static const bool INTERRUPT         = false;
+        static const bool WAIT_SEC          = 10e-6;
         
         // Register Adress
-        static const int HARD_ADR          = 0x50;
-        static const int USER_ADR_MASK     = 0x07;
+        static const int HARD_ADR           = 0x50;
+        static const int USER_ADR_MASK      = 0x07;
         
-        static const int CMD_RW_CS0        = 0x01;
-        static const int CMD_RW_CS1        = 0x02;
-        static const int CMD_RW_CS2        = 0x04;
-        static const int CMD_RW_CS3        = 0x08;
+        struct{
+            static const int CS0            = 0x01;
+            static const int CS1            = 0x02;
+            static const int CS2            = 0x04;
+            static const int CS3            = 0x08;
+        }CMD_RW;
         
-        static const int ADR_SPI_CONF      = 0xF0;
-        static const int ADR_GPIO_WRITE    = 0xF4;
-        static const int ADR_GPIO_READ     = 0xF5;
-        static const int ADR_GPIO_EN       = 0xF6;
-        static const int ADR_GPIO_CONF     = 0xF7;
+        static const int ADR_SPI_CONF       = 0xF0;
+        
+        struct{
+            static const int WRITE          = 0xF4;
+            static const int READ           = 0xF5;
+            static const int EN             = 0xF6;
+            static const int CONF           = 0xF7;
+        }ADR_GPIO;
         
         
         //Bit position of register Configure SPI Interface
@@ -38,8 +43,11 @@
         static const int SPI_CLK_RATE       = 0;
         
         // Register Value SPI bit order
-        static const int SPI_BIT_ORDER_MSB  = 0;                                // MSB of the data word is transmitted first
-        static const int SPI_BIT_ORDER_LSB  = 1;                                // LSB of the data word is transmitted first
+        struct{
+            static const int MSB            = 0;                                // MSB of the data word is transmitted first
+            static const int LSB            = 1;                                // LSB of the data word is transmitted first
+        }SPI_BITORDER;
+        
         
         // Register Value SPI Mode (CPOL, CPHA)
         static const int SPI_MODE_00       = 0;
@@ -56,10 +64,12 @@
         
                 
         // Bist position of Register GPIO Enable
-        static const int GPIO_CS0          = 0;
-        static const int GPIO_CS1          = 1;
-        static const int GPIO_CS2          = 2;
-        static const int GPIO_CS3          = 3;
+        struct{
+            static const int CS0          = 0;
+            static const int CS1          = 1;
+            static const int CS2          = 2;
+            static const int CS3          = 3;
+        }GPIO;
         
         
         
@@ -89,8 +99,8 @@
         bool enableGPIO(uint8_t uiConf);
         bool configGPIO(uint8_t uiConf);
 
-        bool GPIO_pin3_on();
-        bool GPIO_pin3_off();
+        bool gpio_pin3_on();
+        bool gpio_pin3_off();
         bool gpio_toggle(uint8_t uiPort);
         
         bool sendViaSPI(char cAdrByte, char *cDataBytes, uint8_t uiNum);
@@ -99,7 +109,7 @@
     
         //void setIntFuncPtr( bool (*Int_ptr)(void));
     
-    private:                                                                    // private
+    protected:                                                                    // private
         I2C *i2c;                                                               // Serial Data & Clock
         PCA9555 *pca;
         DigitalIn *IntPin;                                                      // Interrupt pin
@@ -107,11 +117,13 @@
         
         bool sendViaI2C(const char *cData, int iLength, string sDebug = "");
         bool readViaI2C(char *cData, int iLength, string sDebug = "");
+        void waitFor(bool bInt);
+        
         
         bool getInt();
         bool clearInt();
         
-        bool (*getInt_ptr)(void);
+        //bool (*getInt_ptr)(void);
         
         
         // variable
@@ -125,6 +137,8 @@
         
         char cDebug[100];
         
+        int iTimeOut;
+        
 };