PDL for FM4  Version1.2
Peripheral Driverl Library for FM4
UsbDeviceCdcCom.c File Reference
#include "UsbDeviceCdcCom.h"
Include dependency graph for UsbDeviceCdcCom.c:

Go to the source code of this file.

Functions

static void ConfCallback (stc_usbn_t *pstcUsb)
 Configuration change callback, used to see if configuration is set or cleared. More...
 
static void RxTxCallback (stc_usbn_t *pstcUsb, struct stc_usbn_endpoint_data *pstcEndpoint)
 Receive or transmitted data callback. More...
 
static boolean_t SendData (uint8_t *pu8Buffer, uint32_t u32DataSize, en_usbsend_mode_t enMode)
 
static void DecodeSetupRequest (stc_usbn_t *pstcUsb, stc_usb_request_t *pstcSetup)
 
static void SetLineCoding (stc_usbn_t *pstcUsb, stc_usbn_endpoint_data_t *pstcEndpoint)
 
static void SendLineCoding (void)
 
static uint32_t ASCIItobin (uint8_t k)
 
void UsbDeviceCdcCom_Init (stc_usbn_t *pstcUsb)
 Initialisation callback. More...
 
void UsbDeviceCdcCom_SetReceivedCallback (cdc_data_received_t pstnCallback)
 
void UsbDeviceCdcCom_SetSentCallback (cdc_data_sent_t pstnCallback)
 
boolean_t UsbDeviceCdcCom_DataSent (void)
 
void UsbDeviceCdcCom_SetCallbackLineCodingChange (usbdevicecdccom_linecodingchange_func_ptr_t pfnLineCodingChangeCallback)
 
boolean_t UsbDeviceCdcCom_IsConnected (void)
 
uint8_t UsbDeviceCdcCom_SendByte (char_t c)
 
uint8_t UsbDeviceCdcCom_SendString (char_t *pcBuffer)
 
uint8_t UsbDeviceCdcCom_SendBuffer (uint8_t *pu8Buffer, uint32_t u32Size)
 
void UsbDeviceCdcCom_SetSeparator (const char_t cNewSeperator)
 
void UsbDeviceCdcCom_SetEchomode (boolean_t bEchoOnOff)
 
void UsbDeviceCdcCom_SetEchoAtSeperatorOnly (boolean_t bEchoAtSeperatorOnlyOnOff)
 
uint32_t UsbDeviceCdcCom_ReceivedLength (void)
 
uint32_t UsbDeviceCdcCom_ReceiveBuffer (uint8_t *pu8Buffer)
 
uint8_t UsbDeviceCdcCom_ReceiveByte (void)
 
uint8_t UsbDeviceCdcCom_ReceiveLastByte (void)
 
uint8_t UsbDeviceCdcCom_SendHex (uint32_t n, uint8_t digits)
 
uint8_t UsbDeviceCdcCom_SendDec (uint32_t x)
 
void UsbDeviceCdcCom_SendBinAsci4 (uint16_t a, uint8_t base, char_t fill)
 
void UsbDeviceCdcCom_SendBinAsci8 (uint16_t a, uint8_t base, char_t fill)
 
void UsbDeviceCdcCom_SendBin2DotDec99 (uint8_t a)
 
uint32_t UsbDeviceCdcCom_ReceiveHex (uint8_t digits)
 

Variables

static const char_t pcASCII [] = "0123456789ABCDEF"
 
static volatile uint8_t DataReceivedFlags = 0
 
static volatile uint8_t DataSentFlags = 0
 
static uint8_t pu8VcommBuffer [512]
 
static stc_cdc_linecoding_t stcLineCoding = {9600, 0 , 0 ,8}
 
static uint8_t pu8LineCoding [8]
 
static boolean_t bEchoMode = FALSE
 
static boolean_t bEchoAtSeperatorOnly = FALSE
 
static boolean_t bVcommActive = FALSE
 
static boolean_t bSeperatorFlag = FALSE
 
static char_t cSeperator = '\0'
 
static volatile uint32_t u32ReceivedData = 0
 
static uint8_t pu8IngoingBuffer [128]
 
static boolean_t bReady = FALSE
 
static stc_usbn_t * pstcUsbHandle = NULL
 
static stc_usbn_endpoint_data_t * pstcEndpointIN
 
static stc_usbn_endpoint_data_t * pstcEndpointOUT
 
static stc_usbn_endpoint_buffer_t stcEndpointBufferIN
 
static stc_usbn_endpoint_buffer_t stcEndpointBufferOUT
 
static
usbdevicecdccom_linecodingchange_func_ptr_t 
pfnLineCodingChange
 
static cdc_data_received_t pstnReceivedData
 
static cdc_data_sent_t pstnSentData
 

Detailed Description

CONST USB_ASSISTANT_OFF

A detailed description is available at USB Device Cdc Com Module description

History:

  • 2009-08-31 1.0 MSc First version (works with 16FX)
  • 2010-04-16 1.1 MSc new USB library added - API had changed
  • 2011-08-30 1.2 MSc bug fixes while echo data added UsbDeviceCdcCom_SetEchoAtSeperatorOnly for echo data only after seperator received
  • 2012-07-24 1.3 MSc Version for USB Library >= FM3
  • 2012-11-26 1.4 MSc Data received routine added
  • 2013-01-30 1.5 MSc DMA routines added
  • 2013-04-24 1.6 MSc Data sent handle added
  • 2013-10-14 1.7 MSc PDL support added

Definition in file UsbDeviceCdcCom.c.

Function Documentation

static uint32_t ASCIItobin ( uint8_t  k)
static

Definition at line 876 of file UsbDeviceCdcCom.c.

Referenced by UsbDeviceCdcCom_ReceiveHex().

Here is the caller graph for this function:

static void ConfCallback ( stc_usbn_t *  pstcUsb)
static

Configuration change callback, used to see if configuration is set or cleared.

Parameters
pstcUsbPointer to USB instance

Definition at line 137 of file UsbDeviceCdcCom.c.

References bReady, FALSE, TRUE, UsbConfigured, and UsbDevice_GetStatus().

Referenced by UsbDeviceCdcCom_Init().

Here is the call graph for this function:

Here is the caller graph for this function:

static void DecodeSetupRequest ( stc_usbn_t *  pstcUsb,
stc_usb_request_t *  pstcSetup 
)
static

Decode setup request (class specific) handler

Parameters
pstcUsbUSB handle
pstcSetuppointer of setup request

Definition at line 356 of file UsbDeviceCdcCom.c.

References stc_usb_request::bRequest, bVcommActive, FALSE, GET_LINE_CODING, pstcUsbHandle, SendLineCoding(), SET_CONTROL_LINE_STATE, SET_LINE_CODING, SetLineCoding(), TRUE, UsbDevice_ReceiveDataControl(), UsbDevice_SendDataControl(), and stc_usb_request::wValue.

Referenced by UsbDeviceCdcCom_Init().

Here is the call graph for this function:

Here is the caller graph for this function:

static void RxTxCallback ( stc_usbn_t *  pstcUsb,
struct stc_usbn_endpoint_data *  pstcEndpoint 
)
static
static boolean_t SendData ( uint8_t *  pu8Buffer,
uint32_t  u32DataSize,
en_usbsend_mode_t  enMode 
)
static

Is called from main application to send data via endpoint 1

Parameters
pu8BufferBuffer to send
u32DataSizeBuffersize
enModeSending mode: UsbPOLL, UsbIRQ or UsbDMA;
Returns
TRUE: if succesful, FALSE: if usb was not ready

Definition at line 303 of file UsbDeviceCdcCom.c.

References DataSentFlags, FALSE, Ok, pstcUsbHandle, TRUE, UsbConfigured, UsbDevice_GetStatus(), UsbDevice_SendData(), and UsbPOLL.

Referenced by UsbDeviceCdcCom_SendBuffer(), UsbDeviceCdcCom_SendByte(), and UsbDeviceCdcCom_SendString().

Here is the call graph for this function:

Here is the caller graph for this function:

static void SendLineCoding ( void  )
static

answer for request "GET_LINE_CODING"

Definition at line 458 of file UsbDeviceCdcCom.c.

References stc_cdc_linecoding::bCharFormat, stc_cdc_linecoding::bDataBits, stc_cdc_linecoding::bParityType, stc_cdc_linecoding::dwDTERate, pstcUsbHandle, pu8LineCoding, and UsbDevice_SendDataControl().

Referenced by DecodeSetupRequest().

Here is the call graph for this function:

Here is the caller graph for this function:

static void SetLineCoding ( stc_usbn_t *  pstcUsb,
stc_usbn_endpoint_data_t *  pstcEndpoint 
)
static

callback for data package of setup request "SET_LINE_CODING"

Parameters
pstcUsbUSB handle
pstcEndpointendpoint handle of received data

Definition at line 401 of file UsbDeviceCdcCom.c.

References stc_cdc_linecoding::bCharFormat, stc_cdc_linecoding::bDataBits, stc_cdc_linecoding::bParityType, stc_cdc_linecoding::dwDTERate, pfnLineCodingChange, stc_usbn_endpoint_data::pstcEndpointBuffer, and stc_usbn_endpoint_buffer::pu8Buffer.

Referenced by DecodeSetupRequest().

Here is the caller graph for this function:

Variable Documentation

boolean_t bEchoAtSeperatorOnly = FALSE
static

Definition at line 98 of file UsbDeviceCdcCom.c.

Referenced by RxTxCallback(), and UsbDeviceCdcCom_SetEchoAtSeperatorOnly().

boolean_t bEchoMode = FALSE
static

Definition at line 97 of file UsbDeviceCdcCom.c.

Referenced by RxTxCallback(), and UsbDeviceCdcCom_SetEchomode().

boolean_t bReady = FALSE
static

Definition at line 104 of file UsbDeviceCdcCom.c.

Referenced by ConfCallback(), and UsbDeviceCdcCom_IsConnected().

boolean_t bSeperatorFlag = FALSE
static
char_t cSeperator = '\0'
static
volatile uint8_t DataReceivedFlags = 0
static

Definition at line 92 of file UsbDeviceCdcCom.c.

Referenced by RxTxCallback().

volatile uint8_t DataSentFlags = 0
static

Definition at line 93 of file UsbDeviceCdcCom.c.

Referenced by RxTxCallback(), SendData(), and UsbDeviceCdcCom_DataSent().

const char_t pcASCII[] = "0123456789ABCDEF"
static

Definition at line 80 of file UsbDeviceCdcCom.c.

Referenced by UsbDeviceCdcCom_SendDec(), and UsbDeviceCdcCom_SendHex().

stc_usbn_endpoint_data_t* pstcEndpointIN
static

Definition at line 106 of file UsbDeviceCdcCom.c.

stc_usbn_endpoint_data_t* pstcEndpointOUT
static

Definition at line 107 of file UsbDeviceCdcCom.c.

stc_usbn_t* pstcUsbHandle = NULL
static
cdc_data_received_t pstnReceivedData
static

Definition at line 121 of file UsbDeviceCdcCom.c.

Referenced by RxTxCallback(), and UsbDeviceCdcCom_SetReceivedCallback().

cdc_data_sent_t pstnSentData
static

Definition at line 122 of file UsbDeviceCdcCom.c.

Referenced by RxTxCallback(), and UsbDeviceCdcCom_SetSentCallback().

uint8_t pu8IngoingBuffer[128]
static

Definition at line 103 of file UsbDeviceCdcCom.c.

Referenced by UsbDeviceCdcCom_Init().

uint8_t pu8LineCoding[8]
static

Definition at line 96 of file UsbDeviceCdcCom.c.

Referenced by SendLineCoding().

uint8_t pu8VcommBuffer[512]
static
stc_usbn_endpoint_buffer_t stcEndpointBufferIN
static

Definition at line 108 of file UsbDeviceCdcCom.c.

Referenced by UsbDeviceCdcCom_Init().

stc_usbn_endpoint_buffer_t stcEndpointBufferOUT
static

Definition at line 109 of file UsbDeviceCdcCom.c.

Referenced by UsbDeviceCdcCom_Init().

stc_cdc_linecoding_t stcLineCoding = {9600, 0 , 0 ,8}
static

Definition at line 95 of file UsbDeviceCdcCom.c.