Paparazzi UAS  v5.18.0_stable
Paparazzi is a free software Unmanned Aircraft System.
usb_ser_hw.c
Go to the documentation of this file.
1 /*
2  LPCUSB, an USB device driver for LPC microcontrollers
3  Copyright (C) 2006 Bertrik Sikken (bertrik@sikken.nl)
4  adapted to pprz Martin Mueller (martinmm@pfump.org)
5 
6  Redistribution and use in source and binary forms, with or without
7  modification, are permitted provided that the following conditions are met:
8 
9  1. Redistributions of source code must retain the above copyright
10  notice, this list of conditions and the following disclaimer.
11  2. Redistributions in binary form must reproduce the above copyright
12  notice, this list of conditions and the following disclaimer in the
13  documentation and/or other materials provided with the distribution.
14  3. The name of the author may not be used to endorse or promote products
15  derived from this software without specific prior written permission.
16 
17  THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18  IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19  OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26  THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28 
29 /*
30  Minimal implementation of a USB serial port, using the CDC class.
31  This example application simply echoes everything it receives right back
32  to the host.
33 
34  Windows:
35  Extract the usbser.sys file from .cab file in C:\WINDOWS\Driver Cache\i386
36  and store it somewhere (C:\temp is a good place) along with the usbser.inf
37  file. Then plug in the LPC214x and direct windows to the usbser driver.
38  Windows then creates an extra COMx port that you can open in a terminal
39  program, like hyperterminal.
40 
41  Linux:
42  The device should be recognised automatically by the cdc_acm driver,
43  which creates a /dev/ttyACMx device file that acts just like a regular
44  serial port.
45 
46 */
47 
48 
49 #include <string.h>
50 #include "std.h"
51 #include <stdbool.h>
52 #include "LPC21xx.h"
53 #include "armVIC.h"
54 #include "mcu_periph/usb_serial.h"
55 #include BOARD_CONFIG
56 
57 #include "lpcusb/usbapi.h"
58 
59 #if USE_USB_SERIAL
60 #if PCLK < 18000000
61 #error PCLK needs to be higher than 18MHz for USB to work properly
62 #endif
63 #endif
64 
65 #ifndef USB_VIC_SLOT
66 #define USB_VIC_SLOT 10
67 #endif
68 
69 #define INT_IN_EP 0x81
70 #define BULK_OUT_EP 0x05
71 #define BULK_IN_EP 0x82
72 
73 #define MAX_PACKET_SIZE 64
74 
75 #define LE_WORD(x) ((x)&0xFF),((x)>>8)
76 
77 // CDC definitions
78 #define CS_INTERFACE 0x24
79 #define CS_ENDPOINT 0x25
80 
81 #define SET_LINE_CODING 0x20
82 #define GET_LINE_CODING 0x21
83 #define SET_CONTROL_LINE_STATE 0x22
84 
85 #define VCOM_FIFO_SIZE 128
86 
87 #define EOF (-1)
88 #define ASSERT(x)
89 
90 typedef struct {
91  int head;
92  int tail;
94 } fifo_t;
95 
96 // data structure for GET_LINE_CODING / SET_LINE_CODING class requests
97 typedef struct {
102 } TLineCoding;
103 
105 /* this settings are virtual unless you enable line coding */
106 static TLineCoding LineCoding = {115200, 0, 0, 8};
107 static uint8_t abBulkBuf[64];
109 
112 
113 static fifo_t txfifo;
114 static fifo_t rxfifo;
115 
116 static bool BulkOut_is_blocked = false;
117 
118 // forward declaration of interrupt handler
119 static void USBIntHandler(void) __attribute__((interrupt("IRQ")));
120 
121 static void BulkOut(U8 bEP, U8 bEPStatus);
122 
123 #ifdef USE_USB_LINE_CODING
124 void set_linecoding(TLineCoding linecoding);
125 #endif
126 
127 void fifo_init(fifo_t *fifo, U8 *buf);
128 BOOL fifo_put(fifo_t *fifo, U8 c);
129 BOOL fifo_get(fifo_t *fifo, U8 *pc);
130 int fifo_avail(fifo_t *fifo);
131 int fifo_free(fifo_t *fifo);
132 
133 static const uint8_t abDescriptors[] = {
134 
135 // device descriptor
136  0x12,
137  DESC_DEVICE,
138  LE_WORD(0x0101), // bcdUSB
139  0x02, // bDeviceClass
140  0x00, // bDeviceSubClass
141  0x00, // bDeviceProtocol
142  MAX_PACKET_SIZE0, // bMaxPacketSize
143  LE_WORD(0x7070), // idVendor
144  LE_WORD(0x1235), // idProduct
145  LE_WORD(0x0100), // bcdDevice
146  0x01, // iManufacturer
147  0x02, // iProduct
148  0x03, // iSerialNumber
149  0x01, // bNumConfigurations
150 
151 // configuration descriptor
152  0x09,
153  DESC_CONFIGURATION,
154  LE_WORD(67), // wTotalLength
155  0x02, // bNumInterfaces
156  0x01, // bConfigurationValue
157  0x00, // iConfiguration
158  0xC0, // bmAttributes
159  0x32, // bMaxPower
160 // control class interface
161  0x09,
162  DESC_INTERFACE,
163  0x00, // bInterfaceNumber
164  0x00, // bAlternateSetting
165  0x01, // bNumEndPoints
166  0x02, // bInterfaceClass
167  0x02, // bInterfaceSubClass
168  0x01, // bInterfaceProtocol, linux requires value of 1 for the cdc_acm module
169  0x00, // iInterface
170 // header functional descriptor
171  0x05,
172  CS_INTERFACE,
173  0x00,
174  LE_WORD(0x0110),
175 // call management functional descriptor
176  0x05,
177  CS_INTERFACE,
178  0x01,
179  0x01, // bmCapabilities = device handles call management
180  0x01, // bDataInterface
181 // ACM functional descriptor
182  0x04,
183  CS_INTERFACE,
184  0x02,
185  0x02, // bmCapabilities
186 // union functional descriptor
187  0x05,
188  CS_INTERFACE,
189  0x06,
190  0x00, // bMasterInterface
191  0x01, // bSlaveInterface0
192 // notification EP
193  0x07,
194  DESC_ENDPOINT,
195  INT_IN_EP, // bEndpointAddress
196  0x03, // bmAttributes = intr
197  LE_WORD(8), // wMaxPacketSize
198  0xFE, // bInterval
199 // data class interface descriptor
200  0x09,
201  DESC_INTERFACE,
202  0x01, // bInterfaceNumber
203  0x00, // bAlternateSetting
204  0x02, // bNumEndPoints
205  0x0A, // bInterfaceClass = data
206  0x00, // bInterfaceSubClass
207  0x00, // bInterfaceProtocol
208  0x00, // iInterface
209 // data EP OUT
210  0x07,
211  DESC_ENDPOINT,
212  BULK_OUT_EP, // bEndpointAddress
213  0x02, // bmAttributes = bulk
214  LE_WORD(MAX_PACKET_SIZE), // wMaxPacketSize
215  0x00, // bInterval
216 // data EP in
217  0x07,
218  DESC_ENDPOINT,
219  BULK_IN_EP, // bEndpointAddress
220  0x02, // bmAttributes = bulk
221  LE_WORD(MAX_PACKET_SIZE), // wMaxPacketSize
222  0x00, // bInterval
223 
224  // string descriptors
225  0x04,
226  DESC_STRING,
227  LE_WORD(0x0409),
228 
229  0x0E,
230  DESC_STRING,
231  'L', 0, 'P', 0, 'C', 0, 'U', 0, 'S', 0, 'B', 0,
232 
233  0x14,
234  DESC_STRING,
235  'U', 0, 'S', 0, 'B', 0, 'S', 0, 'e', 0, 'r', 0, 'i', 0, 'a', 0, 'l', 0,
236 
237  0x12,
238  DESC_STRING,
239  '1', 0, '2', 0, '3', 0, '4', 0, '5', 0, '6', 0, '7', 0, '8', 0,
240 
241 // terminating zero
242  0
243 };
244 
245 
246 void fifo_init(fifo_t *fifo, U8 *buf)
247 {
248  fifo->head = 0;
249  fifo->tail = 0;
250  fifo->buf = buf;
251 }
252 
253 BOOL fifo_put(fifo_t *fifo, U8 c)
254 {
255  int next;
256 
257  // check if FIFO has room
258  next = (fifo->head + 1) % VCOM_FIFO_SIZE;
259  if (next == fifo->tail) {
260  // full
261  return FALSE;
262  }
263 
264  fifo->buf[fifo->head] = c;
265  fifo->head = next;
266 
267  return TRUE;
268 }
269 
270 BOOL fifo_get(fifo_t *fifo, U8 *pc)
271 {
272  int next;
273 
274  // check if FIFO has data
275  if (fifo->head == fifo->tail) {
276  return FALSE;
277  }
278 
279  next = (fifo->tail + 1) % VCOM_FIFO_SIZE;
280 
281  *pc = fifo->buf[fifo->tail];
282  fifo->tail = next;
283 
284  return TRUE;
285 }
286 
287 int fifo_avail(fifo_t *fifo)
288 {
289  return (VCOM_FIFO_SIZE + fifo->head - fifo->tail) % VCOM_FIFO_SIZE;
290 }
291 
292 int fifo_free(fifo_t *fifo)
293 {
294  return (VCOM_FIFO_SIZE - 1 - fifo_avail(fifo));
295 }
296 
297 #ifdef USE_USB_LINE_CODING
298 void set_linecoding(TLineCoding linecoding)
299 {
300  uint16_t baud;
301  uint8_t mode;
302 
303  // set the baudrate
304  baud = (uint16_t)((PCLK / ((linecoding.dwDTERate) * 16.0)) + 0.5);
305 
306  // set the number of characters and other
307  // user specified operating parameters
308  switch (linecoding.bCharFormat) {
309  case 0: /* 1 stop bit */
310  mode = ULCR_STOP_1;
311  break;
312  case 1: /* 1.5 stop bit (only with 5 bit character) */
313  case 2: /* 2 stop bit */
314  mode = ULCR_STOP_2;
315  break;
316  default:
317  mode = ULCR_STOP_1;
318  break;
319  }
320  switch (linecoding.bParityType) {
321  case 0: mode += ULCR_PAR_NO;
322  break;
323  case 1: mode += ULCR_PAR_ODD;
324  break;
325  case 2: mode += ULCR_PAR_EVEN;
326  break;
327  case 3: mode += ULCR_PAR_MARK;
328  break;
329  case 4: mode += ULCR_PAR_SPACE;
330  break;
331  default: mode += ULCR_PAR_NO;
332  break;
333  }
334  switch (linecoding.bDataBits) {
335  case 5: mode += ULCR_CHAR_5;
336  break;
337  case 6: mode += ULCR_CHAR_6;
338  break;
339  case 7: mode += ULCR_CHAR_7;
340  break;
341  case 8: mode += ULCR_CHAR_8;
342  break;
343  case 16:
344  default: mode += ULCR_CHAR_8;
345  break;
346  }
347 
348 #if USE_UART0
349  U0LCR = ULCR_DLAB_ENABLE; // select divisor latches
350  U0DLL = (uint8_t)baud; // set for baud low byte
351  U0DLM = (uint8_t)(baud >> 8); // set for baud high byte
352  U0LCR = (mode & ~ULCR_DLAB_ENABLE);
353 #endif
354 #if USE_UART1
355  U1LCR = ULCR_DLAB_ENABLE; // select divisor latches
356  U1DLL = (uint8_t)baud; // set for baud low byte
357  U1DLM = (uint8_t)(baud >> 8); // set for baud high byte
358  U1LCR = (mode & ~ULCR_DLAB_ENABLE);
359 #endif
360 }
361 #endif
362 
363 #ifdef USE_USB_LINE_CODING
365 {
367 }
368 #endif
369 
376 int VCOM_putchar(int c)
377 {
378  return fifo_put(&txfifo, c) ? c : EOF;
379 }
380 
386 int VCOM_getchar(void)
387 {
388  int result;
389  U8 c;
390 
391  result = fifo_get(&rxfifo, &c) ? c : EOF;
392 
394  disableIRQ();
395  // get more data from usb bus
396  BulkOut(BULK_OUT_EP, 0);
397  BulkOut_is_blocked = false;
398  enableIRQ();
399  }
400 
401  return result;
402 }
403 
410 {
411  return (fifo_free(&txfifo) >= len ? TRUE : FALSE);
412 }
413 
414 
421 {
422  return (fifo_avail(&rxfifo));
423 }
424 
425 
432 static void BulkOut(U8 bEP, U8 bEPStatus __attribute__((unused)))
433 {
434  int i, iLen;
435 
436  if (fifo_free(&rxfifo) < MAX_PACKET_SIZE) {
437  // may not fit into fifo
438  BulkOut_is_blocked = true;
439  return;
440  }
441 
442  // get data from USB into intermediate buffer
443  iLen = USBHwEPRead(bEP, abBulkBuf, sizeof(abBulkBuf));
444  for (i = 0; i < iLen; i++) {
445  // put into FIFO
446  if (!fifo_put(&rxfifo, abBulkBuf[i])) {
447  // overflow... :(
448  ASSERT(FALSE);
449  break;
450  }
451  }
452 }
453 
454 
461 static void BulkIn(U8 bEP, U8 bEPStatus __attribute__((unused)))
462 {
463  int i, iLen;
464 
465  if (fifo_avail(&txfifo) == 0) {
466  // no more data, disable further NAK interrupts until next USB frame
467  USBHwNakIntEnable(0);
468  return;
469  }
470 
471  // get bytes from transmit FIFO into intermediate buffer
472  for (i = 0; i < MAX_PACKET_SIZE; i++) {
473  if (!fifo_get(&txfifo, &abBulkBuf[i])) {
474  break;
475  }
476  }
477  iLen = i;
478 
479  // send over USB
480  if (iLen > 0) {
481  USBHwEPWrite(bEP, abBulkBuf, iLen);
482  }
483 }
484 
485 
493 static BOOL HandleClassRequest(TSetupPacket *pSetup, int *piLen, U8 **ppbData)
494 {
495  switch (pSetup->bRequest) {
496 
497  // set line coding
498  case SET_LINE_CODING:
499  memcpy((U8 *)&LineCoding, *ppbData, 7);
500  *piLen = 7;
501 #ifdef USE_USB_LINE_CODING
502  if (allow_line_coding) {
503  set_linecoding(LineCoding);
504  }
505 #endif
506  break;
507 
508  // get line coding
509  case GET_LINE_CODING:
510  *ppbData = (U8 *)&LineCoding;
511  *piLen = 7;
512  break;
513 
514  // set control line state
516  // bit0 = DTR, bit1 = RTS
517  break;
518 
519  default:
520  return FALSE;
521  }
522  return TRUE;
523 }
524 
525 
531 static void USBIntHandler(void)
532 {
533  USBHwISR();
534  VICVectAddr = 0x00; // dummy write to VIC to signal end of ISR
535 }
536 
537 
538 static void USBFrameHandler(U16 wFrame __attribute__((unused)))
539 {
540  if (fifo_avail(&txfifo) > 0) {
541  // data available, enable NAK interrupt on bulk in
542  USBHwNakIntEnable(INACK_BI);
543  }
544 }
545 
546 // Periph with generic device API
548 
549 // Functions for the generic device API
550 static int usb_serial_check_free_space(struct usb_serial_periph *p __attribute__((unused)), long *fd __attribute__((unused)), uint16_t len)
551 {
552  return (int)VCOM_check_free_space(len);
553 }
554 
555 static void usb_serial_transmit(struct usb_serial_periph *p __attribute__((unused)), long fd __attribute__((unused)), uint8_t byte)
556 {
557  VCOM_putchar(byte);
558 }
559 
560 static void usb_serial_transmit_buffer(struct usb_serial_periph *p __attribute__((unused)), long fd __attribute__((unused)), uint8_t *data, uint16_t len)
561 {
562  int i;
563  for (i = 0; i < len; i++) {
564  VCOM_putchar(data[i]);
565  }
566 }
567 
568 static void usb_serial_send(struct usb_serial_periph *p __attribute__((unused)), long fd __attribute__((unused))) { }
569 
570 // Empty for lpc21
571 void VCOM_event(void) {}
572 
573 // Empty for lpc21
574 void VCOM_send_message(void) {}
575 
576 static int usb_serial_char_available(struct usb_serial_periph *p __attribute__((unused)))
577 {
578  return VCOM_check_available();
579 }
580 
581 static uint8_t usb_serial_getch(struct usb_serial_periph *p __attribute__((unused)))
582 {
583  return (uint8_t)(VCOM_getchar());
584 }
585 
586 void VCOM_init(void)
587 {
588  // initialise stack
589  USBInit();
590 #ifdef USE_USB_LINE_CODING
591  // set default line coding
592  set_linecoding(LineCoding);
593 #endif
594 
595  // register descriptors
596  USBRegisterDescriptors(abDescriptors);
597 
598  // register class request handler
599  USBRegisterRequestHandler(REQTYPE_TYPE_CLASS, HandleClassRequest, abClassReqData);
600 
601  // register endpoint handlers
602  USBHwRegisterEPIntHandler(INT_IN_EP, NULL);
603  USBHwRegisterEPIntHandler(BULK_IN_EP, BulkIn);
604  USBHwRegisterEPIntHandler(BULK_OUT_EP, BulkOut);
605 
606  // register frame handler
607  USBHwRegisterFrameHandler(USBFrameHandler);
608 
609  // enable bulk-in interrupts on NAKs
610  USBHwNakIntEnable(INACK_BI);
611 
612  // initialise fifos
615 
616  // set up USB interrupt
617  VICIntSelect &= ~VIC_BIT(VIC_USB); // select IRQ for USB
619 
622 
623  // connect to bus
624  USBHwConnect(TRUE);
625 
626  // Configure generic device
627  usb_serial.device.periph = (void *)(&usb_serial);
628  usb_serial.device.check_free_space = (check_free_space_t) usb_serial_check_free_space;
629  usb_serial.device.put_byte = (put_byte_t) usb_serial_transmit;
630  usb_serial.device.put_buffer = (put_buffer_t) usb_serial_transmit_buffer;
631  usb_serial.device.send_message = (send_message_t) usb_serial_send;
632  usb_serial.device.char_available = (char_available_t) usb_serial_char_available;
633  usb_serial.device.get_byte = (get_byte_t) usb_serial_getch;
634 }
abBulkBuf
static uint8_t abBulkBuf[64]
Definition: usb_ser_hw.c:107
ULCR_PAR_MARK
#define ULCR_PAR_MARK
Definition: lpcUART.h:91
VCOM_check_available
int VCOM_check_available(void)
Checks if data available in VCOM buffer.
Definition: usb_ser_hw.c:420
c
VIC slots used for the LPC2148 define name e g gps UART1_VIC_SLOT e g modem SPI1_VIC_SLOT SPI1 in mcu_periph spi_arch c or spi_slave_hs_arch c(and some others not using the SPI peripheral yet..) I2C0_VIC_SLOT 8 mcu_periph/i2c_arch.c I2C1_VIC_SLOT 9 mcu_periph/i2c_arch.c USB_VIC_SLOT 10 usb
BULK_OUT_EP
#define BULK_OUT_EP
Definition: usb_ser_hw.c:70
uint16_t
unsigned short uint16_t
Definition: types.h:16
ULCR_STOP_1
#define ULCR_STOP_1
Definition: lpcUART.h:86
disableIRQ
unsigned disableIRQ(void)
Definition: armVIC.c:33
usb_serial_getch
static uint8_t usb_serial_getch(struct usb_serial_periph *p)
Definition: usb_ser_hw.c:581
ULCR_CHAR_8
#define ULCR_CHAR_8
Definition: lpcUART.h:85
GET_LINE_CODING
#define GET_LINE_CODING
Definition: usb_ser_hw.c:82
usb_serial.h
arch independent USB API
VCOM_FIFO_SIZE
#define VCOM_FIFO_SIZE
Definition: usb_ser_hw.c:85
VCOM_event
void VCOM_event(void)
Definition: usb_ser_hw.c:571
ULCR_PAR_SPACE
#define ULCR_PAR_SPACE
Definition: lpcUART.h:92
armVIC.h
LPC21xx.h
abClassReqData
static uint8_t abClassReqData[8]
Definition: usb_ser_hw.c:108
fifo_free
int fifo_free(fifo_t *fifo)
Definition: usb_ser_hw.c:292
VICIntSelect
#define VICIntSelect
Definition: LPC21xx.h:430
usb_serial_check_free_space
static int usb_serial_check_free_space(struct usb_serial_periph *p, long *fd, uint16_t len)
Definition: usb_ser_hw.c:550
VCOM_send_message
void VCOM_send_message(void)
Definition: usb_ser_hw.c:574
BulkOut
static void BulkOut(U8 bEP, U8 bEPStatus)
Local function to handle incoming bulk data.
Definition: usb_ser_hw.c:432
ULCR_CHAR_7
#define ULCR_CHAR_7
Definition: lpcUART.h:84
fifo_t::buf
uint8_t * buf
Definition: usb_ser_hw.c:93
fifo_t::tail
int tail
Definition: usb_ser_hw.c:92
uint32_t
unsigned long uint32_t
Definition: types.h:18
usb_serial
struct usb_serial_periph usb_serial
Definition: usb_ser_hw.c:547
TLineCoding::bParityType
uint8_t bParityType
Definition: usb_ser_hw.c:100
ULCR_STOP_2
#define ULCR_STOP_2
Definition: lpcUART.h:87
ASSERT
#define ASSERT(x)
Definition: usb_ser_hw.c:88
usb_serial_char_available
static int usb_serial_char_available(struct usb_serial_periph *p)
Definition: usb_ser_hw.c:576
BULK_IN_EP
#define BULK_IN_EP
Definition: usb_ser_hw.c:71
SET_LINE_CODING
#define SET_LINE_CODING
Definition: usb_ser_hw.c:81
usb_serial_send
static void usb_serial_send(struct usb_serial_periph *p, long fd)
Definition: usb_ser_hw.c:568
CS_INTERFACE
#define CS_INTERFACE
Definition: usb_ser_hw.c:78
usb_serial_transmit_buffer
static void usb_serial_transmit_buffer(struct usb_serial_periph *p, long fd, uint8_t *data, uint16_t len)
Definition: usb_ser_hw.c:560
TLineCoding::bCharFormat
uint8_t bCharFormat
Definition: usb_ser_hw.c:99
INT_IN_EP
#define INT_IN_EP
Definition: usb_ser_hw.c:69
usb_serial_periph
Definition: usb_serial.h:35
_VIC_ADDR
#define _VIC_ADDR(idx)
Definition: armVIC.h:20
PCLK
#define PCLK
Definition: booz_1.0.h:18
LineCoding
static TLineCoding LineCoding
Definition: usb_ser_hw.c:106
usb_serial_periph::device
struct link_device device
Generic device interface.
Definition: usb_serial.h:37
U0DLM
#define U0DLM
Definition: LPC21xx.h:128
ULCR_CHAR_6
#define ULCR_CHAR_6
Definition: lpcUART.h:83
VIC_BIT
#define VIC_BIT(chan)
Definition: lpcVIC.h:105
std.h
BulkIn
static void BulkIn(U8 bEP, U8 bEPStatus)
Local function to handle outgoing bulk data.
Definition: usb_ser_hw.c:461
EOF
#define EOF
Definition: usb_ser_hw.c:87
fifo_t::head
int head
Definition: usb_ser_hw.c:91
VCOM_check_free_space
bool VCOM_check_free_space(uint16_t len)
Checks if buffer free in VCOM buffer.
Definition: usb_ser_hw.c:409
U1DLL
#define U1DLL
Definition: LPC21xx.h:149
fifo_init
void fifo_init(fifo_t *fifo, U8 *buf)
Definition: usb_ser_hw.c:246
VCOM_getchar
int VCOM_getchar(void)
Reads one character from VCOM port.
Definition: usb_ser_hw.c:386
TLineCoding::dwDTERate
uint32_t dwDTERate
Definition: usb_ser_hw.c:98
allow_line_coding
int allow_line_coding
Definition: usb_ser_hw.c:104
rxfifo
static fifo_t rxfifo
Definition: usb_ser_hw.c:114
uint8_t
unsigned char uint8_t
Definition: types.h:14
U0LCR
#define U0LCR
Definition: LPC21xx.h:124
VICVectAddr
#define VICVectAddr
Definition: LPC21xx.h:436
fifo_avail
int fifo_avail(fifo_t *fifo)
Definition: usb_ser_hw.c:287
txfifo
static fifo_t txfifo
Definition: usb_ser_hw.c:113
fifo_t
Definition: usb_ser_hw.c:90
HandleClassRequest
static BOOL HandleClassRequest(TSetupPacket *pSetup, int *piLen, U8 **ppbData)
Local function to handle the USB-CDC class requests.
Definition: usb_ser_hw.c:493
ULCR_PAR_EVEN
#define ULCR_PAR_EVEN
Definition: lpcUART.h:90
LE_WORD
#define LE_WORD(x)
Definition: usb_ser_hw.c:75
fd
int fd
Definition: serial.c:26
U0DLL
#define U0DLL
Definition: LPC21xx.h:127
usb_serial_transmit
static void usb_serial_transmit(struct usb_serial_periph *p, long fd, uint8_t byte)
Definition: usb_ser_hw.c:555
ULCR_PAR_NO
#define ULCR_PAR_NO
Definition: lpcUART.h:88
rxdata
static uint8_t rxdata[VCOM_FIFO_SIZE]
Definition: usb_ser_hw.c:111
VCOM_allow_linecoding
void VCOM_allow_linecoding(uint8_t mode)
TLineCoding::bDataBits
uint8_t bDataBits
Definition: usb_ser_hw.c:101
enableIRQ
unsigned enableIRQ(void)
Definition: armVIC.c:51
USB_VIC_SLOT
#define USB_VIC_SLOT
Definition: usb_ser_hw.c:66
MAX_PACKET_SIZE
#define MAX_PACKET_SIZE
Definition: usb_ser_hw.c:73
SET_CONTROL_LINE_STATE
#define SET_CONTROL_LINE_STATE
Definition: usb_ser_hw.c:83
fifo_put
BOOL fifo_put(fifo_t *fifo, U8 c)
Definition: usb_ser_hw.c:253
U1DLM
#define U1DLM
Definition: LPC21xx.h:150
VCOM_putchar
int VCOM_putchar(int c)
Writes one character to VCOM port.
Definition: usb_ser_hw.c:376
BulkOut_is_blocked
static bool BulkOut_is_blocked
Definition: usb_ser_hw.c:116
VIC_ENABLE
#define VIC_ENABLE
Definition: lpcVIC.h:102
TLineCoding
Definition: usb_ser_hw.c:97
VICIntEnable
#define VICIntEnable
Definition: LPC21xx.h:431
ULCR_CHAR_5
#define ULCR_CHAR_5
Definition: lpcUART.h:82
ULCR_DLAB_ENABLE
#define ULCR_DLAB_ENABLE
Definition: lpcUART.h:94
USBIntHandler
static void USBIntHandler(void)
Interrupt handler.
Definition: usb_ser_hw.c:531
mode
static uint8_t mode
mode holds the current sonar mode mode = 0 used at high altitude, uses 16 wave patterns mode = 1 used...
Definition: sonar_bebop.c:69
abDescriptors
static const uint8_t abDescriptors[]
Definition: usb_ser_hw.c:133
FALSE
#define FALSE
Definition: std.h:5
TRUE
#define TRUE
Definition: std.h:4
_VIC_CNTL
#define _VIC_CNTL(idx)
Definition: armVIC.h:19
U1LCR
#define U1LCR
Definition: LPC21xx.h:144
VCOM_init
void VCOM_init(void)
Definition: usb_ser_hw.c:586
USBFrameHandler
static void USBFrameHandler(U16 wFrame)
Definition: usb_ser_hw.c:538
VIC_USB
#define VIC_USB
Definition: lpcVIC.h:92
p
static float p[2][2]
Definition: ins_alt_float.c:268
fifo_get
BOOL fifo_get(fifo_t *fifo, U8 *pc)
Definition: usb_ser_hw.c:270
ULCR_PAR_ODD
#define ULCR_PAR_ODD
Definition: lpcUART.h:89
txdata
static uint8_t txdata[VCOM_FIFO_SIZE]
Definition: usb_ser_hw.c:110