General Configuration
Some constants are available to customize the class. These constants are located in the usbd_cfg.h
file. shows a description of each of them.
If you set USBD_PHDC_OS_CFG_SCHED_EN
to DEF_ENABLED
and you use a µC/OS-II or µC/OS-III RTOS port, PHDC will need an internal task for the scheduling operations. There are two application specific configurations that must be set in this case. They should be defined in the app_cfg.h
file. describes these configurations.
Class Instance Configuration
Before starting the communication phase, your application needs to initialize and configure the class to suit its needs. summarizes the initialization functions provided by the PHDC implementation. For a complete API reference, see the PHDC Functions reference.
You need to follow these steps to successfully initialize PHDC:
- Call
USBD_PHDC_Init()
This is the first function you should call, and you should do it only once, even if you use multiple class instances. This function will initialize all internal structures and variables that the class will need. It will also initialize the real-time operating system (RTOS) layer. - Call
USBD_PHDC_Add()
This function will allocate a PHDC instance. This call will also let you determine if the PHDC instance is capable of sending / receiving the metadata message preamble and if it uses a vendor-defined or ISO/IEEE-11073 based data and messaging protocol.
Another parameter of this function lets you specify a callback function that the class will call when the host enables / disables metadata message preambles. This is useful for the application as the behavior in communication will differ depending on the metadata message preamble state.
If your application needs to send low latency / good reliability data, the class will need to allocate an interrupt endpoint. The endpoint’s interval will be specified in this call as well. Call
USBD_PHDC_RdCfg()
andUSBD_PHDC_WrCfg()
The next step is to callUSBD_PHDC_RdCfg()
andUSBD_PHDC_WrCfg()
. These functions will let you set the latency / reliability bins that the communication pipe will carry. Bins are listed in . It will also be used to specify opaque data to send within extra endpoint metadata descriptors (see “USB Device Class Definition for Personal Healthcare Devices”, Release 1.0, Section 5 for more details on PHDC extra descriptors).- Call
USBD_PHDC_11073_ExtCfg()
(optional)
If the PHDC instance uses ISO/IEEE 11073-based data and messaging protocol, a call to this function will let you configure the device specialization code(s). - Call
USBD_PHDC_CfgAdd()
Finally, once the class instance is correctly configured and initialized, you will need to add it to a USB configuration. This is done by calling USBD_PHDC_CfgAdd()
.
shows an example of initialization and configuration of a PHDC instance. If you need more than one class instance of PHDC for your application, refer to the Class Instance Concept page for generic examples of how to build your device.