Open Model Railroad Network (OpenMRN)
Loading...
Searching...
No Matches
TivaUsbCdcDevice.cxx File Reference
#include <algorithm>
#include <cstdint>
#include <fcntl.h>
#include <sys/select.h>
#include "inc/hw_types.h"
#include "inc/hw_memmap.h"
#include "inc/hw_ints.h"
#include "driverlib/rom.h"
#include "driverlib/rom_map.h"
#include "usblib/usblib.h"
#include "usblib/usbcdc.h"
#include "usblib/usb-ids.h"
#include "usblib/device/usbdevice.h"
#include "usblib/device/usbdcdc.h"
#include "TivaDev.hxx"

Go to the source code of this file.

Macros

#define gcc
 not sure why this is needed
 
#define TIVA_USB_PACKET_SIZE   64
 This is fixed and equals the USB packet size that the CDC device will advertise to be able to receive.
 
#define TIVA_USB_BUFFER_SIZE   (TIVA_USB_PACKET_SIZE * 4)
 This is the size of the RX buffer in bytes.
 
#define NUM_STRING_DESCRIPTORS   (sizeof(stringDescriptors) / sizeof(uint8_t *))
 number of string descriptors
 

Functions

void usb0_interrupt_handler (void)
 Handle interrupts for USB0.
 

Variables

const uint8_t langDescriptor []
 The languages supported by this device.
 
const uint8_t manufacturerString []
 The manufacturur string.
 
const uint8_t productString []
 The product string.
 
const uint8_t serialNumberString []
 The serial number string.
 
const uint8_t controlInterfaceString []
 The configuration interface description string.
 
const uint8_t configString []
 The configuration description string.
 
const uint8_t *const stringDescriptors []
 The descriptor string table.
 
static TivaCdcinstances [1] = {NULL}
 Instance pointers help us get context from the interrupt handler(s)
 

Detailed Description

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  • Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  • Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

This file implements a USB CDC device driver layer specific to TivaWare.

Author
Stuart W. Baker
Date
6 May 2014

Definition in file TivaUsbCdcDevice.cxx.

Macro Definition Documentation

◆ gcc

#define gcc

not sure why this is needed

Definition at line 36 of file TivaUsbCdcDevice.cxx.

◆ NUM_STRING_DESCRIPTORS

#define NUM_STRING_DESCRIPTORS   (sizeof(stringDescriptors) / sizeof(uint8_t *))

number of string descriptors

Definition at line 142 of file TivaUsbCdcDevice.cxx.

◆ TIVA_USB_BUFFER_SIZE

#define TIVA_USB_BUFFER_SIZE   (TIVA_USB_PACKET_SIZE * 4)

This is the size of the RX buffer in bytes.

This is a performance parameter and larger values will result in higher max throughput.

Definition at line 66 of file TivaUsbCdcDevice.cxx.

◆ TIVA_USB_PACKET_SIZE

#define TIVA_USB_PACKET_SIZE   64

This is fixed and equals the USB packet size that the CDC device will advertise to be able to receive.

This is a performance parameter, 64 is the largest packet size permitted by USB for virtual serial ports.

Definition at line 61 of file TivaUsbCdcDevice.cxx.

Function Documentation

◆ usb0_interrupt_handler()

void usb0_interrupt_handler ( void  )

Handle interrupts for USB0.

Definition at line 426 of file TivaUsbCdcDevice.cxx.

Variable Documentation

◆ configString

const uint8_t configString[]
Initial value:
=
{
2 + (26 * 2),
USB_DTYPE_STRING,
'S', 0, 'e', 0, 'l', 0, 'f', 0, ' ', 0, 'P', 0, 'o', 0, 'w', 0,
'e', 0, 'r', 0, 'e', 0, 'd', 0, ' ', 0, 'C', 0, 'o', 0, 'n', 0,
'f', 0, 'i', 0, 'g', 0, 'u', 0, 'r', 0, 'a', 0, 't', 0, 'i', 0,
'o', 0, 'n', 0
}

The configuration description string.

Definition at line 119 of file TivaUsbCdcDevice.cxx.

◆ controlInterfaceString

const uint8_t controlInterfaceString[]
Initial value:
=
{
2 + (21 * 2),
USB_DTYPE_STRING,
'A', 0, 'C', 0, 'M', 0, ' ', 0, 'C', 0, 'o', 0, 'n', 0, 't', 0,
'r', 0, 'o', 0, 'l', 0, ' ', 0, 'I', 0, 'n', 0, 't', 0, 'e', 0,
'r', 0, 'f', 0, 'a', 0, 'c', 0, 'e', 0
}

The configuration interface description string.

Definition at line 108 of file TivaUsbCdcDevice.cxx.

◆ instances

TivaCdc* instances[1] = {NULL}
static

Instance pointers help us get context from the interrupt handler(s)

Definition at line 145 of file TivaUsbCdcDevice.cxx.

◆ langDescriptor

const uint8_t langDescriptor[]
Initial value:
=
{
4,
USB_DTYPE_STRING,
USBShort(USB_LANG_EN_US)
}

The languages supported by this device.

Definition at line 70 of file TivaUsbCdcDevice.cxx.

◆ manufacturerString

const uint8_t manufacturerString[]
Initial value:
=
{
2 + (7 * 2),
USB_DTYPE_STRING,
'O', 0, 'p', 0, 'e', 0, 'n', 0, 'M', 0, 'R', 0, 'N', 0
}

The manufacturur string.

Definition at line 79 of file TivaUsbCdcDevice.cxx.

◆ productString

const uint8_t productString[]
Initial value:
=
{
2 + (16 * 2),
USB_DTYPE_STRING,
'V', 0, 'i', 0, 'r', 0, 't', 0, 'u', 0, 'a', 0, 'l', 0, ' ', 0,
'C', 0, 'O', 0, 'M', 0, ' ', 0, 'P', 0, 'o', 0, 'r', 0, 't', 0
}

The product string.

Definition at line 88 of file TivaUsbCdcDevice.cxx.

◆ serialNumberString

const uint8_t serialNumberString[]
Initial value:
=
{
2 + (8 * 2),
USB_DTYPE_STRING,
'2', 0, '2', 0, '3', 0, '4', 0, '5', 0, '6', 0, '7', 0, '8', 0
}

The serial number string.

Definition at line 99 of file TivaUsbCdcDevice.cxx.

◆ stringDescriptors

const uint8_t* const stringDescriptors[]
Initial value:
=
{
}
const uint8_t controlInterfaceString[]
The configuration interface description string.
const uint8_t langDescriptor[]
The languages supported by this device.
const uint8_t manufacturerString[]
The manufacturur string.
const uint8_t productString[]
The product string.
const uint8_t configString[]
The configuration description string.
const uint8_t serialNumberString[]
The serial number string.

The descriptor string table.

Definition at line 131 of file TivaUsbCdcDevice.cxx.