Gecko USB RS232 bridgeKit Drivers

Detailed Description

Gecko USB to RS232 bridge (CDC Class).

CDC Implementation

This driver implements a basic USB to RS232 bridge.

CDC Device Configuration Options

This section contains a description of the configuration options for the driver. The options are #defines which are expected to be found in the application "usbconfig.h" header file. The values shown below are from the Giant Gecko DK3750 CDC example.

// USB interface numbers. Interfaces are numbered from zero to one less than
// the number of concurrent interfaces supported by the configuration. A CDC
// device is by itself a composite device and has two interfaces.
// The interface numbers must be 0 and 1 for a standalone CDC device, for a
// composite device which includes a CDC interface it must not be in conflict
// with other device interfaces.
#define CDC_CTRL_INTERFACE_NO ( 0 )
#define CDC_DATA_INTERFACE_NO ( 1 )

// Endpoint address for CDC data reception.
#define CDC_EP_DATA_OUT ( 0x01 )

// Endpoint address for CDC data transmission.
#define CDC_EP_DATA_IN ( 0x81 )

// Endpoint address for the notification endpoint (not used).
#define CDC_EP_NOTIFY ( 0x82 )

// Timer id, see USBTIMER in the USB device stack documentation.
// The CDC driver has a Rx timeout functionality which require a timer.
#define CDC_TIMER_ID ( 0 )

// DMA related macros, select DMA channels and DMA request signals.
#define CDC_UART_TX_DMA_CHANNEL   ( 0 )
#define CDC_UART_RX_DMA_CHANNEL   ( 1 )
#define CDC_TX_DMA_SIGNAL         DMAREQ_UART1_TXBL
#define CDC_RX_DMA_SIGNAL         DMAREQ_UART1_RXDATAV

// UART/USART selection macros.
#define CDC_UART                  UART1
#define CDC_UART_CLOCK            cmuClock_UART1
#define CDC_UART_ROUTE            ( UART_ROUTE_RXPEN | UART_ROUTE_TXPEN | \
                                   UART_ROUTE_LOCATION_LOC2 )
#define CDC_UART_TX_PORT          gpioPortB
#define CDC_UART_TX_PIN           9
#define CDC_UART_RX_PORT          gpioPortB
#define CDC_UART_RX_PIN           10

// Activate the RS232 switch on DKs.
#define CDC_ENABLE_DK_UART_SWITCH() BSP_PeripheralAccess(BSP_RS232_UART, true)

// No RS232 switch on STKs. Leave the definition "empty".
#define CDC_ENABLE_DK_UART_SWITCH()

Functions

void CDC_Init (void)
CDC device initialization.
int CDC_SetupCmd (const USB_Setup_TypeDef *setup)
Handle USB setup commands. Implements CDC class specific commands.
void CDC_StateChangeEvent (USBD_State_TypeDef oldState, USBD_State_TypeDef newState)
Callback function called each time the USB device state is changed. Starts CDC operation when device has been configured by USB host.

Function Documentation

int CDC_SetupCmd ( const USB_Setup_TypeDef * setup )

Handle USB setup commands. Implements CDC class specific commands.

Parameters
[in] setup Pointer to the setup packet received.
Returns
USB_STATUS_OK if command accepted. USB_STATUS_REQ_UNHANDLED when command is unknown, the USB device stack will handle the request.

Definition at line 206 of file cdc.c .

void CDC_StateChangeEvent ( USBD_State_TypeDef oldState,
USBD_State_TypeDef newState
)

Callback function called each time the USB device state is changed. Starts CDC operation when device has been configured by USB host.

Parameters
[in] oldState The device state the device has just left.
[in] newState The new device state.

Definition at line 259 of file cdc.c .