|
| 1 | +部分改动迁移指南 |
| 2 | +======================== |
| 3 | + |
| 4 | + |
| 5 | +usbh_initialize |
| 6 | +------------------ |
| 7 | + |
| 8 | +usbh_initialize 从 v1.6.0 开始新增 event_handler 参数,通常不需要使用,可以传入 NULL。 |
| 9 | + |
| 10 | +dwc2 glue st |
| 11 | +---------------- |
| 12 | + |
| 13 | +dwc2 从 v1.5.0 开始 glue 文件内置底层初始化,比如 `usb_dc_low_level_init`,底层依赖 `HAL_PCD_MspInit` 和 `HAL_HCD_MspInit`,必须使用 stm32cubemx 生成。第三方平台不保证有这些函数实现,自行检查。 |
| 14 | + |
| 15 | + |
| 16 | +dwc2 glue |
| 17 | +---------------- |
| 18 | + |
| 19 | +dwc2 从 v1.5.1 开始新增 `struct dwc2_user_params`,用于实现多 dwc2 port 不同配置。并替代 `usbd_get_dwc2_gccfg_conf` 和 `usbh_get_dwc2_hccfg_conf` 函数, |
| 20 | +并增加 `dwc2_get_user_params` 函数实现,举例如下: |
| 21 | + |
| 22 | +.. code-block:: C |
| 23 | +
|
| 24 | + #ifndef CONFIG_USB_DWC2_CUSTOM_PARAM |
| 25 | + void dwc2_get_user_params(uint32_t reg_base, struct dwc2_user_params *params) |
| 26 | + { |
| 27 | + memcpy(params, ¶m_common, sizeof(struct dwc2_user_params)); |
| 28 | + #ifdef CONFIG_USB_DWC2_CUSTOM_FIFO |
| 29 | + struct usb_dwc2_user_fifo_config s_dwc2_fifo_config; |
| 30 | +
|
| 31 | + dwc2_get_user_fifo_config(reg_base, &s_dwc2_fifo_config); |
| 32 | +
|
| 33 | + params->device_rx_fifo_size = s_dwc2_fifo_config.device_rx_fifo_size; |
| 34 | + for (uint8_t i = 0; i < MAX_EPS_CHANNELS; i++) { |
| 35 | + params->device_tx_fifo_size[i] = s_dwc2_fifo_config.device_tx_fifo_size[i]; |
| 36 | + } |
| 37 | + #endif |
| 38 | + } |
| 39 | + #endif |
| 40 | +
|
| 41 | +host serial |
| 42 | +---------------- |
| 43 | + |
| 44 | +从 v1.6.0 开始,主机增加 host serial 框架,用于统一所有类串口设备。以下 API 需要使用新 serial API 替换: |
| 45 | + |
| 46 | +.. code-block:: C |
| 47 | +
|
| 48 | + int usbh_xxx_set_line_coding(struct usbh_xxx *xxx_class, struct cdc_line_coding *line_coding); |
| 49 | + int usbh_xxx_get_line_coding(struct usbh_xxx *xxx_class, struct cdc_line_coding *line_coding); |
| 50 | + int usbh_xxx_set_line_state(struct usbh_xxx *xxx_class, bool dtr, bool rts); |
| 51 | +
|
| 52 | + int usbh_xxx_bulk_in_transfer(struct usbh_xxx *xxx_class, uint8_t *buffer, uint32_t buflen, uint32_t timeout); |
| 53 | + int usbh_xxx_bulk_out_transfer(struct usbh_xxx *xxx_class, uint8_t *buffer, uint32_t buflen, uint32_t timeout); |
| 54 | +
|
| 55 | +替换为: |
| 56 | + |
| 57 | +.. code-block:: C |
| 58 | +
|
| 59 | + struct usbh_serial *usbh_serial_open(const char *devname, uint32_t open_flags); |
| 60 | + int usbh_serial_close(struct usbh_serial *serial); |
| 61 | + int usbh_serial_control(struct usbh_serial *serial, int cmd, void *arg); |
| 62 | + int usbh_serial_write(struct usbh_serial *serial, const void *buffer, uint32_t buflen); |
| 63 | + int usbh_serial_read(struct usbh_serial *serial, void *buffer, uint32_t buflen); |
0 commit comments