summaryrefslogtreecommitdiff
path: root/examples/device
diff options
context:
space:
mode:
authorNathan Conrad <[email protected]>2019-09-14 22:55:42 -0400
committerNathan Conrad <[email protected]>2019-09-17 13:29:38 -0400
commitc755aee7d0c1e2486055e02ac353878d8da3ba59 (patch)
tree4ceab626cdc1c823f0e8ed00386ebdb571ce0f15 /examples/device
parente53e9bd4f0749e53740c9c33e740998ac202dd8a (diff)
Clear
Diffstat (limited to 'examples/device')
-rw-r--r--examples/device/usbtmc/src/usbtmc_app.c44
1 files changed, 30 insertions, 14 deletions
diff --git a/examples/device/usbtmc/src/usbtmc_app.c b/examples/device/usbtmc/src/usbtmc_app.c
index af97939b9..a41d911d2 100644
--- a/examples/device/usbtmc/src/usbtmc_app.c
+++ b/examples/device/usbtmc/src/usbtmc_app.c
@@ -97,7 +97,9 @@ bool usbtmcd_app_msg_trigger(uint8_t rhport, usbtmc_msg_generic_t* msg) {
bool usbtmcd_app_msg_data(uint8_t rhport, void *data, size_t len, bool transfer_complete)
{
(void)rhport;
- (void)transfer_complete;
+
+ // If transfer isn't finished, we just ignore it (for now)
+
if(transfer_complete && (len >=4) && !strncasecmp("*idn?",data,4)) {
queryState = 1;
}
@@ -107,26 +109,24 @@ bool usbtmcd_app_msg_data(uint8_t rhport, void *data, size_t len, bool transfer_
bool usbtmcd_app_msgBulkIn_complete(uint8_t rhport)
{
(void)rhport;
+
+ status &= (uint8_t)~(0x10u); // clear MAV
+
return true;
}
-static uint8_t noQueryMsg[] = "ERR: No query\n";
-
bool usbtmcd_app_msgBulkIn_request(uint8_t rhport, usbtmc_msg_request_dev_dep_in const * request)
{
rspMsg.header.MsgID = request->header.MsgID,
rspMsg.header.bTag = request->header.bTag,
rspMsg.header.bTagInverse = request->header.bTagInverse;
- if(queryState != 0)
- {
- TU_ASSERT(bulkInStarted == 0);
- bulkInStarted = 1;
- }
- else
- {
- rspMsg.TransferSize = sizeof(noQueryMsg)-1;
- usbtmcd_transmit_dev_msg_data(rhport, &rspMsg, noQueryMsg);
- }
+
+ TU_ASSERT(bulkInStarted == 0);
+ bulkInStarted = 1;
+
+ // > If a USBTMC interface receives a Bulk-IN request prior to receiving a USBTMC command message
+ // that expects a response, the device must NAK the request
+
// Always return true indicating not to stall the EP.
return true;
}
@@ -157,12 +157,28 @@ void usbtmc_app_task_iter(void) {
bulkInStarted = 0;
rspMsg.TransferSize = sizeof(idn)-1;
usbtmcd_transmit_dev_msg_data(rhport, &rspMsg, idn);
- status &= ~(0x10u); // MAV
+ // MAV is cleared in the transfer complete callback.
}
break;
+ default:
+ TU_ASSERT(false,);
+ return;
}
}
+bool usbtmcd_app_initiate_clear(uint8_t rhport, uint8_t *tmcResult) {
+ (void)rhport;
+ *tmcResult = USBTMC_STATUS_SUCCESS;
+ return true;
+}
+
+bool usbtmcd_app_get_clear_status(uint8_t rhport, usbtmc_get_clear_status_rsp_t *rsp) {
+ (void)rhport;
+ rsp->USBTMC_status = USBTMC_STATUS_SUCCESS;
+ rsp->bmClear.BulkInFifoBytes = 0u;
+ return true;
+}
+
// Return status byte, but put the transfer result status code in the rspResult argument.
uint8_t usbtmcd_app_get_stb(uint8_t rhport, uint8_t *tmcResult)
{