hv_mw_UsbTask.h 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. /**
  2. * @file hv_mw_UsbTask.h
  3. * @brief Header file of USB task module.
  4. *
  5. * @verbatim
  6. * ==============================================================================
  7. * ##### How to use #####
  8. * ==============================================================================
  9. * (+) Use Hv_Mw_UsbTaskHandle(...) s a task function handle.
  10. *
  11. * @endverbatim
  12. *
  13. * @author HiView SoC Software Team
  14. * @version 1.0.0
  15. * @date 2022-08-10
  16. */
  17. #ifndef __SDK_MIDDLEWARE_RUNTIME_USBTASK_INC_USBTASK_H__
  18. #define __SDK_MIDDLEWARE_RUNTIME_USBTASK_INC_USBTASK_H__
  19. #ifdef CONFIG_USER_USB_OTA_ON
  20. #include "hv_comm_DataType.h"
  21. #include "hv_comm_Event.h"
  22. #include "hv_drv_UsbFatfs.h"
  23. #include "hv_drv_UsbFatfsDiskIo.h"
  24. #include "hv_vos_Comm.h"
  25. /**
  26. * @brief Defines the state of USB, which can be used for state machine operation and also for event notification with other modules.
  27. */
  28. typedef enum _UsbState
  29. {
  30. USB_STATE_IDLE = 0x01, /*!< 空闲态,无实际作用 */
  31. USB_STATE_NO_UDISK_IN = 0x02, /*!< 端口检查结果:无设备接入 */
  32. USB_STATE_PLUGGED_IN = 0x03, /*!< 端口检查结果:有设备接入 */
  33. USB_STATE_NO_OTA_FILE = 0x04, /*!< OTA目标文件查找结果:未找到文件 */
  34. USB_STATE_FOUND_OTA_FILE = 0x05, /*!< OTA目标文件查找结果:命中 */
  35. USB_STATE_OTA_IN_PROCESSING = 0x08, /*!< OTA运行中 */
  36. USB_STATE_OTA_SUCCESS = 0x09, /*!< OTA结果:成功 */
  37. USB_STATE_OTA_FAIL = 0x0A, /*!< OTA结果:失败 */
  38. USB_STATE_ANY = 0xFF, /*!< 任意态,用于不限制状态机触发的初始状态时 */
  39. } UsbState;
  40. /**
  41. * @brief OTA State Machine
  42. */
  43. typedef struct _UsbStateMachine
  44. {
  45. USHORT16 usAcceptStates;
  46. UsbEventId enEventId;
  47. Status (*pfActionHandle)(UsbEvent *pstEvent);
  48. }UsbStateMachine;
  49. /**
  50. * @brief Set USB state.
  51. * @param[in] enState enum value of UsbOtaState
  52. * @return none
  53. */
  54. VOID Hv_Mw_USB_SetUsbState(UsbState enState);
  55. /**
  56. * @brief Get USB state.
  57. * @return enum value of UsbState.
  58. */
  59. UsbState Hv_Mw_USB_GetUsbState(VOID);
  60. /**
  61. * @brief Send event to usb module.
  62. * @return VOID
  63. */
  64. VOID Hv_Mw_SendEvtToUsb(UsbEventId enEvtID, USHORT16 usValue);
  65. /**
  66. * @brief Usb Host task init.
  67. * @return VOID
  68. */
  69. VOID Hv_Mw_UsbHost_TaskStartInit(VOID);
  70. #endif
  71. /**
  72. * @brief Stop Usb Host task.
  73. * @return VOID
  74. */
  75. VOID Hv_Mw_UsbHost_TaskStop(VOID);
  76. /**
  77. * @brief USB task function handle.
  78. * @param[in] arg unused.
  79. * @return VOID
  80. */
  81. VOID Hv_Mw_UsbTaskHandle( VOID *arg );
  82. #endif