Open FFBoard
Open source force feedback firmware
usbtmc_device.h
Go to the documentation of this file.
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)
53#else
55#endif
56
57void tud_usbtmc_open_cb(uint8_t interface_id);
58
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
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);
70bool tud_usbtmc_initiate_clear_cb(uint8_t *tmcResult);
71
75
76// The interrupt-IN endpoint buffer was transmitted to the host. Use
77// tud_usbtmc_transmit_notification_data to send another notification.
79
80// Indicator pulse should be 0.5 to 1.0 seconds long
81TU_ATTR_WEAK bool tud_usbtmc_indicator_pulse_cb(tusb_control_request_t const * msg, uint8_t *tmcResult);
82
83#if (CFG_TUD_USBTMC_ENABLE_488)
84uint8_t tud_usbtmc_get_stb_cb(uint8_t *tmcResult);
86//TU_ATTR_WEAK bool tud_usbtmc_app_go_to_local_cb();
87#endif
88
89// Called from app
90//
91// We keep a reference to the buffer, so it MUST not change until the app is
92// notified that the transfer is complete.
94 const void * data, size_t len,
95 bool endOfMessage, bool usingTermChar);
96
97// Buffers a notification to be sent to the host. The data starts
98// with the bNotify1 field, see the USBTMC Specification, Table 13.
99//
100// If the previous notification data has not yet been sent, this
101// returns false.
102//
103// Requires an interrupt endpoint in the interface.
104bool tud_usbtmc_transmit_notification_data(const void * data, size_t len);
105
107
108
109/* "callbacks" from USB device core */
110
111void usbtmcd_init_cb(void);
112bool usbtmcd_deinit(void);
113uint16_t usbtmcd_open_cb(uint8_t rhport, tusb_desc_interface_t const * itf_desc, uint16_t max_len);
114void usbtmcd_reset_cb(uint8_t rhport);
115bool usbtmcd_xfer_cb(uint8_t rhport, uint8_t ep_addr, xfer_result_t result, uint32_t xferred_bytes);
116bool usbtmcd_control_xfer_cb(uint8_t rhport, uint8_t stage, tusb_control_request_t const * request);
117
118#endif /* CLASS_USBTMC_USBTMC_DEVICE_H_ */
static struct @612 data
AUDIO Channel Cluster Descriptor (4.1)
Definition: audio.h:647
xfer_result_t
Definition: tusb_types.h:236
CFG_TUH_MEM_ALIGN tusb_control_request_t request
Definition: usbh.c:259
volatile uint8_t stage
Definition: usbh.c:265
bool tud_usbtmc_initiate_abort_bulk_in_cb(uint8_t *tmcResult)
TU_ATTR_WEAK bool tud_usbtmc_indicator_pulse_cb(tusb_control_request_t const *msg, uint8_t *tmcResult)
TU_ATTR_WEAK bool tud_usbtmc_notification_complete_cb(void)
void tud_usbtmc_open_cb(uint8_t interface_id)
bool usbtmcd_xfer_cb(uint8_t rhport, uint8_t ep_addr, xfer_result_t result, uint32_t xferred_bytes)
bool tud_usbtmc_msgBulkOut_start_cb(usbtmc_msg_request_dev_dep_out const *msgHeader)
bool tud_usbtmc_msg_data_cb(void *data, size_t len, bool transfer_complete)
bool tud_usbtmc_transmit_dev_msg_data(const void *data, size_t len, bool endOfMessage, bool usingTermChar)
bool tud_usbtmc_msgBulkIn_complete_cb(void)
TU_ATTR_WEAK bool tud_usbtmc_msg_trigger_cb(usbtmc_msg_generic_t *msg)
bool tud_usbtmc_initiate_abort_bulk_out_cb(uint8_t *tmcResult)
bool tud_usbtmc_check_abort_bulk_out_cb(usbtmc_check_abort_bulk_rsp_t *rsp)
bool tud_usbtmc_check_abort_bulk_in_cb(usbtmc_check_abort_bulk_rsp_t *rsp)
void usbtmcd_init_cb(void)
uint16_t usbtmcd_open_cb(uint8_t rhport, tusb_desc_interface_t const *itf_desc, uint16_t max_len)
bool usbtmcd_deinit(void)
void tud_usbtmc_bulkIn_clearFeature_cb(void)
void usbtmcd_reset_cb(uint8_t rhport)
bool tud_usbtmc_check_clear_cb(usbtmc_get_clear_status_rsp_t *rsp)
bool usbtmcd_control_xfer_cb(uint8_t rhport, uint8_t stage, tusb_control_request_t const *request)
bool tud_usbtmc_initiate_clear_cb(uint8_t *tmcResult)
bool tud_usbtmc_transmit_notification_data(const void *data, size_t len)
void tud_usbtmc_bulkOut_clearFeature_cb(void)
uint8_t tud_usbtmc_get_stb_cb(uint8_t *tmcResult)
usbtmc_response_capabilities_488_t const * tud_usbtmc_get_capabilities_cb(void)
bool tud_usbtmc_msgBulkIn_request_cb(usbtmc_msg_request_dev_dep_in const *request)
bool tud_usbtmc_start_bus_read(void)