mirror of
https://github.com/hathach/tinyusb.git
synced 2025-10-13 17:36:18 +08:00
successfully
This commit is contained in:
@@ -109,20 +109,35 @@ extern void* tusb_app_phys_to_virt(void *phys_addr);
|
||||
|
||||
// This is a backport of memset_s from c11
|
||||
TU_ATTR_ALWAYS_INLINE static inline int tu_memset_s(void *dest, size_t destsz, int ch, size_t count) {
|
||||
// TODO may check if desst and src is not NULL
|
||||
if ( count > destsz ) {
|
||||
// Validate parameters
|
||||
if (dest == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (count > destsz) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
memset(dest, ch, count);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// This is a backport of memcpy_s from c11
|
||||
TU_ATTR_ALWAYS_INLINE static inline int tu_memcpy_s(void *dest, size_t destsz, const void *src, size_t count) {
|
||||
// TODO may check if desst and src is not NULL
|
||||
if ( count > destsz ) {
|
||||
// Validate parameters
|
||||
if (dest == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
// For memcpy, src may be NULL only if count == 0. Reject otherwise.
|
||||
if (src == NULL && count != 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (count > destsz) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
memcpy(dest, src, count);
|
||||
return 0;
|
||||
}
|
||||
|
@@ -814,17 +814,18 @@ static void handle_rxflvl_irq(uint8_t rhport) {
|
||||
dfifo_read_packet(dwc2, xfer->buffer, byte_count);
|
||||
xfer->buffer += byte_count;
|
||||
}
|
||||
}
|
||||
|
||||
// short packet, minus remaining bytes (xfer_size)
|
||||
if (byte_count < xfer->max_size) {
|
||||
const dwc2_ep_tsize_t tsiz = {.value = epout->tsiz};
|
||||
xfer->total_len -= tsiz.xfer_size;
|
||||
if (epnum == 0) {
|
||||
xfer->total_len -= _dcd_data.ep0_pending[TUSB_DIR_OUT];
|
||||
_dcd_data.ep0_pending[TUSB_DIR_OUT] = 0;
|
||||
}
|
||||
// short packet (including ZLP when byte_count == 0), minus remaining bytes (xfer_size)
|
||||
if (byte_count < xfer->max_size) {
|
||||
const dwc2_ep_tsize_t tsiz = {.value = epout->tsiz};
|
||||
xfer->total_len -= tsiz.xfer_size;
|
||||
if (epnum == 0) {
|
||||
xfer->total_len -= _dcd_data.ep0_pending[TUSB_DIR_OUT];
|
||||
_dcd_data.ep0_pending[TUSB_DIR_OUT] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user