CDC-ACM now asserts DCD to allow opening tty devs in BSD/MacOS.

Cleaned up compiler warnings.
This commit is contained in:
Gareth McMullin 2011-02-17 15:06:27 +13:00
parent f08914ec1f
commit b36242d021
4 changed files with 30 additions and 1 deletions

View File

@ -341,6 +341,8 @@ static int cdcacm_control_request(struct usb_setup_data *req, uint8_t **buf,
uint16_t *len, void (**complete)(struct usb_setup_data *req))
{
(void)complete;
(void)buf;
(void)len;
switch(req->bRequest) {
case USB_CDC_REQ_SET_CONTROL_LINE_STATE:
@ -432,6 +434,25 @@ static void cdcacm_set_config(u16 wValue)
USB_REQ_TYPE_CLASS | USB_REQ_TYPE_INTERFACE,
USB_REQ_TYPE_TYPE | USB_REQ_TYPE_RECIPIENT,
cdcacm_control_request);
/* Notify the host that DCD is asserted.
* Allows the use of /dev/tty* devices on *BSD/MacOS
*/
char buf[10];
struct usb_cdc_notification *notif = (void*)buf;
/* We echo signals back to host as notification */
notif->bmRequestType = 0xA1;
notif->bNotification = USB_CDC_NOTIFY_SERIAL_STATE;
notif->wValue = 0;
notif->wIndex = 0;
notif->wLength = 2;
buf[8] = 3; /* DCD | DSR */
buf[9] = 0;
usbd_ep_write_packet(0x82, buf, 10);
#ifdef INCLUDE_UART_INTERFACE
notif->wIndex = 2;
usbd_ep_write_packet(0x84, buf, 10);
#endif
}
/* We need a special large control buffer for this device: */

View File

@ -23,7 +23,7 @@
* uses the USB CDC-ACM device bulk endpoints to implement the channel.
*/
#include "platform.h"
#include <usbd.h>
#include <libopencm3/usb/usbd.h>
#include "gdb_if.h"

View File

@ -41,7 +41,10 @@ jmp_buf fatal_error_jmpbuf;
void morse(const char *msg, char repeat);
static void morse_update(void);
#ifdef INCLUDE_UART_INTERFACE
static void uart_init(void);
#endif
int platform_init(void)
{

View File

@ -119,6 +119,11 @@ extern const char *morse_msg;
int platform_init(void);
void morse(const char *msg, char repeat);
/* <cdcacm.c> */
void cdcacm_init(void);
/* Returns current usb configuration, or 0 if not configured. */
int cdcacm_get_config(void);
/* Use newlib provided integer only stdio functions */
#define sscanf siscanf
#define sprintf siprintf