Open Model Railroad Network (OpenMRN)
Loading...
Searching...
No Matches
TinyUsbCdcImpl.hxx File Reference
#include "freertos_drivers/tinyusb/TinyUsbCdc.hxx"
#include "freertos_drivers/common/DeviceBuffer.hxx"
#include "os/OS.hxx"
#include <fcntl.h>
#include "tusb.h"

Go to the source code of this file.

Macros

#define USBD_STACK_SIZE   768
 
#define USBD_TASK_PRIO   3
 
#define _PID_MAP(itf, n)   ((CFG_TUD_##itf) << (n))
 
#define USB_PID
 
#define USB_VID   0xCAFE
 
#define USB_BCD   0x0200
 
#define EPNUM_CDC_NOTIF   0x81
 
#define EPNUM_CDC_OUT   0x02
 
#define EPNUM_CDC_IN   0x82
 
#define CONFIG_TOTAL_LEN   (TUD_CONFIG_DESC_LEN + TUD_CDC_DESC_LEN)
 

Enumerations

enum  { ITF_NUM_CDC = 0 , ITF_NUM_CDC_DATA , ITF_NUM_TOTAL }
 

Functions

void tud_cdc_rx_cb (uint8_t itf)
 
void tud_cdc_tx_complete_cb (uint8_t itf)
 
uint8_t const * tud_descriptor_device_cb (void)
 
uint8_t const * tud_descriptor_configuration_cb (uint8_t index)
 
uint16_t const * tud_descriptor_string_cb (uint8_t index, uint16_t langid)
 

Variables

uint8_t const desc_fs_configuration []
 
char const * string_desc_arr []
 
static uint16_t _desc_str [32]
 

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.

Base class for implementing a CDC Device driver using the TinyUsb stack.

Author
Balazs Racz
Date
13 Nov 2023

Definition in file TinyUsbCdcImpl.hxx.

Macro Definition Documentation

◆ _PID_MAP

#define _PID_MAP (   itf,
 
)    ((CFG_TUD_##itf) << (n))

Definition at line 255 of file TinyUsbCdcImpl.hxx.

◆ CONFIG_TOTAL_LEN

#define CONFIG_TOTAL_LEN   (TUD_CONFIG_DESC_LEN + TUD_CDC_DESC_LEN)

Definition at line 305 of file TinyUsbCdcImpl.hxx.

◆ EPNUM_CDC_IN

#define EPNUM_CDC_IN   0x82

Definition at line 303 of file TinyUsbCdcImpl.hxx.

◆ EPNUM_CDC_NOTIF

#define EPNUM_CDC_NOTIF   0x81

Definition at line 301 of file TinyUsbCdcImpl.hxx.

◆ EPNUM_CDC_OUT

#define EPNUM_CDC_OUT   0x02

Definition at line 302 of file TinyUsbCdcImpl.hxx.

◆ USB_BCD

#define USB_BCD   0x0200

Definition at line 261 of file TinyUsbCdcImpl.hxx.

◆ USB_PID

#define USB_PID
Value:
(0x4000 | _PID_MAP(CDC, 0) | _PID_MAP(MSC, 1) | _PID_MAP(HID, 2) | \
_PID_MAP(MIDI, 3) | _PID_MAP(VENDOR, 4))

Definition at line 256 of file TinyUsbCdcImpl.hxx.

◆ USB_VID

#define USB_VID   0xCAFE

Definition at line 260 of file TinyUsbCdcImpl.hxx.

◆ USBD_STACK_SIZE

#define USBD_STACK_SIZE   768

Definition at line 48 of file TinyUsbCdcImpl.hxx.

◆ USBD_TASK_PRIO

#define USBD_TASK_PRIO   3

Definition at line 52 of file TinyUsbCdcImpl.hxx.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum

Definition at line 294 of file TinyUsbCdcImpl.hxx.

Function Documentation

◆ tud_cdc_rx_cb()

void tud_cdc_rx_cb ( uint8_t  itf)

Definition at line 232 of file TinyUsbCdcImpl.hxx.

◆ tud_cdc_tx_complete_cb()

void tud_cdc_tx_complete_cb ( uint8_t  itf)

Definition at line 240 of file TinyUsbCdcImpl.hxx.

◆ tud_descriptor_configuration_cb()

uint8_t const * tud_descriptor_configuration_cb ( uint8_t  index)

Definition at line 389 of file TinyUsbCdcImpl.hxx.

◆ tud_descriptor_device_cb()

uint8_t const * tud_descriptor_device_cb ( void  )

Definition at line 265 of file TinyUsbCdcImpl.hxx.

◆ tud_descriptor_string_cb()

uint16_t const * tud_descriptor_string_cb ( uint8_t  index,
uint16_t  langid 
)

Definition at line 416 of file TinyUsbCdcImpl.hxx.

Variable Documentation

◆ _desc_str

uint16_t _desc_str[32]
static

Definition at line 411 of file TinyUsbCdcImpl.hxx.

◆ desc_fs_configuration

uint8_t const desc_fs_configuration[]
Initial value:
= {
TUD_CONFIG_DESCRIPTOR(1, ITF_NUM_TOTAL, 0, CONFIG_TOTAL_LEN, 0x00, 100),
TUD_CDC_DESCRIPTOR(
ITF_NUM_CDC, 4, EPNUM_CDC_NOTIF, 8, EPNUM_CDC_OUT, EPNUM_CDC_IN, 64),
}

Definition at line 308 of file TinyUsbCdcImpl.hxx.

◆ string_desc_arr

char const* string_desc_arr[]
Initial value:
= {
(const char[]) {0x09, 0x04},
"TinyUSB",
"TinyUSB Device",
"123456789012",
"TinyUSB CDC",
}

Definition at line 403 of file TinyUsbCdcImpl.hxx.