tinyusb  0.4
Click here to lend your support to tinyusb donation and make a donation at pledgie.com
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Groups Pages
usbh.h
Go to the documentation of this file.
1 /**************************************************************************/
37 /**************************************************************************/
38 
42 #ifndef _TUSB_USBH_H_
43 #define _TUSB_USBH_H_
44 
45 #ifdef __cplusplus
46  extern "C" {
47 #endif
48 
49 //--------------------------------------------------------------------+
50 // INCLUDE
51 //--------------------------------------------------------------------+
52 #include "osal/osal.h" // TODO refractor move to common.h ?
53 #include "hcd.h"
54 
55 //--------------------------------------------------------------------+
56 // MACRO CONSTANT TYPEDEF
57 //--------------------------------------------------------------------+
59  TUSB_INTERFACE_STATUS_READY = 0,
60  TUSB_INTERFACE_STATUS_BUSY,
61  TUSB_INTERFACE_STATUS_COMPLETE,
62  TUSB_INTERFACE_STATUS_ERROR,
63  TUSB_INTERFACE_STATUS_INVALID_PARA
65 
66 typedef struct {
67  void (* const init) (void);
68  tusb_error_t (* const open_subtask)(uint8_t, tusb_descriptor_interface_t const *, uint16_t*);
69  void (* const isr) (pipe_handle_t, tusb_event_t, uint32_t);
70  void (* const close) (uint8_t);
72 //--------------------------------------------------------------------+
73 // INTERNAL OBJECT & FUNCTION DECLARATION
74 //--------------------------------------------------------------------+
75 
76 //--------------------------------------------------------------------+
77 // APPLICATION API
78 //--------------------------------------------------------------------+
79 //tusb_error_t tusbh_configuration_set (uint8_t dev_addr, uint8_t configure_number) ATTR_WARN_UNUSED_RESULT;
80 tusb_device_state_t tusbh_device_get_state (uint8_t dev_addr) ATTR_WARN_UNUSED_RESULT ATTR_PURE;
81 static inline bool tusbh_device_is_configured(uint8_t dev_addr) ATTR_ALWAYS_INLINE ATTR_WARN_UNUSED_RESULT ATTR_PURE;
82 static inline bool tusbh_device_is_configured(uint8_t dev_addr)
83 {
84  return tusbh_device_get_state(dev_addr) == TUSB_DEVICE_STATE_CONFIGURED;
85 }
86 uint32_t tusbh_device_get_mounted_class_flag(uint8_t dev_addr);
87 
88 //--------------------------------------------------------------------+
89 // APPLICATION CALLBACK
90 //--------------------------------------------------------------------+
91 ATTR_WEAK uint8_t tusbh_device_attached_cb (tusb_descriptor_device_t const *p_desc_device) ATTR_WARN_UNUSED_RESULT;
92 ATTR_WEAK void tusbh_device_mount_succeed_cb (uint8_t dev_addr);
93 ATTR_WEAK void tusbh_device_mount_failed_cb(tusb_error_t error, tusb_descriptor_device_t const *p_desc_device); // TODO refractor remove desc_device
94 
95 //--------------------------------------------------------------------+
96 // CLASS-USBH & INTERNAL API
97 //--------------------------------------------------------------------+
98 #ifdef _TINY_USB_SOURCE_FILE_
99 
100 
101 OSAL_TASK_FUNCTION (usbh_enumeration_task, p_task_para);
102 tusb_error_t usbh_init(void);
103 
104 tusb_error_t usbh_control_xfer_subtask(uint8_t dev_addr, uint8_t bmRequestType, uint8_t bRequest,
105  uint16_t wValue, uint16_t wIndex, uint16_t wLength, uint8_t* data);
106 
107 
108 #endif
109 
110 #ifdef __cplusplus
111  }
112 #endif
113 
114 #endif /* _TUSB_USBH_H_ */
115 
USB Standard Interface Descriptor (section 9.6.1 table 9-12)
#define ATTR_WARN_UNUSED_RESULT
The warn_unused_result attribute causes a warning to be emitted if a caller of the function with this...
Definition: compiler_gcc.h:118
#define ATTR_PURE
Many functions have no effects except the return value and their return value depends only on the par...
Definition: compiler_gcc.h:96
tusb_device_state_t
Device State.
Definition: tusb_types.h:163
tusb_interface_status_
Definition: usbh.h:58
enum tusb_interface_status_ tusb_interface_status_t
#define ATTR_WEAK
The weak attribute causes the declaration to be emitted as a weak symbol rather than a global...
Definition: compiler_gcc.h:109
tusb_error_t
Error Code returned.
Definition: tusb_errors.h:100
#define ATTR_ALWAYS_INLINE
Generally, functions are not inlined unless optimization is specified. For functions declared inline...
Definition: compiler_gcc.h:89
USB Standard Device Descriptor (section 9.6.1, table 9-8)