Functions | Variables

lufa_serial.c File Reference

Main source file for the VirtualSerial demo. More...

#include "lufa_serial.h"
#include <avr/pgmspace.h>

Functions

void serial_init (void)
 initialise serial subsystem
void EVENT_USB_Device_Connect (void)
 Event handler for the USB_Connect event.
void EVENT_USB_Device_Disconnect (void)
 Event handler for the USB_Disconnect event.
void EVENT_USB_Device_ConfigurationChanged (void)
 Event handler for the USB_ConfigurationChanged event.
void EVENT_USB_Device_ControlRequest (void)
 Event handler for the USB_ControlRequest event.
uint8_t serial_rxchars (void)
uint8_t serial_popchar (void)
void serial_writestr_P (PGM_P data)
void serial_writechar (uint8_t data)

Variables

CDC_LineEncoding_t LineEncoding
 Contains the current baud rate and other settings of the virtual serial port.

Detailed Description

Main source file for the VirtualSerial demo.

This file contains the main tasks of the demo and is responsible for the initial application hardware configuration.


Function Documentation

void EVENT_USB_Device_ConfigurationChanged ( void   )

Event handler for the USB_ConfigurationChanged event.

This is fired when the host set the current configuration of the USB device after enumeration - the device endpoints are configured and the CDC management task started.

void EVENT_USB_Device_Connect ( void   )

Event handler for the USB_Connect event.

This indicates that the device is enumerating via the status LEDs and starts the library USB task to begin the enumeration and USB management process.

void EVENT_USB_Device_ControlRequest ( void   )

Event handler for the USB_ControlRequest event.

This is used to catch and process control requests sent to the device from the USB host before passing along unhandled control requests to the library for processing internally.

void EVENT_USB_Device_Disconnect ( void   )

Event handler for the USB_Disconnect event.

This indicates that the device is no longer connected to a host via the status LEDs and stops the USB management and CDC management tasks.

void serial_init ( void   )

initialise serial subsystem

set up baud generator and interrupts, clear buffers


Variable Documentation

CDC_LineEncoding_t LineEncoding
Initial value:
 { .BaudRateBPS = 0,
                                    .CharFormat  = CDC_LINEENCODING_OneStopBit,
                                    .ParityType  = CDC_PARITY_None,
                                    .DataBits    = 8                            }

Contains the current baud rate and other settings of the virtual serial port.

While this demo does not use the physical USART and thus does not use these settings, they must still be retained and returned to the host upon request or the host will assume the device is non-functional.

These values are set by the host via a class-specific request, however they are not required to be used accurately. It is possible to completely ignore these value or use other settings as the host is completely unaware of the physical serial link characteristics and instead sends and receives data in endpoint streams.

Referenced by EVENT_USB_Device_ConfigurationChanged(), and EVENT_USB_Device_ControlRequest().

 All Data Structures Files Functions Variables Defines