Mistake on this page?
Report an issue in GitHub or email us
USBEndpointTester.h
1 /*
2  * Copyright (c) 2018-2018, ARM Limited, All Rights Reserved
3  * SPDX-License-Identifier: Apache-2.0
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License"); you may
6  * not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
18 #ifndef USB_ENDPOINT_TESTER_H
19 #define USB_ENDPOINT_TESTER_H
20 
21 /* These headers are included for child class. */
22 #include "USBDescriptor.h"
23 #include "USBDevice_Types.h"
24 #include "EventQueue.h"
25 #include "EventFlags.h"
26 
27 #include "USBDevice.h"
28 
29 #define NUM_ENDPOINTS 6 // Not including CTRL OUT/IN
30 
32 
33 public:
34  USBEndpointTester(USBPhy *phy, uint16_t vendor_id, uint16_t product_id, uint16_t product_release,
35  bool abort_transfer_test);
36  virtual ~USBEndpointTester();
37  const char *get_serial_desc_string();
38  void start_ep_in_abort_test();
39 
40  uint32_t get_cnt_cb_set_conf() const
41  {
42  return _cnt_cb_set_conf;
43  }
44  uint32_t get_cnt_cb_set_intf() const
45  {
46  return _cnt_cb_set_intf;
47  }
48  uint32_t get_cnt_cb_bulk_out() const
49  {
50  return _cnt_cb_bulk_out;
51  }
52  uint32_t get_cnt_cb_bulk_in() const
53  {
54  return _cnt_cb_bulk_in;
55  }
56  uint32_t get_cnt_cb_int_out() const
57  {
58  return _cnt_cb_int_out;
59  }
60  uint32_t get_cnt_cb_int_in() const
61  {
62  return _cnt_cb_int_in;
63  }
64  uint32_t get_cnt_cb_iso_out() const
65  {
66  return _cnt_cb_iso_out;
67  }
68  uint32_t get_cnt_cb_iso_in() const
69  {
70  return _cnt_cb_iso_in;
71  }
72 
73  struct ep_config_t {
74  bool dir_in;
75  usb_ep_type_t type;
76  uint32_t max_packet;
77  ep_cb_t callback;
78  };
79 
80 protected:
81  events::EventQueue *queue;
82  rtos::EventFlags flags;
83  uint8_t ctrl_buf[2048];
84 
85  bool _abort_transfer_test;
86  usb_ep_t _endpoints[NUM_ENDPOINTS];
87  uint8_t *_endpoint_buffs[NUM_ENDPOINTS];
88  ep_config_t (*_endpoint_configs)[NUM_ENDPOINTS];
89 
90  static ep_config_t _intf_config_max[NUM_ENDPOINTS];
91  static ep_config_t _intf_config0[NUM_ENDPOINTS];
92  static ep_config_t _intf_config1[NUM_ENDPOINTS];
93  static ep_config_t _intf_config2[NUM_ENDPOINTS];
94  static ep_config_t _intf_config3[NUM_ENDPOINTS];
95  static ep_config_t _intf_config4[NUM_ENDPOINTS];
96 
97  volatile uint32_t _cnt_cb_set_conf;
98  volatile uint32_t _cnt_cb_set_intf;
99  volatile uint32_t _cnt_cb_bulk_out;
100  volatile uint32_t _cnt_cb_bulk_in;
101  volatile uint32_t _cnt_cb_int_out;
102  volatile uint32_t _cnt_cb_int_in;
103  volatile uint32_t _cnt_cb_iso_out;
104  volatile uint32_t _cnt_cb_iso_in;
105 
106  volatile uint32_t _num_packets_bulk_out_abort;
107  volatile uint32_t _num_packets_bulk_in_abort;
108  volatile uint32_t _num_packets_int_out_abort;
109  volatile uint32_t _num_packets_int_in_abort;
110 
111  virtual const uint8_t *configuration_desc(uint8_t index);
112  virtual void callback_state_change(DeviceState new_state);
113  virtual void callback_request(const setup_packet_t *setup);
114  virtual void callback_request_xfer_done(const setup_packet_t *setup, bool aborted);
115  virtual void callback_set_configuration(uint8_t configuration);
116  virtual void callback_set_interface(uint16_t interface, uint8_t alternate);
117 
118  void _setup_non_zero_endpoints();
119  bool _setup_interface(uint16_t interface, uint8_t alternate);
120 
121  virtual void _cb_bulk_out();
122  virtual void _cb_bulk_in();
123  virtual void _cb_int_out();
124  virtual void _cb_int_in();
125  virtual void _cb_iso_out();
126  virtual void _cb_iso_in();
127 
128 private:
129  const char *get_desc_string(const uint8_t *desc);
130  bool _request_rw_restart(const setup_packet_t *setup);
131  bool _request_abort_buff_check(const setup_packet_t *setup);
132 };
133 
134 #endif
virtual void callback_request_xfer_done(const setup_packet_t *setup, bool aborted)
Called by USBDevice on data stage completion.
virtual void callback_request(const setup_packet_t *setup)
Called by USBDevice on Endpoint0 request.
The EventFlags class is used to control event flags or wait for event flags other threads control...
Definition: EventFlags.h:49
EventQueue.
Definition: EventQueue.h:52
Abstract interface to physical USB hardware.
Definition: USBPhy.h:82
Core USB Device driver.
Definition: USBDevice.h:44
virtual void callback_state_change(DeviceState new_state)
Called when USB changes state.
Important Information for this Arm website

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies. If you are not happy with the use of these cookies, please review our Cookie Policy to learn how they can be disabled. By disabling cookies, some features of the site will not work.