mirror of
https://github.com/esp8266/Arduino.git
synced 2025-06-22 08:22:04 +03:00
USBHost is now a library
This commit is contained in:
@ -0,0 +1,54 @@
|
||||
#include "variant.h"
|
||||
#include <stdio.h>
|
||||
#include <adk.h>
|
||||
|
||||
// Accessory descriptor. It's how Arduino identifies itself to Android.
|
||||
char applicationName[] = "Arduino_Terminal"; // the app on your phone
|
||||
char accessoryName[] = "Arduino Due X"; // your Arduino board
|
||||
char companyName[] = "Arduino SA";
|
||||
|
||||
// Make up anything you want for these
|
||||
char versionNumber[] = "1.0";
|
||||
char serialNumber[] = "1";
|
||||
char url[] = "http://labs.arduino.cc/uploads/ADK/ArduinoTerminal/ThibaultTerminal_ICS_0001.apk";
|
||||
|
||||
USBHost Usb;
|
||||
ADK adk(&Usb, companyName, applicationName, accessoryName,versionNumber,url,serialNumber);
|
||||
|
||||
void setup()
|
||||
{
|
||||
cpu_irq_enable();
|
||||
printf("\r\nADK demo start\r\n");
|
||||
delay(200);
|
||||
}
|
||||
|
||||
#define RCVSIZE 128
|
||||
|
||||
void loop()
|
||||
{
|
||||
uint8_t buf[RCVSIZE];
|
||||
uint32_t nbread = 0;
|
||||
char helloworld[] = "Hello World!\r\n";
|
||||
|
||||
Usb.Task();
|
||||
|
||||
if (adk.isReady())
|
||||
{
|
||||
/* Write hello string to ADK */
|
||||
adk.write(strlen(helloworld), (uint8_t *)helloworld);
|
||||
|
||||
delay(1000);
|
||||
|
||||
/* Read data from ADK and print to UART */
|
||||
adk.read(&nbread, RCVSIZE, buf);
|
||||
if (nbread > 0)
|
||||
{
|
||||
printf("RCV: ");
|
||||
for (uint32_t i = 0; i < nbread; ++i)
|
||||
{
|
||||
printf("%c", (char)buf[i]);
|
||||
}
|
||||
printf("\r\n");
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user