mikroSDK Reference Manual
usbtmc_device.h
1/*
2 * The MIT License (MIT)
3 *
4 * Copyright (c) 2019 N Conrad
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights
9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 * copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 * THE SOFTWARE.
23 *
24 * This file is part of the TinyUSB stack.
25 */
26
27
28#ifndef CLASS_USBTMC_USBTMC_DEVICE_H_
29#define CLASS_USBTMC_USBTMC_DEVICE_H_
30
31#include "usbtmc.h"
32
33// Enable 488 mode by default
34#if !defined(CFG_TUD_USBTMC_ENABLE_488)
35#define CFG_TUD_USBTMC_ENABLE_488 (1)
36#endif
37
38/***********************************************
39 * Functions to be implemented by the class implementation
40 */
41
42// In order to proceed, app must call call tud_usbtmc_start_bus_read(rhport) during or soon after:
43// * tud_usbtmc_open_cb
44// * tud_usbtmc_msg_data_cb
45// * tud_usbtmc_msgBulkIn_complete_cb
46// * tud_usbtmc_msg_trigger_cb
47// * (successful) tud_usbtmc_check_abort_bulk_out_cb
48// * (successful) tud_usbtmc_check_abort_bulk_in_cb
49// * (successful) tud_usmtmc_bulkOut_clearFeature_cb
50
51#if (CFG_TUD_USBTMC_ENABLE_488)
52usbtmc_response_capabilities_488_t const * tud_usbtmc_get_capabilities_cb(void);
53#else
54usbtmc_response_capabilities_t const * tud_usbtmc_get_capabilities_cb(void);
55#endif
56
57void tud_usbtmc_open_cb(uint8_t interface_id);
58
59bool tud_usbtmc_msgBulkOut_start_cb(usbtmc_msg_request_dev_dep_out const * msgHeader);
60// transfer_complete does not imply that a message is complete.
61bool tud_usbtmc_msg_data_cb( void *data, size_t len, bool transfer_complete);
62void tud_usbtmc_bulkOut_clearFeature_cb(void); // Notice to clear and abort the pending BULK out transfer
63
64bool tud_usbtmc_msgBulkIn_request_cb(usbtmc_msg_request_dev_dep_in const * request);
65bool tud_usbtmc_msgBulkIn_complete_cb(void);
66void tud_usbtmc_bulkIn_clearFeature_cb(void); // Notice to clear and abort the pending BULK out transfer
67
68bool tud_usbtmc_initiate_abort_bulk_in_cb(uint8_t *tmcResult);
69bool tud_usbtmc_initiate_abort_bulk_out_cb(uint8_t *tmcResult);
70bool tud_usbtmc_initiate_clear_cb(uint8_t *tmcResult);
71
72bool tud_usbtmc_check_abort_bulk_in_cb(usbtmc_check_abort_bulk_rsp_t *rsp);
73bool tud_usbtmc_check_abort_bulk_out_cb(usbtmc_check_abort_bulk_rsp_t *rsp);
74bool tud_usbtmc_check_clear_cb(usbtmc_get_clear_status_rsp_t *rsp);
75
76// Indicator pulse should be 0.5 to 1.0 seconds long
77TU_ATTR_WEAK bool tud_usbtmc_indicator_pulse_cb(tusb_control_request_t const * msg, uint8_t *tmcResult);
78
79#if (CFG_TUD_USBTMC_ENABLE_488)
80uint8_t tud_usbtmc_get_stb_cb(uint8_t *tmcResult);
81TU_ATTR_WEAK bool tud_usbtmc_msg_trigger_cb(usbtmc_msg_generic_t* msg);
82//TU_ATTR_WEAK bool tud_usbtmc_app_go_to_local_cb();
83#endif
84
85/*******************************************
86 * Called from app
87 *
88 * We keep a reference to the buffer, so it MUST not change until the app is
89 * notified that the transfer is complete.
90 ******************************************/
91
92bool tud_usbtmc_transmit_dev_msg_data(
93 const void * data, size_t len,
94 bool endOfMessage, bool usingTermChar);
95
96bool tud_usbtmc_start_bus_read(void);
97
98
99/* "callbacks" from USB device core */
100
101uint16_t usbtmcd_open_cb(uint8_t rhport, tusb_desc_interface_t const * itf_desc, uint16_t max_len);
102void usbtmcd_reset_cb(uint8_t rhport);
103bool usbtmcd_xfer_cb(uint8_t rhport, uint8_t ep_addr, xfer_result_t result, uint32_t xferred_bytes);
104bool usbtmcd_control_xfer_cb(uint8_t rhport, uint8_t stage, tusb_control_request_t const * request);
105void usbtmcd_init_cb(void);
106
107/************************************************************
108 * USBTMC Descriptor Templates
109 *************************************************************/
110
111
112#endif /* CLASS_USBTMC_USBTMC_DEVICE_H_ */
AUDIO Channel Cluster Descriptor (4.1)
Definition audio.h:647