Initialization Functions

group group_usbfs_dev_hal_functions_common

The Initialization functions provide an API to begin the USBFS driver operation (configure and enable) and to stop operation (disable and de-initialize).

Functions

cy_en_usbfs_dev_drv_status_t Cy_USBFS_Dev_Drv_Init(USBFS_Type *base, cy_stc_usbfs_dev_drv_config_t const *config, cy_stc_usbfs_dev_drv_context_t *context)

Initializes the USBFS in device mode.

If DMAs are used, initialize the DMAs.

Return

The status code of the function execution cy_en_usbfs_dev_drv_status_t.

Parameters
  • base: The pointer to the USBFS instance.

  • config: The pointer to the configuration structure cy_stc_usbfs_dev_drv_config_t.

  • context: The pointer to the context structure cy_stc_usbfs_dev_drv_context_t allocated by the user. The structure is used during the USBFS Device operation for internal configuration and data retention. The user must not modify anything in this structure.

void Cy_USBFS_Dev_Drv_DeInit(USBFS_Type *base, cy_stc_usbfs_dev_drv_context_t *context)

De-initializes the USBFS Device hardware (returns the register values to default) and removes all registered callbacks.

Parameters
  • base: The pointer to the USBFS instance.

  • context: The pointer to the context structure cy_stc_usbfs_dev_drv_context_t allocated by the user. The structure is used during the USBFS Device operation for internal configuration and data retention. The user must not modify anything in this structure.

void Cy_USBFS_Dev_Drv_Enable(USBFS_Type *base, cy_stc_usbfs_dev_drv_context_t const *context)

Enables the USBFS Device operation.

Parameters
  • base: The pointer to the USBFS instance.

  • context: The pointer to the context structure cy_stc_usbfs_dev_drv_context_t allocated by the user. The structure is used during the USBFS Device operation for internal configuration and data retention. The user must not modify anything in this structure.

void Cy_USBFS_Dev_Drv_Disable(USBFS_Type *base, cy_stc_usbfs_dev_drv_context_t *context)

Disables the USBFS Device operation.

If DMAs are used, disables the DMAs.

Parameters
  • base: The pointer to the USBFS instance.

  • context: The pointer to the context structure cy_stc_usbfs_dev_drv_context_t allocated by the user. The structure is used during the USBFS Device operation for internal configuration and data retention. The user must not modify anything in this structure.

__STATIC_INLINE void Cy_USBFS_Dev_Drv_SetAddress (USBFS_Type *base, uint8_t address, cy_stc_usbfs_dev_drv_context_t *context)

Posts a request to set the device address after the completion status stage of the control transfer.

This function must be used if a higher level requests to set an address before the status stage of the control transfer.

Parameters
  • base: The pointer to the USBFS instance.

  • address: The device address.

  • context: The pointer to the context structure cy_stc_usbfs_dev_drv_context_t allocated by the user. The structure is used during the USBFS Device operation for internal configuration and data retention. The user must not modify anything in this structure.

__STATIC_INLINE void Cy_USBFS_Dev_Drv_SetDeviceAddress (USBFS_Type *base, uint8_t address)

Sets the device address (writes the address directly into the register).

Parameters
  • base: The pointer to the USBFS instance.

  • address: Device address.

__STATIC_INLINE uint32_t Cy_USBFS_Dev_Drv_GetDeviceAddress (USBFS_Type const *base)

Returns the device address (reads the address directly from the register).

Return

The device address. The device address is assigned by the Host during device enumeration. Zero means that the device address is not assigned.

Parameters
  • base: The pointer to the USBFS instance.

__STATIC_INLINE void Cy_USBFS_Dev_Drv_SetDevContext (USBFS_Type const *base, void *devContext, cy_stc_usbfs_dev_drv_context_t *context)

Stores a pointer to the USB Device context in the driver context.

note

This function is intended for the USB Device middleware operation.

Parameters
  • base: The pointer to the USBFS instance

  • devContext: The pointer to the USB Device context structure.

  • context: The pointer to the context structure cy_stc_usbfs_dev_drv_context_t allocated by the user. The structure is used during the USBFS Device operation for internal configuration and data retention. The user must not modify anything in this structure.

__STATIC_INLINE void * Cy_USBFS_Dev_Drv_GetDevContext (USBFS_Type const *base, cy_stc_usbfs_dev_drv_context_t *context)

Returns a pointer to the USB Device context.

note

This function is intended for the USB Device middleware operation.

Return

The pointer to the USB Device context.

Parameters
  • base: The pointer to the USBFS instance.

  • context: The pointer to the context structure cy_stc_usbfs_dev_drv_context_t allocated by the user. The structure is used during USBFS Device operation for internal configuration and data retention. The user must not modify anything in this structure.

void Cy_USBFS_Dev_Drv_ConfigDevice(USBFS_Type *base, cy_stc_usbfs_dev_drv_context_t *context)

Sets the basic device configuration (clears previous configuration).

Call this function after the endpoints were configured to complete the device configuration.

Parameters
  • base: The pointer to the USBFS instance.

  • context: The pointer to the context structure cy_stc_usbfs_dev_drv_context_t allocated by the user. The structure is used during the USBFS Device operation for internal configuration and data retention. The user must not modify anything in this structure.

void Cy_USBFS_Dev_Drv_UnConfigureDevice(USBFS_Type *base, cy_stc_usbfs_dev_drv_context_t *context)

Clears device configuration.

Call this function before setting a configuration or a configuration failure to set the configuration into the default state. Alternately, call Cy_USBFS_Dev_Drv_RemoveEndpoint for each active endpoint.

Parameters
  • base: The pointer to the USBFS instance.

  • context: The pointer to the context structure cy_stc_usbfs_dev_drv_context_t allocated by the user. The structure is used during the USBFS Device operation for internal configuration and data retention. The user must not modify anything in this structure.