mirror of
https://github.com/esp8266/Arduino.git
synced 2025-06-19 09:42:11 +03:00
[sam] fixed CDC com issue in Arduino IDE
cherry pick from 96e8db0299
Conflicts:
hardware/arduino/sam/cores/arduino/USB/USBDesc.h
hardware/arduino/sam/system/libsam/source/uotghs_device.c
hardware/arduino/sam/variants/arduino_due_x/libsam_sam3x8e_gcc_rel.a
hardware/arduino/sam/variants/arduino_due_x/libsam_sam3x8e_gcc_rel.a.txt
This commit is contained in:
@ -23,6 +23,7 @@
|
|||||||
|
|
||||||
#define CDC_SERIAL_BUFFER_SIZE 64
|
#define CDC_SERIAL_BUFFER_SIZE 64
|
||||||
|
|
||||||
|
/* For information purpose only since RTS is not always handled by the terminal application */
|
||||||
#define CDC_LINESTATE_DTR 0x01 // Data Terminal Ready
|
#define CDC_LINESTATE_DTR 0x01 // Data Terminal Ready
|
||||||
#define CDC_LINESTATE_RTS 0x02 // Ready to Send
|
#define CDC_LINESTATE_RTS 0x02 // Ready to Send
|
||||||
|
|
||||||
@ -211,7 +212,7 @@ size_t Serial_::write(uint8_t c)
|
|||||||
// TODO - ZE - check behavior on different OSes and test what happens if an
|
// TODO - ZE - check behavior on different OSes and test what happens if an
|
||||||
// open connection isn't broken cleanly (cable is yanked out, host dies
|
// open connection isn't broken cleanly (cable is yanked out, host dies
|
||||||
// or locks up, or host virtual serial port hangs)
|
// or locks up, or host virtual serial port hangs)
|
||||||
if (_usbLineInfo.lineState == CDC_LINESTATE_READY)
|
if (_usbLineInfo.lineState > 0)
|
||||||
{
|
{
|
||||||
int r = USBD_Send(CDC_TX,&c,1);
|
int r = USBD_Send(CDC_TX,&c,1);
|
||||||
|
|
||||||
@ -240,7 +241,7 @@ Serial_::operator bool()
|
|||||||
{
|
{
|
||||||
bool result = false;
|
bool result = false;
|
||||||
|
|
||||||
if (_usbLineInfo.lineState == CDC_LINESTATE_READY)
|
if (_usbLineInfo.lineState > 0)
|
||||||
{
|
{
|
||||||
result = true;
|
result = true;
|
||||||
}
|
}
|
||||||
|
@ -503,9 +503,12 @@ void Keyboard_::releaseAll(void)
|
|||||||
|
|
||||||
size_t Keyboard_::write(uint8_t c)
|
size_t Keyboard_::write(uint8_t c)
|
||||||
{
|
{
|
||||||
uint8_t p = press(c); // Keydown
|
uint8_t p = 0;
|
||||||
uint8_t r = release(c); // Keyup
|
|
||||||
return (p); // just return the result of press() since release() almost always returns 1
|
p = press(c); // Keydown
|
||||||
|
release(c); // Keyup
|
||||||
|
|
||||||
|
return (p); // Just return the result of press() since release() almost always returns 1
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/* Copyright (c) 2010, Peter Barrett
|
// Copyright (c) 2010, Peter Barrett
|
||||||
**
|
/*
|
||||||
** Permission to use, copy, modify, and/or distribute this software for
|
** Permission to use, copy, modify, and/or distribute this software for
|
||||||
** any purpose with or without fee is hereby granted, provided that the
|
** any purpose with or without fee is hereby granted, provided that the
|
||||||
** above copyright notice and this permission notice appear in all copies.
|
** above copyright notice and this permission notice appear in all copies.
|
||||||
@ -44,11 +44,11 @@ volatile uint8_t RxLEDPulse; /**< Milliseconds remaining for data Rx LED pulse *
|
|||||||
//==================================================================
|
//==================================================================
|
||||||
//==================================================================
|
//==================================================================
|
||||||
|
|
||||||
extern const uint16_t STRING_LANGUAGE[] ;
|
extern const uint16_t STRING_LANGUAGE[];
|
||||||
extern const uint16_t STRING_IPRODUCT[] ;
|
extern const uint16_t STRING_IPRODUCT[];
|
||||||
extern const uint16_t STRING_IMANUFACTURER[] ;
|
extern const uint16_t STRING_IMANUFACTURER[];
|
||||||
extern const DeviceDescriptor USB_DeviceDescriptor ;
|
extern const DeviceDescriptor USB_DeviceDescriptor;
|
||||||
extern const DeviceDescriptor USB_DeviceDescriptorA ;
|
extern const DeviceDescriptor USB_DeviceDescriptorA;
|
||||||
|
|
||||||
const uint16_t STRING_LANGUAGE[2] = {
|
const uint16_t STRING_LANGUAGE[2] = {
|
||||||
(3<<8) | (2+2),
|
(3<<8) | (2+2),
|
||||||
@ -86,8 +86,6 @@ const DeviceDescriptor USB_DeviceDescriptor =
|
|||||||
const DeviceDescriptor USB_DeviceDescriptorA =
|
const DeviceDescriptor USB_DeviceDescriptorA =
|
||||||
D_DEVICE(DEVICE_CLASS,0x00,0x00,64,USB_VID,USB_PID,0x100,IMANUFACTURER,IPRODUCT,0,1);
|
D_DEVICE(DEVICE_CLASS,0x00,0x00,64,USB_VID,USB_PID,0x100,IMANUFACTURER,IPRODUCT,0,1);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//==================================================================
|
//==================================================================
|
||||||
//==================================================================
|
//==================================================================
|
||||||
|
|
||||||
@ -233,11 +231,11 @@ int USBD_SendControl(uint8_t flags, const void* d, uint32_t len)
|
|||||||
// TODO
|
// TODO
|
||||||
int USBD_RecvControl(void* d, uint32_t len)
|
int USBD_RecvControl(void* d, uint32_t len)
|
||||||
{
|
{
|
||||||
UDD_WaitOUT() ;
|
UDD_WaitOUT();
|
||||||
UDD_Recv(EP0, (uint8_t*)d, len ) ;
|
UDD_Recv(EP0, (uint8_t*)d, len);
|
||||||
UDD_ClearOUT() ;
|
UDD_ClearOUT();
|
||||||
|
|
||||||
return len ;
|
return len;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle CLASS_INTERFACE requests
|
// Handle CLASS_INTERFACE requests
|
||||||
@ -248,20 +246,20 @@ bool USBD_ClassInterfaceRequest(Setup& setup)
|
|||||||
TRACE_CORE(printf("=> USBD_ClassInterfaceRequest\r\n");)
|
TRACE_CORE(printf("=> USBD_ClassInterfaceRequest\r\n");)
|
||||||
|
|
||||||
#ifdef CDC_ENABLED
|
#ifdef CDC_ENABLED
|
||||||
if ( CDC_ACM_INTERFACE == i )
|
if (CDC_ACM_INTERFACE == i)
|
||||||
{
|
{
|
||||||
return CDC_Setup(setup);
|
return CDC_Setup(setup);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HID_ENABLED
|
#ifdef HID_ENABLED
|
||||||
if ( HID_INTERFACE == i )
|
if (HID_INTERFACE == i)
|
||||||
{
|
{
|
||||||
return HID_Setup(setup);
|
return HID_Setup(setup);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return false ;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
int USBD_SendInterfaces(void)
|
int USBD_SendInterfaces(void)
|
||||||
@ -270,11 +268,11 @@ int USBD_SendInterfaces(void)
|
|||||||
uint8_t interfaces = 0;
|
uint8_t interfaces = 0;
|
||||||
|
|
||||||
#ifdef CDC_ENABLED
|
#ifdef CDC_ENABLED
|
||||||
total = CDC_GetInterface(&interfaces) ;
|
total = CDC_GetInterface(&interfaces);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HID_ENABLED
|
#ifdef HID_ENABLED
|
||||||
total += HID_GetInterface(&interfaces) ;
|
total += HID_GetInterface(&interfaces);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
total = total; // Get rid of compiler warning
|
total = total; // Get rid of compiler warning
|
||||||
@ -314,7 +312,7 @@ static bool USBD_SendDescriptor(Setup& setup)
|
|||||||
uint8_t desc_length = 0;
|
uint8_t desc_length = 0;
|
||||||
const uint8_t* desc_addr = 0;
|
const uint8_t* desc_addr = 0;
|
||||||
|
|
||||||
if ( USB_CONFIGURATION_DESCRIPTOR_TYPE == t )
|
if (USB_CONFIGURATION_DESCRIPTOR_TYPE == t)
|
||||||
{
|
{
|
||||||
TRACE_CORE(printf("=> USBD_SendDescriptor : USB_CONFIGURATION_DESCRIPTOR_TYPE length=%d\r\n", setup.wLength);)
|
TRACE_CORE(printf("=> USBD_SendDescriptor : USB_CONFIGURATION_DESCRIPTOR_TYPE length=%d\r\n", setup.wLength);)
|
||||||
return USBD_SendConfiguration(setup.wLength);
|
return USBD_SendConfiguration(setup.wLength);
|
||||||
@ -322,17 +320,17 @@ static bool USBD_SendDescriptor(Setup& setup)
|
|||||||
|
|
||||||
USBD_InitControl(setup.wLength);
|
USBD_InitControl(setup.wLength);
|
||||||
#ifdef HID_ENABLED
|
#ifdef HID_ENABLED
|
||||||
if ( HID_REPORT_DESCRIPTOR_TYPE == t )
|
if (HID_REPORT_DESCRIPTOR_TYPE == t)
|
||||||
{
|
{
|
||||||
TRACE_CORE(puts("=> USBD_SendDescriptor : HID_REPORT_DESCRIPTOR_TYPE\r\n");)
|
TRACE_CORE(puts("=> USBD_SendDescriptor : HID_REPORT_DESCRIPTOR_TYPE\r\n");)
|
||||||
return HID_GetDescriptor( t ) ;
|
return HID_GetDescriptor(t);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (USB_DEVICE_DESCRIPTOR_TYPE == t)
|
if (USB_DEVICE_DESCRIPTOR_TYPE == t)
|
||||||
{
|
{
|
||||||
TRACE_CORE(puts("=> USBD_SendDescriptor : USB_DEVICE_DESCRIPTOR_TYPE\r\n");)
|
TRACE_CORE(puts("=> USBD_SendDescriptor : USB_DEVICE_DESCRIPTOR_TYPE\r\n");)
|
||||||
if ( setup.wLength == 8 )
|
if (setup.wLength == 8)
|
||||||
{
|
{
|
||||||
_cdcComposite = 1;
|
_cdcComposite = 1;
|
||||||
}
|
}
|
||||||
@ -351,17 +349,17 @@ static bool USBD_SendDescriptor(Setup& setup)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( desc_addr == 0 )
|
if (desc_addr == 0)
|
||||||
{
|
{
|
||||||
return false ;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( desc_length == 0 )
|
if (desc_length == 0)
|
||||||
{
|
{
|
||||||
desc_length = *desc_addr;
|
desc_length = *desc_addr;
|
||||||
}
|
}
|
||||||
|
|
||||||
TRACE_CORE(printf("=> USBD_SendDescriptor : desc_addr=%x desc_length=%d\r\n", desc_addr, desc_length);)
|
TRACE_CORE(printf("=> USBD_SendDescriptor : desc_addr=%p desc_length=%d\r\n", desc_addr, desc_length);)
|
||||||
USBD_SendControl(0, desc_addr, desc_length);
|
USBD_SendControl(0, desc_addr, desc_length);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -397,7 +395,7 @@ static void USB_ISR(void)
|
|||||||
while (USBD_Available(CDC_RX))
|
while (USBD_Available(CDC_RX))
|
||||||
Serial.accept();
|
Serial.accept();
|
||||||
|
|
||||||
udd_ack_fifocon(CDC_RX) ;
|
udd_ack_fifocon(CDC_RX);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -405,12 +403,12 @@ static void USB_ISR(void)
|
|||||||
if (Is_udd_endpoint_interrupt(0))
|
if (Is_udd_endpoint_interrupt(0))
|
||||||
{
|
{
|
||||||
|
|
||||||
if ( !UDD_ReceivedSetupInt() )
|
if (!UDD_ReceivedSetupInt())
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Setup setup ;
|
Setup setup;
|
||||||
UDD_Recv(EP0, (uint8_t*)&setup, 8);
|
UDD_Recv(EP0, (uint8_t*)&setup, 8);
|
||||||
UDD_ClearSetupInt();
|
UDD_ClearSetupInt();
|
||||||
|
|
||||||
@ -426,7 +424,7 @@ static void USB_ISR(void)
|
|||||||
UDD_ClearIN();
|
UDD_ClearIN();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ok = true ;
|
bool ok = true;
|
||||||
if (REQUEST_STANDARD == (requestType & REQUEST_TYPE))
|
if (REQUEST_STANDARD == (requestType & REQUEST_TYPE))
|
||||||
{
|
{
|
||||||
// Standard Requests
|
// Standard Requests
|
||||||
@ -544,36 +542,36 @@ USBDevice_::USBDevice_()
|
|||||||
{
|
{
|
||||||
UDD_SetStack(&USB_ISR);
|
UDD_SetStack(&USB_ISR);
|
||||||
|
|
||||||
if ( UDD_Init() == 0UL )
|
if (UDD_Init() == 0UL)
|
||||||
{
|
{
|
||||||
_usbInitialized=1UL ;
|
_usbInitialized=1UL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool USBDevice_::attach(void)
|
bool USBDevice_::attach(void)
|
||||||
{
|
{
|
||||||
if ( _usbInitialized != 0UL )
|
if (_usbInitialized != 0UL)
|
||||||
{
|
{
|
||||||
UDD_Attach() ;
|
UDD_Attach();
|
||||||
_usbConfiguration = 0;
|
_usbConfiguration = 0;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return false ;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool USBDevice_::detach(void)
|
bool USBDevice_::detach(void)
|
||||||
{
|
{
|
||||||
if ( _usbInitialized != 0UL )
|
if (_usbInitialized != 0UL)
|
||||||
{
|
{
|
||||||
UDD_Detach() ;
|
UDD_Detach();
|
||||||
return true ;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return false ;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
// Copyright (c) 2010, Peter Barrett
|
// Copyright (c) 2010, Peter Barrett
|
||||||
/*
|
/*
|
||||||
** Permission to use, copy, modify, and/or distribute this software for
|
** Permission to use, copy, modify, and/or distribute this software for
|
||||||
@ -238,7 +237,7 @@ typedef struct
|
|||||||
IADDescriptor iad; // Only needed on compound device
|
IADDescriptor iad; // Only needed on compound device
|
||||||
|
|
||||||
// Control
|
// Control
|
||||||
InterfaceDescriptor cif; //
|
InterfaceDescriptor cif;
|
||||||
CDCCSInterfaceDescriptor header;
|
CDCCSInterfaceDescriptor header;
|
||||||
CMFunctionalDescriptor callManagement; // Call Management
|
CMFunctionalDescriptor callManagement; // Call Management
|
||||||
ACMFunctionalDescriptor controlManagement; // ACM
|
ACMFunctionalDescriptor controlManagement; // ACM
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
|
// Copyright (c) 2010, Peter Barrett
|
||||||
|
/*
|
||||||
/* Copyright (c) 2011, Peter Barrett
|
|
||||||
**
|
|
||||||
** Permission to use, copy, modify, and/or distribute this software for
|
** Permission to use, copy, modify, and/or distribute this software for
|
||||||
** any purpose with or without fee is hereby granted, provided that the
|
** any purpose with or without fee is hereby granted, provided that the
|
||||||
** above copyright notice and this permission notice appear in all copies.
|
** above copyright notice and this permission notice appear in all copies.
|
||||||
@ -16,10 +14,12 @@
|
|||||||
** SOFTWARE.
|
** SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#ifndef __USBDESC_H__
|
||||||
|
#define __USBDESC_H__
|
||||||
|
|
||||||
#define CDC_ENABLED
|
#define CDC_ENABLED
|
||||||
#define HID_ENABLED
|
#define HID_ENABLED
|
||||||
|
|
||||||
|
|
||||||
#ifdef CDC_ENABLED
|
#ifdef CDC_ENABLED
|
||||||
#define CDC_INTERFACE_COUNT 2
|
#define CDC_INTERFACE_COUNT 2
|
||||||
#define CDC_ENPOINT_COUNT 3
|
#define CDC_ENPOINT_COUNT 3
|
||||||
@ -61,3 +61,4 @@
|
|||||||
#define IMANUFACTURER 1
|
#define IMANUFACTURER 1
|
||||||
#define IPRODUCT 2
|
#define IPRODUCT 2
|
||||||
|
|
||||||
|
#endif /* __USBDESC_H__ */
|
||||||
|
@ -25,7 +25,6 @@ void setup() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
|
|
||||||
Mouse.move(1, 0, 0);
|
Mouse.move(1, 0, 0);
|
||||||
|
|
||||||
if (Serial.available() > 0)
|
if (Serial.available() > 0)
|
||||||
|
@ -21,49 +21,35 @@
|
|||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
extern void UDD_WaitIN(void) ;
|
extern void UDD_WaitIN(void);
|
||||||
extern void UDD_WaitOUT(void) ;
|
extern void UDD_WaitOUT(void);
|
||||||
extern void UDD_ClearIN(void) ;
|
extern void UDD_ClearIN(void);
|
||||||
extern void UDD_ClearOUT(void) ;
|
extern void UDD_ClearOUT(void);
|
||||||
extern uint32_t UDD_WaitForINOrOUT(void) ;
|
extern uint32_t UDD_WaitForINOrOUT(void);
|
||||||
|
extern void UDD_ClearRxFlag(unsigned char bEndpoint);
|
||||||
extern void UDD_ClearRxFlag( unsigned char bEndpoint ) ;
|
|
||||||
|
|
||||||
|
|
||||||
extern uint32_t UDD_ReceivedSetupInt(void);
|
extern uint32_t UDD_ReceivedSetupInt(void);
|
||||||
extern void UDD_ClearSetupInt(void);
|
extern void UDD_ClearSetupInt(void);
|
||||||
|
extern uint32_t UDD_ReadWriteAllowed(uint32_t ep);
|
||||||
extern uint32_t UDD_ReadWriteAllowed(uint32_t ep) ;
|
extern uint32_t UDD_FifoByteCount(uint32_t ep);
|
||||||
|
extern uint8_t UDD_FifoFree(void);
|
||||||
|
extern void UDD_ReleaseRX(uint32_t ep);
|
||||||
extern uint32_t UDD_FifoByteCount(uint32_t ep) ;
|
extern void UDD_ReleaseTX(uint32_t ep);
|
||||||
extern uint8_t UDD_FifoFree(void) ;
|
extern uint8_t UDD_FrameNumber(void);
|
||||||
|
extern uint8_t UDD_GetConfiguration(void);
|
||||||
extern void UDD_ReleaseRX(uint32_t ep) ;
|
|
||||||
extern void UDD_ReleaseTX(uint32_t ep) ;
|
|
||||||
extern uint8_t UDD_FrameNumber(void) ;
|
|
||||||
|
|
||||||
extern uint8_t UDD_GetConfiguration(void) ;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
extern uint32_t UDD_Send(uint32_t ep, const void* data, uint32_t len);
|
extern uint32_t UDD_Send(uint32_t ep, const void* data, uint32_t len);
|
||||||
extern void UDD_Send8(uint32_t ep, uint8_t data );
|
extern void UDD_Send8(uint32_t ep, uint8_t data );
|
||||||
extern uint8_t UDD_Recv8(uint32_t ep);
|
extern uint8_t UDD_Recv8(uint32_t ep);
|
||||||
extern void UDD_Recv(uint32_t ep, uint8_t* data, uint32_t len);
|
extern void UDD_Recv(uint32_t ep, uint8_t* data, uint32_t len);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
extern void UDD_InitEndpoints(const uint32_t* eps_table, const uint32_t ul_eps_table_size);
|
extern void UDD_InitEndpoints(const uint32_t* eps_table, const uint32_t ul_eps_table_size);
|
||||||
|
extern void UDD_InitControl(int end);
|
||||||
extern void UDD_InitControl(int end) ;
|
extern uint32_t UDD_Init(void);
|
||||||
|
|
||||||
extern uint32_t UDD_Init(void) ;
|
|
||||||
extern void UDD_InitEP( uint32_t ul_ep, uint32_t ul_ep_cfg );
|
extern void UDD_InitEP( uint32_t ul_ep, uint32_t ul_ep_cfg );
|
||||||
|
|
||||||
extern void UDD_Attach(void) ;
|
extern void UDD_Attach(void);
|
||||||
extern void UDD_Detach(void) ;
|
extern void UDD_Detach(void);
|
||||||
|
|
||||||
extern void UDD_SetStack(void (*pf_isr)(void));
|
extern void UDD_SetStack(void (*pf_isr)(void));
|
||||||
extern void UDD_SetAddress(uint32_t addr);
|
extern void UDD_SetAddress(uint32_t addr);
|
||||||
extern void UDD_Stall(void);
|
extern void UDD_Stall(void);
|
||||||
@ -80,8 +66,8 @@ typedef unsigned char Bool; //!< Boolean.
|
|||||||
typedef unsigned char bool; //!< Boolean.
|
typedef unsigned char bool; //!< Boolean.
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
typedef int8_t S8 ; //!< 8-bit signed integer.
|
typedef int8_t S8; //!< 8-bit signed integer.
|
||||||
typedef uint8_t U8 ; //!< 8-bit unsigned integer.
|
typedef uint8_t U8; //!< 8-bit unsigned integer.
|
||||||
typedef int16_t S16; //!< 16-bit signed integer.
|
typedef int16_t S16; //!< 16-bit signed integer.
|
||||||
typedef uint16_t U16; //!< 16-bit unsigned integer.
|
typedef uint16_t U16; //!< 16-bit unsigned integer.
|
||||||
typedef uint16_t le16_t;
|
typedef uint16_t le16_t;
|
||||||
|
Reference in New Issue
Block a user