XDK API  3.6.0
Documentation
Data Structures | Typedefs | Enumerations | Functions | Variables
BCDS_USB.h File Reference
#include <stdint.h>
#include "em_usb.h"
+ Include dependency graph for BCDS_USB.h:
+ This graph shows which files directly or indirectly include this file:

Data Structures

struct  USB_lineCoding_s
 

Typedefs

typedef enum USB_returnCode_e USB_returnCode_t
 USB Driver Interface. More...
 
typedef void(* USB_rxCallback )(uint8_t *, uint16_t)
 

Enumerations

enum  USB_returnCode_e
 USB Driver Interface. More...
 

Functions

struct USB_lineCoding_s __attribute__ ((packed)) USB_lineCoding_t
 
uint8_t RETARGET_ReadChar (void)
 RETARGET API used by printf to Get single byte from USB. More...
 
USB_returnCode_t RETARGET_WriteChar (uint8_t *data, uint32_t len)
 RETARGET API used by printf to transmit single byte to USB. More...
 
USB_returnCode_t USB_callBackMapping (USB_rxCallback usbcallback)
 This API used to map the call back that needed to be called whenever a USB interrupt occurs. More...
 
void USB_DisConnect (void)
 Disconnect the USB device. More...
 
void USB_init (USB_lineCoding_tp lineCoding, USB_rxCallback usbRxCallback)
 Initializes the USB device. More...
 
USB_returnCode_t USB_receiveByte (uint8_t *byte)
 Get single byte from USB. More...
 
int USB_setupCommand (const USB_Setup_TypeDef *setup)
 Called each time the USB host sends a SETUP command. Implements CDC class specific commands. More...
 
void USB_stateChange (USBD_State_TypeDef oldState, USBD_State_TypeDef newState)
 Called each time the USB device state is changed. Starts CDC operation when device has been configured by USB host. More...
 
USB_returnCode_t USB_transmitByte (uint8_t byte)
 Transmit single byte to USB.(only for printf purpose) More...
 
USB_returnCode_t USB_transmitData (uint8_t *data, uint32_t len)
 Transmit Data to USB.(only for printf purpose) More...
 

Variables

uint32_t Baudrate
 
uint8_t charFormat
 
uint8_t dataBits
 
uint8_t dummy
 
uint8_t parityType
 
struct USB_lineCoding_sUSB_lineCoding_tp
 
USB_rxCallback usbRxCallback
 

Typedef Documentation

Return status for the USB transfer

typedef void(* USB_rxCallback)(uint8_t *, uint16_t)

Define the prototype to which USB receive callback functions must confirm.

Functions implementing USB receive callbacks do not need to return, therefore their return type is void none.

Example task function prototype which confirms to the type declaration:

1 void EXL_exampleTxCallbackFunction(buffer,length);

Enumeration Type Documentation

Return status for the USB transfer

Enumerator
USB_SUCCESS 
USB_FAILURE 

Function Documentation

uint8_t RETARGET_ReadChar ( void  )
Parameters
[in]void
See also
retargetio.c
Returns
byte : The byte which was received from USB
Warning
This API was made to retarget the scanf API to transmit data through USB The USB_receiveByte API is blocking and other API(TBD) must be used for interrupt based USB transfers.
Usage of RETARGET_ReadChar should not be used in application code , since this api is required only for usb library
USB_returnCode_t RETARGET_WriteChar ( uint8_t *  data,
uint32_t  len 
)
Parameters
[in]data: The byte to be sent
See also
retargetio.c
Return values
USB_returnCode_tUSB_FAILURE : USB transfer was not successful USB_SUCCESS : USB transfer was successful
Warning
: This API was made to retarget the printf API to transmit data through USB The USB_transmitByte API is blocking and other API(TBD) must be used for interrupt based USB transfers.
Usage of RETARGET_WriteChar should not be used in application code , since this api is required only for usb library
USB_returnCode_t USB_callBackMapping ( USB_rxCallback  usbcallback)
Parameters
[in]usbcallback- function pointer of the callback to be mapped

USB_FAILURE : API call failed USB_SUCCESS : API call succeeded

Warning
This API will over-write any previous callback if configured.
Usage of USB_callBackMapping should not be used in application code , since this api is required only for usb library
void USB_DisConnect ( void  )
void USB_init ( USB_lineCoding_tp  lineCoding,
USB_rxCallback  usbRxCallback 
)
Parameters
[in]lineCoding- The usb port LINE CODING data structure, used to carry information about serial port baudrate, parity etc. between host and device.
[in]usbRxCallback- Application receive callback function to receive data over USB
Warning
Please give the parameter usbRxCallback value as NULL.
Note
If the user wants to re-init USB please Refer code given as below for example
1 Example:
2 #include "XdkUsbResetUtility.h"
3 
4 USB_lineCoding_t BSP_USBHandle1;
5 
6 Retcode_T ReInitUSB(void)
7 {
8 Retcode_T retcode = RETCODE_OK;
9 BSP_USBHandle1.Baudrate = USB_SET_BAUDRATE;
10 BSP_USBHandle1.charFormat = USB_SET_STOPBITS_MODE;
11 BSP_USBHandle1.parityType = USB_SET_PARITY;
12 BSP_USBHandle1.dataBits = USB_SET_DATA_BITS;
13 BSP_USBHandle1.dummy = 0;
14 NVIC_SetPriority(USB_IRQn, 5);
15 USB_init(&BSP_USBHandle1, NULL); // Note - If required please give few seconds delay for USB enumeration
16 returnValue = UsbResetUtility_Init(); // Note - USB receive callback is set to UsbResetUtility_UsbISRCallback() by implementation.
17  if (RETCODE_OK == returnValue)
18  {
19  // If user wants to handle receive then the below API calls are required
20  returnValue = UsbResetUtility_RegAppISR(&ApplicationUsbRXcallback);
21  if (RETCODE_OK == returnValue)
22  {
23  // application usb receive call back successfully registered
24  }
25  }
26 }
27 
28  // user application receive USB call back sample implementation
29  void ApplicationUsbRXcallback(uint8_t * usbRcvBuffer, uint32_t usbRcvBufLength)
30  {
31  // Print received data and length
32  }

+ Here is the caller graph for this function:

USB_returnCode_t USB_receiveByte ( uint8_t *  byte)
Parameters
[in]byte: Pointer to which the received byte must be written USB_FAILURE : API call failed USB_SUCCESS : API call succeeded
Warning
: This API was made to scan the data received through scanf API. This API is blocking TODO interrupt based USB transfers must be implemented
Usage of USB_receiveByte should not be used in application code , since this api is required only for usb library
int USB_setupCommand ( const USB_Setup_TypeDef *  setup)
Parameters
[in]setup: USB Setup request package
Returns
USB_STATUS_REQ_UNHANDLED : Setup request not handled.
USB_STATUS_OK : No errors detected
Warning
Usage of USB_setupCommand should not be used in application code , since this api is required only for usb library
void USB_stateChange ( USBD_State_TypeDef  oldState,
USBD_State_TypeDef  newState 
)
Parameters
[in]oldState: previous USB device state enumerator. Unused parameter.
[in]newState: present USB device state enumerator
Returns
void
Warning
Usage of USB_stateChange should not be used in application code , since this api is required only for usb library
USB_returnCode_t USB_transmitByte ( uint8_t  byte)
Parameters
[in]byte: The byte to be sent USB_FAILURE : API call failed USB_SUCCESS : API call succeeded
Warning
: This API was made to transmit the data send through printf API. This API is blocking TODO interrupt based USB transfers must be implemented.
Usage of USB_transmitByte should not be used in application code , since this api is required only for usb library
USB_returnCode_t USB_transmitData ( uint8_t *  data,
uint32_t  len 
)
Parameters
[in]data: buffer of data that to be transmitted
[in]len: length of data that to be transmitted USB_FAILURE : API call failed USB_SUCCESS : API call succeeded
Warning
: This API was made to transmit the data send through printf API. This API is blocking and other API(TBD) must be used for interrupt based USB transfers
Usage of USB_transmitData should not be used in application code , since this api is required only for usb library

Variable Documentation

uint32_t Baudrate

Baudrate

uint8_t charFormat

Stop bits, 0=1 1=1.5 2=2

uint8_t dataBits

5, 6, 7, 8 or 16

uint8_t dummy

To ensure size is a multiple of 4 bytes.

uint8_t parityType

0=None 1=Odd 2=Even 3=Mark 4=Space

struct USB_lineCoding_s * USB_lineCoding_tp
USB_rxCallback usbRxCallback

received callback


All rights reserved. The use is subject to the XDK SDK EULA by Bosch Connected Devices and Solutions GmbH.
This documentation file has been automatically generated on Thu Mar 14 2019 19:12:47 by doxygen 1.8.8