2018-10-14 13:59:39 +02:00
|
|
|
/* Example of reading USB Host Shield GPI input
|
|
|
|
Author: Brian Walton (brian@riban.co.uk)
|
|
|
|
*/
|
|
|
|
#include <UHS2_gpio.h>
|
|
|
|
|
|
|
|
// Satisfy the IDE, which needs to see the include statment in the ino too.
|
|
|
|
#ifdef dobogusinclude
|
|
|
|
#include <spi4teensy3.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define INPUT_PIN 0
|
|
|
|
#define OUTPUT_PIN 0
|
|
|
|
|
2018-10-15 09:18:16 +02:00
|
|
|
USB Usb; // Create an UHS2 interface object
|
2018-10-15 10:13:30 +02:00
|
|
|
UHS2_GPIO Gpio(&Usb); // Create a GPIO object
|
2018-10-14 13:59:39 +02:00
|
|
|
|
2018-10-15 10:13:30 +02:00
|
|
|
void setup() {
|
2018-10-14 13:59:39 +02:00
|
|
|
Serial.begin( 115200 );
|
|
|
|
#if !defined(__MIPSEL__)
|
|
|
|
while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection
|
|
|
|
#endif
|
|
|
|
Serial.println("Start");
|
|
|
|
|
|
|
|
if (Usb.Init() == -1)
|
|
|
|
Serial.println("OSC did not start.");
|
|
|
|
|
|
|
|
delay( 200 );
|
|
|
|
}
|
|
|
|
|
2018-10-15 10:13:30 +02:00
|
|
|
void loop() {
|
2018-10-15 09:18:16 +02:00
|
|
|
// Get the value of input, set value of output
|
2018-10-15 10:13:30 +02:00
|
|
|
int nValue = Gpio.digitalRead(INPUT_PIN);
|
2018-10-15 09:18:16 +02:00
|
|
|
nValue = (nValue ? LOW : HIGH);
|
2018-10-15 10:13:30 +02:00
|
|
|
Gpio.digitalWrite(OUTPUT_PIN, nValue);
|
2018-10-14 13:59:39 +02:00
|
|
|
}
|
|
|
|
|