mirror of
https://github.com/arduino/Arduino.git
synced 2024-12-01 12:24:14 +01:00
Added keywords for new libraries, rearranged and modified Due and USB examples
Renamed Leonardo Only examples folder to USB. Modified keyboard and Mouse examples to indicate Due compatibility. Minor modifications to Due examples to conform with existing example sketches. Added keywords to for Audio, Scheduer, and USBHost libraries.
This commit is contained in:
parent
c97e3623a4
commit
68e5047736
@ -1,95 +0,0 @@
|
||||
/*
|
||||
Keyboard logout
|
||||
|
||||
This sketch demonstrates the Keyboard library.
|
||||
|
||||
When you connect pin 2 to ground, it performs a logout.
|
||||
It uses keyboard combinations to do this, as follows:
|
||||
|
||||
On Windows, CTRL-ALT-DEL followed by ALT-l
|
||||
On Ubuntu, CTRL-ALT-DEL, and ENTER
|
||||
On OSX, CMD-SHIFT-q
|
||||
|
||||
To wake: Spacebar.
|
||||
|
||||
Circuit:
|
||||
* Arduino Leonardo
|
||||
* wire to connect D2 to ground.
|
||||
|
||||
created 6 Mar 2012
|
||||
modified 27 Mar 2012
|
||||
by Tom Igoe
|
||||
|
||||
This example is in the public domain
|
||||
|
||||
http://www.arduino.cc/en/Tutorial/KeyboardLogout
|
||||
*/
|
||||
|
||||
#define OSX 0
|
||||
#define WINDOWS 1
|
||||
#define UBUNTU 2
|
||||
|
||||
// change this to match your platform:
|
||||
int platform = OSX;
|
||||
|
||||
void setup() {
|
||||
// make pin 2 an input and turn on the
|
||||
// pullup resistor so it goes high unless
|
||||
// connected to ground:
|
||||
pinMode(2, INPUT_PULLUP);
|
||||
Keyboard.begin();
|
||||
}
|
||||
|
||||
void loop() {
|
||||
while (digitalRead(2) == HIGH) {
|
||||
// do nothing until pin 2 goes low
|
||||
delay(500);
|
||||
}
|
||||
delay(1000);
|
||||
|
||||
switch (platform) {
|
||||
case OSX:
|
||||
Keyboard.press(KEY_LEFT_GUI);
|
||||
// Shift-Q logs out:
|
||||
Keyboard.press(KEY_LEFT_SHIFT);
|
||||
Keyboard.press('Q');
|
||||
delay(100);
|
||||
Keyboard.releaseAll();
|
||||
// enter:
|
||||
Keyboard.write(KEY_RETURN);
|
||||
break;
|
||||
case WINDOWS:
|
||||
// CTRL-ALT-DEL:
|
||||
Keyboard.press(KEY_LEFT_CTRL);
|
||||
Keyboard.press(KEY_LEFT_ALT);
|
||||
Keyboard.press(KEY_DELETE);
|
||||
delay(100);
|
||||
Keyboard.releaseAll();
|
||||
//ALT-s:
|
||||
delay(2000);
|
||||
Keyboard.press(KEY_LEFT_ALT);
|
||||
Keyboard.press('l');
|
||||
Keyboard.releaseAll();
|
||||
break;
|
||||
case UBUNTU:
|
||||
// CTRL-ALT-DEL:
|
||||
Keyboard.press(KEY_LEFT_CTRL);
|
||||
Keyboard.press(KEY_LEFT_ALT);
|
||||
Keyboard.press(KEY_DELETE);
|
||||
delay(1000);
|
||||
Keyboard.releaseAll();
|
||||
// Enter to confirm logout:
|
||||
Keyboard.write(KEY_RETURN);
|
||||
break;
|
||||
}
|
||||
// do nothing:
|
||||
while(true);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -1,6 +1,8 @@
|
||||
/*
|
||||
Keyboard Button test
|
||||
|
||||
For Leonardo and Due boards only.
|
||||
|
||||
Sends a text string when a button is pressed.
|
||||
|
||||
The circuit:
|
@ -3,6 +3,8 @@
|
||||
|
||||
This sketch demonstrates the Keyboard library.
|
||||
|
||||
For Leonardo and Due boards only.
|
||||
|
||||
When you connect pin 2 to ground, it creates a new
|
||||
window with a key combination (CTRL-N),
|
||||
then types in the Blink sketch, then auto-formats the text
|
@ -1,6 +1,8 @@
|
||||
/*
|
||||
Keyboard test
|
||||
|
||||
For Leonardo and Due boards only
|
||||
|
||||
Reads a byte from the serial port, sends a keystroke back.
|
||||
The sent keystroke is one higher than what's received, e.g.
|
||||
if you send a, you get b, send A you get B, and so forth.
|
@ -2,6 +2,8 @@
|
||||
/*
|
||||
KeyboardAndMouseControl
|
||||
|
||||
For Leonardo and Due boards only.
|
||||
|
||||
Controls the mouse from five pushbuttons on an Arduino Leonardo.
|
||||
|
||||
Hardware:
|
@ -2,7 +2,9 @@
|
||||
/*
|
||||
ButtonMouseControl
|
||||
|
||||
Controls the mouse from five pushbuttons on an Arduino Leonardo.
|
||||
For Leonardo and Due boards only.
|
||||
|
||||
Controls the mouse from five pushbuttons on an Arduino Leonardo or Due.
|
||||
|
||||
Hardware:
|
||||
* 5 pushbuttons attached to D2, D3, D4, D5, D6
|
@ -1,7 +1,9 @@
|
||||
/*
|
||||
JoystickMouseControl
|
||||
|
||||
Controls the mouse from a joystick on an Arduino Leonardo.
|
||||
For Leonardo and Due boards only.
|
||||
|
||||
Controls the mouse from a joystick on an Arduino Leonardo or Due.
|
||||
Uses a pushbutton to turn on and off mouse control, and
|
||||
a second pushbutton to click the left mouse button
|
||||
|
@ -1,11 +1,30 @@
|
||||
/*
|
||||
Simple Audio Player
|
||||
|
||||
Demonstrates the use of the Audio library for the Arduino Due
|
||||
|
||||
Hardware required :
|
||||
* Arduino shield with a SD card on CS4
|
||||
* A sound file named "test.wav" in the root directory of the SD card
|
||||
* Speaker attched to ground and DAC0
|
||||
|
||||
Original by Massimo Banzi September 20, 2012
|
||||
Modified by Scott Fitzgerald October 19, 2012
|
||||
|
||||
This example code is in the public domain
|
||||
|
||||
http://arduino.cc/en/Tutorial/SimpleAudioPlayer
|
||||
|
||||
*/
|
||||
|
||||
#include <SD.h>
|
||||
#include <SPI.h>
|
||||
#include <Audio.h>
|
||||
|
||||
void setup()
|
||||
{
|
||||
// debug output at 115.2K
|
||||
Serial.begin(115200);
|
||||
// debug output at 9600 baud
|
||||
Serial.begin(9600);
|
||||
|
||||
// setup SD-card
|
||||
Serial.print("Initializing SD card...");
|
||||
@ -27,15 +46,15 @@ void loop()
|
||||
int count=0;
|
||||
|
||||
// open wave file from sdcard
|
||||
File myFile = SD.open("fadh.wav");
|
||||
File myFile = SD.open("test.wav");
|
||||
if (!myFile) {
|
||||
// if the file didn't open, print an error and stop
|
||||
Serial.println("error opening fadh.wav");
|
||||
Serial.println("error opening test.wav");
|
||||
while (true);
|
||||
}
|
||||
|
||||
const int S=1024; // Number of samples to read in block
|
||||
int16_t buffer[S];
|
||||
short buffer[S];
|
||||
|
||||
Serial.print("Playing");
|
||||
// until the file is not finished
|
||||
|
@ -0,0 +1,21 @@
|
||||
#######################################
|
||||
# Syntax Coloring Map For Audio
|
||||
#######################################
|
||||
|
||||
#######################################
|
||||
# Datatypes (KEYWORD1)
|
||||
#######################################
|
||||
|
||||
Audio KEYWORD1
|
||||
|
||||
#######################################
|
||||
# Methods and Functions (KEYWORD2)
|
||||
#######################################
|
||||
|
||||
prepare KEYWORD2
|
||||
write KEYWORD2
|
||||
|
||||
#######################################
|
||||
# Constants (LITERAL1)
|
||||
#######################################
|
||||
|
@ -1,3 +1,22 @@
|
||||
/*
|
||||
Multiple Blinks
|
||||
|
||||
Demonstrates the use of the Scheduler library for the Arduino Due
|
||||
|
||||
Hardware required :
|
||||
* LEDs connected to pins 11, 12, and 13
|
||||
|
||||
created 8 Oct 2012
|
||||
by Cristian Maglie
|
||||
Modified by
|
||||
Scott Fitzgerald 19 Oct 2012
|
||||
|
||||
This example code is in the public domain
|
||||
|
||||
http://arduino.cc/en/Tutorial/MultipleBlinks
|
||||
|
||||
*/
|
||||
|
||||
|
||||
// Include Scheduler since we want to manage multiple tasks.
|
||||
#include <Scheduler.h>
|
||||
@ -7,7 +26,7 @@ int led2 = 12;
|
||||
int led3 = 11;
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
Serial.begin(9600);
|
||||
|
||||
// Setup the 3 pins as OUTPUT
|
||||
pinMode(led1, OUTPUT);
|
||||
@ -42,7 +61,7 @@ void loop2() {
|
||||
wait(100);
|
||||
}
|
||||
|
||||
// Task no.3: accept commands from Serial1 port
|
||||
// Task no.3: accept commands from Serial port
|
||||
// '0' turns off LED
|
||||
// '1' turns on LED
|
||||
void loop3() {
|
||||
|
22
hardware/arduino/sam/libraries/Scheduler/keywords.txt
Normal file
22
hardware/arduino/sam/libraries/Scheduler/keywords.txt
Normal file
@ -0,0 +1,22 @@
|
||||
#######################################
|
||||
# Syntax Coloring Map For Scheduler
|
||||
#######################################
|
||||
|
||||
#######################################
|
||||
# Datatypes (KEYWORD1)
|
||||
#######################################
|
||||
|
||||
Scheduler KEYWORD1
|
||||
|
||||
#######################################
|
||||
# Methods and Functions (KEYWORD2)
|
||||
#######################################
|
||||
|
||||
yield KEYWORD2
|
||||
wait KEYWORD2
|
||||
startLoop KEYWORD2
|
||||
|
||||
#######################################
|
||||
# Constants (LITERAL1)
|
||||
#######################################
|
||||
|
@ -1,10 +1,26 @@
|
||||
/*
|
||||
|
||||
ADK Terminal Test
|
||||
|
||||
This demonstrates USB Host connectivity between an
|
||||
Android phone and an Arduino Due.
|
||||
|
||||
The ADK for the Arduino Due is a work in progress
|
||||
For additional information on the Arduino ADK visit
|
||||
http://labs.arduino.cc/ADK/Index
|
||||
|
||||
created 27 June 2012
|
||||
by Cristian Maglie
|
||||
|
||||
*/
|
||||
|
||||
#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 accessoryName[] = "Arduino Due"; // your Arduino board
|
||||
char companyName[] = "Arduino SA";
|
||||
|
||||
// Make up anything you want for these
|
||||
|
@ -1,281 +0,0 @@
|
||||
#include "variant.h"
|
||||
#include <stdio.h>
|
||||
#include "descriptor_strings.h"
|
||||
|
||||
USBHost Usb;
|
||||
|
||||
/* Forward declarations */
|
||||
void PrintAllAddresses(UsbDevice *pdev);
|
||||
void PrintAddress(uint32_t addr);
|
||||
void PrintDescriptors(uint32_t addr);
|
||||
void PrintAllDescriptors(UsbDevice *pdev);
|
||||
uint32_t getdevdescr(uint32_t addr, uint32_t &num_conf);
|
||||
//void printhubdescr(uint8_t *descrptr, uint32_t addr);
|
||||
uint32_t getconfdescr(uint32_t addr, uint32_t conf);
|
||||
void printconfdescr(uint8_t* descr_ptr);
|
||||
void printintfdescr(uint8_t* descr_ptr);
|
||||
void printepdescr(uint8_t* descr_ptr);
|
||||
void printunkdescr(uint8_t* descr_ptr);
|
||||
|
||||
void setup()
|
||||
{
|
||||
cpu_irq_enable();
|
||||
printf("\r\nProgram started:\r\n");
|
||||
delay(200);
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
Usb.Task();
|
||||
|
||||
if( Usb.getUsbTaskState() == USB_STATE_RUNNING )
|
||||
{
|
||||
|
||||
Usb.ForEachUsbDevice(&PrintAllDescriptors);
|
||||
Usb.ForEachUsbDevice(&PrintAllAddresses);
|
||||
|
||||
// Stop here
|
||||
while( 1 )
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
void PrintAllAddresses(UsbDevice *pdev)
|
||||
{
|
||||
UsbDeviceAddress adr;
|
||||
adr.devAddress = pdev->address;
|
||||
printf("\r\nAddr: %lu (%lu.%lu.%lu)", adr.devAddress, adr.bmHub, adr.bmParent, adr.bmAddress);
|
||||
}
|
||||
|
||||
void PrintAddress(uint32_t addr)
|
||||
{
|
||||
UsbDeviceAddress adr;
|
||||
adr.devAddress = addr;
|
||||
printf("\r\nAddr: %lu (%lu.%lu.%lu)", adr.devAddress, adr.bmHub, adr.bmParent, adr.bmAddress);
|
||||
}
|
||||
|
||||
void PrintDescriptors(uint32_t addr)
|
||||
{
|
||||
uint32_t rcode = 0;
|
||||
uint32_t num_conf = 0;
|
||||
|
||||
// Get device descriptor
|
||||
rcode = getdevdescr(addr, num_conf);
|
||||
if (rcode)
|
||||
{
|
||||
printf("%s%lu\r\n", Gen_Error_str, rcode);
|
||||
}
|
||||
printf("\r\n");
|
||||
|
||||
for (uint32_t i = 0; i < num_conf; ++i)
|
||||
{
|
||||
// Get configuration descriptor
|
||||
rcode = getconfdescr(addr, i);
|
||||
if (rcode)
|
||||
{
|
||||
printf("%s%lu\r\n", Gen_Error_str, rcode);
|
||||
}
|
||||
printf("\r\n");
|
||||
}
|
||||
}
|
||||
|
||||
void PrintAllDescriptors(UsbDevice *pdev)
|
||||
{
|
||||
printf("\r\nDevice address %lu:\r\n", pdev->address);
|
||||
PrintDescriptors(pdev->address);
|
||||
}
|
||||
|
||||
uint32_t getdevdescr(uint32_t addr, uint32_t &num_conf)
|
||||
{
|
||||
USB_DEVICE_DESCRIPTOR buf;
|
||||
uint32_t rcode;
|
||||
|
||||
rcode = Usb.getDevDescr(addr, 0, 0x12, (uint8_t*)&buf);
|
||||
if (rcode)
|
||||
{
|
||||
return rcode;
|
||||
}
|
||||
|
||||
printf("%s", Dev_Header_str);
|
||||
printf("%s0x%x", Dev_Length_str, buf.bLength);
|
||||
printf("%s0x%x", Dev_Type_str, buf.bDescriptorType);
|
||||
printf("%s0x%x", Dev_Version_str, buf.bcdUSB);
|
||||
printf("%s0x%x", Dev_Class_str, buf.bDeviceClass);
|
||||
printf("%s0x%x", Dev_Subclass_str, buf.bDeviceSubClass);
|
||||
printf("%s0x%x", Dev_Protocol_str, buf.bDeviceProtocol);
|
||||
printf("%s0x%x", Dev_Pktsize_str, buf.bMaxPacketSize0);
|
||||
printf("%s0x%x", Dev_Vendor_str, buf.idVendor);
|
||||
printf("%s0x%x", Dev_Product_str, buf.idProduct);
|
||||
printf("%s0x%x", Dev_Revision_str, buf.bcdDevice);
|
||||
printf("%s0x%x", Dev_Mfg_str, buf.iManufacturer);
|
||||
printf("%s0x%x", Dev_Prod_str, buf.iProduct);
|
||||
printf("%s0x%x", Dev_Serial_str, buf.iSerialNumber);
|
||||
printf("%s0x%x", Dev_Nconf_str, buf.bNumConfigurations);
|
||||
num_conf = buf.bNumConfigurations;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
void printhubdescr(uint8_t *descrptr, uint32_t addr)
|
||||
{
|
||||
HubDescriptor *pHub = (HubDescriptor*) descrptr;
|
||||
uint8_t len = *((uint8_t*)descrptr);
|
||||
|
||||
printf("%s", PSTR("\r\n\r\nHub Descriptor:\r\n"));
|
||||
printf("%s", PSTR("bDescLength:\t\t"));
|
||||
printfln(pHub->bDescLength, HEX);
|
||||
|
||||
printf("%s", PSTR("bDescriptorType:\t"));
|
||||
printfln(pHub->bDescriptorType, HEX);
|
||||
|
||||
printf("%s", PSTR("bNbrPorts:\t\t"));
|
||||
printfln(pHub->bNbrPorts, HEX);
|
||||
|
||||
printf("%s", PSTR("LogPwrSwitchMode:\t"));
|
||||
printfln(pHub->LogPwrSwitchMode, BIN);
|
||||
|
||||
printf("%s", PSTR("CompoundDevice:\t\t"));
|
||||
printfln(pHub->CompoundDevice, BIN);
|
||||
|
||||
printf("%s", PSTR("OverCurrentProtectMode:\t"));
|
||||
printfln(pHub->OverCurrentProtectMode, BIN);
|
||||
|
||||
printf("%s", PSTR("TTThinkTime:\t\t"));
|
||||
printfln(pHub->TTThinkTime, BIN);
|
||||
|
||||
printf("%s", PSTR("PortIndicatorsSupported:"));
|
||||
printfln(pHub->PortIndicatorsSupported, BIN);
|
||||
|
||||
printf("%s", PSTR("Reserved:\t\t"));
|
||||
printfln(pHub->Reserved, HEX);
|
||||
|
||||
printf("%s", PSTR("bPwrOn2PwrGood:\t\t"));
|
||||
printfln(pHub->bPwrOn2PwrGood, HEX);
|
||||
|
||||
printf("%s", PSTR("bHubContrCurrent:\t"));
|
||||
printfln(pHub->bHubContrCurrent, HEX);
|
||||
|
||||
for (uint8_t i=7; i<len; i++)
|
||||
print_hex(descrptr[i], 8);
|
||||
|
||||
//for (uint8_t i=1; i<=pHub->bNbrPorts; i++)
|
||||
// PrintHubPortStatus(&Usb, addr, i, 1);
|
||||
}*/
|
||||
|
||||
uint32_t getconfdescr(uint32_t addr, uint32_t conf)
|
||||
{
|
||||
uint8_t buf[BUFSIZE];
|
||||
uint8_t* buf_ptr = buf;
|
||||
uint32_t rcode = 0;
|
||||
uint32_t descr_length = 0;
|
||||
uint32_t descr_type = 0;
|
||||
uint32_t total_length = 0;
|
||||
|
||||
// Get total length
|
||||
rcode = Usb.getConfDescr(addr, 0, 4, conf, buf);
|
||||
if (rcode)
|
||||
{
|
||||
printf("\r\nError retrieving configuration length. Error code %lu\r\n", rcode);
|
||||
return(0);
|
||||
}
|
||||
|
||||
total_length = buf[3] << 8;
|
||||
total_length |= (buf[2] & 0xff);
|
||||
|
||||
if( total_length > 256 )
|
||||
{
|
||||
// Check if total length is larger than buffer
|
||||
printf("%s", Conf_Trunc_str);
|
||||
total_length = 256;
|
||||
}
|
||||
|
||||
// Get the whole descriptor
|
||||
rcode = Usb.getConfDescr(addr, 0, total_length, conf, buf);
|
||||
while (buf_ptr < buf + total_length)
|
||||
{
|
||||
// Parsing descriptors
|
||||
descr_length = *(buf_ptr);
|
||||
descr_type = *(buf_ptr + 1);
|
||||
switch (descr_type)
|
||||
{
|
||||
case USB_DESCRIPTOR_CONFIGURATION:
|
||||
printconfdescr(buf_ptr);
|
||||
break;
|
||||
case USB_DESCRIPTOR_INTERFACE:
|
||||
printintfdescr(buf_ptr);
|
||||
break;
|
||||
case USB_DESCRIPTOR_ENDPOINT:
|
||||
printepdescr(buf_ptr);
|
||||
break;
|
||||
/*case 0x29:
|
||||
printhubdescr(buf_ptr, addr);
|
||||
break;*/
|
||||
default:
|
||||
printunkdescr(buf_ptr);
|
||||
break;
|
||||
}
|
||||
// Advance buffer pointer
|
||||
buf_ptr = (buf_ptr + descr_length);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* function to print configuration descriptor */
|
||||
void printconfdescr(uint8_t* descr_ptr)
|
||||
{
|
||||
USB_CONFIGURATION_DESCRIPTOR* conf_ptr = (USB_CONFIGURATION_DESCRIPTOR*)descr_ptr;
|
||||
|
||||
printf("%s", Conf_Header_str);
|
||||
printf("%s0x%x", Conf_Totlen_str, conf_ptr->wTotalLength);
|
||||
printf("%s0x%x", Conf_Nint_str, conf_ptr->bNumInterfaces);
|
||||
printf("%s0x%x", Conf_Value_str, conf_ptr->bConfigurationValue);
|
||||
printf("%s0x%x", Conf_String_str, conf_ptr->iConfiguration);
|
||||
printf("%s0x%x", Conf_Attr_str, conf_ptr->bmAttributes);
|
||||
printf("%s0x%x", Conf_Pwr_str, conf_ptr->bMaxPower);
|
||||
}
|
||||
|
||||
/* function to print interface descriptor */
|
||||
void printintfdescr(uint8_t* descr_ptr)
|
||||
{
|
||||
USB_INTERFACE_DESCRIPTOR* intf_ptr = (USB_INTERFACE_DESCRIPTOR*)descr_ptr;
|
||||
|
||||
printf("%s", Int_Header_str);
|
||||
printf("%s0x%x", Int_Number_str, intf_ptr->bInterfaceNumber);
|
||||
printf("%s0x%x", Int_Alt_str, intf_ptr->bAlternateSetting);
|
||||
printf("%s0x%x", Int_Endpoints_str, intf_ptr->bNumEndpoints);
|
||||
printf("%s0x%x", Int_Class_str, intf_ptr->bInterfaceClass);
|
||||
printf("%s0x%x", Int_Subclass_str, intf_ptr->bInterfaceSubClass);
|
||||
printf("%s0x%x", Int_Protocol_str, intf_ptr->bInterfaceProtocol);
|
||||
printf("%s0x%x", Int_String_str, intf_ptr->iInterface);
|
||||
}
|
||||
|
||||
/* function to print endpoint descriptor */
|
||||
void printepdescr(uint8_t* descr_ptr)
|
||||
{
|
||||
USB_ENDPOINT_DESCRIPTOR* ep_ptr = (USB_ENDPOINT_DESCRIPTOR*)descr_ptr;
|
||||
|
||||
printf("%s", End_Header_str);
|
||||
printf("%s0x%x", End_Address_str, ep_ptr->bEndpointAddress);
|
||||
printf("%s0x%x", End_Attr_str, ep_ptr->bmAttributes);
|
||||
printf("%s0x%x", End_Pktsize_str, ep_ptr->wMaxPacketSize);
|
||||
printf("%s0x%x", End_Interval_str, ep_ptr->bInterval);
|
||||
}
|
||||
|
||||
/* function to print unknown descriptor */
|
||||
void printunkdescr(uint8_t* descr_ptr)
|
||||
{
|
||||
uint8_t length = *descr_ptr;
|
||||
uint32_t i;
|
||||
|
||||
printf("%s", Unk_Header_str);
|
||||
printf("%s0x%x", Unk_Length_str, *descr_ptr);
|
||||
printf("%s0x%x", Unk_Type_str, *(descr_ptr + 1));
|
||||
printf("%s0x", Unk_Contents_str);
|
||||
descr_ptr += 2;
|
||||
for( i = 0; i < length; i++ )
|
||||
{
|
||||
printf("%02x", *descr_ptr);
|
||||
descr_ptr++;
|
||||
}
|
||||
}
|
@ -1,50 +0,0 @@
|
||||
#ifndef DESCRIPTOR_STRINGS_H_INCLUDED
|
||||
#define DESCRIPTOR_STRINGS_H_INCLUDED
|
||||
|
||||
// Buffer size
|
||||
#define BUFSIZE 256
|
||||
|
||||
/* Print strings in Program Memory */
|
||||
const char Gen_Error_str[] = "\r\nRequest error. Error code:\t";
|
||||
const char Dev_Header_str[] = "\r\nDevice descriptor: ";
|
||||
const char Dev_Length_str[] = "\r\nDescriptor Length:\t";
|
||||
const char Dev_Type_str[] = "\r\nDescriptor type:\t";
|
||||
const char Dev_Version_str[] = "\r\nUSB version:\t\t";
|
||||
const char Dev_Class_str[] = "\r\nDevice class:\t\t";
|
||||
const char Dev_Subclass_str[] = "\r\nDevice Subclass:\t";
|
||||
const char Dev_Protocol_str[] = "\r\nDevice Protocol:\t";
|
||||
const char Dev_Pktsize_str[] = "\r\nMax.packet size:\t";
|
||||
const char Dev_Vendor_str[] = "\r\nVendor ID:\t\t";
|
||||
const char Dev_Product_str[] = "\r\nProduct ID:\t\t";
|
||||
const char Dev_Revision_str[] = "\r\nRevision ID:\t\t";
|
||||
const char Dev_Mfg_str[] = "\r\nMfg.string index:\t";
|
||||
const char Dev_Prod_str[] = "\r\nProd.string index:\t";
|
||||
const char Dev_Serial_str[] = "\r\nSerial number index:\t";
|
||||
const char Dev_Nconf_str[] = "\r\nNumber of conf.:\t";
|
||||
const char Conf_Trunc_str[] = "Total length truncated to 256 bytes";
|
||||
const char Conf_Header_str[] = "\r\nConfiguration descriptor:";
|
||||
const char Conf_Totlen_str[] = "\r\nTotal length:\t\t";
|
||||
const char Conf_Nint_str[] = "\r\nNum.intf:\t\t";
|
||||
const char Conf_Value_str[] = "\r\nConf.value:\t\t";
|
||||
const char Conf_String_str[] = "\r\nConf.string:\t\t";
|
||||
const char Conf_Attr_str[] = "\r\nAttr.:\t\t\t";
|
||||
const char Conf_Pwr_str[] = "\r\nMax.pwr:\t\t";
|
||||
const char Int_Header_str[] = "\r\n\r\nInterface descriptor:";
|
||||
const char Int_Number_str[] = "\r\nIntf.number:\t\t";
|
||||
const char Int_Alt_str[] = "\r\nAlt.:\t\t\t";
|
||||
const char Int_Endpoints_str[] = "\r\nEndpoints:\t\t";
|
||||
const char Int_Class_str[] = "\r\nIntf. Class:\t\t";
|
||||
const char Int_Subclass_str[] = "\r\nIntf. Subclass:\t\t";
|
||||
const char Int_Protocol_str[] = "\r\nIntf. Protocol:\t\t";
|
||||
const char Int_String_str[] = "\r\nIntf.string:\t\t";
|
||||
const char End_Header_str[] = "\r\n\r\nEndpoint descriptor:";
|
||||
const char End_Address_str[] = "\r\nEndpoint address:\t";
|
||||
const char End_Attr_str[] = "\r\nAttr.:\t\t\t";
|
||||
const char End_Pktsize_str[] = "\r\nMax.pkt size:\t\t";
|
||||
const char End_Interval_str[] = "\r\nPolling interval:\t";
|
||||
const char Unk_Header_str[] = "\r\n\r\nUnknown descriptor:";
|
||||
const char Unk_Length_str[] = "\r\nLength:\t\t\t";
|
||||
const char Unk_Type_str[] = "\r\nType:\t\t\t";
|
||||
const char Unk_Contents_str[] = "\r\nContents:\t\t";
|
||||
|
||||
#endif /* DESCRIPTOR_STRINGS_H_INCLUDED */
|
@ -1,13 +1,18 @@
|
||||
/*
|
||||
Keyboard Controller HID Example
|
||||
Keyboard Controller Example
|
||||
|
||||
Shows the output of a USB Keyboard connected to the USB
|
||||
controller of an Arduino Due Board.
|
||||
Shows the output of a USB Keyboard connected to
|
||||
the Native USB port on an Arduino Due Board.
|
||||
|
||||
created 8 Oct 2012
|
||||
by Cristian Maglie
|
||||
|
||||
http://arduino.cc/en/Tutorial/KeyboardController
|
||||
|
||||
This samlple code is part of the public domain.
|
||||
*/
|
||||
|
||||
|
||||
// Require keyboard control library
|
||||
#include <KeyboardController.h>
|
||||
|
||||
@ -66,7 +71,7 @@ void printKey() {
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
Serial.begin(9600);
|
||||
Serial.println("Program started");
|
||||
delay(200);
|
||||
}
|
||||
|
@ -1,11 +1,15 @@
|
||||
/*
|
||||
Mouse Controller HID Example
|
||||
Mouse Controller Example
|
||||
|
||||
Shows the output of a USB Mouse connected to the USB
|
||||
controller of an Arduino Due Board.
|
||||
Shows the output of a USB Mouse connected to
|
||||
the Native USB port on an Arduino Due Board.
|
||||
|
||||
created 8 Oct 2012
|
||||
by Cristian Maglie
|
||||
|
||||
http://arduino.cc/en/Tutorial/MouseController
|
||||
|
||||
This samlple code is part of the public domain.
|
||||
*/
|
||||
|
||||
// Require mouse control library
|
||||
@ -17,6 +21,11 @@ USBHost usb;
|
||||
// Attach mouse controller to USB
|
||||
MouseController mouse(usb);
|
||||
|
||||
// variables for mouse button states
|
||||
boolean leftButton = false;
|
||||
boolean middleButton = false;
|
||||
boolean rightButton = false;
|
||||
|
||||
// This function intercepts mouse movements
|
||||
void mouseMoved() {
|
||||
Serial.print("Move: ");
|
||||
@ -25,7 +34,7 @@ void mouseMoved() {
|
||||
Serial.println(mouse.getYChange());
|
||||
}
|
||||
|
||||
// This function intercepts mouse movements when a button is pressed
|
||||
// This function intercepts mouse movements while a button is pressed
|
||||
void mouseDragged() {
|
||||
Serial.print("DRAG: ");
|
||||
Serial.print(mouse.getXChange());
|
||||
@ -36,30 +45,42 @@ void mouseDragged() {
|
||||
// This function intercepts mouse button press
|
||||
void mousePressed() {
|
||||
Serial.print("Pressed: ");
|
||||
if (mouse.getButton(LEFT_BUTTON))
|
||||
if (mouse.getButton(LEFT_BUTTON)){
|
||||
Serial.print("L");
|
||||
if (mouse.getButton(MIDDLE_BUTTON))
|
||||
leftButton = true;
|
||||
}
|
||||
if (mouse.getButton(MIDDLE_BUTTON)){
|
||||
Serial.print("M");
|
||||
if (mouse.getButton(RIGHT_BUTTON))
|
||||
middleButton = true;
|
||||
}
|
||||
if (mouse.getButton(RIGHT_BUTTON)){
|
||||
Serial.print("R");
|
||||
Serial.println();
|
||||
Serial.println();
|
||||
rightButton = true;
|
||||
}
|
||||
}
|
||||
|
||||
// This function intercepts mouse button release
|
||||
void mouseReleased() {
|
||||
Serial.print("Released: ");
|
||||
if (mouse.getButton(LEFT_BUTTON))
|
||||
if (!mouse.getButton(LEFT_BUTTON) && left==true) {
|
||||
Serial.print("L");
|
||||
if (mouse.getButton(MIDDLE_BUTTON))
|
||||
leftButton = false;
|
||||
}
|
||||
if (!mouse.getButton(MIDDLE_BUTTON) && middle==true) {
|
||||
Serial.print("M");
|
||||
if (mouse.getButton(RIGHT_BUTTON))
|
||||
middleButton = false;
|
||||
}
|
||||
if (!mouse.getButton(RIGHT_BUTTON) && right==true) {
|
||||
Serial.print("R");
|
||||
rightButton = false;
|
||||
}
|
||||
Serial.println();
|
||||
}
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
Serial.begin(9600);
|
||||
Serial.println("Program started");
|
||||
delay(200);
|
||||
}
|
||||
@ -69,3 +90,4 @@ void loop()
|
||||
// Process USB tasks
|
||||
usb.Task();
|
||||
}
|
||||
|
||||
|
35
hardware/arduino/sam/libraries/USBHost/keywords.txt
Normal file
35
hardware/arduino/sam/libraries/USBHost/keywords.txt
Normal file
@ -0,0 +1,35 @@
|
||||
#######################################
|
||||
# Syntax Coloring Map For USBHost
|
||||
#######################################
|
||||
|
||||
#######################################
|
||||
# Datatypes (KEYWORD1)
|
||||
#######################################
|
||||
|
||||
MouseController KEYWORD1
|
||||
USBHost KEYWORD1
|
||||
KeyboardController KEYWORD1
|
||||
|
||||
#######################################
|
||||
# Methods and Functions (KEYWORD2)
|
||||
#######################################
|
||||
|
||||
Task KEYWORD2
|
||||
mouseMoved KEYWORD2
|
||||
mouseDragged KEYWORD2
|
||||
mousePressed KEYWORD2
|
||||
mouseReleased KEYWORD2
|
||||
getXChange KEYWORD2
|
||||
getYChange KEYWORD2
|
||||
getButton KEYWORD2
|
||||
keyPressed KEYWORD2
|
||||
keyReleased KEYWORD2
|
||||
getModifiers KEYWORD2
|
||||
getKey KEYWORD2
|
||||
getOemKey KEYWORD2
|
||||
|
||||
|
||||
#######################################
|
||||
# Constants (LITERAL1)
|
||||
#######################################
|
||||
|
Loading…
Reference in New Issue
Block a user