PDL for FM4  Version1.2
Peripheral Driverl Library for FM4
USB Device Middleware: CDC Com - Virtual Com Port

Data Structures

struct  stc_cdc_linecoding
 

Macros

#define USBDEVICECDCCOM_EPOUT_BUFFERSIZE   128
 
#define USBDEVICECDCCOM_MAX_RECEIVE_BUFFER   512
 
#define USBDEVICECDCCOM_USE_UARTCOMMANDS   0
 
#define SEND_ENCAPSULATED_COMMAND   0x00
 
#define GET_ENCAPSULATED_RESPONSE   0x01
 
#define SET_COMM_FEATURE   0x02
 
#define GET_COMM_FEATURE   0x03
 
#define CLEAR_COMM_FEATURE   0x04
 
#define SET_AUX_LINE_STATE   0x10
 
#define SET_HOOK_STATE   0x11
 
#define PULSE_SETUP   0x12
 
#define SEND_PULSE   0x13
 
#define SET_PULSE_TIME   0x14
 
#define RING_AUX_JACK   0x15
 
#define SET_LINE_CODING   0x20
 
#define GET_LINE_CODING   0x21
 
#define SET_CONTROL_LINE_STATE   0x22
 
#define SEND_BREAK   0x23
 
#define SET_RINGER_PARMS   0x30
 
#define GET_RINGER_PARMS   0x31
 
#define SET_OPERATION_PARMS   0x32
 
#define GET_OPERATION_PARMS   0x33
 
#define SET_LINE_PARMS   0x34
 
#define GET_LINE_PARMS   0x35
 
#define DIAL_DIGITS   0x36
 
#define SET_UNIT_PARAMETER   0x37
 
#define GET_UNIT_PARAMETER   0x38
 
#define CLEAR_UNIT_PARAMETER   0x39
 
#define GET_PROFILE   0x3A
 
#define SET_ETHERNET_MULTICAST_FILTERS   0x40
 
#define SET_ETHERNET_POWER_MANAGEMENT_PATTERN_FILTER   0x41
 
#define GET_ETHERNET_POWER_MANAGEMENT_PATTERN_FILTER   0x42
 
#define SET_ETHERNET_PACKET_FILTER   0x43
 
#define GET_ETHERNET_STATISTIC   0x44
 
#define SET_ATM_DATA_FORMAT   0x50
 
#define GET_ATM_DEVICE_STATISTICS   0x51
 
#define SET_ATM_DEFAULT_VC   0x52
 
#define GET_ATM_VC_STATISTICS   0x53
 
#define DEC   0
 
#define HEX   1
 
#define USBCLASSCDC_CHARFORMAT_1STOPBIT   0
 
#define USBCLASSCDC_CHARFORMAT_1_5STOPBIT   1
 
#define USBCLASSCDC_CHARFORMAT_2STOPBIT   2
 
#define USBCLASSCDC_PARITYTYPE_NONE   0
 
#define USBCLASSCDC_PARITYTYPE_ODD   1
 
#define USBCLASSCDC_PARITYTYPE_EVEN   2
 
#define USBCLASSCDC_PARITYTYPE_MARK   3
 
#define USBCLASSCDC_PARITYTYPE_SPACE   4
 

Typedefs

typedef void(* cdc_data_received_t )(uint8_t *pu8Data, uint32_t u32ReceviedSize)
 
typedef void(* cdc_data_sent_t )(void)
 
typedef struct stc_cdc_linecoding stc_cdc_linecoding_t
 
typedef void(* usbdevicecdccom_linecodingchange_func_ptr_t )(stc_cdc_linecoding_t *pstcLineCoding)
 

Functions

void UsbDeviceCdcCom_Init (stc_usbn_t *pstcUsb)
 Initialisation callback. More...
 
boolean_t UsbDeviceCdcCom_DataSent (void)
 
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)
 
void UsbDeviceCdcCom_SetReceivedCallback (cdc_data_received_t pstnCallback)
 
void UsbDeviceCdcCom_SetSentCallback (cdc_data_sent_t pstnCallback)
 
void UsbDeviceCdcCom_SetCallbackLineCodingChange (usbdevicecdccom_linecodingchange_func_ptr_t pfnLineCodingChangeCallback)
 

Detailed Description

Provided functions of USB module:

Emulates UART routines for USB virtual com port

Macro Definition Documentation

#define CLEAR_COMM_FEATURE   0x04

Definition at line 134 of file UsbDeviceCdcCom.h.

#define CLEAR_UNIT_PARAMETER   0x39

Definition at line 154 of file UsbDeviceCdcCom.h.

#define DEC   0
#define DIAL_DIGITS   0x36

Definition at line 151 of file UsbDeviceCdcCom.h.

#define GET_ATM_DEVICE_STATISTICS   0x51

Definition at line 162 of file UsbDeviceCdcCom.h.

#define GET_ATM_VC_STATISTICS   0x53

Definition at line 164 of file UsbDeviceCdcCom.h.

#define GET_COMM_FEATURE   0x03

Definition at line 133 of file UsbDeviceCdcCom.h.

#define GET_ENCAPSULATED_RESPONSE   0x01

Definition at line 131 of file UsbDeviceCdcCom.h.

#define GET_ETHERNET_POWER_MANAGEMENT_PATTERN_FILTER   0x42

Definition at line 158 of file UsbDeviceCdcCom.h.

#define GET_ETHERNET_STATISTIC   0x44

Definition at line 160 of file UsbDeviceCdcCom.h.

#define GET_LINE_CODING   0x21

Definition at line 142 of file UsbDeviceCdcCom.h.

Referenced by DecodeSetupRequest().

#define GET_LINE_PARMS   0x35

Definition at line 150 of file UsbDeviceCdcCom.h.

#define GET_OPERATION_PARMS   0x33

Definition at line 148 of file UsbDeviceCdcCom.h.

#define GET_PROFILE   0x3A

Definition at line 155 of file UsbDeviceCdcCom.h.

#define GET_RINGER_PARMS   0x31

Definition at line 146 of file UsbDeviceCdcCom.h.

#define GET_UNIT_PARAMETER   0x38

Definition at line 153 of file UsbDeviceCdcCom.h.

#define HEX   1
#define PULSE_SETUP   0x12

Definition at line 137 of file UsbDeviceCdcCom.h.

#define RING_AUX_JACK   0x15

Definition at line 140 of file UsbDeviceCdcCom.h.

#define SEND_BREAK   0x23

Definition at line 144 of file UsbDeviceCdcCom.h.

#define SEND_ENCAPSULATED_COMMAND   0x00

Definition at line 130 of file UsbDeviceCdcCom.h.

#define SEND_PULSE   0x13

Definition at line 138 of file UsbDeviceCdcCom.h.

#define SET_ATM_DATA_FORMAT   0x50

Definition at line 161 of file UsbDeviceCdcCom.h.

#define SET_ATM_DEFAULT_VC   0x52

Definition at line 163 of file UsbDeviceCdcCom.h.

#define SET_AUX_LINE_STATE   0x10

Definition at line 135 of file UsbDeviceCdcCom.h.

#define SET_COMM_FEATURE   0x02

Definition at line 132 of file UsbDeviceCdcCom.h.

#define SET_CONTROL_LINE_STATE   0x22

Definition at line 143 of file UsbDeviceCdcCom.h.

Referenced by DecodeSetupRequest().

#define SET_ETHERNET_MULTICAST_FILTERS   0x40

Definition at line 156 of file UsbDeviceCdcCom.h.

#define SET_ETHERNET_PACKET_FILTER   0x43

Definition at line 159 of file UsbDeviceCdcCom.h.

#define SET_ETHERNET_POWER_MANAGEMENT_PATTERN_FILTER   0x41

Definition at line 157 of file UsbDeviceCdcCom.h.

#define SET_HOOK_STATE   0x11

Definition at line 136 of file UsbDeviceCdcCom.h.

#define SET_LINE_CODING   0x20

Definition at line 141 of file UsbDeviceCdcCom.h.

Referenced by DecodeSetupRequest().

#define SET_LINE_PARMS   0x34

Definition at line 149 of file UsbDeviceCdcCom.h.

#define SET_OPERATION_PARMS   0x32

Definition at line 147 of file UsbDeviceCdcCom.h.

#define SET_PULSE_TIME   0x14

Definition at line 139 of file UsbDeviceCdcCom.h.

#define SET_RINGER_PARMS   0x30

Definition at line 145 of file UsbDeviceCdcCom.h.

#define SET_UNIT_PARAMETER   0x37

Definition at line 152 of file UsbDeviceCdcCom.h.

#define USBCLASSCDC_CHARFORMAT_1_5STOPBIT   1

Definition at line 184 of file UsbDeviceCdcCom.h.

#define USBCLASSCDC_CHARFORMAT_1STOPBIT   0

Definition at line 183 of file UsbDeviceCdcCom.h.

#define USBCLASSCDC_CHARFORMAT_2STOPBIT   2

Definition at line 185 of file UsbDeviceCdcCom.h.

#define USBCLASSCDC_PARITYTYPE_EVEN   2

Definition at line 189 of file UsbDeviceCdcCom.h.

#define USBCLASSCDC_PARITYTYPE_MARK   3

Definition at line 190 of file UsbDeviceCdcCom.h.

#define USBCLASSCDC_PARITYTYPE_NONE   0

Definition at line 187 of file UsbDeviceCdcCom.h.

#define USBCLASSCDC_PARITYTYPE_ODD   1

Definition at line 188 of file UsbDeviceCdcCom.h.

#define USBCLASSCDC_PARITYTYPE_SPACE   4

Definition at line 191 of file UsbDeviceCdcCom.h.

#define USBDEVICECDCCOM_EPOUT_BUFFERSIZE   128

Definition at line 123 of file UsbDeviceCdcCom.h.

Referenced by UsbDeviceCdcCom_Init().

#define USBDEVICECDCCOM_MAX_RECEIVE_BUFFER   512

Definition at line 124 of file UsbDeviceCdcCom.h.

Referenced by RxTxCallback().

#define USBDEVICECDCCOM_USE_UARTCOMMANDS   0

Definition at line 126 of file UsbDeviceCdcCom.h.

Typedef Documentation

typedef void(* cdc_data_received_t)(uint8_t *pu8Data, uint32_t u32ReceviedSize)

Definition at line 193 of file UsbDeviceCdcCom.h.

typedef void(* cdc_data_sent_t)(void)

Definition at line 194 of file UsbDeviceCdcCom.h.

typedef void(* usbdevicecdccom_linecodingchange_func_ptr_t)(stc_cdc_linecoding_t *pstcLineCoding)

Definition at line 204 of file UsbDeviceCdcCom.h.

Function Documentation

boolean_t UsbDeviceCdcCom_DataSent ( void  )

Check if data was sent

Returns
TRUE if data was sent

Definition at line 325 of file UsbDeviceCdcCom.c.

References DataSentFlags, FALSE, and TRUE.

boolean_t UsbDeviceCdcCom_IsConnected ( void  )

getting vcomm connection status

Returns
TRUE: active / FALSE: inactive

Definition at line 479 of file UsbDeviceCdcCom.c.

References bReady, and bVcommActive.

uint32_t UsbDeviceCdcCom_ReceiveBuffer ( uint8_t *  pu8Buffer)

transfer receive buffer and clear it

Parameters
pu8Bufferbuffer to write in
Returns
buffer size

Definition at line 623 of file UsbDeviceCdcCom.c.

References bSeperatorFlag, FALSE, pu8VcommBuffer, and u32ReceivedData.

uint8_t UsbDeviceCdcCom_ReceiveByte ( void  )

transfer one byte from the buffer

Returns
received byte

Definition at line 644 of file UsbDeviceCdcCom.c.

References pu8VcommBuffer, and u32ReceivedData.

Referenced by UsbDeviceCdcCom_ReceiveHex().

Here is the caller graph for this function:

uint32_t UsbDeviceCdcCom_ReceivedLength ( void  )

returns number of received bytes in buffer

Returns
number of received bytes in buffer

Definition at line 603 of file UsbDeviceCdcCom.c.

References bSeperatorFlag, cSeperator, TRUE, and u32ReceivedData.

uint32_t UsbDeviceCdcCom_ReceiveHex ( uint8_t  digits)

receive hex value

Parameters
digitsnumber of digits
Returns
value

Definition at line 844 of file UsbDeviceCdcCom.c.

References ASCIItobin(), FALSE, TRUE, UsbDeviceCdcCom_ReceiveByte(), UsbDeviceCdcCom_SendByte(), UsbDeviceCdcCom_SendString(), UsbDeviceCdcCom_SetEchomode(), and UsbDeviceCdcCom_SetSeparator().

Here is the call graph for this function:

uint8_t UsbDeviceCdcCom_ReceiveLastByte ( void  )

transfer last received byte without touching the buffer

Returns
received byte

Definition at line 668 of file UsbDeviceCdcCom.c.

References pu8VcommBuffer, and u32ReceivedData.

void UsbDeviceCdcCom_SendBin2DotDec99 ( uint8_t  a)

bin to ascii function

Parameters
avalue

Definition at line 818 of file UsbDeviceCdcCom.c.

References UsbDeviceCdcCom_SendByte().

Here is the call graph for this function:

void UsbDeviceCdcCom_SendBinAsci4 ( uint16_t  a,
uint8_t  base,
char_t  fill 
)

4-bit bin to ascii function

Parameters
avalue
basetype: HEX / DEC
fillfill char

Definition at line 750 of file UsbDeviceCdcCom.c.

References DEC, HEX, UsbDeviceCdcCom_SendByte(), and UsbDeviceCdcCom_SendString().

Referenced by UsbDeviceCdcCom_SendBinAsci8().

Here is the call graph for this function:

Here is the caller graph for this function:

void UsbDeviceCdcCom_SendBinAsci8 ( uint16_t  a,
uint8_t  base,
char_t  fill 
)

8-bit bin to ascii function

Parameters
avalue
basetype: HEX / DEC
fillfill char

Definition at line 782 of file UsbDeviceCdcCom.c.

References DEC, HEX, UsbDeviceCdcCom_SendBinAsci4(), UsbDeviceCdcCom_SendByte(), and UsbDeviceCdcCom_SendString().

Here is the call graph for this function:

uint8_t UsbDeviceCdcCom_SendBuffer ( uint8_t *  pu8Buffer,
uint32_t  u32Size 
)

sending a buffer

Parameters
pu8Bufferbuffer to send
u32Sizebuffersize
Returns
1: error vcomm inactive / 0: successful sent

Definition at line 538 of file UsbDeviceCdcCom.c.

References bVcommActive, SendData(), UsbDMA, and UsbIRQ.

Here is the call graph for this function:

uint8_t UsbDeviceCdcCom_SendByte ( char_t  c)

sending byte / char_t

Parameters
cbyte / char_t to send
Returns
1: error vcomm inactive / 0: successful sent

Definition at line 494 of file UsbDeviceCdcCom.c.

References bVcommActive, SendData(), and UsbPOLL.

Referenced by UsbDeviceCdcCom_ReceiveHex(), UsbDeviceCdcCom_SendBin2DotDec99(), UsbDeviceCdcCom_SendBinAsci4(), UsbDeviceCdcCom_SendBinAsci8(), and UsbDeviceCdcCom_SendHex().

Here is the call graph for this function:

Here is the caller graph for this function:

uint8_t UsbDeviceCdcCom_SendDec ( uint32_t  x)

sends a decimal-digit

Parameters
xvalue
Returns
1: error vcomm inactive / 0: successful sent

Definition at line 713 of file UsbDeviceCdcCom.c.

References pcASCII, and UsbDeviceCdcCom_SendString().

Here is the call graph for this function:

uint8_t UsbDeviceCdcCom_SendHex ( uint32_t  n,
uint8_t  digits 
)

sends a x-digit Hex-number (as ASCII charcaters)

Parameters
nvalue
digitsnumber of hex-digits
Returns
1: error vcomm inactive / 0: successful sent

Definition at line 688 of file UsbDeviceCdcCom.c.

References pcASCII, UsbDeviceCdcCom_SendByte(), and UsbDeviceCdcCom_SendString().

Here is the call graph for this function:

uint8_t UsbDeviceCdcCom_SendString ( char_t *  pcBuffer)

sending a null terminated string

Parameters
pcBufferstring to send
Returns
1: error vcomm inactive / 0: successful sent

Definition at line 514 of file UsbDeviceCdcCom.c.

References bVcommActive, SendData(), and UsbPOLL.

Referenced by UsbDeviceCdcCom_ReceiveHex(), UsbDeviceCdcCom_SendBinAsci4(), UsbDeviceCdcCom_SendBinAsci8(), UsbDeviceCdcCom_SendDec(), and UsbDeviceCdcCom_SendHex().

Here is the call graph for this function:

Here is the caller graph for this function:

void UsbDeviceCdcCom_SetCallbackLineCodingChange ( usbdevicecdccom_linecodingchange_func_ptr_t  pfnLineCodingChangeCallback)

Set callback function for LineCoding changed event

Parameters
pfnLineCodingChangeCallbackCallback handler

Definition at line 343 of file UsbDeviceCdcCom.c.

References pfnLineCodingChange.

void UsbDeviceCdcCom_SetEchoAtSeperatorOnly ( boolean_t  bEchoAtSeperatorOnlyOnOff)

echoes every received char after receiving defined seperator

Parameters
bEchoAtSeperatorOnlyOnOffswitch echo on/off

Definition at line 590 of file UsbDeviceCdcCom.c.

References bEchoAtSeperatorOnly.

void UsbDeviceCdcCom_SetEchomode ( boolean_t  bEchoOnOff)

echoes every received char

Parameters
bEchoOnOffswitch echo on/off

Definition at line 577 of file UsbDeviceCdcCom.c.

References bEchoMode.

Referenced by UsbDeviceCdcCom_ReceiveHex().

Here is the caller graph for this function:

void UsbDeviceCdcCom_SetReceivedCallback ( cdc_data_received_t  pstnCallback)

Set received callback

Parameters
pstnCallbackcallback handle

Definition at line 276 of file UsbDeviceCdcCom.c.

References pstnReceivedData.

void UsbDeviceCdcCom_SetSentCallback ( cdc_data_sent_t  pstnCallback)

Set sent callback

Parameters
pstnCallbackcallback handle

Definition at line 288 of file UsbDeviceCdcCom.c.

References pstnSentData.

void UsbDeviceCdcCom_SetSeparator ( const char_t  cNewSeperator)

splits the buffer at a defined character

Parameters
cNewSeperatorsplit buffer every newSeparator if zerro, ignore splitting (default)
Returns
1: error vcomm inactive / 0: successful sent

Definition at line 563 of file UsbDeviceCdcCom.c.

References cSeperator.

Referenced by UsbDeviceCdcCom_ReceiveHex().

Here is the caller graph for this function: