User API reference of the Communication Device Class (ACM). More...
Functions | |
void | USBD_CDCn_ACM_Initialize (void) |
Callback function called during USBD_Initialize to initialize the USB CDC class instance (ACM) | |
void | USBD_CDCn_ACM_Uninitialize (void) |
Callback function called during USBD_Uninitialize to de-initialize the USB CDC class instance (ACM) | |
void | USBD_CDCn_ACM_Reset (void) |
Callback function called upon USB Bus Reset signaling. | |
bool | USBD_CDCn_ACM_SendEncapsulatedCommand (const uint8_t *buf, uint16_t len) |
Callback function called upon reception of request send encapsulated command sent by the USB Host. | |
bool | USBD_CDCn_ACM_GetEncapsulatedResponse (uint16_t max_len, uint8_t **buf, uint16_t *len) |
Callback function called upon reception of request to get encapsulated response sent by the USB Host. | |
bool | USBD_CDCn_ACM_SetLineCoding (const CDC_LINE_CODING *line_coding) |
Callback function called upon USB Host request to change communication settings. | |
bool | USBD_CDCn_ACM_GetLineCoding (CDC_LINE_CODING *line_coding) |
Callback function called upon USB Host request to retrieve communication settings. | |
bool | USBD_CDCn_ACM_SetControlLineState (uint16_t state) |
Callback function called upon USB Host request to set control line states. | |
void | USBD_CDCn_ACM_DataReceived (uint32_t len) |
Callback function called when new data was received. | |
void | USBD_CDCn_ACM_DataSent (void) |
Callback function called when all data was sent. | |
int32_t | USBD_CDC_ACM_WriteData (uint8_t instance, const uint8_t *buf, int32_t len) |
Write data from Communication Device to USB Host. | |
int | USBD_CDC_ACM_PutChar (uint8_t instance, int ch) |
Write a single character from Communication Device to USB Host. | |
int32_t | USBD_CDC_ACM_ReadData (uint8_t instance, uint8_t *buf, int32_t len) |
Read multiple data bytes received by Communication Device from USB Host. | |
int | USBD_CDC_ACM_GetChar (uint8_t instance) |
Read one character received by Communication Device from USB Host. | |
int32_t | USBD_CDC_ACM_DataAvailable (uint8_t instance) |
Retrieve number of data bytes received by Communication Device from USB Host that are available to read. | |
usbStatus | USBD_CDC_ACM_Notify_SerialState (uint8_t instance, uint16_t state) |
Send notification of Communication Device status and line states to USB Host. | |
usbStatus | USBD_CDC_ACM_Notify_ResponseAvailable (uint8_t instance) |
Send notification to USB Host signaling that response is available. | |
User API reference of the Communication Device Class (ACM).
int32_t USBD_CDC_ACM_DataAvailable | ( | uint8_t | instance | ) |
Retrieve number of data bytes received by Communication Device from USB Host that are available to read.
[in] | instance | instance of CDC class. |
The function USBD_CDC_ACM_DataAvailable returns the number of bytes available in the intermediate buffer that was received from the USB Host by the CDC device instance that is specified by the argument instance.
int USBD_CDC_ACM_GetChar | ( | uint8_t | instance | ) |
Read one character received by Communication Device from USB Host.
[in] | instance | instance of CDC class. |
The function USBD_CDC_ACM_GetChar reads a data character from the intermediate buffer that was received from the USB Host by the CDC device instance that is specified by the argument instance.
usbStatus USBD_CDC_ACM_Notify_ResponseAvailable | ( | uint8_t | instance | ) |
Send notification to USB Host signaling that response is available.
[in] | instance | instance of CDC class. |
The function USBD_CDC_ACM_Notify_ResponseAvailable sends notification that response is available over the Interrupt Endpoint.
The argument instance specifies the CDC device that is to be used with USBD_CDC_ACM_Notify_ResponseAvailable.
usbStatus USBD_CDC_ACM_Notify_SerialState | ( | uint8_t | instance, |
uint16_t | state | ||
) |
Send notification of Communication Device status and line states to USB Host.
[in] | instance | instance of CDC class. |
[in] | state | error status and line states :
|
The function USBD_CDC_ACM_Notify_SerialState sends error and line status information about the Virtual COM Port over the Interrupt Endpoint.
The argument instance specifies the CDC device that is to be used with USBD_CDC_ACM_Notify_SerialState.
The argument state specifies the error status and the line state.
int USBD_CDC_ACM_PutChar | ( | uint8_t | instance, |
int | ch | ||
) |
Write a single character from Communication Device to USB Host.
[in] | instance | instance of CDC class. |
[in] | ch | character to write. |
The function USBD_CDC_ACM_PutChar asynchronously prepares a data byte that will be returned to the USB Host upon request.
The argument instance specifies the CDC class instance that is to be used.
The argument ch represents the character to be written.
int32_t USBD_CDC_ACM_ReadData | ( | uint8_t | instance, |
uint8_t * | buf, | ||
int32_t | len | ||
) |
Read multiple data bytes received by Communication Device from USB Host.
[in] | instance | instance of CDC class. |
[out] | buf | buffer that receives data. |
[in] | len | maximum number of bytes to read. |
The function USBD_CDC_ACM_ReadData reads data from the intermediate buffer that was received from the USB Host and stores them into a buffer.
The argument instance specifies the CDC class instance that is to be used.
The argument buf is a pointer to the buffer where received data will be stored.
The argument len specifies the number of bytes to be read.
int32_t USBD_CDC_ACM_WriteData | ( | uint8_t | instance, |
const uint8_t * | buf, | ||
int32_t | len | ||
) |
Write data from Communication Device to USB Host.
[in] | instance | instance of CDC class. |
[in] | buf | buffer containing data bytes to write. |
[in] | len | number of bytes to write. |
The function USBD_CDC_ACM_WriteData asynchronously prepares data that will be returned to the USB Host upon request.
The argument instance specifies the CDC class instance that is to be used.
The argument buf is a pointer to the buffer containing the data to be written.
The argument len specifies the number of bytes to be written.
void USBD_CDCn_ACM_DataReceived | ( | uint32_t | len | ) |
Callback function called when new data was received.
[in] | len | number of bytes available to read. |
The function USBD_CDCn_ACM_DataReceived notifies that there is newly received data available.
The argument len is number of bytes available to read.
Modify this function to the application needs.
void USBD_CDCn_ACM_DataSent | ( | void | ) |
Callback function called when all data was sent.
The function USBD_CDCn_ACM_DataSent notifies that all data was sent.
bool USBD_CDCn_ACM_GetEncapsulatedResponse | ( | uint16_t | max_len, |
uint8_t ** | buf, | ||
uint16_t * | len | ||
) |
Callback function called upon reception of request to get encapsulated response sent by the USB Host.
[in] | max_len | maximum number of data bytes that USB Host expects to receive. |
[out] | buf | pointer to buffer containing get encapsulated response to be returned to USB Host. |
[out] | len | pointer to number of data bytes to be returned to USB Host. |
The function USBD_CDCn_ACM_GetEncapsulatedResponse is used for transferring data from standard CDC ACM USB Device to USB Host, and content of data is specified by protocol used. This command is used for RNDIS device in which case protocol is Vendor-specific and specified by Remote Network Driver Interface Specification.
The argument max_len is a maximum number of bytes that USB Host expects to receive.
The argument buf is a pointer to the buffer containing response to get encapsulated response request to be sent by the USB Device.
The argument len is a pointer to number of bytes, that encapsulated response data contains, and will be returned to USB Host.
Modify this function to the application needs.
bool USBD_CDCn_ACM_GetLineCoding | ( | CDC_LINE_CODING * | line_coding | ) |
Callback function called upon USB Host request to retrieve communication settings.
[out] | line_coding | pointer to CDC_LINE_CODING structure. |
The function USBD_CDCn_ACM_GetLineCoding retrieves communication settings of the port used as the Virtual COM Port.
The argument line_coding is a pointer to the CDC Line Coding structure containing coding settings.
Modify this function to the application needs.
void USBD_CDCn_ACM_Initialize | ( | void | ) |
Callback function called during USBD_Initialize to initialize the USB CDC class instance (ACM)
The function USBD_CDCn_ACM_Initialize initializes the hardware resources of the port used as the Virtual COM Port. It is called during USBD_Initialize. The function may be used to allocate resources and initialize peripherals.
Modify this function to the application's needs.
Code Example
The following code initializes an UART that is mapped as the Virtual COM Port to the CDC class.
void USBD_CDCn_ACM_Reset | ( | void | ) |
Callback function called upon USB Bus Reset signaling.
The function USBD_CDCn_ACM_Reset resets the internal states of the port used as the Virtual COM Port.
Modify this function to the application's needs.
Code Example
The following code resets an UART that is mapped as the Virtual COM Port to the CDC class.
bool USBD_CDCn_ACM_SendEncapsulatedCommand | ( | const uint8_t * | buf, |
uint16_t | len | ||
) |
Callback function called upon reception of request send encapsulated command sent by the USB Host.
[in] | buf | buffer that contains send encapsulated command request. |
[in] | len | length of send encapsulated command request. |
The function USBD_CDCn_ACM_SendEncapsulatedCommand is used for transferring data from USB Host to standard CDC ACM USB Device, and content of data is specified by protocol used. This command is used for RNDIS device in which case protocol is Vendor-specific and specified by Remote Network Driver Interface Specification.
The argument buf is a pointer to the encapsulated command request received by the USB Device.
The argument len is number of bytes, that encapsulated command data contains, and is available for reading.
Modify this function to the application needs.
bool USBD_CDCn_ACM_SetControlLineState | ( | uint16_t | state | ) |
Callback function called upon USB Host request to set control line states.
[in] | state | control line settings bitmap :
|
The function USBD_CDCn_ACM_SetControlLineState sets control line state on the port used as the Virtual COM Port.
The argument state represents control signal bitmap (0. bit - DTR line state, 1. bit - RTS line state).
Modify this function to the application needs.
Code Example
The following code outputs the line state to LEDs.
bool USBD_CDCn_ACM_SetLineCoding | ( | const CDC_LINE_CODING * | line_coding | ) |
Callback function called upon USB Host request to change communication settings.
[in] | line_coding | pointer to CDC_LINE_CODING structure. |
The function USBD_CDCn_ACM_SetLineCoding changes communication settings of the port used as the Virtual COM Port.
The argument line_coding is a pointer to the CDC Line Coding structure containing the requested coding settings.
Modify this function to the application needs.
Code Example
The following code configures an UART that is mapped as the Virtual COM Port to the CDC class.
void USBD_CDCn_ACM_Uninitialize | ( | void | ) |
Callback function called during USBD_Uninitialize to de-initialize the USB CDC class instance (ACM)
The function USBD_CDCn_ACM_Uninitialize de-initializes/releases the hardware resources of the port used as the Virtual COM Port. It is called during USBD_Uninitialize. If USBD_CDCn_ACM_Initialize has been adapted to the application, USBD_CDCn_ACM_Uninitialize should release resources and should de-initialize peripherals.
Code Example