source: rtos_arduino/trunk/arduino_lib/hardware/arduino/samd/cores/validation/validation_usb_host/test_usb_host.cpp@ 136

Last change on this file since 136 was 136, checked in by ertl-honda, 8 years ago

ライブラリとOS及びベーシックなサンプルの追加.

File size: 1.2 KB
Line 
1#include "variant.h"
2#include <stdio.h>
3#include <adk.h>
4
5// Accessory descriptor. It's how Arduino identifies itself to Android.
6char applicationName[] = "Arduino_Terminal"; // the app on your phone
7char accessoryName[] = "Arduino Due X"; // your Arduino board
8char companyName[] = "Arduino SA";
9
10// Make up anything you want for these
11char versionNumber[] = "1.0";
12char serialNumber[] = "1";
13char url[] = "http://labs.arduino.cc/uploads/ADK/ArduinoTerminal/ThibaultTerminal_ICS_0001.apk";
14
15USBHost Usb;
16ADK adk(&Usb, companyName, applicationName, accessoryName,versionNumber,url,serialNumber);
17
18void setup()
19{
20 cpu_irq_enable();
21 printf("\r\nADK demo start\r\n");
22 delay(200);
23}
24
25#define RCVSIZE 128
26
27void 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.