#include <SPI.h> #include <Wire.h> #include <SC16IS750.h> #include <string.h> SC16IS750 spiuart = SC16IS750(SC16IS750_PROTOCOL_SPI,6); //Pin 6 should be connected to CS of the module. #define GPIO 7 void setup() { Serial.begin(115200); Serial.println("Start testing"); // UART to Serial Bridge Initialization spiuart.begin(9600); //baudrate setting Serial.println("BAUDRATE SET"); if (spiuart.ping()!=1) { Serial.println("Device not found"); while(1); } else { Serial.println("Device found"); } Serial.println("Start serial communication"); spiuart.pinMode(GPIO, OUTPUT); } void loop() { spiuart.digitalWrite(GPIO, HIGH); delay(1000); spiuart.digitalWrite(GPIO, LOW); delay(1000); } |
#include <SPI.h> #include <Wire.h> #include <SC16IS750.h> #include <string.h> SC16IS750 spiuart = SC16IS750(SC16IS750_PROTOCOL_SPI,6); //Pin 6 should be connected to CS of the module. #define GPIO0 0 #define GPIO1 1 #define GPIO2 2 #define GPIO3 3 void setup() { Serial.begin(115200); Serial.println("Start testing"); // UART to Serial Bridge Initialization spiuart.begin(9600); //baudrate setting Serial.println("BAUDRATE SET"); if (spiuart.ping()!=1) { Serial.println("Device not found"); while(1); } else { Serial.println("Device found"); } Serial.println("Start serial communication"); spiuart.pinMode(GPIO0, INPUT); spiuart.pinMode(GPIO1, INPUT); spiuart.pinMode(GPIO2, INPUT); spiuart.pinMode(GPIO3, INPUT); } void loop() { uint8_t value = spiuart.GPIOGetPortState(); Serial.print("value = "); Serial.println(value,HEX); if ( (value & 0x01) == 0x01) Serial.println("GPIO0 ON"); if ( (value & 0x02) == 0x02) Serial.println("GPIO1 ON"); if ( (value & 0x04) == 0x04) Serial.println("GPIO2 ON"); if ( (value & 0x08) == 0x08) Serial.println("GPIO3 ON"); delay(1000); } |