@@ -86,6 +86,11 @@ tu_static char logMsg[150];
86
86
// imposes a minimum buffer size of 32 bytes.
87
87
#define USBTMCD_BUFFER_SIZE (TUD_OPT_HIGH_SPEED ? 512 : 64)
88
88
89
+ // Interrupt endpoint buffer size, default to 2 bytes as USB488 specification.
90
+ #ifndef CFG_TUD_USBTMC_INT_EP_SIZE
91
+ #define CFG_TUD_USBTMC_INT_EP_SIZE 2
92
+ #endif
93
+
89
94
/*
90
95
* The state machine does not allow simultaneous reading and writing. This is
91
96
* consistent with USBTMC.
@@ -124,13 +129,15 @@ typedef struct
124
129
uint8_t ep_bulk_in ;
125
130
uint8_t ep_bulk_out ;
126
131
uint8_t ep_int_in ;
132
+ uint32_t ep_bulk_in_wMaxPacketSize ;
133
+ uint32_t ep_bulk_out_wMaxPacketSize ;
127
134
// IN buffer is only used for first packet, not the remainder
128
135
// in order to deal with prepending header
129
136
CFG_TUSB_MEM_ALIGN uint8_t ep_bulk_in_buf [USBTMCD_BUFFER_SIZE ];
130
- uint32_t ep_bulk_in_wMaxPacketSize ;
131
137
// OUT buffer receives one packet at a time
132
138
CFG_TUSB_MEM_ALIGN uint8_t ep_bulk_out_buf [USBTMCD_BUFFER_SIZE ];
133
- uint32_t ep_bulk_out_wMaxPacketSize ;
139
+ // Buffer int msg to ensure alignment and placement correctness
140
+ CFG_TUSB_MEM_ALIGN uint8_t ep_int_in_buf [CFG_TUD_USBTMC_INT_EP_SIZE ];
134
141
135
142
uint32_t transfer_size_remaining ; // also used for requested length for bulk IN.
136
143
uint32_t transfer_size_sent ; // To keep track of data bytes that have been queued in FIFO (not header bytes)
@@ -243,12 +250,13 @@ bool tud_usbtmc_transmit_dev_msg_data(
243
250
bool tud_usbtmc_transmit_notification_data (const void * data , size_t len )
244
251
{
245
252
#ifndef NDEBUG
246
- TU_ASSERT (len >= 1 );
253
+ TU_ASSERT (len > 0 );
247
254
TU_ASSERT (usbtmc_state .ep_int_in != 0 );
248
255
#endif
249
- if (usbd_edpt_busy (usbtmc_state .rhport , usbtmc_state .ep_int_in )) return false ;
256
+ TU_VERIFY (usbd_edpt_busy (usbtmc_state .rhport , usbtmc_state .ep_int_in ));
250
257
251
- TU_VERIFY (usbd_edpt_xfer (usbtmc_state .rhport , usbtmc_state .ep_int_in , (void * )(uintptr_t ) data , len ));
258
+ TU_VERIFY (tu_memcpy_s (usbtmc_state .ep_int_in_buf , sizeof (usbtmc_state .ep_int_in_buf ), data , len ) == 0 );
259
+ TU_VERIFY (usbd_edpt_xfer (usbtmc_state .rhport , usbtmc_state .ep_int_in , usbtmc_state .ep_int_in_buf , len ));
252
260
return true;
253
261
}
254
262
0 commit comments