USB cdc stdout stream
parent
63aead0ab8
commit
362d012eff
|
|
@ -55,7 +55,7 @@
|
||||||
#define CDC_NOTIFICATION_EPSIZE 8
|
#define CDC_NOTIFICATION_EPSIZE 8
|
||||||
|
|
||||||
/** Size in bytes of the CDC data IN and OUT endpoints. */
|
/** Size in bytes of the CDC data IN and OUT endpoints. */
|
||||||
#define CDC_TXRX_EPSIZE 16
|
#define CDC_TXRX_EPSIZE 64
|
||||||
|
|
||||||
/* Type Defines: */
|
/* Type Defines: */
|
||||||
/** Type define for the device configuration descriptor structure. This must be defined in the
|
/** Type define for the device configuration descriptor structure. This must be defined in the
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@
|
||||||
#include "pins.h"
|
#include "pins.h"
|
||||||
#include <avr/interrupt.h>
|
#include <avr/interrupt.h>
|
||||||
#include <util/delay.h>
|
#include <util/delay.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
#include "modules/buttons.h"
|
#include "modules/buttons.h"
|
||||||
#include "modules/finda.h"
|
#include "modules/finda.h"
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,12 @@ extern "C" {
|
||||||
#include "Descriptors.h"
|
#include "Descriptors.h"
|
||||||
#include "lufa/LUFA/Drivers/USB/USB.h"
|
#include "lufa/LUFA/Drivers/USB/USB.h"
|
||||||
|
|
||||||
|
|
||||||
|
/** Standard file stream for the CDC interface when set up, so that the virtual CDC COM port can be
|
||||||
|
* used like any regular character stream in the C APIs.
|
||||||
|
*/
|
||||||
|
static FILE USBSerialStream;
|
||||||
|
|
||||||
/** LUFA CDC Class driver interface configuration and state information. This structure is
|
/** LUFA CDC Class driver interface configuration and state information. This structure is
|
||||||
* passed to all CDC Class driver functions, so that multiple instances of the same class
|
* passed to all CDC Class driver functions, so that multiple instances of the same class
|
||||||
* within a device can be differentiated from one another.
|
* within a device can be differentiated from one another.
|
||||||
|
|
@ -104,10 +110,16 @@ CDC cdc;
|
||||||
|
|
||||||
void CDC::Init() {
|
void CDC::Init() {
|
||||||
USB_Init();
|
USB_Init();
|
||||||
|
|
||||||
|
/* Create a regular character stream for the interface so that it can be used with the stdio.h functions */
|
||||||
|
CDC_Device_CreateStream(&VirtualSerial_CDC_Interface, &USBSerialStream);
|
||||||
|
stdout = &USBSerialStream;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CDC::Step() {
|
void CDC::Step() {
|
||||||
|
/* Must throw away unused bytes from the host, or it will lock up while waiting for the device */
|
||||||
CDC_Device_ReceiveByte(&VirtualSerial_CDC_Interface);
|
CDC_Device_ReceiveByte(&VirtualSerial_CDC_Interface);
|
||||||
|
|
||||||
CDC_Device_USBTask(&VirtualSerial_CDC_Interface);
|
CDC_Device_USBTask(&VirtualSerial_CDC_Interface);
|
||||||
USB_USBTask();
|
USB_USBTask();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue