LUFA Library - Virtual Serial Device Demo
VirtualSerial.c File Reference
#include "VirtualSerial.h"
#include <stdlib.h>

Data Structures

struct  couleur
 

Macros

#define LED_BIT   0
 
#define BUT_BIT   0
 
#define MAX_BUFFER   64
 
#define NB_COLORS   4
 
#define MAX_COLOR_INTENSITY   4095
 
#define MAX_COLORS   5
 

Functions

char * random_series (int n, couleur *bank)
 
int equals (couleur c1, couleur c2)
 
int contains (couleur c1, couleur *series, size_t length)
 
int main (void)
 
void SetupHardware (void)
 
void EVENT_USB_Device_Connect (void)
 
void EVENT_USB_Device_Disconnect (void)
 
void EVENT_USB_Device_ConfigurationChanged (void)
 
void EVENT_USB_Device_ControlRequest (void)
 
void CDC_Task (void)
 

Variables

const char * CORRECT = "good"
 
const char * MISS = "miss"
 
const char * WRONG = "wrong"
 
int cpt = 0
 
char history [6] = ""
 
char * serie
 
static CDC_LineEncoding_t LineEncoding
 

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.

Macro Definition Documentation

◆ BUT_BIT

#define BUT_BIT   0

◆ LED_BIT

#define LED_BIT   0

◆ MAX_BUFFER

#define MAX_BUFFER   64

◆ MAX_COLOR_INTENSITY

#define MAX_COLOR_INTENSITY   4095

◆ MAX_COLORS

#define MAX_COLORS   5

◆ NB_COLORS

#define NB_COLORS   4

Function Documentation

◆ CDC_Task()

void CDC_Task ( void  )

Function to manage CDC data transmission and reception to and from the host.

◆ contains()

int contains ( couleur  c1,
couleur series,
size_t  length 
)

◆ equals()

int equals ( couleur  c1,
couleur  c2 
)

◆ EVENT_USB_Device_ConfigurationChanged()

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.

◆ EVENT_USB_Device_Connect()

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.

◆ EVENT_USB_Device_ControlRequest()

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.

◆ EVENT_USB_Device_Disconnect()

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.

◆ main()

int main ( void  )

Main program entry point. This routine contains the overall program flow, including initial setup of all components and the main program loop.

◆ random_series()

char * random_series ( int  n,
couleur bank 
)

◆ SetupHardware()

void SetupHardware ( void  )

Configures the board hardware and chip peripherals for the demo's functionality.

Variable Documentation

◆ CORRECT

const char* CORRECT = "good"

◆ cpt

int cpt = 0

◆ history

char history[6] = ""

◆ LineEncoding

CDC_LineEncoding_t LineEncoding
static
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.

◆ MISS

const char* MISS = "miss"

◆ serie

char* serie

◆ WRONG

const char* WRONG = "wrong"