Rev | Line | |
---|
[136] | 1 | #include "variant.h"
|
---|
| 2 | #include <stdio.h>
|
---|
| 3 | #include <adk.h>
|
---|
| 4 |
|
---|
| 5 | // Accessory descriptor. It's how Arduino identifies itself to Android.
|
---|
| 6 | char applicationName[] = "Arduino_Terminal"; // the app on your phone
|
---|
| 7 | char accessoryName[] = "Arduino Due X"; // your Arduino board
|
---|
| 8 | char companyName[] = "Arduino SA";
|
---|
| 9 |
|
---|
| 10 | // Make up anything you want for these
|
---|
| 11 | char versionNumber[] = "1.0";
|
---|
| 12 | char serialNumber[] = "1";
|
---|
| 13 | char url[] = "http://labs.arduino.cc/uploads/ADK/ArduinoTerminal/ThibaultTerminal_ICS_0001.apk";
|
---|
| 14 |
|
---|
| 15 | USBHost Usb;
|
---|
| 16 | ADK adk(&Usb, companyName, applicationName, accessoryName,versionNumber,url,serialNumber);
|
---|
| 17 |
|
---|
| 18 | void setup()
|
---|
| 19 | {
|
---|
| 20 | cpu_irq_enable();
|
---|
| 21 | printf("\r\nADK demo start\r\n");
|
---|
| 22 | delay(200);
|
---|
| 23 | }
|
---|
| 24 |
|
---|
| 25 | #define RCVSIZE 128
|
---|
| 26 |
|
---|
| 27 | void loop()
|
---|
| 28 | {
|
---|
| 29 | uint8_t buf[RCVSIZE];
|
---|
| 30 | uint32_t nbread = 0;
|
---|
| 31 | char helloworld[] = "Hello World!\r\n";
|
---|
| 32 |
|
---|
| 33 | Usb.Task();
|
---|
| 34 |
|
---|
| 35 | if (adk.isReady())
|
---|
| 36 | {
|
---|
| 37 | /* Write hello string to ADK */
|
---|
| 38 | adk.write(strlen(helloworld), (uint8_t *)helloworld);
|
---|
| 39 |
|
---|
| 40 | delay(1000);
|
---|
| 41 |
|
---|
| 42 | /* Read data from ADK and print to UART */
|
---|
| 43 | adk.read(&nbread, RCVSIZE, buf);
|
---|
| 44 | if (nbread > 0)
|
---|
| 45 | {
|
---|
| 46 | printf("RCV: ");
|
---|
| 47 | for (uint32_t i = 0; i < nbread; ++i)
|
---|
| 48 | {
|
---|
| 49 | printf("%c", (char)buf[i]);
|
---|
| 50 | }
|
---|
| 51 | printf("\r\n");
|
---|
| 52 | }
|
---|
| 53 | }
|
---|
| 54 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.