tinyusb
dcd.h
Go to the documentation of this file.
1 /**************************************************************************/
37 /**************************************************************************/
38 
43 #ifndef _TUSB_DCD_H_
44 #define _TUSB_DCD_H_
45 
46 #include "common/common.h"
47 
48 #ifdef __cplusplus
49  extern "C" {
50 #endif
51 
52 typedef struct {
53  uint8_t coreid;
54  uint8_t reserved; // TODO redundant, cannot be control as control uses separated API
55  uint8_t index;
56  uint8_t class_code;
58 
59 static inline bool endpointhandle_is_valid(endpoint_handle_t edpt_hdl) ATTR_CONST ATTR_ALWAYS_INLINE ATTR_WARN_UNUSED_RESULT;
60 static inline bool endpointhandle_is_valid(endpoint_handle_t edpt_hdl)
61 {
62  return (edpt_hdl.class_code != 0);
63 }
64 
65 static inline bool endpointhandle_is_equal(endpoint_handle_t x, endpoint_handle_t y) ATTR_CONST ATTR_ALWAYS_INLINE ATTR_WARN_UNUSED_RESULT;
66 static inline bool endpointhandle_is_equal(endpoint_handle_t x, endpoint_handle_t y)
67 {
68  return (x.coreid == y.coreid) && (x.index == y.index) && (x.class_code == y.class_code);
69 }
70 
71 tusb_error_t dcd_init(void) ATTR_WARN_UNUSED_RESULT;
72 
73 void dcd_isr(uint8_t coreid);
74 
75 //------------- Controller API -------------//
76 void dcd_controller_connect (uint8_t coreid);
77 void dcd_controller_disconnect (uint8_t coreid);
78 void dcd_controller_set_address (uint8_t coreid, uint8_t dev_addr);
79 void dcd_controller_set_configuration (uint8_t coreid);
80 
81 //------------- PIPE API -------------//
82 tusb_error_t dcd_pipe_control_xfer(uint8_t coreid, tusb_direction_t dir, uint8_t * p_buffer, uint16_t length, bool int_on_complete);
83 void dcd_pipe_control_stall(uint8_t coreid);
84 
85 endpoint_handle_t dcd_pipe_open(uint8_t coreid, tusb_descriptor_endpoint_t const * p_endpoint_desc, uint8_t class_code) ATTR_WARN_UNUSED_RESULT;
86 tusb_error_t dcd_pipe_queue_xfer(endpoint_handle_t edpt_hdl, uint8_t * buffer, uint16_t total_bytes) ATTR_WARN_UNUSED_RESULT; // only queue, not transferring yet
87 tusb_error_t dcd_pipe_xfer(endpoint_handle_t edpt_hdl, uint8_t * buffer, uint16_t total_bytes, bool int_on_complete) ATTR_WARN_UNUSED_RESULT;
88 tusb_error_t dcd_pipe_stall(endpoint_handle_t edpt_hdl);
89 bool dcd_pipe_is_busy(endpoint_handle_t edpt_hdl) ATTR_WARN_UNUSED_RESULT ;
90 
91 // TODO coreid + endpoint address are part of endpoint handle, not endpoint handle, data toggle also need to be reset
92 tusb_error_t dcd_pipe_clear_stall(uint8_t coreid, uint8_t edpt_addr);
93 
94 #ifdef __cplusplus
95  }
96 #endif
97 
98 #endif /* _TUSB_DCD_H_ */
99 
#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
USB Standard Endpoint Descriptor (section 9.6.1 table 9-13)
Definition: std_descriptors.h:104
Definition: dcd.h:52
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
#define ATTR_CONST
Many functions do not examine any values except their arguments, and have no effects except the retur...
Definition: compiler_gcc.h:100