diff options
| author | hathach <[email protected]> | 2018-11-14 15:36:12 +0700 |
|---|---|---|
| committer | GitHub <[email protected]> | 2018-11-14 15:36:12 +0700 |
| commit | 983225ae606653202c4f1bba8e34a4a9825daa2a (patch) | |
| tree | 0e8b3168c5104bc2f6338ad5fb14ead28dc58197 /src/device/control.h | |
| parent | 039550d7feac21333c99ae3730c5def29ddc7be0 (diff) | |
| parent | 299a2f12de2ddb76b9a488b23e7e562058faee90 (diff) | |
Merge pull request #7 from tannewt/tinyusb_samd
Add SAMD support and simplify OS_NONE
Diffstat (limited to 'src/device/control.h')
| -rw-r--r-- | src/device/control.h | 98 |
1 files changed, 98 insertions, 0 deletions
diff --git a/src/device/control.h b/src/device/control.h new file mode 100644 index 000000000..881c99ead --- /dev/null +++ b/src/device/control.h @@ -0,0 +1,98 @@ +/**************************************************************************/
+/*!
+ @file usbd.h
+ @author hathach (tinyusb.org)
+
+ @section LICENSE
+
+ Software License Agreement (BSD License)
+
+ Copyright (c) 2013, hathach (tinyusb.org)
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+ 1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+ 3. Neither the name of the copyright holders nor the
+ names of its contributors may be used to endorse or promote products
+ derived from this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
+ EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+ This file is part of the tinyusb stack.
+*/
+/**************************************************************************/
+
+/** \ingroup group_usbd
+ * @{ */
+
+#ifndef _TUSB_CONTROL_H_
+#define _TUSB_CONTROL_H_
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+#include "tusb.h"
+
+typedef enum {
+ CONTROL_STAGE_SETUP, // Waiting for a setup token.
+ CONTROL_STAGE_DATA, // In the process of sending or receiving data.
+ CONTROL_STAGE_STATUS // In the process of transmitting the STATUS ZLP.
+} control_stage_t;
+
+typedef struct {
+ control_stage_t current_stage;
+ tusb_control_request_t current_request;
+ uint16_t total_transferred;
+ uint8_t config;
+} control_t;
+
+CFG_TUSB_ATTR_USBRAM CFG_TUSB_MEM_ALIGN uint8_t _shared_control_buffer[64];
+
+tusb_error_t controld_process_setup_request(uint8_t rhport, tusb_control_request_t const * const p_request);
+
+// Callback when the configuration of the device is changed.
+tusb_error_t tud_control_set_config_cb(uint8_t rhport, uint8_t config_number);
+
+// Called when the DATA stage of a control transaction is complete.
+void tud_control_interface_control_complete_cb(uint8_t rhport, uint8_t interface, tusb_control_request_t const * const p_request);
+
+tusb_error_t tud_control_interface_control_cb(uint8_t rhport, uint8_t interface, tusb_control_request_t const * const p_request, uint16_t bytes_already_sent);
+
+//--------------------------------------------------------------------+
+// INTERNAL API
+//--------------------------------------------------------------------+
+
+void controld_init(void);
+tusb_error_t controld_open(uint8_t rhport, tusb_desc_interface_t const * p_interface_desc, uint16_t *p_length);
+
+// This tracks the state of a control request.
+tusb_error_t controld_process_setup_request(uint8_t rhport, tusb_control_request_t const * p_request);
+
+// This handles the actual request and its response.
+tusb_error_t controld_process_control_request(uint8_t rhport, tusb_control_request_t const * p_request, uint16_t bytes_already_sent);
+
+tusb_error_t controld_xfer_cb(uint8_t rhport, uint8_t edpt_addr, tusb_event_t event, uint32_t xferred_bytes);
+void controld_reset(uint8_t rhport);
+
+#ifdef __cplusplus
+ }
+#endif
+
+#endif /* _TUSB_CONTROL_H_ */
+
+/** @} */
|
