]> git.gir.st - tmk_keyboard.git/blob - protocol/usb_hid/USB_Host_Shield_2.0/examples/adk/term_test/term_test.ino
Squashed 'tmk_core/' changes from caca2c0..dc0e46e
[tmk_keyboard.git] / protocol / usb_hid / USB_Host_Shield_2.0 / examples / adk / term_test / term_test.ino
1 #include <adk.h>
2 #include <usbhub.h>
3
4 // Satisfy IDE, which only needs to see the include statment in the ino.
5 #ifdef dobogusinclude
6 #include <spi4teensy3.h>
7 #include <SPI.h>
8 #endif
9
10 USB Usb;
11 //USBHub Hub(&Usb);
12
13 ADK adk(&Usb,"Circuits@Home, ltd.",
14 "USB Host Shield",
15 "Arduino Terminal for Android",
16 "1.0",
17 "http://www.circuitsathome.com",
18 "0000000000000001");
19
20 void setup()
21 {
22 Serial.begin(115200);
23 #if !defined(__MIPSEL__)
24 while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection
25 #endif
26 Serial.println("\r\nADK demo start");
27
28 if (Usb.Init() == -1) {
29 Serial.println("OSCOKIRQ failed to assert");
30 while(1); //halt
31 }//if (Usb.Init() == -1...
32 }
33
34 void loop()
35 {
36 uint8_t rcode;
37 uint8_t msg[64] = { 0x00 };
38 const char* recv = "Received: ";
39
40 Usb.Task();
41
42 if( adk.isReady() == false ) {
43 return;
44 }
45 uint16_t len = 64;
46
47 rcode = adk.RcvData(&len, msg);
48 if( rcode & ( rcode != hrNAK )) {
49 USBTRACE2("Data rcv. :", rcode );
50 }
51 if(len > 0) {
52 USBTRACE("\r\nData Packet.");
53
54 for( uint8_t i = 0; i < len; i++ ) {
55 Serial.print((char)msg[i]);
56 }
57 /* sending back what was received */
58 rcode = adk.SndData( strlen( recv ), (uint8_t *)recv );
59 rcode = adk.SndData( strlen(( char * )msg ), msg );
60
61 }//if( len > 0 )...
62
63 delay( 1000 );
64 }
65
Imprint / Impressum