mirror of
https://github.com/hathach/tinyusb.git
synced 2025-03-14 04:18:56 +00:00
change license email to website
added support for cdc devices
This commit is contained in:
parent
2dd9501f37
commit
879fb21f99
@ -59,7 +59,7 @@
|
||||
</toolChain>
|
||||
</folderInfo>
|
||||
<sourceEntries>
|
||||
<entry excluding="usbd.c|usb_cdc.c|demos" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name=""/>
|
||||
<entry excluding="usbd.c|demos" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name=""/>
|
||||
</sourceEntries>
|
||||
</configuration>
|
||||
</storageModule>
|
||||
@ -454,7 +454,7 @@
|
||||
</toolChain>
|
||||
</folderInfo>
|
||||
<sourceEntries>
|
||||
<entry excluding="usbd.c|usb_cdc.c|demos" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name=""/>
|
||||
<entry excluding="usbd.c|demos" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name=""/>
|
||||
</sourceEntries>
|
||||
</configuration>
|
||||
</storageModule>
|
||||
|
@ -2,12 +2,12 @@
|
||||
* descriptors.c
|
||||
*
|
||||
* Created on: Nov 26, 2012
|
||||
* Author: hathach (thachha@live.com)
|
||||
* Author: hathach
|
||||
*/
|
||||
|
||||
/*
|
||||
* Software License Agreement (BSD License)
|
||||
* Copyright (c) 2012, hathach (thachha@live.com)
|
||||
* Copyright (c) 2012, hathach (tinyusb.net)
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
@ -130,7 +130,7 @@ ATTR_ALIGNED(4) const USB_DEVICE_DESCRIPTOR USB_DeviceDescriptor =
|
||||
.bDeviceClass = USB_DEVICE_CLASS_IAD,
|
||||
.bDeviceSubClass = USB_DEVICE_SUBCLASS_IAD,
|
||||
.bDeviceProtocol = USB_DEVICE_PROTOCOL_IAD,
|
||||
#elif defined CFG_USB_CDC
|
||||
#elif defined CFG_CLASS_CDC
|
||||
.bDeviceClass = CDC_COMMUNICATION_INTERFACE_CLASS,
|
||||
.bDeviceSubClass = 0x00,
|
||||
.bDeviceProtocol = 0x00,
|
||||
@ -187,7 +187,7 @@ ATTR_ALIGNED(4) const USB_FS_CONFIGURATION_DESCRIPTOR USB_FsConfigDescriptor =
|
||||
},
|
||||
#endif
|
||||
|
||||
#ifdef CFG_USB_CDC
|
||||
#ifdef CFG_CLASS_CDC
|
||||
// USB CDC Serial Interface
|
||||
// CDC Control Interface
|
||||
.CDC_CCI_Interface =
|
||||
|
@ -2,13 +2,8 @@
|
||||
* descriptors.h
|
||||
*
|
||||
* Created on: Nov 26, 2012
|
||||
* Author: hathach (thachha@live.com)
|
||||
*/
|
||||
|
||||
/*
|
||||
* Software License Agreement (BSD License)
|
||||
* Copyright (c) 2012, hathach (thachha@live.com)
|
||||
* All rights reserved.
|
||||
* Author: hathachtware License Agreement (BSD License)
|
||||
* Copyright (c) 2012, hathach (tinyusb.net)All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
@ -88,9 +83,9 @@ typedef PRE_PACK struct POST_PACK _USB_INTERFACE_ASSOCIATION_DESCRIPTOR
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
// Interface Assosication Descriptor if device is CDC + other class
|
||||
#define IAD_DESC_REQUIRED ( defined(CFG_USB_CDC) && (CLASS_HID) )
|
||||
#define IAD_DESC_REQUIRED ( defined(CFG_CLASS_CDC) && (CLASS_HID) )
|
||||
|
||||
#ifdef CFG_USB_CDC
|
||||
#ifdef CFG_CLASS_CDC
|
||||
#define INTERFACES_OF_CDC 2
|
||||
#else
|
||||
#define INTERFACES_OF_CDC 0
|
||||
@ -142,7 +137,7 @@ typedef struct
|
||||
USB_INTERFACE_ASSOCIATION_DESCRIPTOR CDC_IAD;
|
||||
#endif
|
||||
|
||||
#ifdef CFG_USB_CDC
|
||||
#ifdef CFG_CLASS_CDC
|
||||
//CDC - Serial
|
||||
//CDC Control Interface
|
||||
USB_INTERFACE_DESCRIPTOR CDC_CCI_Interface;
|
||||
|
@ -40,20 +40,53 @@ int main(void)
|
||||
lastSecond = currentSecond;
|
||||
GPIOSetBitValue(CFG_LED_PORT, CFG_LED_PIN, lastSecond % 2);
|
||||
|
||||
#if !defined(CFG_USB_CDC)
|
||||
#ifndef CFG_CLASS_CDC
|
||||
if (usb_isConfigured())
|
||||
{
|
||||
#ifdef CFG_CLASS_HID_KEYBOARD
|
||||
uint8_t keys[6] = {HID_USAGE_KEYBOARD_aA};
|
||||
usb_hid_keyboard_sendKeys(0x00, keys, 1);
|
||||
tusb_hid_keyboard_sendKeys(0x00, keys, 1);
|
||||
#endif
|
||||
|
||||
#ifdef CFG_CLASS_HID_MOUSE
|
||||
usb_hid_mouse_send(0, 10, 10);
|
||||
tusb_hid_mouse_send(0, 10, 10);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef CFG_CLASS_CDC
|
||||
if (usb_isConfigured())
|
||||
{
|
||||
uint8_t cdc_char;
|
||||
if( tusb_cdc_getc(&cdc_char) )
|
||||
{
|
||||
switch (cdc_char)
|
||||
{
|
||||
#ifdef CFG_CLASS_HID_KEYBOARD
|
||||
case '1' :
|
||||
{
|
||||
uint8_t keys[6] = {HID_USAGE_KEYBOARD_aA + 'e' - 'a'};
|
||||
tusb_hid_keyboard_sendKeys(0x08, keys, 1); // windows + E --> open explorer
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
|
||||
#ifdef CFG_CLASS_HID_MOUSE
|
||||
case '2' :
|
||||
tusb_hid_mouse_send(0, 10, 10);
|
||||
break;
|
||||
#endif
|
||||
|
||||
default :
|
||||
cdc_char = toupper(cdc_char);
|
||||
tusb_cdc_putc(cdc_char);
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Software License Agreement (BSD License)
|
||||
* Copyright (c) 2012, hathach (thachha@live.com)
|
||||
* Copyright (c) 2012, hathach (tinyusb.net)
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
|
105
tinyusb/class/WinCDCdriver.inf
Normal file
105
tinyusb/class/WinCDCdriver.inf
Normal file
@ -0,0 +1,105 @@
|
||||
;************************************************************
|
||||
; Windows USB CDC ACM Setup File
|
||||
; Copyright (c) 2000 Microsoft Corporation
|
||||
|
||||
|
||||
[Version]
|
||||
Signature="$Windows NT$"
|
||||
Class=Ports
|
||||
ClassGuid={4D36E978-E325-11CE-BFC1-08002BE10318}
|
||||
Provider=%MFGNAME%
|
||||
LayoutFile=layout.inf
|
||||
CatalogFile=%MFGFILENAME%.cat
|
||||
DriverVer=11/15/2007,5.1.2600.0
|
||||
|
||||
[Manufacturer]
|
||||
%MFGNAME%=DeviceList, NTamd64
|
||||
|
||||
[DestinationDirs]
|
||||
DefaultDestDir=12
|
||||
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; Windows 2000/XP/Vista-32bit Sections
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
[DriverInstall.nt]
|
||||
include=mdmcpq.inf
|
||||
CopyFiles=DriverCopyFiles.nt
|
||||
AddReg=DriverInstall.nt.AddReg
|
||||
|
||||
[DriverCopyFiles.nt]
|
||||
usbser.sys,,,0x20
|
||||
|
||||
[DriverInstall.nt.AddReg]
|
||||
HKR,,DevLoader,,*ntkern
|
||||
HKR,,NTMPDriver,,%DRIVERFILENAME%.sys
|
||||
HKR,,EnumPropPages32,,"MsPorts.dll,SerialPortPropPageProvider"
|
||||
|
||||
[DriverInstall.nt.Services]
|
||||
AddService=usbser, 0x00000002, DriverService.nt
|
||||
|
||||
[DriverService.nt]
|
||||
DisplayName=%SERVICE%
|
||||
ServiceType=1
|
||||
StartType=3
|
||||
ErrorControl=1
|
||||
ServiceBinary=%12%\%DRIVERFILENAME%.sys
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; Vista-64bit Sections
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
[DriverInstall.NTamd64]
|
||||
include=mdmcpq.inf
|
||||
CopyFiles=DriverCopyFiles.NTamd64
|
||||
AddReg=DriverInstall.NTamd64.AddReg
|
||||
|
||||
[DriverCopyFiles.NTamd64]
|
||||
%DRIVERFILENAME%.sys,,,0x20
|
||||
|
||||
[DriverInstall.NTamd64.AddReg]
|
||||
HKR,,DevLoader,,*ntkern
|
||||
HKR,,NTMPDriver,,%DRIVERFILENAME%.sys
|
||||
HKR,,EnumPropPages32,,"MsPorts.dll,SerialPortPropPageProvider"
|
||||
|
||||
[DriverInstall.NTamd64.Services]
|
||||
AddService=usbser, 0x00000002, DriverService.NTamd64
|
||||
|
||||
[DriverService.NTamd64]
|
||||
DisplayName=%SERVICE%
|
||||
ServiceType=1
|
||||
StartType=3
|
||||
ErrorControl=1
|
||||
ServiceBinary=%12%\%DRIVERFILENAME%.sys
|
||||
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; Vendor and Product ID Definitions
|
||||
;------------------------------------------------------------------------------
|
||||
; When developing your USB device, the VID and PID used in the PC side
|
||||
; application program and the firmware on the microcontroller must match.
|
||||
; Modify the below line to use your VID and PID. Use the format as shown below.
|
||||
; Note: One INF file can be used for multiple devices with different VID and PIDs.
|
||||
; For each supported device, append ",USB\VID_xxxx&PID_yyyy" to the end of the line.
|
||||
;------------------------------------------------------------------------------
|
||||
[SourceDisksFiles]
|
||||
[SourceDisksNames]
|
||||
[DeviceList]
|
||||
%DESCRIPTION%=DriverInstall, USB\VID_1FC9&PID_2001, USB\VID_1FC9&PID_2003&MI_00, USB\VID_1FC9&PID_2005&MI_00, USB\VID_1FC9&PID_2007&MI_00
|
||||
|
||||
[DeviceList.NTamd64]
|
||||
%DESCRIPTION%=DriverInstall, USB\VID_1FC9&PID_2001, USB\VID_1FC9&PID_2003&MI_00, USB\VID_1FC9&PID_2005&MI_00, USB\VID_1FC9&PID_2007&MI_00
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; String Definitions
|
||||
;------------------------------------------------------------------------------
|
||||
;Modify these strings to customize your device
|
||||
;------------------------------------------------------------------------------
|
||||
[Strings]
|
||||
MFGFILENAME="CDC_vista"
|
||||
DRIVERFILENAME ="usbser"
|
||||
MFGNAME="tinyusb.net"
|
||||
INSTDISK="tinyUSB CDC driver"
|
||||
DESCRIPTION="Communications Port"
|
||||
SERVICE="USB RS-232 Emulation Driver"
|
325
tinyusb/class/cdc.c
Normal file
325
tinyusb/class/cdc.c
Normal file
@ -0,0 +1,325 @@
|
||||
/*
|
||||
* ${file_name}
|
||||
*
|
||||
* Created on: ${date}
|
||||
* Author: hathach
|
||||
*/
|
||||
|
||||
/*
|
||||
* Software License Agreement (BSD License)
|
||||
* Copyright (c) 2012, hathach (tinyusb.net)
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
||||
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
* OF SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the tiny usb stack.
|
||||
*/
|
||||
|
||||
#include "cdc.h"
|
||||
#include "common/fifo.h"
|
||||
|
||||
#ifdef CFG_CLASS_CDC
|
||||
|
||||
static USBD_HANDLE_T g_hCdc;
|
||||
static CDC_LINE_CODING line_coding;
|
||||
|
||||
static uint8_t qBuffer[2][CDC_BUFFER_SIZE]; /* TX and RX buffers */
|
||||
static fifo_t ffTX, ffRX;
|
||||
|
||||
void usb_cdc_recv_isr(void) ATTR_WEAK ATTR_ALIAS(usb_cdc_recv_isr_stub);
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief Stub for the optional CDC receive ISR that can be used
|
||||
to perform some action when data arrives via USB CDC
|
||||
*/
|
||||
/**************************************************************************/
|
||||
void usb_cdc_recv_isr_stub (void)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief Adds a single byte to the transmit buffer for USB CDC
|
||||
|
||||
@param[in] c
|
||||
The byte to send
|
||||
|
||||
@returns TRUE if the byte was successfully added to the TX buffer
|
||||
|
||||
@note See example for tusb_cdc_getc
|
||||
*/
|
||||
/**************************************************************************/
|
||||
bool tusb_cdc_putc(uint8_t c)
|
||||
{
|
||||
return fifo_write(&ffTX, c);
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief Reads a single byte from the USB CDC buffer
|
||||
|
||||
@param[in] c
|
||||
Pointer to the location where the byte should be written
|
||||
|
||||
@returns TRUE if a byte was read from the buffer
|
||||
|
||||
@section EXAMPLE
|
||||
|
||||
@code
|
||||
|
||||
// Convert incoming characters to upper case and send back via CDC
|
||||
if (usb_isConfigured())
|
||||
{
|
||||
uint8_t cdc_char;
|
||||
if( tusb_cdc_getc(&cdc_char) )
|
||||
{
|
||||
switch (cdc_char)
|
||||
{
|
||||
default :
|
||||
cdc_char = toupper(cdc_char);
|
||||
tusb_cdc_putc(cdc_char);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@endcode
|
||||
*/
|
||||
/**************************************************************************/
|
||||
bool tusb_cdc_getc(uint8_t *c)
|
||||
{
|
||||
ASSERT(c, false); // not empty pointer
|
||||
|
||||
return fifo_read(&ffRX, c);
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief Writes the supplied buffer to the USB CDC device
|
||||
|
||||
@param[in] buffer
|
||||
Pointer to the buffer that should be written via USB CDC
|
||||
@param[in] count
|
||||
The number of bytes to write
|
||||
|
||||
@returns The actual number of bytes sent out via USB CDC
|
||||
|
||||
@section EXAMPLE
|
||||
|
||||
@code
|
||||
|
||||
// Capture printf output (in Red Suite) and send it to USB CDC
|
||||
// (Note: With newlib this function should be renamed to _write)
|
||||
int __sys_write(int file, char *ptr, int len)
|
||||
{
|
||||
#ifdef CFG_PRINTF_USBCDC
|
||||
// Handle USB CDC output
|
||||
if (usb_isConfigured())
|
||||
{
|
||||
int length = len;
|
||||
while(length > 0)
|
||||
{
|
||||
uint16_t transferredCount;
|
||||
|
||||
transferredCount = tusb_cdc_send( (uint8_t*) ptr, length);
|
||||
ptr += transferredCount;
|
||||
length -= transferredCount;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
@endcode
|
||||
*/
|
||||
/**************************************************************************/
|
||||
uint16_t tusb_cdc_send(uint8_t* buffer, uint16_t count)
|
||||
{
|
||||
uint16_t i=0;
|
||||
|
||||
ASSERT(buffer && count, 0);
|
||||
|
||||
while (i < count && fifo_write(&ffTX, buffer[i]) )
|
||||
{
|
||||
i++;
|
||||
}
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief Reads the incoming CDC buffer up to a maximum number of bytes
|
||||
|
||||
@param[in] buffer
|
||||
Pointer to the buffer where data should be written
|
||||
@param[in] max
|
||||
The maximum number of bytes to read
|
||||
|
||||
@returns The actual number of bytes received
|
||||
*/
|
||||
/**************************************************************************/
|
||||
uint16_t tusb_cdc_recv(uint8_t* buffer, uint16_t max)
|
||||
{
|
||||
ASSERT(buffer && max, 0);
|
||||
|
||||
return fifo_readArray(&ffRX, buffer, max);
|
||||
}
|
||||
|
||||
// ROM driver bug: cannot hook this to CIC_GetRequest
|
||||
// Need this to implement GetLineCode & detect
|
||||
//ErrorCode_t CDC_Control_GetRequest(USBD_HANDLE_T hUsb, USB_SETUP_PACKET *pSetup, uint8_t **pBuffer, uint16_t *length)
|
||||
//{
|
||||
// return LPC_OK;
|
||||
//}
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief TODO Add description
|
||||
*/
|
||||
/**************************************************************************/
|
||||
ErrorCode_t CDC_SetLineCoding(USBD_HANDLE_T hUsb, CDC_LINE_CODING *lineCoding)
|
||||
{
|
||||
ASSERT(lineCoding, ERR_FAILED);
|
||||
memcpy(&line_coding, lineCoding, sizeof(CDC_LINE_CODING));
|
||||
return LPC_OK;
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief TODO Add description
|
||||
*/
|
||||
/**************************************************************************/
|
||||
ErrorCode_t CDC_SendBreak(USBD_HANDLE_T hCDC, uint16_t mstime)
|
||||
{
|
||||
return LPC_OK;
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief Bulk Out handler for the USB ROM drivers (UART TX)
|
||||
*/
|
||||
/**************************************************************************/
|
||||
ErrorCode_t CDC_BulkIn_Hdlr(USBD_HANDLE_T hUsb, void* data, uint32_t event)
|
||||
{
|
||||
if (USB_EVT_IN == event)
|
||||
{
|
||||
uint8_t buffer[CDC_DATA_EP_MAXPACKET_SIZE];
|
||||
uint16_t count;
|
||||
|
||||
count = fifo_readArray(&ffTX, buffer, CDC_DATA_EP_MAXPACKET_SIZE);
|
||||
USBD_API->hw->WriteEP(hUsb, CDC_DATA_EP_IN, buffer, count); // write data to EP
|
||||
}
|
||||
|
||||
return LPC_OK;
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief Bulk Out handler for the USB ROM drivers (UART RX)
|
||||
*/
|
||||
/**************************************************************************/
|
||||
ErrorCode_t CDC_BulkOut_Hdlr(USBD_HANDLE_T hUsb, void* data, uint32_t event)
|
||||
{
|
||||
if (USB_EVT_OUT == event)
|
||||
{
|
||||
uint16_t count, i;
|
||||
uint8_t buffer[CDC_DATA_EP_MAXPACKET_SIZE];
|
||||
|
||||
count = USBD_API->hw->ReadEP(hUsb, CDC_DATA_EP_OUT, buffer);
|
||||
for (i=0; i<count; i++)
|
||||
{
|
||||
fifo_write(&ffRX, buffer[i]);
|
||||
}
|
||||
|
||||
usb_cdc_recv_isr();
|
||||
}
|
||||
|
||||
return LPC_OK;
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief Initialises USB CDC using the ROM driver
|
||||
*/
|
||||
/**************************************************************************/
|
||||
TUSB_Error_t tusb_cdc_init(USBD_HANDLE_T hUsb, USB_INTERFACE_DESCRIPTOR const *const pControlIntfDesc, USB_INTERFACE_DESCRIPTOR const *const pDataIntfDesc, uint32_t* mem_base, uint32_t* mem_size)
|
||||
{
|
||||
USBD_CDC_INIT_PARAM_T cdc_param =
|
||||
{
|
||||
.mem_base = *mem_base,
|
||||
.mem_size = *mem_size,
|
||||
|
||||
.cif_intf_desc = (uint8_t*) pControlIntfDesc,
|
||||
.dif_intf_desc = (uint8_t*) pDataIntfDesc,
|
||||
|
||||
.SetLineCode = CDC_SetLineCoding,
|
||||
.SendBreak = CDC_SendBreak,
|
||||
|
||||
// .CIC_GetRequest = CDC_Control_GetRequest, // bug from romdrive cannot hook to this handler
|
||||
// Bug from ROM driver: can not hook bulk in & out handler here, must use USBD API register instead
|
||||
// .CDC_BulkIN_Hdlr = CDC_BulkIn_Hdlr,
|
||||
// .CDC_BulkOUT_Hdlr = CDC_BulkOut_Hdlr,
|
||||
};
|
||||
|
||||
ASSERT (pControlIntfDesc && pDataIntfDesc, ERR_FAILED);
|
||||
|
||||
/* register Bulk IN & OUT endpoint interrupt handler */
|
||||
ASSERT ( LPC_OK == USBD_API->core->RegisterEpHandler (hUsb , ((CDC_DATA_EP_IN & 0x0F) << 1) +1 , CDC_BulkIn_Hdlr , NULL), tERROR_FAILED );
|
||||
ASSERT ( LPC_OK == USBD_API->core->RegisterEpHandler (hUsb , (CDC_DATA_EP_OUT & 0x0F) << 1 , CDC_BulkOut_Hdlr , NULL), tERROR_FAILED );
|
||||
|
||||
ASSERT ( LPC_OK == USBD_API->cdc->init(hUsb, &cdc_param, &g_hCdc), tERROR_FAILED);
|
||||
|
||||
/* update memory variables */
|
||||
*mem_base = cdc_param.mem_base;
|
||||
*mem_size = cdc_param.mem_size;
|
||||
|
||||
return tERROR_NONE;
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief TODO Add description
|
||||
*/
|
||||
/**************************************************************************/
|
||||
TUSB_Error_t tusb_cdc_configured(USBD_HANDLE_T hUsb)
|
||||
{
|
||||
uint8_t dummy=0;
|
||||
USBD_API->hw->WriteEP(hUsb, CDC_DATA_EP_IN, &dummy, 1); // initial packet for IN endpoint, will not work if omitted
|
||||
|
||||
// #if defined CFG_MCU_FAMILY_LPC11UXX
|
||||
// fifo_init (&ffTX, qBuffer[0], CDC_BUFFER_SIZE, false, USB_IRQn); // TX is non-overwritable
|
||||
// fifo_init (&ffRX, qBuffer[1], CDC_BUFFER_SIZE, true, USB_IRQn); // RX is overwritable
|
||||
// #elif defined CFG_MCU_FAMILY_LPC13UXX
|
||||
fifo_init (&ffTX, qBuffer[0], CDC_BUFFER_SIZE, false, USB_IRQ_IRQn); // TX is non-overwritable
|
||||
fifo_init (&ffRX, qBuffer[1], CDC_BUFFER_SIZE, true, USB_IRQ_IRQn); // RX is overwritable
|
||||
// #else
|
||||
// #error "usb_cdc.c: No MCU defined"
|
||||
// #endif
|
||||
|
||||
return tERROR_NONE;
|
||||
}
|
||||
|
||||
#endif
|
113
tinyusb/class/cdc.h
Normal file
113
tinyusb/class/cdc.h
Normal file
@ -0,0 +1,113 @@
|
||||
/*
|
||||
* cdc.h
|
||||
*
|
||||
* Created on: Nov 27, 2012
|
||||
* Author: hathach
|
||||
*/
|
||||
|
||||
/*
|
||||
* Software License Agreement (BSD License)
|
||||
* Copyright (c) 2012, hathach (tinyusb.net)
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
||||
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
* OF SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the tiny usb stack.
|
||||
*/
|
||||
|
||||
/** \file
|
||||
* \brief CDC Class Driver
|
||||
*
|
||||
* \note TBD
|
||||
*/
|
||||
|
||||
/** \ingroup Group_TinyUSB
|
||||
* \addtogroup Group_ClassDriver Class Driver
|
||||
* @{
|
||||
* \defgroup Group_CDC Communication Device Class
|
||||
* @{
|
||||
*/
|
||||
|
||||
#ifndef _TUSB_CDC_H__
|
||||
#define _TUSB_CDC_H__
|
||||
|
||||
// todo refractor later
|
||||
#include "common/common.h"
|
||||
#include "device/dcd.h"
|
||||
|
||||
#define CDC_BUFFER_SIZE (2*CDC_DATA_EP_MAXPACKET_SIZE)
|
||||
|
||||
/** \brief send a character to host
|
||||
*
|
||||
* \param[in] para1
|
||||
* \param[out] para2
|
||||
* \return Error Code of the \ref TUSB_ERROR enum
|
||||
* \note
|
||||
*/
|
||||
bool tusb_cdc_putc(uint8_t c);
|
||||
|
||||
/** \brief get a character from host
|
||||
*
|
||||
* \param[in] para1
|
||||
* \param[out] para2
|
||||
* \return Error Code of the \ref TUSB_ERROR enum
|
||||
* \note
|
||||
*/
|
||||
bool tusb_cdc_getc(uint8_t *c);
|
||||
|
||||
/** \brief send a number of characters to host
|
||||
*
|
||||
* \param[in] para1
|
||||
* \param[out] para2
|
||||
* \return Error Code of the \ref TUSB_ERROR enum
|
||||
* \note
|
||||
*/
|
||||
uint16_t tusb_cdc_send(uint8_t* buffer, uint16_t count);
|
||||
|
||||
/** \brief get a number of characters from host
|
||||
*
|
||||
* \param[in] para1
|
||||
* \param[out] para2
|
||||
* \return Error Code of the \ref TUSB_ERROR enum
|
||||
* \note
|
||||
*/
|
||||
uint16_t tusb_cdc_recv(uint8_t* buffer, uint16_t max);
|
||||
|
||||
/** \brief initialize cdc driver
|
||||
*
|
||||
* \param[in] para1
|
||||
* \param[out] para2
|
||||
* \return Error Code of the \ref TUSB_ERROR enum
|
||||
* \note
|
||||
*/
|
||||
TUSB_Error_t tusb_cdc_init(USBD_HANDLE_T hUsb, USB_INTERFACE_DESCRIPTOR const *const pControlIntfDesc, USB_INTERFACE_DESCRIPTOR const *const pDataIntfDesc, uint32_t* mem_base, uint32_t* mem_size);
|
||||
|
||||
/** \brief notify cdc driver that usb is configured
|
||||
*
|
||||
* \param[in] para1
|
||||
* \param[out] para2
|
||||
* \return Error Code of the \ref TUSB_ERROR enum
|
||||
* \note
|
||||
*/
|
||||
TUSB_Error_t tusb_cdc_configured(USBD_HANDLE_T hUsb);
|
||||
#endif
|
@ -2,12 +2,12 @@
|
||||
* hid.c
|
||||
*
|
||||
* Created on: Nov 27, 2012
|
||||
* Author: hathach (thachha@live.com)
|
||||
* Author: hathach
|
||||
*/
|
||||
|
||||
/*
|
||||
* Software License Agreement (BSD License)
|
||||
* Copyright (c) 2012, hathach (thachha@live.com)
|
||||
* Copyright (c) 2012, hathach (tinyusb.net)
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
@ -179,7 +179,7 @@ ErrorCode_t HID_EpOut_Hdlr (USBD_HANDLE_T hUsb, void* data, uint32_t event)
|
||||
@brief Initialises USB HID using the ROM based drivers
|
||||
*/
|
||||
/**************************************************************************/
|
||||
TUSB_Error_t usb_hid_init(USBD_HANDLE_T hUsb, USB_INTERFACE_DESCRIPTOR const *const pIntfDesc, uint8_t const * const pHIDReportDesc, uint32_t ReportDescLength, uint32_t* mem_base, uint32_t* mem_size)
|
||||
TUSB_Error_t tusb_hid_init(USBD_HANDLE_T hUsb, USB_INTERFACE_DESCRIPTOR const *const pIntfDesc, uint8_t const * const pHIDReportDesc, uint32_t ReportDescLength, uint32_t* mem_base, uint32_t* mem_size)
|
||||
{
|
||||
USB_HID_REPORT_T reports_data =
|
||||
{
|
||||
@ -220,7 +220,7 @@ TUSB_Error_t usb_hid_init(USBD_HANDLE_T hUsb, USB_INTERFACE_DESCRIPTOR const *co
|
||||
|
||||
*/
|
||||
/**************************************************************************/
|
||||
TUSB_Error_t usb_hid_configured(USBD_HANDLE_T hUsb)
|
||||
TUSB_Error_t tusb_hid_configured(USBD_HANDLE_T hUsb)
|
||||
{
|
||||
#ifdef CFG_CLASS_HID_KEYBOARD
|
||||
USBD_API->hw->WriteEP(hUsb , HID_KEYBOARD_EP_IN , (uint8_t* ) &hid_keyboard_report , sizeof(USB_HID_KeyboardReport_t) ); // initial packet for IN endpoint , will not work if omitted
|
||||
@ -257,20 +257,20 @@ TUSB_Error_t usb_hid_configured(USBD_HANDLE_T hUsb)
|
||||
if (usb_isConfigured())
|
||||
{
|
||||
uint8_t keys[6] = {HID_USAGE_KEYBOARD_aA};
|
||||
usb_hid_keyboard_sendKeys(0x00, keys, 1);
|
||||
tusb_hid_keyboard_sendKeys(0x00, keys, 1);
|
||||
}
|
||||
|
||||
// Send Windows + 'e' (shortcut for 'explorer.exe')
|
||||
if (usb_isConfigured())
|
||||
{
|
||||
uint8_t keys[6] = {HID_USAGE_KEYBOARD_aA + 'e' - 'a'};
|
||||
usb_hid_keyboard_sendKeys((1<<HID_KEYMODIFIER_LEFTGUI), keys, 1);
|
||||
tusb_hid_keyboard_sendKeys((1<<HID_KEYMODIFIER_LEFTGUI), keys, 1);
|
||||
}
|
||||
|
||||
@endcode
|
||||
*/
|
||||
/**************************************************************************/
|
||||
TUSB_Error_t usb_hid_keyboard_sendKeys(uint8_t modifier, uint8_t keycodes[], uint8_t numkey)
|
||||
TUSB_Error_t tusb_hid_keyboard_sendKeys(uint8_t modifier, uint8_t keycodes[], uint8_t numkey)
|
||||
{
|
||||
// uint32_t start_time = systickGetSecondsActive();
|
||||
// while (bKeyChanged) // TODO blocking while previous key has yet sent - can use fifo to improve this
|
||||
@ -315,13 +315,13 @@ TUSB_Error_t usb_hid_keyboard_sendKeys(uint8_t modifier, uint8_t keycodes[], uin
|
||||
if (usb_isConfigured())
|
||||
{
|
||||
// Move the mouse +10 in the X direction and + 10 in the Y direction
|
||||
usb_hid_mouse_send(0x00, 10, 10);
|
||||
tusb_hid_mouse_send(0x00, 10, 10);
|
||||
}
|
||||
|
||||
@endcode
|
||||
*/
|
||||
/**************************************************************************/
|
||||
TUSB_Error_t usb_hid_mouse_send(uint8_t buttons, int8_t x, int8_t y)
|
||||
TUSB_Error_t tusb_hid_mouse_send(uint8_t buttons, int8_t x, int8_t y)
|
||||
{
|
||||
// uint32_t start_time = systickGetSecondsActive();
|
||||
// while (bMouseChanged) // TODO Block while previous key hasn't been sent - can use fifo to improve this
|
||||
|
@ -2,12 +2,12 @@
|
||||
* hid.h
|
||||
*
|
||||
* Created on: Nov 27, 2012
|
||||
* Author: hathach (thachha@live.com)
|
||||
* Author: hathach
|
||||
*/
|
||||
|
||||
/*
|
||||
* Software License Agreement (BSD License)
|
||||
* Copyright (c) 2012, hathach (thachha@live.com)
|
||||
* Copyright (c) 2012, hathach (tinyusb.net)
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
@ -152,11 +152,41 @@ enum USB_HID_LOCAL_CODE
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
TUSB_Error_t usb_hid_init(USBD_HANDLE_T hUsb, USB_INTERFACE_DESCRIPTOR const *const pIntfDesc, uint8_t const * const pHIDReportDesc, uint32_t ReportDescLength, uint32_t* mem_base, uint32_t* mem_size) ATTR_NON_NULL;
|
||||
TUSB_Error_t usb_hid_configured(USBD_HANDLE_T hUsb);
|
||||
/** \brief Initialize HID driver
|
||||
*
|
||||
* \param[in] para1
|
||||
* \param[out] para2
|
||||
* \return Error Code of the \ref TUSB_ERROR enum
|
||||
* \note
|
||||
*/
|
||||
TUSB_Error_t tusb_hid_init(USBD_HANDLE_T hUsb, USB_INTERFACE_DESCRIPTOR const *const pIntfDesc, uint8_t const * const pHIDReportDesc, uint32_t ReportDescLength, uint32_t* mem_base, uint32_t* mem_size) ATTR_NON_NULL;
|
||||
|
||||
TUSB_Error_t usb_hid_keyboard_sendKeys(uint8_t modifier, uint8_t keycodes[], uint8_t numkey) ATTR_NON_NULL;
|
||||
TUSB_Error_t usb_hid_mouse_send(uint8_t buttons, int8_t x, int8_t y);
|
||||
/** \brief Notify HID class that usb is configured
|
||||
*
|
||||
* \param[in] para1
|
||||
* \param[out] para2
|
||||
* \return Error Code of the \ref TUSB_ERROR enum
|
||||
* \note
|
||||
*/
|
||||
TUSB_Error_t tusb_hid_configured(USBD_HANDLE_T hUsb);
|
||||
|
||||
/** \brief Used by Application to send Keycode to Host
|
||||
*
|
||||
* \param[in] para1
|
||||
* \param[out] para2
|
||||
* \return Error Code of the \ref TUSB_ERROR enum
|
||||
* \note
|
||||
*/
|
||||
TUSB_Error_t tusb_hid_keyboard_sendKeys(uint8_t modifier, uint8_t keycodes[], uint8_t numkey) ATTR_NON_NULL;
|
||||
|
||||
/** \brief
|
||||
*
|
||||
* \param[in] para1
|
||||
* \param[out] para2
|
||||
* \return Error Code of the \ref TUSB_ERROR enum
|
||||
* \note
|
||||
*/
|
||||
TUSB_Error_t tusb_hid_mouse_send(uint8_t buttons, int8_t x, int8_t y);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -7,7 +7,7 @@
|
||||
|
||||
/*
|
||||
* Software License Agreement (BSD License)
|
||||
* Copyright (c) 2012, hathach (thachha@live.com)
|
||||
* Copyright (c) 2012, hathach (tinyusb.net)
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
|
60
tinyusb/common/arch/arch_lpc11xx.h
Normal file
60
tinyusb/common/arch/arch_lpc11xx.h
Normal file
@ -0,0 +1,60 @@
|
||||
/*
|
||||
* arch_lpc11xx.h
|
||||
*
|
||||
* Created on: Nov 29, 2012
|
||||
* Author: hathach
|
||||
*/
|
||||
|
||||
/*
|
||||
* Software License Agreement (BSD License)
|
||||
* Copyright (c) 2012, hathach (tinyusb.net)
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
||||
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
* OF SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the tiny usb stack.
|
||||
*/
|
||||
|
||||
/** \file
|
||||
* \brief LPC11xx Header File
|
||||
*
|
||||
* \note TBD
|
||||
*/
|
||||
|
||||
/** \ingroup Group_Arch
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
#ifndef ARCH_LPC11XX_H_
|
||||
#define ARCH_LPC11XX_H_
|
||||
|
||||
#define ARM_M0
|
||||
#define DEVICE_ROMDRIVER
|
||||
|
||||
#include "arm_mx.h"
|
||||
#include "LPC11Uxx.h"
|
||||
|
||||
#endif /* ARCH_LPC11XX_H_ */
|
||||
|
||||
/** @} */
|
@ -2,12 +2,12 @@
|
||||
* arch_lpc134x.h
|
||||
*
|
||||
* Created on: Nov 26, 2012
|
||||
* Author: hathach (thachha@live.com)
|
||||
* Author: hathach
|
||||
*/
|
||||
|
||||
/*
|
||||
* Software License Agreement (BSD License)
|
||||
* Copyright (c) 2012, hathach (thachha@live.com)
|
||||
* Copyright (c) 2012, hathach (tinyusb.net)
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
|
@ -2,12 +2,12 @@
|
||||
* arch_lpc43xx.h
|
||||
*
|
||||
* Created on: Nov 26, 2012
|
||||
* Author: hathach (thachha@live.com)
|
||||
* Author: hathach
|
||||
*/
|
||||
|
||||
/*
|
||||
* Software License Agreement (BSD License)
|
||||
* Copyright (c) 2012, hathach (thachha@live.com)
|
||||
* Copyright (c) 2012, hathach (tinyusb.net)
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
|
@ -2,12 +2,12 @@
|
||||
* arm_mx.h
|
||||
*
|
||||
* Created on: Nov 26, 2012
|
||||
* Author: hathach (thachha@live.com)
|
||||
* Author: hathach
|
||||
*/
|
||||
|
||||
/*
|
||||
* Software License Agreement (BSD License)
|
||||
* Copyright (c) 2012, hathach (thachha@live.com)
|
||||
* Copyright (c) 2012, hathach (tinyusb.net)
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
|
@ -2,12 +2,12 @@
|
||||
* common.h
|
||||
*
|
||||
* Created on: Nov 26, 2012
|
||||
* Author: hathach (thachha@live.com)
|
||||
* Author: hathach
|
||||
*/
|
||||
|
||||
/*
|
||||
* Software License Agreement (BSD License)
|
||||
* Copyright (c) 2012, hathach (thachha@live.com)
|
||||
* Copyright (c) 2012, hathach (tinyusb.net)
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
|
@ -2,12 +2,12 @@
|
||||
* compiler.h
|
||||
*
|
||||
* Created on: Nov 26, 2012
|
||||
* Author: hathach (thachha@live.com)
|
||||
* Author: hathach
|
||||
*/
|
||||
|
||||
/*
|
||||
* Software License Agreement (BSD License)
|
||||
* Copyright (c) 2012, hathach (thachha@live.com)
|
||||
* Copyright (c) 2012, hathach (tinyusb.net)
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
|
@ -2,12 +2,12 @@
|
||||
* compiler_gcc.h
|
||||
*
|
||||
* Created on: Nov 26, 2012
|
||||
* Author: hathach (thachha@live.com)
|
||||
* Author: hathach
|
||||
*/
|
||||
|
||||
/*
|
||||
* Software License Agreement (BSD License)
|
||||
* Copyright (c) 2012, hathach (thachha@live.com)
|
||||
* Copyright (c) 2012, hathach (tinyusb.net)
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
@ -103,7 +103,7 @@
|
||||
/// The alias attribute causes the declaration to be emitted as an alias for another symbol, which must be specified
|
||||
#define ATTR_ALIAS(func) __attribute__ ((alias(#func)))
|
||||
|
||||
/// The weakref attribute marks a declaration as a weak reference. It is equivalent with weak + alias attribute
|
||||
/// The weakref attribute marks a declaration as a weak reference. It is equivalent with weak + alias attribute, but require function is static
|
||||
#define ATTR_WEAKREF(func) __attribute__ ((weakref(#func)))
|
||||
|
||||
/// The warn_unused_result attribute causes a warning to be emitted if a caller of the function with this attribute does not use its return value. This is useful for functions where not checking the result is either a security problem or always a bug
|
||||
|
@ -2,12 +2,12 @@
|
||||
* errors.c
|
||||
*
|
||||
* Created on: Nov 27, 2012
|
||||
* Author: hathach (thachha@live.com)
|
||||
* Author: hathach
|
||||
*/
|
||||
|
||||
/*
|
||||
* Software License Agreement (BSD License)
|
||||
* Copyright (c) 2012, hathach (thachha@live.com)
|
||||
* Copyright (c) 2012, hathach (tinyusb.net)
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
|
@ -2,12 +2,12 @@
|
||||
* errors.h
|
||||
*
|
||||
* Created on: Nov 27, 2012
|
||||
* Author: hathach (thachha@live.com)
|
||||
* Author: hathach
|
||||
*/
|
||||
|
||||
/*
|
||||
* Software License Agreement (BSD License)
|
||||
* Copyright (c) 2012, hathach (thachha@live.com)
|
||||
* Copyright (c) 2012, hathach (tinyusb.net)
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
|
@ -2,12 +2,12 @@
|
||||
* errors_def
|
||||
*
|
||||
* Created on: Nov 27, 2012
|
||||
* Author: hathach (thachha@live.com)
|
||||
* Author: hathach
|
||||
*/
|
||||
|
||||
/*
|
||||
* Software License Agreement (BSD License)
|
||||
* Copyright (c) 2012, hathach (thachha@live.com)
|
||||
* Copyright (c) 2012, hathach (tinyusb.net)
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
|
@ -2,12 +2,12 @@
|
||||
* fifo.c
|
||||
*
|
||||
* Created on: Nov 27, 2012
|
||||
* Author: hathach (thachha@live.com)
|
||||
* Author: hathach
|
||||
*/
|
||||
|
||||
/*
|
||||
* Software License Agreement (BSD License)
|
||||
* Copyright (c) 2012, hathach (thachha@live.com)
|
||||
* Copyright (c) 2012, hathach (tinyusb.net)
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
|
@ -2,12 +2,12 @@
|
||||
* fifo.h
|
||||
*
|
||||
* Created on: Nov 27, 2012
|
||||
* Author: hathach (thachha@live.com)
|
||||
* Author: hathach
|
||||
*/
|
||||
|
||||
/*
|
||||
* Software License Agreement (BSD License)
|
||||
* Copyright (c) 2012, hathach (thachha@live.com)
|
||||
* Copyright (c) 2012, hathach (tinyusb.net)
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
|
@ -2,12 +2,12 @@
|
||||
* dcd.c
|
||||
*
|
||||
* Created on: Nov 27, 2012
|
||||
* Author: hathach (thachha@live.com)
|
||||
* Author: hathach
|
||||
*/
|
||||
|
||||
/*
|
||||
* Software License Agreement (BSD License)
|
||||
* Copyright (c) 2012, hathach (thachha@live.com)
|
||||
* Copyright (c) 2012, hathach (tinyusb.net)
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
@ -60,11 +60,11 @@ ErrorCode_t USB_Configure_Event (USBD_HANDLE_T hUsb)
|
||||
if (pCtrl->config_value)
|
||||
{
|
||||
#if defined(CLASS_HID)
|
||||
ASSERT( tERROR_NONE == usb_hid_configured(hUsb), ERR_FAILED );
|
||||
ASSERT( tERROR_NONE == tusb_hid_configured(hUsb), ERR_FAILED );
|
||||
#endif
|
||||
|
||||
#ifdef CFG_USB_CDC
|
||||
ASSERT_STATUS( usb_cdc_configured(hUsb) );
|
||||
#ifdef CFG_CLASS_CDC
|
||||
ASSERT( tERROR_NONE == tusb_cdc_configured(hUsb), ERR_FAILED );
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -118,18 +118,18 @@ TUSB_Error_t dcd_init()
|
||||
|
||||
/* Initialise the class driver(s) */
|
||||
#ifdef CFG_CLASS_CDC
|
||||
ASSERT_ERROR( usb_cdc_init(g_hUsb, &USB_FsConfigDescriptor.CDC_CCI_Interface,
|
||||
ASSERT_ERROR( tusb_cdc_init(g_hUsb, &USB_FsConfigDescriptor.CDC_CCI_Interface,
|
||||
&USB_FsConfigDescriptor.CDC_DCI_Interface, &membase, &memsize) );
|
||||
#endif
|
||||
|
||||
#ifdef CFG_CLASS_HID_KEYBOARD
|
||||
ASSERT_ERROR( usb_hid_init(g_hUsb , &USB_FsConfigDescriptor.HID_KeyboardInterface ,
|
||||
ASSERT_ERROR( tusb_hid_init(g_hUsb , &USB_FsConfigDescriptor.HID_KeyboardInterface ,
|
||||
HID_KeyboardReportDescriptor, USB_FsConfigDescriptor.HID_KeyboardHID.DescriptorList[0].wDescriptorLength,
|
||||
&membase , &memsize) );
|
||||
#endif
|
||||
|
||||
#ifdef CFG_CLASS_HID_MOUSE
|
||||
ASSERT_ERROR( usb_hid_init(g_hUsb , &USB_FsConfigDescriptor.HID_MouseInterface ,
|
||||
ASSERT_ERROR( tusb_hid_init(g_hUsb , &USB_FsConfigDescriptor.HID_MouseInterface ,
|
||||
HID_MouseReportDescriptor, USB_FsConfigDescriptor.HID_MouseHID.DescriptorList[0].wDescriptorLength,
|
||||
&membase , &memsize) );
|
||||
#endif
|
||||
|
@ -2,12 +2,12 @@
|
||||
* dcd.h
|
||||
*
|
||||
* Created on: Nov 26, 2012
|
||||
* Author: hathach (thachha@live.com)
|
||||
* Author: hathach
|
||||
*/
|
||||
|
||||
/*
|
||||
* Software License Agreement (BSD License)
|
||||
* Copyright (c) 2012, hathach (thachha@live.com)
|
||||
* Copyright (c) 2012, hathach (tinyusb.net)
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
|
@ -2,12 +2,12 @@
|
||||
* hcd.c
|
||||
*
|
||||
* Created on: Nov 29, 2012
|
||||
* Author: hathach (thachha@live.com)
|
||||
* Author: hathach
|
||||
*/
|
||||
|
||||
/*
|
||||
* Software License Agreement (BSD License)
|
||||
* Copyright (c) 2012, hathach (thachha@live.com)
|
||||
* Copyright (c) 2012, hathach (tinyusb.net)
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
|
@ -2,12 +2,12 @@
|
||||
* hcd.h
|
||||
*
|
||||
* Created on: Nov 26, 2012
|
||||
* Author: hathach (thachha@live.com)
|
||||
* Author: hathach
|
||||
*/
|
||||
|
||||
/*
|
||||
* Software License Agreement (BSD License)
|
||||
* Copyright (c) 2012, hathach (thachha@live.com)
|
||||
* Copyright (c) 2012, hathach (tinyusb.net)
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
|
@ -2,12 +2,12 @@
|
||||
* tusb.c
|
||||
*
|
||||
* Created on: Nov 27, 2012
|
||||
* Author: hathach (thachha@live.com)
|
||||
* Author: hathach
|
||||
*/
|
||||
|
||||
/*
|
||||
* Software License Agreement (BSD License)
|
||||
* Copyright (c) 2012, hathach (thachha@live.com)
|
||||
* Copyright (c) 2012, hathach (tinyusb.net)
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
|
@ -2,12 +2,12 @@
|
||||
* tusb.h
|
||||
*
|
||||
* Created on: Nov 27, 2012
|
||||
* Author: hathach (thachha@live.com)
|
||||
* Author: hathach
|
||||
*/
|
||||
|
||||
/*
|
||||
* Software License Agreement (BSD License)
|
||||
* Copyright (c) 2012, hathach (thachha@live.com)
|
||||
* Copyright (c) 2012, hathach (tinyusb.net)
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
@ -68,6 +68,10 @@
|
||||
#include "class/hid.h"
|
||||
#endif
|
||||
|
||||
#ifdef CFG_CLASS_CDC
|
||||
#include "class/cdc.h"
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -2,12 +2,12 @@
|
||||
* tusb_cfg.h
|
||||
*
|
||||
* Created on: Nov 26, 2012
|
||||
* Author: hathach (thachha@live.com)
|
||||
* Author: hathach
|
||||
*/
|
||||
|
||||
/*
|
||||
* Software License Agreement (BSD License)
|
||||
* Copyright (c) 2012, hathach (thachha@live.com)
|
||||
* Copyright (c) 2012, hathach (tinyusb.net)
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
@ -58,6 +58,9 @@
|
||||
/// Enable Device Support
|
||||
#define CFG_TUSB_DEVICE
|
||||
|
||||
/// Enable CDC Support
|
||||
#define CFG_CLASS_CDC
|
||||
|
||||
/// Enable HID Keyboard support
|
||||
#define CFG_CLASS_HID_KEYBOARD
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user