git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@3260 35acf78f-673a-0410-8e92-d51de3d6d3f4

master
gdisirio 2011-08-28 12:55:02 +00:00
parent 8f5830dad8
commit 339cbbd60e
5 changed files with 32 additions and 22 deletions

View File

@ -33,6 +33,10 @@
/* Driver constants. */ /* Driver constants. */
/*===========================================================================*/ /*===========================================================================*/
/**
* @name CDC specific messages.
* @{
*/
#define CDC_SEND_ENCAPSULATED_COMMAND 0x00 #define CDC_SEND_ENCAPSULATED_COMMAND 0x00
#define CDC_GET_ENCAPSULATED_RESPONSE 0x01 #define CDC_GET_ENCAPSULATED_RESPONSE 0x01
#define CDC_SET_COMM_FEATURE 0x02 #define CDC_SET_COMM_FEATURE 0x02
@ -52,7 +56,12 @@
#define CDC_GET_RINGER_PARMS 0x31 #define CDC_GET_RINGER_PARMS 0x31
#define CDC_SET_OPERATION_PARMS 0x32 #define CDC_SET_OPERATION_PARMS 0x32
#define CDC_GET_OPERATION_PARMS 0x33 #define CDC_GET_OPERATION_PARMS 0x33
/** @} */
/**
* @name Line Control bit definitions.
* @{
*/
#define LC_STOP_1 0 #define LC_STOP_1 0
#define LC_STOP_1P5 1 #define LC_STOP_1P5 1
#define LC_STOP_2 2 #define LC_STOP_2 2
@ -62,6 +71,7 @@
#define LC_PARITY_EVEN 2 #define LC_PARITY_EVEN 2
#define LC_PARITY_MARK 3 #define LC_PARITY_MARK 3
#define LC_PARITY_SPACE 4 #define LC_PARITY_SPACE 4
/** @} */
/*===========================================================================*/ /*===========================================================================*/
/* Driver pre-compile time settings. */ /* Driver pre-compile time settings. */
@ -74,22 +84,22 @@
/** /**
* @brief Endpoint number for bulk IN. * @brief Endpoint number for bulk IN.
*/ */
#if !defined(DATA_REQUEST_EP) || defined(__DOXYGEN__) #if !defined(USB_CDC_DATA_REQUEST_EP) || defined(__DOXYGEN__)
#define DATA_REQUEST_EP 1 #define USB_CDC_DATA_REQUEST_EP 1
#endif #endif
/** /**
* @brief Endpoint number for interrupt IN. * @brief Endpoint number for interrupt IN.
*/ */
#if !defined(INTERRUPT_REQUEST_EP) || defined(__DOXYGEN__) #if !defined(USB_CDC_INTERRUPT_REQUEST_EP) || defined(__DOXYGEN__)
#define INTERRUPT_REQUEST_EP 2 #define USB_CDC_INTERRUPT_REQUEST_EP 2
#endif #endif
/** /**
* @brief Endpoint number for bulk OUT. * @brief Endpoint number for bulk OUT.
*/ */
#if !defined(DATA_AVAILABLE_EP) || defined(__DOXYGEN__) #if !defined(USB_CDC_DATA_AVAILABLE_EP) || defined(__DOXYGEN__)
#define DATA_AVAILABLE_EP 3 #define USB_CDC_DATA_AVAILABLE_EP 3
#endif #endif
/** @} */ /** @} */

View File

@ -105,7 +105,7 @@ static uint32_t pm_alloc(USBDriver *usbp, size_t size) {
next = usbp->pmnext; next = usbp->pmnext;
usbp->pmnext += size; usbp->pmnext += size;
chDbgAssert(usbp->pmnext > USB_PMA_SIZE, "pm_alloc(), #1", "PMA overflow"); chDbgAssert(usbp->pmnext <= USB_PMA_SIZE, "pm_alloc(), #1", "PMA overflow");
return next; return next;
} }

View File

@ -124,7 +124,7 @@ static void inotify(GenericQueue *qp) {
emptied, then a whole packet is loaded in the queue.*/ emptied, then a whole packet is loaded in the queue.*/
if (chIQIsEmptyI(&sdup->iqueue)) { if (chIQIsEmptyI(&sdup->iqueue)) {
n = usbReadPacketI(sdup->config->usbp, DATA_AVAILABLE_EP, n = usbReadPacketI(sdup->config->usbp, USB_CDC_DATA_AVAILABLE_EP,
sdup->iqueue.q_buffer, SERIAL_USB_BUFFERS_SIZE); sdup->iqueue.q_buffer, SERIAL_USB_BUFFERS_SIZE);
if (n != USB_ENDPOINT_BUSY) { if (n != USB_ENDPOINT_BUSY) {
chIOAddFlagsI(sdup, IO_INPUT_AVAILABLE); chIOAddFlagsI(sdup, IO_INPUT_AVAILABLE);
@ -146,7 +146,7 @@ static void onotify(GenericQueue *qp) {
/* If there is any data in the output queue then it is sent within a /* If there is any data in the output queue then it is sent within a
single packet and the queue is emptied.*/ single packet and the queue is emptied.*/
n = chOQGetFullI(&sdup->oqueue); n = chOQGetFullI(&sdup->oqueue);
w = usbWritePacketI(sdup->config->usbp, DATA_REQUEST_EP, w = usbWritePacketI(sdup->config->usbp, USB_CDC_DATA_REQUEST_EP,
sdup->oqueue.q_buffer, n); sdup->oqueue.q_buffer, n);
if (w != USB_ENDPOINT_BUSY) { if (w != USB_ENDPOINT_BUSY) {
chIOAddFlagsI(sdup, IO_OUTPUT_EMPTY); chIOAddFlagsI(sdup, IO_OUTPUT_EMPTY);
@ -211,10 +211,10 @@ void sduStart(SerialUSBDriver *sdup, const SerialUSBConfig *config) {
"sduStart(), #1", "sduStart(), #1",
"invalid state"); "invalid state");
sdup->config = config; sdup->config = config;
usbStart(config->usbp, &config->usb_config);
config->usbp->param = sdup; config->usbp->param = sdup;
sdup->state = SDU_READY; sdup->state = SDU_READY;
chSysUnlock(); chSysUnlock();
usbStart(config->usbp, &config->usb_config);
} }
/** /**

View File

@ -361,7 +361,7 @@
* @note The default is @p FALSE. * @note The default is @p FALSE.
*/ */
#if !defined(CH_DBG_SYSTEM_STATE_CHECK) || defined(__DOXYGEN__) #if !defined(CH_DBG_SYSTEM_STATE_CHECK) || defined(__DOXYGEN__)
#define CH_DBG_SYSTEM_STATE_CHECK FALSE #define CH_DBG_SYSTEM_STATE_CHECK TRUE
#endif #endif
/** /**
@ -372,7 +372,7 @@
* @note The default is @p FALSE. * @note The default is @p FALSE.
*/ */
#if !defined(CH_DBG_ENABLE_CHECKS) || defined(__DOXYGEN__) #if !defined(CH_DBG_ENABLE_CHECKS) || defined(__DOXYGEN__)
#define CH_DBG_ENABLE_CHECKS FALSE #define CH_DBG_ENABLE_CHECKS TRUE
#endif #endif
/** /**
@ -384,7 +384,7 @@
* @note The default is @p FALSE. * @note The default is @p FALSE.
*/ */
#if !defined(CH_DBG_ENABLE_ASSERTS) || defined(__DOXYGEN__) #if !defined(CH_DBG_ENABLE_ASSERTS) || defined(__DOXYGEN__)
#define CH_DBG_ENABLE_ASSERTS FALSE #define CH_DBG_ENABLE_ASSERTS TRUE
#endif #endif
/** /**
@ -395,7 +395,7 @@
* @note The default is @p FALSE. * @note The default is @p FALSE.
*/ */
#if !defined(CH_DBG_ENABLE_TRACE) || defined(__DOXYGEN__) #if !defined(CH_DBG_ENABLE_TRACE) || defined(__DOXYGEN__)
#define CH_DBG_ENABLE_TRACE FALSE #define CH_DBG_ENABLE_TRACE TRUE
#endif #endif
/** /**
@ -409,7 +409,7 @@
* @p panic_msg variable set to @p NULL. * @p panic_msg variable set to @p NULL.
*/ */
#if !defined(CH_DBG_ENABLE_STACK_CHECK) || defined(__DOXYGEN__) #if !defined(CH_DBG_ENABLE_STACK_CHECK) || defined(__DOXYGEN__)
#define CH_DBG_ENABLE_STACK_CHECK FALSE #define CH_DBG_ENABLE_STACK_CHECK TRUE
#endif #endif
/** /**
@ -421,7 +421,7 @@
* @note The default is @p FALSE. * @note The default is @p FALSE.
*/ */
#if !defined(CH_DBG_FILL_THREADS) || defined(__DOXYGEN__) #if !defined(CH_DBG_FILL_THREADS) || defined(__DOXYGEN__)
#define CH_DBG_FILL_THREADS FALSE #define CH_DBG_FILL_THREADS TRUE
#endif #endif
/** /**

View File

@ -114,7 +114,7 @@ static const uint8_t vcom_configuration_descriptor_data[67] = {
USB_DESC_BYTE (0x01), /* bSlaveInterface0 (Data Class USB_DESC_BYTE (0x01), /* bSlaveInterface0 (Data Class
Interface). */ Interface). */
/* Endpoint 2 Descriptor.*/ /* Endpoint 2 Descriptor.*/
USB_DESC_ENDPOINT (INTERRUPT_REQUEST_EP|0x80, /* bEndpointAddress. */ USB_DESC_ENDPOINT (USB_CDC_INTERRUPT_REQUEST_EP|0x80,
0x03, /* bmAttributes (Interrupt). */ 0x03, /* bmAttributes (Interrupt). */
0x0008, /* wMaxPacketSize. */ 0x0008, /* wMaxPacketSize. */
0xFF), /* bInterval. */ 0xFF), /* bInterval. */
@ -130,12 +130,12 @@ static const uint8_t vcom_configuration_descriptor_data[67] = {
4.7). */ 4.7). */
0x00), /* iInterface. */ 0x00), /* iInterface. */
/* Endpoint 3 Descriptor.*/ /* Endpoint 3 Descriptor.*/
USB_DESC_ENDPOINT (DATA_AVAILABLE_EP, /* bEndpointAddress. */ USB_DESC_ENDPOINT (USB_CDC_DATA_AVAILABLE_EP, /* bEndpointAddress.*/
0x02, /* bmAttributes (Bulk). */ 0x02, /* bmAttributes (Bulk). */
0x0040, /* wMaxPacketSize. */ 0x0040, /* wMaxPacketSize. */
0x00), /* bInterval. */ 0x00), /* bInterval. */
/* Endpoint 1 Descriptor.*/ /* Endpoint 1 Descriptor.*/
USB_DESC_ENDPOINT (DATA_REQUEST_EP|0x80, /* bEndpointAddress. */ USB_DESC_ENDPOINT (USB_CDC_DATA_REQUEST_EP|0x80, /* bEndpointAddress.*/
0x02, /* bmAttributes (Bulk). */ 0x02, /* bmAttributes (Bulk). */
0x0040, /* wMaxPacketSize. */ 0x0040, /* wMaxPacketSize. */
0x00) /* bInterval. */ 0x00) /* bInterval. */
@ -282,9 +282,9 @@ static void usb_event(USBDriver *usbp, usbevent_t event) {
Note, this callback is invoked from an ISR so I-Class functions Note, this callback is invoked from an ISR so I-Class functions
must be used.*/ must be used.*/
chSysLockFromIsr(); chSysLockFromIsr();
usbInitEndpointI(usbp, DATA_REQUEST_EP, &ep1config); usbInitEndpointI(usbp, USB_CDC_DATA_REQUEST_EP, &ep1config);
usbInitEndpointI(usbp, INTERRUPT_REQUEST_EP, &ep2config); usbInitEndpointI(usbp, USB_CDC_INTERRUPT_REQUEST_EP, &ep2config);
usbInitEndpointI(usbp, DATA_AVAILABLE_EP, &ep3config); usbInitEndpointI(usbp, USB_CDC_DATA_AVAILABLE_EP, &ep3config);
chSysUnlockFromIsr(); chSysUnlockFromIsr();
return; return;
case USB_EVENT_SUSPEND: case USB_EVENT_SUSPEND: