1
0
mirror of https://github.com/arduino/Arduino.git synced 2024-12-10 21:24:12 +01:00

[SAM] HID and CDC verified okay on Linux/Mac by Cristian. Fixed OTG clock

init issue. CDC is not working correctly under Windows (possible inf
issue).
This commit is contained in:
Thibault RICHARD 2012-05-07 20:12:00 +02:00
parent 84e887003d
commit d6d23c530a
6 changed files with 18 additions and 77 deletions

View File

@ -51,9 +51,7 @@ static volatile LineInfo _usbLineInfo = { 57600, 0x00, 0x00, 0x00, 0x00 };
_Pragma("pack(1)") _Pragma("pack(1)")
static const CDCDescriptor _cdcInterface = static const CDCDescriptor _cdcInterface =
{ {
#ifdef HID_ENABLED
D_IAD(0,2,CDC_COMMUNICATION_INTERFACE_CLASS,CDC_ABSTRACT_CONTROL_MODEL,1), D_IAD(0,2,CDC_COMMUNICATION_INTERFACE_CLASS,CDC_ABSTRACT_CONTROL_MODEL,1),
#endif
// CDC communication interface // CDC communication interface
D_INTERFACE(CDC_ACM_INTERFACE,1,CDC_COMMUNICATION_INTERFACE_CLASS,CDC_ABSTRACT_CONTROL_MODEL,0), D_INTERFACE(CDC_ACM_INTERFACE,1,CDC_COMMUNICATION_INTERFACE_CLASS,CDC_ABSTRACT_CONTROL_MODEL,0),

View File

@ -234,10 +234,8 @@ typedef struct
typedef struct typedef struct
{ {
#ifdef HID_ENABLED
// IAD // IAD
IADDescriptor iad; // Only needed on compound device IADDescriptor iad; // Only needed on compound device
#endif
// Control // Control
InterfaceDescriptor cif; // InterfaceDescriptor cif; //

View File

@ -29,62 +29,20 @@ const int mouseButton = 6;
int range = 5; // output range of X or Y movement; affects movement speed int range = 5; // output range of X or Y movement; affects movement speed
int responseDelay = 10; // response delay of the mouse, in ms int responseDelay = 10; // response delay of the mouse, in ms
/*
void setup() {
Mouse.begin();
}
//void setup() { void loop() {
// initialize the buttons' inputs: Mouse.move(10, 0, 0);
/* pinMode(upButton, INPUT); delay(1000);
pinMode(downButton, INPUT); }
pinMode(leftButton, INPUT); */
pinMode(rightButton, INPUT);
pinMode(mouseButton, INPUT);*/
// initialize mouse control:
// Mouse.begin();
//}
//void loop() {
// read the buttons:
/* int upState = digitalRead(upButton);
int downState = digitalRead(downButton);
int rightState = digitalRead(rightButton);
int leftState = digitalRead(leftButton);
int clickState = digitalRead(mouseButton);
// calculate the movement distance based on the button states:
int xDistance = (leftState - rightState)*range;
int yDistance = (upState - downState)*range;
// if X or Y is non-zero, move:
if ((xDistance != 0) || (yDistance != 0)) {
Mouse.move(xDistance, yDistance, 0);
}
// if the mouse button is pressed:
if (clickState == HIGH) {
// if the mouse is not pressed, press it:
if (!Mouse.isPressed(MOUSE_LEFT)) {
Mouse.press(MOUSE_LEFT);
}
}
// else the mouse button is not pressed:
else {
// if the mouse is pressed, release it:
if (Mouse.isPressed(MOUSE_LEFT)) {
Mouse.release(MOUSE_LEFT);
}
}*/
/*Mouse.move(10, 0, 0);
// a delay so the mouse doesn't move too fast:
delay(1000);
}*/
/*
//#include "USBAPI.h" void setup() {
// Cet exemple fonctionne !!! ;-)
/*void setup() {
// initialize the digital pin as an output. // initialize the digital pin as an output.
// Pin 13 has an LED connected on most Arduino boards: // Pin 13 has an LED connected on most Arduino boards:
//pinMode(13, OUTPUT); //pinMode(13, OUTPUT);
@ -98,34 +56,21 @@ void loop() {
//digitalWrite(13, LOW); // set the LED off //digitalWrite(13, LOW); // set the LED off
delay(1000); // wait for a second delay(1000); // wait for a second
printf("loop...\r\n"); printf("loop...\r\n");
}*/ }
*/
void setup() { void setup() {
// open the serial port: Serial.begin(57600);
Serial.begin(57600);
// initialize control over the keyboard:
// Keyboard.begin();
} }
void loop() { void loop() {
// check for incoming serial data:
//if (Serial.available() > 0) {
// read incoming serial data:
//char inChar = Serial.read();
// Type the next ASCII value from what you received:
// Keyboard.write(inChar+1);
//Serial.print("toto\r\n");
// check for incoming serial data:
if (Serial.available() > 0) { if (Serial.available() > 0)
// read incoming serial data: {
char inChar = Serial.read(); char inChar = Serial.read();
// Type the next ASCII value from what you received:
Serial.print(inChar); Serial.print(inChar);
Serial1.print(inChar); Serial1.print(inChar);
} }
delay(10); delay(10);
} }

View File

@ -75,8 +75,8 @@ uint32_t UDD_Init(void)
otg_unfreeze_clock(); otg_unfreeze_clock();
// Check USB clock // Check USB clock
while (!Is_otg_clock_usable()) //while (!Is_otg_clock_usable())
; // ;
udd_low_speed_disable(); udd_low_speed_disable();
udd_high_speed_disable(); udd_high_speed_disable();