Paparazzi UAS  v5.10_stable-5-g83a0da5-dirty
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
usb_ser_hw.c File Reference
#include <string.h>
#include "std.h"
#include <stdbool.h>
#include "LPC21xx.h"
#include "armVIC.h"
#include "mcu_periph/usb_serial.h"
#include <BOARD_CONFIG>
#include "lpcusb/usbapi.h"
+ Include dependency graph for usb_ser_hw.c:

Go to the source code of this file.

Data Structures

struct  fifo_t
 
struct  TLineCoding
 

Macros

#define USB_VIC_SLOT   10
 
#define INT_IN_EP   0x81
 
#define BULK_OUT_EP   0x05
 
#define BULK_IN_EP   0x82
 
#define MAX_PACKET_SIZE   64
 
#define LE_WORD(x)   ((x)&0xFF),((x)>>8)
 
#define CS_INTERFACE   0x24
 
#define CS_ENDPOINT   0x25
 
#define SET_LINE_CODING   0x20
 
#define GET_LINE_CODING   0x21
 
#define SET_CONTROL_LINE_STATE   0x22
 
#define VCOM_FIFO_SIZE   128
 
#define EOF   (-1)
 
#define ASSERT(x)
 

Functions

static void USBIntHandler (void)
 Interrupt handler. More...
 
static void BulkOut (U8 bEP, U8 bEPStatus)
 Local function to handle incoming bulk data. More...
 
void fifo_init (fifo_t *fifo, U8 *buf)
 
BOOL fifo_put (fifo_t *fifo, U8 c)
 
BOOL fifo_get (fifo_t *fifo, U8 *pc)
 
int fifo_avail (fifo_t *fifo)
 
int fifo_free (fifo_t *fifo)
 
int VCOM_putchar (int c)
 Writes one character to VCOM port. More...
 
int VCOM_getchar (void)
 Reads one character from VCOM port. More...
 
bool VCOM_check_free_space (uint16_t len)
 Checks if buffer free in VCOM buffer. More...
 
int VCOM_check_available (void)
 Checks if data available in VCOM buffer. More...
 
static void BulkIn (U8 bEP, U8 bEPStatus)
 Local function to handle outgoing bulk data. More...
 
static BOOL HandleClassRequest (TSetupPacket *pSetup, int *piLen, U8 **ppbData)
 Local function to handle the USB-CDC class requests. More...
 
static void USBFrameHandler (U16 wFrame)
 
static int usb_serial_check_free_space (struct usb_serial_periph *p, long *fd, uint16_t len)
 
static void usb_serial_transmit (struct usb_serial_periph *p, long fd, uint8_t byte)
 
static void usb_serial_transmit_buffer (struct usb_serial_periph *p, long fd, uint8_t *data, uint16_t len)
 
static void usb_serial_send (struct usb_serial_periph *p, long fd)
 
void VCOM_event (void)
 
void VCOM_send_message (void)
 
static int usb_serial_char_available (struct usb_serial_periph *p)
 
static uint8_t usb_serial_getch (struct usb_serial_periph *p)
 
void VCOM_init (void)
 

Variables

int allow_line_coding = 0
 
static TLineCoding LineCoding = {115200, 0, 0, 8}
 
static uint8_t abBulkBuf [64]
 
static uint8_t abClassReqData [8]
 
static uint8_t txdata [VCOM_FIFO_SIZE]
 
static uint8_t rxdata [VCOM_FIFO_SIZE]
 
static fifo_t txfifo
 
static fifo_t rxfifo
 
static bool BulkOut_is_blocked = false
 
static const uint8_t abDescriptors []
 
struct usb_serial_periph usb_serial
 

Data Structure Documentation

struct fifo_t

Definition at line 90 of file usb_ser_hw.c.

Data Fields
uint8_t * buf
int head
int tail
struct TLineCoding

Definition at line 97 of file usb_ser_hw.c.

Data Fields
uint8_t bCharFormat
uint8_t bDataBits
uint8_t bParityType
uint32_t dwDTERate

Macro Definition Documentation

#define ASSERT (   x)

Definition at line 88 of file usb_ser_hw.c.

Referenced by BulkOut().

#define BULK_IN_EP   0x82

Definition at line 71 of file usb_ser_hw.c.

Referenced by VCOM_init().

#define BULK_OUT_EP   0x05

Definition at line 70 of file usb_ser_hw.c.

Referenced by VCOM_getchar(), and VCOM_init().

#define CS_ENDPOINT   0x25

Definition at line 79 of file usb_ser_hw.c.

#define CS_INTERFACE   0x24

Definition at line 78 of file usb_ser_hw.c.

#define EOF   (-1)

Definition at line 87 of file usb_ser_hw.c.

Referenced by load_texton_dictionary(), VCOM_getchar(), and VCOM_putchar().

#define GET_LINE_CODING   0x21

Definition at line 82 of file usb_ser_hw.c.

Referenced by HandleClassRequest().

#define INT_IN_EP   0x81

Definition at line 69 of file usb_ser_hw.c.

Referenced by VCOM_init().

#define LE_WORD (   x)    ((x)&0xFF),((x)>>8)

Definition at line 75 of file usb_ser_hw.c.

#define MAX_PACKET_SIZE   64

Definition at line 73 of file usb_ser_hw.c.

Referenced by BulkIn(), BulkOut(), and VCOM_getchar().

#define SET_CONTROL_LINE_STATE   0x22

Definition at line 83 of file usb_ser_hw.c.

Referenced by HandleClassRequest().

#define SET_LINE_CODING   0x20

Definition at line 81 of file usb_ser_hw.c.

Referenced by HandleClassRequest().

#define USB_VIC_SLOT   10

Definition at line 66 of file usb_ser_hw.c.

Referenced by VCOM_init().

#define VCOM_FIFO_SIZE   128

Definition at line 85 of file usb_ser_hw.c.

Referenced by fifo_avail(), fifo_free(), fifo_get(), and fifo_put().

Function Documentation

static void BulkIn ( U8  bEP,
U8  bEPStatus 
)
static

Local function to handle outgoing bulk data.

Parameters
[in]bEP
[in]bEPStatus

Definition at line 461 of file usb_ser_hw.c.

References abBulkBuf, fifo_avail(), fifo_get(), and MAX_PACKET_SIZE.

Referenced by VCOM_init().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void BulkOut ( U8  bEP,
U8  bEPStatus 
)
static

Local function to handle incoming bulk data.

Parameters
[in]bEP
[in]bEPStatus

Definition at line 432 of file usb_ser_hw.c.

References abBulkBuf, ASSERT, BulkOut_is_blocked, FALSE, fifo_free(), fifo_put(), and MAX_PACKET_SIZE.

Referenced by VCOM_getchar(), and VCOM_init().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int fifo_avail ( fifo_t fifo)

Definition at line 287 of file usb_ser_hw.c.

References fifo_t::head, fifo_t::tail, and VCOM_FIFO_SIZE.

Referenced by BulkIn(), fifo_free(), USBFrameHandler(), VCOM_check_available(), and VCOM_event().

+ Here is the caller graph for this function:

int fifo_free ( fifo_t fifo)

Definition at line 292 of file usb_ser_hw.c.

References fifo_avail(), and VCOM_FIFO_SIZE.

Referenced by BulkOut(), VCOM_check_free_space(), and VCOM_getchar().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

BOOL fifo_get ( fifo_t fifo,
U8 *  pc 
)

Definition at line 270 of file usb_ser_hw.c.

References fifo_t::buf, FALSE, fifo_t::head, fifo_t::tail, TRUE, and VCOM_FIFO_SIZE.

Referenced by BulkIn(), VCOM_getchar(), and VCOM_send_message().

+ Here is the caller graph for this function:

void fifo_init ( fifo_t fifo,
U8 *  buf 
)

Definition at line 246 of file usb_ser_hw.c.

References fifo_t::buf, fifo_t::head, and fifo_t::tail.

Referenced by VCOM_init().

+ Here is the caller graph for this function:

BOOL fifo_put ( fifo_t fifo,
U8  c 
)

Definition at line 253 of file usb_ser_hw.c.

References fifo_t::buf, FALSE, fifo_t::head, fifo_t::tail, TRUE, and VCOM_FIFO_SIZE.

Referenced by BulkOut(), cdcacm_data_rx_cb(), and VCOM_putchar().

+ Here is the caller graph for this function:

static BOOL HandleClassRequest ( TSetupPacket *  pSetup,
int *  piLen,
U8 **  ppbData 
)
static

Local function to handle the USB-CDC class requests.

Parameters
[in]pSetup
[out]piLen
[out]ppbData

Definition at line 493 of file usb_ser_hw.c.

References allow_line_coding, FALSE, GET_LINE_CODING, SET_CONTROL_LINE_STATE, SET_LINE_CODING, and TRUE.

Referenced by VCOM_init().

+ Here is the caller graph for this function:

static int usb_serial_char_available ( struct usb_serial_periph p)
static

Definition at line 576 of file usb_ser_hw.c.

References VCOM_check_available().

Referenced by VCOM_init().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static int usb_serial_check_free_space ( struct usb_serial_periph p,
long *  fd,
uint16_t  len 
)
static

Definition at line 550 of file usb_ser_hw.c.

References VCOM_check_free_space().

Referenced by VCOM_init().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static uint8_t usb_serial_getch ( struct usb_serial_periph p)
static

Definition at line 581 of file usb_ser_hw.c.

References VCOM_getchar().

Referenced by VCOM_init().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void usb_serial_send ( struct usb_serial_periph p,
long  fd 
)
static

Definition at line 568 of file usb_ser_hw.c.

Referenced by VCOM_init().

+ Here is the caller graph for this function:

static void usb_serial_transmit ( struct usb_serial_periph p,
long  fd,
uint8_t  byte 
)
static

Definition at line 555 of file usb_ser_hw.c.

References VCOM_putchar().

Referenced by main_periodic_task(), and VCOM_init().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void usb_serial_transmit_buffer ( struct usb_serial_periph p,
long  fd,
uint8_t data,
uint16_t  len 
)
static

Definition at line 560 of file usb_ser_hw.c.

References VCOM_putchar().

Referenced by VCOM_init().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void USBFrameHandler ( U16  wFrame)
static

Definition at line 538 of file usb_ser_hw.c.

References fifo_avail().

Referenced by VCOM_init().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void USBIntHandler ( void  )
static

Interrupt handler.

Simply calls the USB ISR, then signals end of interrupt to VIC

Definition at line 531 of file usb_ser_hw.c.

References VICVectAddr.

Referenced by VCOM_init().

+ Here is the caller graph for this function:

int VCOM_check_available ( void  )

Checks if data available in VCOM buffer.

Returns
character read, or EOF if character could not be read

Definition at line 420 of file usb_ser_hw.c.

Referenced by event_usb_serial(), ReadUsbBuffer(), tunnel_event(), and usb_serial_char_available().

+ Here is the caller graph for this function:

bool VCOM_check_free_space ( uint16_t  len)

Checks if buffer free in VCOM buffer.

Returns
TRUE if len bytes are free

Definition at line 409 of file usb_ser_hw.c.

Referenced by tunnel_event(), usb_serial_check_free_space(), and VCOM_putchar().

+ Here is the caller graph for this function:

void VCOM_event ( void  )

Definition at line 571 of file usb_ser_hw.c.

Referenced by event_usb_serial(), main(), and mcu_event().

+ Here is the caller graph for this function:

int VCOM_getchar ( void  )

Reads one character from VCOM port.

Returns
character read, or EOF if character could not be read

Definition at line 386 of file usb_ser_hw.c.

Referenced by event_usb_serial(), ReadUsbBuffer(), tunnel_event(), and usb_serial_getch().

+ Here is the caller graph for this function:

void VCOM_init ( void  )

Definition at line 586 of file usb_ser_hw.c.

Referenced by init_usb_serial(), main(), and mcu_init().

+ Here is the caller graph for this function:

int VCOM_putchar ( int  c)

Writes one character to VCOM port.

Parameters
[in]ccharacter to write
Returns
character written, or EOF if character could not be written

Definition at line 376 of file usb_ser_hw.c.

Referenced by cmd_execute(), periodic_usb_serial(), tunnel_event(), usb_serial_parse_packet(), usb_serial_transmit(), and usb_serial_transmit_buffer().

+ Here is the caller graph for this function:

void VCOM_send_message ( void  )

Definition at line 574 of file usb_ser_hw.c.

Referenced by cmd_execute(), usb_serial_parse_packet(), usb_serial_send(), VCOM_event(), and VCOM_putchar().

+ Here is the caller graph for this function:

Variable Documentation

uint8_t abBulkBuf[64]
static

Definition at line 107 of file usb_ser_hw.c.

Referenced by BulkIn(), and BulkOut().

uint8_t abClassReqData[8]
static

Definition at line 108 of file usb_ser_hw.c.

Referenced by VCOM_init().

const uint8_t abDescriptors[]
static

Definition at line 133 of file usb_ser_hw.c.

int allow_line_coding = 0

Definition at line 104 of file usb_ser_hw.c.

Referenced by HandleClassRequest().

bool BulkOut_is_blocked = false
static

Definition at line 116 of file usb_ser_hw.c.

Referenced by BulkOut(), and VCOM_getchar().

TLineCoding LineCoding = {115200, 0, 0, 8}
static

Definition at line 106 of file usb_ser_hw.c.

uint8_t rxdata[VCOM_FIFO_SIZE]
static

Definition at line 111 of file usb_ser_hw.c.

Referenced by VCOM_init().

fifo_t rxfifo
static

Definition at line 114 of file usb_ser_hw.c.

uint8_t txdata[VCOM_FIFO_SIZE]
static

Definition at line 110 of file usb_ser_hw.c.

Referenced by VCOM_init().

fifo_t txfifo
static

Definition at line 113 of file usb_ser_hw.c.

struct usb_serial_periph usb_serial

Definition at line 547 of file usb_ser_hw.c.

Referenced by VCOM_init().