mirror of
https://github.com/hathach/tinyusb.git
synced 2025-04-16 05:42:56 +00:00
Handle USBTMC TermChar.
This commit is contained in:
parent
acd8fa7650
commit
6e00886ffb
@ -61,6 +61,9 @@
|
|||||||
// FIXME: I shouldn't need to include _pvt headers.
|
// FIXME: I shouldn't need to include _pvt headers.
|
||||||
#include "device/usbd_pvt.h"
|
#include "device/usbd_pvt.h"
|
||||||
|
|
||||||
|
static uint8_t termChar;
|
||||||
|
static uint8_t termCharRequested = false;
|
||||||
|
|
||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
STATE_IDLE,
|
STATE_IDLE,
|
||||||
@ -113,6 +116,13 @@ bool usbtmcd_transmit_dev_msg_data(
|
|||||||
TU_ASSERT(usbtmc_state.state == STATE_TX_REQUESTED);
|
TU_ASSERT(usbtmc_state.state == STATE_TX_REQUESTED);
|
||||||
TU_ASSERT(hdr->TransferSize > 0u);
|
TU_ASSERT(hdr->TransferSize > 0u);
|
||||||
|
|
||||||
|
if(hdr->bmTransferAttributes.UsingTermChar)
|
||||||
|
{
|
||||||
|
TU_ASSERT(usbtmcd_app_capabilities.bmDevCapabilities.canEndBulkInOnTermChar);
|
||||||
|
TU_ASSERT(termCharRequested);
|
||||||
|
TU_ASSERT(((uint8_t*)data)[hdr->TransferSize-1] == termChar);
|
||||||
|
}
|
||||||
|
|
||||||
// Copy in the header
|
// Copy in the header
|
||||||
memcpy(usbtmc_state.ep_bulk_in_buf, hdr, sizeof(*hdr));
|
memcpy(usbtmc_state.ep_bulk_in_buf, hdr, sizeof(*hdr));
|
||||||
uint packetLen = sizeof(*hdr);
|
uint packetLen = sizeof(*hdr);
|
||||||
@ -260,6 +270,12 @@ static bool handle_devMsgIn(uint8_t rhport, void *data, size_t len)
|
|||||||
TU_VERIFY(usbtmc_state.state == STATE_IDLE);
|
TU_VERIFY(usbtmc_state.state == STATE_IDLE);
|
||||||
usbtmc_state.state = STATE_TX_REQUESTED;
|
usbtmc_state.state = STATE_TX_REQUESTED;
|
||||||
usbtmc_state.transfer_size_remaining = msg->TransferSize;
|
usbtmc_state.transfer_size_remaining = msg->TransferSize;
|
||||||
|
|
||||||
|
termCharRequested = msg->bmTransferAttributes.TermCharEnabled;
|
||||||
|
termChar = msg->TermChar;
|
||||||
|
if(termCharRequested)
|
||||||
|
TU_VERIFY(usbtmcd_app_capabilities.bmDevCapabilities.canEndBulkInOnTermChar);
|
||||||
|
|
||||||
TU_VERIFY(usbtmcd_app_msgBulkIn_request(rhport, msg));
|
TU_VERIFY(usbtmcd_app_msgBulkIn_request(rhport, msg));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -310,6 +326,8 @@ bool usbtmcd_xfer_cb(uint8_t rhport, uint8_t ep_addr, xfer_result_t result, uint
|
|||||||
TU_VERIFY(handle_devMsgOut(rhport, usbtmc_state.ep_bulk_out_buf, xferred_bytes, xferred_bytes));
|
TU_VERIFY(handle_devMsgOut(rhport, usbtmc_state.ep_bulk_out_buf, xferred_bytes, xferred_bytes));
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
case STATE_TX_REQUESTED:
|
||||||
|
case STATE_TX_INITIATED:
|
||||||
default:
|
default:
|
||||||
TU_VERIFY(false);
|
TU_VERIFY(false);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user