mscd_init:
  338|      1|void mscd_init(void) {
  339|      1|  TU_LOG_INT(CFG_TUD_MSC_LOG_LEVEL, sizeof(mscd_interface_t));
  340|      1|  tu_memclr(&_mscd_itf, sizeof(mscd_interface_t));
  ------------------
  |  |   95|      1|#define tu_memclr(buffer, size)  (void) memset((buffer), 0, (size))
  ------------------
  341|      1|}
mscd_reset:
  347|  12.1k|void mscd_reset(uint8_t rhport) {
  348|  12.1k|  (void) rhport;
  349|  12.1k|  tu_memclr(&_mscd_itf, sizeof(mscd_interface_t));
  ------------------
  |  |   95|  12.1k|#define tu_memclr(buffer, size)  (void) memset((buffer), 0, (size))
  ------------------
  350|  12.1k|}
mscd_open:
  352|    225|uint16_t mscd_open(uint8_t rhport, tusb_desc_interface_t const * itf_desc, uint16_t max_len) {
  353|       |  // only support SCSI's BOT protocol
  354|    225|  TU_VERIFY(TUSB_CLASS_MSC    == itf_desc->bInterfaceClass &&
  ------------------
  |  |   95|    225|#define TU_VERIFY(...)                 TU_GET_3RD_ARG(__VA_ARGS__, TU_VERIFY_2ARGS, TU_VERIFY_1ARGS, _dummy)(__VA_ARGS__)
  |  |  ------------------
  |  |  |  |  112|    225|#define TU_GET_3RD_ARG(arg1, arg2, arg3, ...)        arg3
  |  |  |  |  ------------------
  |  |  |  |  |  |   95|    225|#define TU_VERIFY(...)                 TU_GET_3RD_ARG(__VA_ARGS__, TU_VERIFY_2ARGS, TU_VERIFY_1ARGS, _dummy)(__VA_ARGS__)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   93|    225|#define TU_VERIFY_2ARGS(_cond, _ret)   TU_VERIFY_DEFINE(_cond, _ret)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   86|    225|  do {                                \
  |  |  |  |  |  |  |  |  |  |   87|    900|    if (!(_cond)) {                   \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (87:11): [True: 225, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  Branch (87:11): [True: 225, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  Branch (87:11): [True: 225, False: 0]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   88|      0|      return _ret;                    \
  |  |  |  |  |  |  |  |  |  |   89|      0|    }                                 \
  |  |  |  |  |  |  |  |  |  |   90|    225|  } while (0)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (90:12): [Folded, False: 225]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  355|    225|            MSC_SUBCLASS_SCSI == itf_desc->bInterfaceSubClass &&
  356|    225|            MSC_PROTOCOL_BOT  == itf_desc->bInterfaceProtocol, 0);
  357|    225|  uint16_t const drv_len = sizeof(tusb_desc_interface_t) + 2*sizeof(tusb_desc_endpoint_t);
  358|    225|  TU_ASSERT(max_len >= drv_len, 0); // Max length must be at least 1 interface + 2 endpoints
  ------------------
  |  |  112|    225|#define TU_ASSERT(...)                 TU_GET_3RD_ARG(__VA_ARGS__, TU_ASSERT_2ARGS, TU_ASSERT_1ARGS, _dummy)(__VA_ARGS__)
  |  |  ------------------
  |  |  |  |  112|    225|#define TU_GET_3RD_ARG(arg1, arg2, arg3, ...)        arg3
  |  |  |  |  ------------------
  |  |  |  |  |  |  112|    225|#define TU_ASSERT(...)                 TU_GET_3RD_ARG(__VA_ARGS__, TU_ASSERT_2ARGS, TU_ASSERT_1ARGS, _dummy)(__VA_ARGS__)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  109|    225|#define TU_ASSERT_2ARGS(_cond, _ret)   TU_ASSERT_DEFINE(_cond, _ret)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  104|    225|  do {                                                                \
  |  |  |  |  |  |  |  |  |  |  105|    225|    if ( !(_cond) ) { TU_MESS_FAILED(); TU_BREAKPOINT(); return _ret; } \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   54|      0|  #define TU_MESS_FAILED() do {} while (0)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (54:41): [Folded, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |                   if ( !(_cond) ) { TU_MESS_FAILED(); TU_BREAKPOINT(); return _ret; } \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   77|      0|  #define TU_BREAKPOINT() do {} while (0)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (77:40): [Folded, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (105:10): [True: 0, False: 225]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  106|    225|  } while(0)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (106:11): [Folded, False: 225]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  359|       |
  360|    225|  mscd_interface_t * p_msc = &_mscd_itf;
  361|    225|  p_msc->itf_num = itf_desc->bInterfaceNumber;
  362|    225|  p_msc->rhport = rhport;
  363|       |
  364|       |  // Open endpoint pair
  365|    225|  TU_ASSERT(usbd_open_edpt_pair(rhport, tu_desc_next(itf_desc), 2, TUSB_XFER_BULK, &p_msc->ep_out, &p_msc->ep_in), 0);
  ------------------
  |  |  112|    225|#define TU_ASSERT(...)                 TU_GET_3RD_ARG(__VA_ARGS__, TU_ASSERT_2ARGS, TU_ASSERT_1ARGS, _dummy)(__VA_ARGS__)
  |  |  ------------------
  |  |  |  |  112|    225|#define TU_GET_3RD_ARG(arg1, arg2, arg3, ...)        arg3
  |  |  |  |  ------------------
  |  |  |  |  |  |  112|    225|#define TU_ASSERT(...)                 TU_GET_3RD_ARG(__VA_ARGS__, TU_ASSERT_2ARGS, TU_ASSERT_1ARGS, _dummy)(__VA_ARGS__)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  109|    225|#define TU_ASSERT_2ARGS(_cond, _ret)   TU_ASSERT_DEFINE(_cond, _ret)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  104|    225|  do {                                                                \
  |  |  |  |  |  |  |  |  |  |  105|    225|    if ( !(_cond) ) { TU_MESS_FAILED(); TU_BREAKPOINT(); return _ret; } \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   54|    225|  #define TU_MESS_FAILED() do {} while (0)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (54:41): [Folded, False: 225]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |                   if ( !(_cond) ) { TU_MESS_FAILED(); TU_BREAKPOINT(); return _ret; } \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   77|    225|  #define TU_BREAKPOINT() do {} while (0)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (77:40): [Folded, False: 225]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (105:10): [True: 225, False: 0]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  106|    225|  } while(0)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (106:11): [Folded, False: 0]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  366|       |
  367|       |  // Prepare for Command Block Wrapper
  368|      0|  TU_ASSERT(prepare_cbw(p_msc), drv_len);
  ------------------
  |  |  112|      0|#define TU_ASSERT(...)                 TU_GET_3RD_ARG(__VA_ARGS__, TU_ASSERT_2ARGS, TU_ASSERT_1ARGS, _dummy)(__VA_ARGS__)
  |  |  ------------------
  |  |  |  |  112|      0|#define TU_GET_3RD_ARG(arg1, arg2, arg3, ...)        arg3
  |  |  |  |  ------------------
  |  |  |  |  |  |  112|      0|#define TU_ASSERT(...)                 TU_GET_3RD_ARG(__VA_ARGS__, TU_ASSERT_2ARGS, TU_ASSERT_1ARGS, _dummy)(__VA_ARGS__)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  109|      0|#define TU_ASSERT_2ARGS(_cond, _ret)   TU_ASSERT_DEFINE(_cond, _ret)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  104|      0|  do {                                                                \
  |  |  |  |  |  |  |  |  |  |  105|      0|    if ( !(_cond) ) { TU_MESS_FAILED(); TU_BREAKPOINT(); return _ret; } \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   54|      0|  #define TU_MESS_FAILED() do {} while (0)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (54:41): [Folded, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |                   if ( !(_cond) ) { TU_MESS_FAILED(); TU_BREAKPOINT(); return _ret; } \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   77|      0|  #define TU_BREAKPOINT() do {} while (0)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (77:40): [Folded, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (105:10): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  106|      0|  } while(0)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (106:11): [Folded, False: 0]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  369|       |
  370|      0|  return drv_len;
  371|      0|}

tusb_fifo.c:tu_min16:
  187|  28.8k|TU_ATTR_ALWAYS_INLINE static inline uint16_t tu_min16 (uint16_t x, uint16_t y) { return (x < y) ? x : y; }
  ------------------
  |  Branch (187:89): [True: 28.8k, False: 0]
  ------------------
usbd.c:tu_min16:
  187|  3.39k|TU_ATTR_ALWAYS_INLINE static inline uint16_t tu_min16 (uint16_t x, uint16_t y) { return (x < y) ? x : y; }
  ------------------
  |  Branch (187:89): [True: 2.90k, False: 488]
  ------------------
usbd.c:tu_memcpy_s:
  118|    546|TU_ATTR_ALWAYS_INLINE static inline int tu_memcpy_s(void *dest, size_t destsz, const void *src, size_t count) {
  119|    546|  if (dest == NULL) {
  ------------------
  |  Branch (119:7): [True: 0, False: 546]
  ------------------
  120|      0|    return -1;
  121|      0|  }
  122|       |
  123|    546|  if (count == 0u) {
  ------------------
  |  Branch (123:7): [True: 0, False: 546]
  ------------------
  124|      0|    return 0;
  125|      0|  }
  126|       |
  127|    546|  if (src == NULL) {
  ------------------
  |  Branch (127:7): [True: 0, False: 546]
  ------------------
  128|      0|    return -1;
  129|      0|  }
  130|       |
  131|    546|  if (count > destsz) {
  ------------------
  |  Branch (131:7): [True: 0, False: 546]
  ------------------
  132|      0|    return -1;
  133|      0|  }
  134|       |
  135|    546|  (void) memcpy(dest, src, count);
  136|    546|  return 0;
  137|    546|}
usbd.c:tu_u16_low:
  178|  5.24k|TU_ATTR_ALWAYS_INLINE static inline uint8_t tu_u16_low (uint16_t ui16) { return TU_U16_LOW(ui16); }
  ------------------
  |  |   27|  5.24k|#define TU_U16_LOW(_u16)              ((uint8_t) ((uint16_t) (_u16) & 0x00ffu))
  ------------------
usbd.c:tu_desc_in_bounds:
  371|    225|TU_ATTR_ALWAYS_INLINE static inline bool tu_desc_in_bounds(const uint8_t *p_desc, const uint8_t *desc_end) {
  372|    225|  return p_desc < desc_end && tu_desc_next(p_desc) <= desc_end;
  ------------------
  |  Branch (372:10): [True: 225, False: 0]
  |  Branch (372:31): [True: 225, False: 0]
  ------------------
  373|    225|}
usbd.c:tu_desc_type:
  362|    450|TU_ATTR_ALWAYS_INLINE static inline uint8_t tu_desc_type(void const* desc) {
  363|    450|  return ((uint8_t const*) desc)[DESC_OFFSET_TYPE];
  364|    450|}
usbd.c:tu_u16_high:
  177|  2.02k|TU_ATTR_ALWAYS_INLINE static inline uint8_t tu_u16_high(uint16_t ui16) { return TU_U16_HIGH(ui16); }
  ------------------
  |  |   26|  2.02k|#define TU_U16_HIGH(_u16)             ((uint8_t) (((uint16_t) (_u16) >> 8) & 0x00ffu))
  ------------------
usbd.c:tu_unaligned_read16:
  252|    260|TU_ATTR_ALWAYS_INLINE static inline uint16_t tu_unaligned_read16(const void *mem) {
  253|    260|  tu_unaligned_uint16_t const *ua16 = (tu_unaligned_uint16_t const *) mem;
  254|    260|  return ua16->val;
  255|    260|}
usbd.c:tu_desc_len:
  357|    497|TU_ATTR_ALWAYS_INLINE static inline uint8_t tu_desc_len(void const* desc) {
  358|    497|  return ((uint8_t const*) desc)[DESC_OFFSET_LEN];
  359|    497|}
usbd.c:tu_desc_next:
  351|    225|TU_ATTR_ALWAYS_INLINE static inline uint8_t const * tu_desc_next(void const* desc) {
  352|    225|  uint8_t const* desc8 = (uint8_t const*) desc;
  353|    225|  return desc8 + desc8[DESC_OFFSET_LEN];
  354|    225|}
msc_device.c:tu_desc_next:
  351|    225|TU_ATTR_ALWAYS_INLINE static inline uint8_t const * tu_desc_next(void const* desc) {
  352|    225|  uint8_t const* desc8 = (uint8_t const*) desc;
  353|    225|  return desc8 + desc8[DESC_OFFSET_LEN];
  354|    225|}

tu_fifo_clear:
   62|      1|void tu_fifo_clear(tu_fifo_t *f) {
   63|      1|  ff_lock(f->mutex_wr);
   64|      1|  ff_lock(f->mutex_rd);
   65|       |
   66|      1|  f->rd_idx = 0;
   67|      1|  f->wr_idx = 0;
   68|       |
   69|      1|  ff_unlock(f->mutex_wr);
   70|      1|  ff_unlock(f->mutex_rd);
   71|      1|}
tu_fifo_peek_n_access_mode:
  444|  72.8k|                                    const tu_hwfifo_access_t *access_mode) {
  445|  72.8k|  uint16_t count = tu_ff_overflow_count(f->depth, wr_idx, rd_idx);
  446|  72.8k|  if (count == 0) {
  ------------------
  |  Branch (446:7): [True: 43.9k, False: 28.8k]
  ------------------
  447|  43.9k|    return 0; // nothing to peek
  448|  43.9k|  }
  449|       |
  450|       |  // Check overflow and correct if required
  451|  28.8k|  if (count > f->depth) {
  ------------------
  |  Branch (451:7): [True: 0, False: 28.8k]
  ------------------
  452|      0|    rd_idx = correct_read_index(f, wr_idx);
  453|      0|    count  = f->depth;
  454|      0|  }
  455|       |
  456|  28.8k|  if (count < n) {
  ------------------
  |  Branch (456:7): [True: 0, False: 28.8k]
  ------------------
  457|      0|    n = count; // limit to available count
  458|      0|  }
  459|       |
  460|  28.8k|  const uint16_t rd_ptr = idx2ptr(f->depth, rd_idx);
  461|       |
  462|       |#if CFG_TUSB_FIFO_HWFIFO_API
  463|       |  if (access_mode != NULL) {
  464|       |    hwff_pull_n(f, p_buffer, n, rd_ptr, access_mode);
  465|       |  } else
  466|       |#endif
  467|  28.8k|  {
  468|  28.8k|    (void)access_mode;
  469|  28.8k|    ff_pull_n(f, p_buffer, n, rd_ptr);
  470|  28.8k|  }
  471|       |
  472|  28.8k|  return n;
  473|  72.8k|}
tu_fifo_read_n_access_mode:
  486|  72.8k|uint16_t tu_fifo_read_n_access_mode(tu_fifo_t *f, void *buffer, uint16_t n, const tu_hwfifo_access_t *access_mode) {
  487|  72.8k|  ff_lock(f->mutex_rd);
  488|       |
  489|       |  // Peek the data: f->rd_idx might get modified in case of an overflow so we can not use a local variable
  490|  72.8k|  const uint16_t wr_idx = f->wr_idx;
  491|  72.8k|  n         = tu_fifo_peek_n_access_mode(f, buffer, n, wr_idx, f->rd_idx, access_mode);
  492|  72.8k|  f->rd_idx = advance_index(f->depth, f->rd_idx, n);
  493|       |
  494|  72.8k|  ff_unlock(f->mutex_rd);
  495|  72.8k|  return n;
  496|  72.8k|}
tu_fifo_write_n_access_mode:
  500|  28.8k|                                     const tu_hwfifo_access_t *access_mode) {
  501|  28.8k|  if (n == 0) {
  ------------------
  |  Branch (501:7): [True: 0, False: 28.8k]
  ------------------
  502|      0|    return 0;
  503|      0|  }
  504|       |
  505|  28.8k|  ff_lock(f->mutex_wr);
  506|       |
  507|  28.8k|  uint16_t wr_idx = f->wr_idx;
  508|  28.8k|  uint16_t rd_idx = f->rd_idx;
  509|       |
  510|  28.8k|  const uint8_t *buf8 = (const uint8_t *)data;
  511|       |
  512|  28.8k|  TU_LOG(TU_FIFO_DBG, "rd = %3u, wr = %3u, count = %3u, remain = %3u, n = %3u:  ", rd_idx, wr_idx,
  513|  28.8k|         tu_ff_overflow_count(f->depth, wr_idx, rd_idx), tu_ff_remaining_local(f->depth, wr_idx, rd_idx), n);
  514|       |
  515|  28.8k|  if (!f->overwritable) {
  ------------------
  |  Branch (515:7): [True: 28.8k, False: 0]
  ------------------
  516|       |    // limit up to full
  517|  28.8k|    const uint16_t remain = tu_ff_remaining_local(f->depth, wr_idx, rd_idx);
  518|  28.8k|    n                     = tu_min16(n, remain);
  519|  28.8k|  } else {
  520|       |    // In over-writable mode, fifo_write() is allowed even when fifo is full. In such case,
  521|       |    // oldest data in fifo i.e. at read pointer data will be overwritten
  522|       |    // Note: we can modify read buffer contents however we must not modify the read index itself within a write
  523|       |    // function! Since it would end up in a race condition with read functions!
  524|      0|    if (n >= f->depth) {
  ------------------
  |  Branch (524:9): [True: 0, False: 0]
  ------------------
  525|       |      // Only copy last part
  526|      0|      if (access_mode == NULL) {
  ------------------
  |  Branch (526:11): [True: 0, False: 0]
  ------------------
  527|      0|        buf8 += (n - f->depth);
  528|      0|      } else {
  529|       |        // TODO should read from hw fifo to discard data, however reading an odd number could
  530|       |        // accidentally discard data.
  531|      0|      }
  532|       |
  533|      0|      n = f->depth;
  534|       |
  535|       |      // We start writing at the read pointer's position since we fill the whole buffer
  536|      0|      wr_idx = rd_idx;
  537|      0|    } else {
  538|      0|      const uint16_t overflowable_count = tu_ff_overflow_count(f->depth, wr_idx, rd_idx);
  539|      0|      if (overflowable_count + n >= 2 * f->depth) {
  ------------------
  |  Branch (539:11): [True: 0, False: 0]
  ------------------
  540|       |        // Double overflowed
  541|       |        // Index is bigger than the allowed range [0,2*depth)
  542|       |        // re-position write index to have a full fifo after pushed
  543|      0|        wr_idx = advance_index(f->depth, rd_idx, f->depth - n);
  544|       |
  545|       |        // TODO we should also shift out n bytes from read index since we avoid changing rd index !!
  546|       |        // However memmove() is expensive due to actual copying + wrapping consideration.
  547|       |        // Also race condition could happen anyway if read() is invoke while moving result in corrupted memory
  548|       |        // currently deliberately not implemented --> result in incorrect data read back
  549|      0|      } else {
  550|       |        // normal + single overflowed:
  551|       |        // Index is in the range of [0,2*depth) and thus detect and recoverable. Recovering is handled in read()
  552|       |        // Therefore we just increase write index
  553|       |        // we will correct (re-position) read index later on in fifo_read() function
  554|      0|      }
  555|      0|    }
  556|      0|  }
  557|       |
  558|  28.8k|  if (n) {
  ------------------
  |  Branch (558:7): [True: 28.8k, False: 0]
  ------------------
  559|  28.8k|    const uint16_t wr_ptr = idx2ptr(f->depth, wr_idx);
  560|  28.8k|    TU_LOG(TU_FIFO_DBG, "actual_n = %u, wr_ptr = %u", n, wr_ptr);
  561|       |
  562|       |#if CFG_TUSB_FIFO_HWFIFO_API
  563|       |    if (access_mode != NULL) {
  564|       |      hwff_push_n(f, buf8, n, wr_ptr, access_mode);
  565|       |    } else
  566|       |#endif
  567|  28.8k|    {
  568|  28.8k|      ff_push_n(f, buf8, n, wr_ptr);
  569|  28.8k|    }
  570|  28.8k|    f->wr_idx = advance_index(f->depth, wr_idx, n);
  571|       |
  572|  28.8k|    TU_LOG(TU_FIFO_DBG, "\tnew_wr = %u\r\n", f->wr_idx);
  573|  28.8k|  }
  574|       |
  575|  28.8k|  ff_unlock(f->mutex_wr);
  576|       |
  577|  28.8k|  return n;
  578|  28.8k|}
tusb_fifo.c:idx2ptr:
  415|  57.7k|TU_ATTR_ALWAYS_INLINE static inline uint16_t idx2ptr(uint16_t depth, uint16_t idx) {
  416|       |  // Only run at most 3 times since index is limit in the range of [0..2*depth)
  417|  86.6k|  while (idx >= depth) {
  ------------------
  |  Branch (417:10): [True: 28.8k, False: 57.7k]
  ------------------
  418|  28.8k|    idx -= depth;
  419|  28.8k|  }
  420|  57.7k|  return idx;
  421|  57.7k|}
tusb_fifo.c:ff_pull_n:
  379|  28.8k|static void ff_pull_n(const tu_fifo_t *f, void *app_buf, uint16_t n, uint16_t rd_ptr) {
  380|  28.8k|  uint16_t       lin_bytes  = f->depth - rd_ptr;
  381|  28.8k|  uint16_t       wrap_bytes = n - lin_bytes; // only used if wrapped
  382|  28.8k|  const uint8_t *ff_buf     = f->buffer + rd_ptr;
  383|       |
  384|       |  // single byte access
  385|  28.8k|  if (n <= lin_bytes) {
  ------------------
  |  Branch (385:7): [True: 28.8k, False: 0]
  ------------------
  386|       |    // Linear only
  387|  28.8k|    memcpy(app_buf, ff_buf, n);
  388|  28.8k|  } else {
  389|       |    // Wrap around
  390|      0|    memcpy(app_buf, ff_buf, lin_bytes);                            // linear part
  391|      0|    memcpy((uint8_t *)app_buf + lin_bytes, f->buffer, wrap_bytes); // wrapped part
  392|      0|  }
  393|  28.8k|}
tusb_fifo.c:advance_index:
  401|   101k|static uint16_t advance_index(uint16_t depth, uint16_t idx, uint16_t offset) {
  402|       |  // We limit the index space of p such that a correct wrap around happens
  403|       |  // Check for a wrap around or if we are in unused index space - This has to be checked first!!
  404|       |  // We are exploiting the wrap around to the correct index
  405|   101k|  uint16_t new_idx = (uint16_t)(idx + offset);
  406|   101k|  if ((idx > new_idx) || (new_idx >= 2 * depth)) {
  ------------------
  |  Branch (406:7): [True: 0, False: 101k]
  |  Branch (406:26): [True: 1.80k, False: 99.9k]
  ------------------
  407|  1.80k|    const uint16_t non_used_index_space = (uint16_t)(UINT16_MAX - (2 * depth - 1));
  408|  1.80k|    new_idx                             = (uint16_t)(new_idx + non_used_index_space);
  409|  1.80k|  }
  410|       |
  411|   101k|  return new_idx;
  412|   101k|}
tusb_fifo.c:ff_push_n:
  363|  28.8k|static void ff_push_n(const tu_fifo_t *f, const void *app_buf, uint16_t n, uint16_t wr_ptr) {
  364|  28.8k|  uint16_t lin_bytes  = f->depth - wr_ptr;
  365|  28.8k|  uint16_t wrap_bytes = n - lin_bytes;
  366|  28.8k|  uint8_t *ff_buf     = f->buffer + wr_ptr;
  367|       |
  368|  28.8k|  if (n <= lin_bytes) {
  ------------------
  |  Branch (368:7): [True: 28.8k, False: 0]
  ------------------
  369|       |    // Linear only case
  370|  28.8k|    memcpy(ff_buf, app_buf, n);
  371|  28.8k|  } else {
  372|       |    // Wrap around case
  373|      0|    memcpy(ff_buf, app_buf, lin_bytes);                                    // linear part
  374|      0|    memcpy(f->buffer, ((const uint8_t *)app_buf) + lin_bytes, wrap_bytes); // wrapped part
  375|      0|  }
  376|  28.8k|}

tusb_fifo.c:tu_ff_overflow_count:
  243|   101k|TU_ATTR_ALWAYS_INLINE static inline uint16_t tu_ff_overflow_count(uint16_t depth, uint16_t wr_idx, uint16_t rd_idx) {
  244|   101k|  const int32_t diff = (int32_t)wr_idx - (int32_t)rd_idx;
  245|   101k|  if (diff >= 0) {
  ------------------
  |  Branch (245:7): [True: 100k, False: 1.51k]
  ------------------
  246|   100k|    return (uint16_t)diff;
  247|   100k|  } else {
  248|  1.51k|    return (uint16_t)(2 * depth + diff);
  249|  1.51k|  }
  250|   101k|}
tusb_fifo.c:tu_ff_remaining_local:
  253|  28.8k|TU_ATTR_ALWAYS_INLINE static inline uint16_t tu_ff_remaining_local(uint16_t depth, uint16_t wr_idx, uint16_t rd_idx) {
  254|  28.8k|  const uint16_t ovf_count = tu_ff_overflow_count(depth, wr_idx, rd_idx);
  255|  28.8k|  return (depth > ovf_count) ? (depth - ovf_count) : 0;
  ------------------
  |  Branch (255:10): [True: 28.8k, False: 0]
  ------------------
  256|  28.8k|}
usbd.c:tu_fifo_read_n:
  192|  72.8k|TU_ATTR_ALWAYS_INLINE static inline uint16_t tu_fifo_read_n(tu_fifo_t *f, void *buffer, uint16_t n) {
  193|       |  return tu_fifo_read_n_access_mode(f, buffer, n, NULL);
  194|  72.8k|}
usbd.c:tu_fifo_write_n:
  205|  28.8k|TU_ATTR_ALWAYS_INLINE static inline uint16_t tu_fifo_write_n(tu_fifo_t *f, const void *data, uint16_t n) {
  206|       |  return tu_fifo_write_n_access_mode(f, data, n, NULL);
  207|  28.8k|}

usbd.c:tu_edpt_number:
  561|  7.33k|TU_ATTR_ALWAYS_INLINE static inline uint8_t tu_edpt_number(uint8_t addr) {
  562|  7.33k|  return (uint8_t) (addr & TUSB_EPNUM_MASK);
  563|  7.33k|}
usbd.c:tu_edpt_dir:
  556|  7.11k|TU_ATTR_ALWAYS_INLINE static inline tusb_dir_t tu_edpt_dir(uint8_t addr) {
  557|  7.11k|  return (addr & TUSB_DIR_IN_MASK) ? TUSB_DIR_IN : TUSB_DIR_OUT;
  ------------------
  |  Branch (557:10): [True: 3.77k, False: 3.34k]
  ------------------
  558|  7.11k|}
dcd_fuzz.cc:_ZL12tu_edpt_addrhh:
  565|    205|TU_ATTR_ALWAYS_INLINE static inline uint8_t tu_edpt_addr(uint8_t num, uint8_t dir) {
  566|    205|  return (uint8_t) (num | (dir == (uint8_t)TUSB_DIR_IN ? (uint8_t)TUSB_DIR_IN_MASK : 0u));
  ------------------
  |  Branch (566:28): [True: 205, False: 0]
  ------------------
  567|    205|}
dcd_fuzz.cc:_ZL11tu_edpt_dirh:
  556|  4.44k|TU_ATTR_ALWAYS_INLINE static inline tusb_dir_t tu_edpt_dir(uint8_t addr) {
  557|  4.44k|  return (addr & TUSB_DIR_IN_MASK) ? TUSB_DIR_IN : TUSB_DIR_OUT;
  ------------------
  |  Branch (557:10): [True: 3.46k, False: 973]
  ------------------
  558|  4.44k|}

dcd_fuzz.cc:_ZL20dcd_event_bus_signalh13dcd_eventid_tb:
  189|  8.99k|TU_ATTR_ALWAYS_INLINE static inline void dcd_event_bus_signal (uint8_t rhport, dcd_eventid_t eid, bool in_isr) {
  190|  8.99k|  dcd_event_t event;
  191|  8.99k|  event.rhport = rhport;
  192|  8.99k|  event.event_id = eid;
  193|  8.99k|  dcd_event_handler(&event, in_isr);
  194|  8.99k|}
dcd_fuzz.cc:_ZL19dcd_event_bus_reseth12tusb_speed_tb:
  197|  7.86k|TU_ATTR_ALWAYS_INLINE static inline  void dcd_event_bus_reset (uint8_t rhport, tusb_speed_t speed, bool in_isr) {
  198|  7.86k|  dcd_event_t event;
  199|  7.86k|  event.rhport = rhport;
  200|  7.86k|  event.event_id = DCD_EVENT_BUS_RESET;
  ------------------
  |  |   42|  7.86k|#define DCD_EVENT_BUS_RESET DCD_EVENT_BUS_RESET_END // backward compatibility
  ------------------
  201|  7.86k|  event.bus_reset.speed = speed;
  202|  7.86k|  dcd_event_handler(&event, in_isr);
  203|  7.86k|}
dcd_fuzz.cc:_ZL24dcd_event_setup_receivedhPKhb:
  206|  15.3k|TU_ATTR_ALWAYS_INLINE static inline void dcd_event_setup_received(uint8_t rhport, uint8_t const * setup, bool in_isr) {
  207|  15.3k|  dcd_event_t event;
  208|  15.3k|  event.rhport = rhport;
  209|  15.3k|  event.event_id = DCD_EVENT_SETUP_RECEIVED;
  210|  15.3k|  (void) memcpy(&event.setup_received, setup, sizeof(tusb_control_request_t));
  211|       |  // USB wire format is little-endian. Convert multi-byte fields to host byte order
  212|       |  // so the stack always sees correct values regardless of CPU endianness.
  213|  15.3k|  event.setup_received.wValue  = tu_le16toh(event.setup_received.wValue);
  ------------------
  |  |  253|  15.3k|  #define tu_le16toh(u16) (u16)
  ------------------
  214|  15.3k|  event.setup_received.wIndex  = tu_le16toh(event.setup_received.wIndex);
  ------------------
  |  |  253|  15.3k|  #define tu_le16toh(u16) (u16)
  ------------------
  215|  15.3k|  event.setup_received.wLength = tu_le16toh(event.setup_received.wLength);
  ------------------
  |  |  253|  15.3k|  #define tu_le16toh(u16) (u16)
  ------------------
  216|  15.3k|  dcd_event_handler(&event, in_isr);
  217|  15.3k|}

tud_event_hook_cb:
   29|  28.8k|TU_ATTR_WEAK void tud_event_hook_cb(uint8_t rhport, uint32_t eventid, bool in_isr) {
   30|  28.8k|  (void) rhport; (void) eventid; (void) in_isr;
   31|  28.8k|}
tud_descriptor_bos_cb:
   37|    195|TU_ATTR_WEAK uint8_t const* tud_descriptor_bos_cb(void) {
   38|       |  return NULL;
   39|    195|}
tud_descriptor_device_qualifier_cb:
   41|    194|TU_ATTR_WEAK uint8_t const* tud_descriptor_device_qualifier_cb(void) {
   42|       |  return NULL;
   43|    194|}
tud_descriptor_other_speed_configuration_cb:
   45|    197|TU_ATTR_WEAK uint8_t const* tud_descriptor_other_speed_configuration_cb(uint8_t index) {
   46|    197|  (void) index;
   47|       |  return NULL;
   48|    197|}
tud_umount_cb:
   53|  4.26k|TU_ATTR_WEAK void tud_umount_cb(void) {
   54|  4.26k|}
tud_suspend_cb:
   56|    819|TU_ATTR_WEAK void tud_suspend_cb(bool remote_wakeup_en) {
   57|    819|  (void) remote_wakeup_en;
   58|    819|}
tud_resume_cb:
   60|    588|TU_ATTR_WEAK void tud_resume_cb(void) {
   61|    588|}
tud_vendor_control_xfer_cb:
   63|    371|TU_ATTR_WEAK bool tud_vendor_control_xfer_cb(uint8_t rhport, uint8_t stage, tusb_control_request_t const* request) {
   64|    371|  (void) rhport; (void) stage; (void) request;
   65|       |  return false;
   66|    371|}
usbd_app_driver_get_cb:
  438|      1|TU_ATTR_WEAK usbd_class_driver_t const* usbd_app_driver_get_cb(uint8_t* driver_count) {
  439|      1|  *driver_count = 0;
  440|       |  return NULL;
  441|      1|}
tud_inited:
  512|  44.9k|bool tud_inited(void) {
  513|  44.9k|  return _usbd_rhport != RHPORT_INVALID;
  514|  44.9k|}
tud_rhport_init:
  520|    996|bool tud_rhport_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
  521|    996|  if (tud_inited()) {
  ------------------
  |  Branch (521:7): [True: 995, False: 1]
  ------------------
  522|    995|    return true; // skip if already initialized
  523|    995|  }
  524|      1|  TU_ASSERT(rh_init);
  ------------------
  |  |  112|      1|#define TU_ASSERT(...)                 TU_GET_3RD_ARG(__VA_ARGS__, TU_ASSERT_2ARGS, TU_ASSERT_1ARGS, _dummy)(__VA_ARGS__)
  |  |  ------------------
  |  |  |  |  112|      1|#define TU_GET_3RD_ARG(arg1, arg2, arg3, ...)        arg3
  |  |  |  |  ------------------
  |  |  |  |  |  |  112|      1|#define TU_ASSERT(...)                 TU_GET_3RD_ARG(__VA_ARGS__, TU_ASSERT_2ARGS, TU_ASSERT_1ARGS, _dummy)(__VA_ARGS__)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  108|      1|#define TU_ASSERT_1ARGS(_cond)         TU_ASSERT_DEFINE(_cond, false)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  104|      1|  do {                                                                \
  |  |  |  |  |  |  |  |  |  |  105|      1|    if ( !(_cond) ) { TU_MESS_FAILED(); TU_BREAKPOINT(); return _ret; } \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   54|      0|  #define TU_MESS_FAILED() do {} while (0)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (54:41): [Folded, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |                   if ( !(_cond) ) { TU_MESS_FAILED(); TU_BREAKPOINT(); return _ret; } \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   77|      0|  #define TU_BREAKPOINT() do {} while (0)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (77:40): [Folded, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (105:10): [True: 0, False: 1]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  106|      1|  } while(0)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (106:11): [Folded, False: 1]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  525|       | #if CFG_TUSB_DEBUG >= CFG_TUD_LOG_LEVEL
  526|       |  char const* speed_str = 0;
  527|       |  switch (rh_init->speed) {
  528|       |    case TUSB_SPEED_HIGH:
  529|       |      speed_str = "High";
  530|       |    break;
  531|       |    case TUSB_SPEED_FULL:
  532|       |      speed_str = "Full";
  533|       |    break;
  534|       |    case TUSB_SPEED_LOW:
  535|       |      speed_str = "Low";
  536|       |    break;
  537|       |    case TUSB_SPEED_AUTO:
  538|       |      speed_str = "Auto";
  539|       |    break;
  540|       |  default:
  541|       |    break;
  542|       |  }
  543|       |  TU_LOG_USBD("USBD init on controller %u, speed = %s\r\n", rhport, speed_str);
  544|       |  TU_LOG_INT(CFG_TUD_LOG_LEVEL, sizeof(usbd_device_t));
  545|       |  TU_LOG_INT(CFG_TUD_LOG_LEVEL, sizeof(dcd_event_t));
  546|       |  TU_LOG_INT(CFG_TUD_LOG_LEVEL, sizeof(tu_fifo_t));
  547|       |  TU_LOG_INT(CFG_TUD_LOG_LEVEL, sizeof(tu_edpt_stream_t));
  548|       |#endif
  549|       |
  550|      1|  tu_varclr(&_usbd_dev);
  ------------------
  |  |   96|      1|#define tu_varclr(_var)          tu_memclr(_var, sizeof(*(_var)))
  |  |  ------------------
  |  |  |  |   95|      1|#define tu_memclr(buffer, size)  (void) memset((buffer), 0, (size))
  |  |  ------------------
  ------------------
  551|      1|  _usbd_queued_setup = 0;
  552|       |
  553|      1|  osal_spin_init(&_usbd_spin);
  554|       |
  555|       |#if OSAL_MUTEX_REQUIRED
  556|       |  // Init device mutex
  557|       |  _usbd_mutex = osal_mutex_create(&_ubsd_mutexdef);
  558|       |  TU_ASSERT(_usbd_mutex);
  559|       |#endif
  560|       |
  561|       |  // Init device queue & task
  562|      1|  _usbd_q = osal_queue_create(&_usbd_qdef);
  563|      1|  TU_ASSERT(_usbd_q);
  ------------------
  |  |  112|      1|#define TU_ASSERT(...)                 TU_GET_3RD_ARG(__VA_ARGS__, TU_ASSERT_2ARGS, TU_ASSERT_1ARGS, _dummy)(__VA_ARGS__)
  |  |  ------------------
  |  |  |  |  112|      1|#define TU_GET_3RD_ARG(arg1, arg2, arg3, ...)        arg3
  |  |  |  |  ------------------
  |  |  |  |  |  |  112|      1|#define TU_ASSERT(...)                 TU_GET_3RD_ARG(__VA_ARGS__, TU_ASSERT_2ARGS, TU_ASSERT_1ARGS, _dummy)(__VA_ARGS__)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  108|      1|#define TU_ASSERT_1ARGS(_cond)         TU_ASSERT_DEFINE(_cond, false)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  104|      1|  do {                                                                \
  |  |  |  |  |  |  |  |  |  |  105|      1|    if ( !(_cond) ) { TU_MESS_FAILED(); TU_BREAKPOINT(); return _ret; } \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   54|      0|  #define TU_MESS_FAILED() do {} while (0)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (54:41): [Folded, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |                   if ( !(_cond) ) { TU_MESS_FAILED(); TU_BREAKPOINT(); return _ret; } \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   77|      0|  #define TU_BREAKPOINT() do {} while (0)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (77:40): [Folded, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (105:10): [True: 0, False: 1]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  106|      1|  } while(0)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (106:11): [Folded, False: 1]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  564|       |
  565|       |  // Get application driver if available
  566|      1|  _app_driver = usbd_app_driver_get_cb(&_app_driver_count);
  567|      1|  TU_ASSERT(_app_driver_count + _builtin_driver_count <= UINT8_MAX);
  ------------------
  |  |  112|      1|#define TU_ASSERT(...)                 TU_GET_3RD_ARG(__VA_ARGS__, TU_ASSERT_2ARGS, TU_ASSERT_1ARGS, _dummy)(__VA_ARGS__)
  |  |  ------------------
  |  |  |  |  112|      1|#define TU_GET_3RD_ARG(arg1, arg2, arg3, ...)        arg3
  |  |  |  |  ------------------
  |  |  |  |  |  |  112|      1|#define TU_ASSERT(...)                 TU_GET_3RD_ARG(__VA_ARGS__, TU_ASSERT_2ARGS, TU_ASSERT_1ARGS, _dummy)(__VA_ARGS__)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  108|      1|#define TU_ASSERT_1ARGS(_cond)         TU_ASSERT_DEFINE(_cond, false)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  104|      1|  do {                                                                \
  |  |  |  |  |  |  |  |  |  |  105|      1|    if ( !(_cond) ) { TU_MESS_FAILED(); TU_BREAKPOINT(); return _ret; } \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   54|      0|  #define TU_MESS_FAILED() do {} while (0)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (54:41): [Folded, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |                   if ( !(_cond) ) { TU_MESS_FAILED(); TU_BREAKPOINT(); return _ret; } \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   77|      0|  #define TU_BREAKPOINT() do {} while (0)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (77:40): [Folded, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (105:10): [True: 0, False: 1]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  106|      1|  } while(0)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (106:11): [Folded, False: 1]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  568|       |
  569|       |  // Init class drivers
  570|      2|  for (uint8_t i = 0; i < TOTAL_DRIVER_COUNT; i++) {
  ------------------
  |  |  369|      2|#define TOTAL_DRIVER_COUNT    ((uint8_t) (_app_driver_count + _builtin_driver_count))
  ------------------
  |  Branch (570:23): [True: 1, False: 1]
  ------------------
  571|      1|    usbd_class_driver_t const* driver = get_driver(i);
  572|      1|    TU_ASSERT(driver && driver->init);
  ------------------
  |  |  112|      1|#define TU_ASSERT(...)                 TU_GET_3RD_ARG(__VA_ARGS__, TU_ASSERT_2ARGS, TU_ASSERT_1ARGS, _dummy)(__VA_ARGS__)
  |  |  ------------------
  |  |  |  |  112|      1|#define TU_GET_3RD_ARG(arg1, arg2, arg3, ...)        arg3
  |  |  |  |  ------------------
  |  |  |  |  |  |  112|      1|#define TU_ASSERT(...)                 TU_GET_3RD_ARG(__VA_ARGS__, TU_ASSERT_2ARGS, TU_ASSERT_1ARGS, _dummy)(__VA_ARGS__)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  108|      1|#define TU_ASSERT_1ARGS(_cond)         TU_ASSERT_DEFINE(_cond, false)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  104|      1|  do {                                                                \
  |  |  |  |  |  |  |  |  |  |  105|      2|    if ( !(_cond) ) { TU_MESS_FAILED(); TU_BREAKPOINT(); return _ret; } \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   54|      0|  #define TU_MESS_FAILED() do {} while (0)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (54:41): [Folded, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |                   if ( !(_cond) ) { TU_MESS_FAILED(); TU_BREAKPOINT(); return _ret; } \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   77|      0|  #define TU_BREAKPOINT() do {} while (0)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (77:40): [Folded, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (105:12): [True: 1, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  Branch (105:12): [True: 1, False: 0]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  106|      1|  } while(0)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (106:11): [Folded, False: 1]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  573|      1|    TU_LOG_USBD("%s init\r\n", driver->name);
  574|      1|    driver->init();
  575|      1|  }
  576|       |
  577|      1|  _usbd_rhport = rhport;
  578|       |
  579|       |  // Init device controller driver
  580|      1|  TU_ASSERT(dcd_init(rhport, rh_init));
  ------------------
  |  |  112|      1|#define TU_ASSERT(...)                 TU_GET_3RD_ARG(__VA_ARGS__, TU_ASSERT_2ARGS, TU_ASSERT_1ARGS, _dummy)(__VA_ARGS__)
  |  |  ------------------
  |  |  |  |  112|      1|#define TU_GET_3RD_ARG(arg1, arg2, arg3, ...)        arg3
  |  |  |  |  ------------------
  |  |  |  |  |  |  112|      1|#define TU_ASSERT(...)                 TU_GET_3RD_ARG(__VA_ARGS__, TU_ASSERT_2ARGS, TU_ASSERT_1ARGS, _dummy)(__VA_ARGS__)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  108|      1|#define TU_ASSERT_1ARGS(_cond)         TU_ASSERT_DEFINE(_cond, false)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  104|      1|  do {                                                                \
  |  |  |  |  |  |  |  |  |  |  105|      1|    if ( !(_cond) ) { TU_MESS_FAILED(); TU_BREAKPOINT(); return _ret; } \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   54|      0|  #define TU_MESS_FAILED() do {} while (0)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (54:41): [Folded, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |                   if ( !(_cond) ) { TU_MESS_FAILED(); TU_BREAKPOINT(); return _ret; } \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   77|      0|  #define TU_BREAKPOINT() do {} while (0)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (77:40): [Folded, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (105:10): [True: 0, False: 1]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  106|      1|  } while(0)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (106:11): [Folded, False: 1]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  581|      1|  dcd_int_enable(rhport);
  582|       |
  583|       |  return true;
  584|      1|}
tud_task_ext:
  672|  43.9k|void tud_task_ext(uint32_t timeout_ms, bool in_isr) {
  673|  43.9k|  (void) in_isr; // not implemented yet
  674|       |
  675|       |  // Skip if stack is not initialized
  676|  43.9k|  if (!tud_inited()) {
  ------------------
  |  Branch (676:7): [True: 0, False: 43.9k]
  ------------------
  677|      0|    return;
  678|      0|  }
  679|       |
  680|       |  // Loop until there are no more events in the queue or CFG_TUD_TASK_EVENTS_PER_RUN is reached
  681|  72.8k|  for (unsigned epr = 0;; epr++) {
  682|  72.8k|#if CFG_TUD_TASK_EVENTS_PER_RUN > 0
  683|  72.8k|    if (epr >= CFG_TUD_TASK_EVENTS_PER_RUN) {
  ------------------
  |  |  640|  72.8k|  #define CFG_TUD_TASK_EVENTS_PER_RUN  16
  ------------------
  |  Branch (683:9): [True: 0, False: 72.8k]
  ------------------
  684|      0|      TU_LOG_USBD("USBD event limit (" TU_XSTRING(CFG_TUD_TASK_EVENTS_PER_RUN) ") reached\r\n");
  685|      0|      break;
  686|      0|    }
  687|  72.8k|#endif
  688|  72.8k|    dcd_event_t event;
  689|  72.8k|    if (!osal_queue_receive(_usbd_q, &event, timeout_ms)) {
  ------------------
  |  Branch (689:9): [True: 43.9k, False: 28.8k]
  ------------------
  690|  43.9k|      return;
  691|  43.9k|    }
  692|       |
  693|       |#if CFG_TUSB_DEBUG >= CFG_TUD_LOG_LEVEL
  694|       |    if (event.event_id == DCD_EVENT_SETUP_RECEIVED) {
  695|       |      TU_LOG_USBD("\r\n"); // extra line for setup
  696|       |    }
  697|       |    TU_LOG_USBD("USBD %s ", event.event_id < DCD_EVENT_COUNT ? _usbd_event_str[event.event_id] : "CORRUPTED");
  698|       |#endif
  699|       |
  700|  28.8k|    switch (event.event_id) {
  701|      0|      case DCD_EVENT_BUS_RESET_START:
  ------------------
  |  Branch (701:7): [True: 0, False: 28.8k]
  ------------------
  702|      0|        TU_LOG_USBD("\r\n");
  703|      0|        usbd_reset(event.rhport);
  704|      0|        break;
  705|       |
  706|  7.86k|      case DCD_EVENT_BUS_RESET_END:
  ------------------
  |  Branch (706:7): [True: 7.86k, False: 21.0k]
  ------------------
  707|  7.86k|        TU_LOG_USBD(": %s Speed\r\n", tu_str_speed[event.bus_reset.speed]);
  708|       |        // TODO a DCD that reports both edges pays for two teardowns: track a per-rhport
  709|       |        // "start seen" flag and skip this reset, keeping it for the single-event DCDs.
  710|  7.86k|        usbd_reset(event.rhport);
  711|  7.86k|        _usbd_dev.speed = event.bus_reset.speed;
  712|  7.86k|        break;
  713|       |
  714|  4.26k|      case DCD_EVENT_UNPLUGGED:
  ------------------
  |  Branch (714:7): [True: 4.26k, False: 24.6k]
  ------------------
  715|  4.26k|        TU_LOG_USBD("\r\n");
  716|  4.26k|        usbd_reset(event.rhport);
  717|  4.26k|        tud_umount_cb();
  718|  4.26k|        break;
  719|       |
  720|  15.3k|      case DCD_EVENT_SETUP_RECEIVED:
  ------------------
  |  Branch (720:7): [True: 15.3k, False: 13.5k]
  ------------------
  721|  15.3k|        if (_usbd_queued_setup == 0) {
  ------------------
  |  Branch (721:13): [True: 3.91k, False: 11.4k]
  ------------------
  722|  3.91k|          break;
  723|  3.91k|        }
  724|  11.4k|        _usbd_queued_setup--;
  725|  11.4k|        TU_LOG_BUF(CFG_TUD_LOG_LEVEL, &event.setup_received, 8);
  726|  11.4k|        if (_usbd_queued_setup != 0) {
  ------------------
  |  Branch (726:13): [True: 0, False: 11.4k]
  ------------------
  727|      0|          TU_LOG_USBD("  Skipped since there is other SETUP in queue\r\n");
  728|      0|          break;
  729|      0|        }
  730|       |
  731|       |        // Mark as connected after receiving 1st setup packet.
  732|       |        // But it is easier to set it every time instead of wasting time to check then set
  733|  11.4k|        _usbd_dev.connected = 1;
  734|       |
  735|       |        // reset ep state
  736|  11.4k|        _usbd_dev.ep_status[0][TUSB_DIR_OUT] = 0;
  737|  11.4k|        _usbd_dev.ep_status[0][TUSB_DIR_IN] = 0;
  738|       |
  739|       |        // Process control request
  740|  11.4k|        if (!process_setup_received(event.rhport, &event.setup_received)) {
  ------------------
  |  Branch (740:13): [True: 8.05k, False: 3.37k]
  ------------------
  741|  8.05k|          TU_LOG_USBD("  Stall EP0\r\n");
  742|       |          // Failed -> stall both control endpoint IN and OUT
  743|  8.05k|          dcd_edpt_stall(event.rhport, TU_EP0_OUT);
  744|  8.05k|          dcd_edpt_stall(event.rhport, TU_EP0_IN);
  745|  8.05k|        }
  746|  11.4k|        break;
  747|       |
  748|      0|      case DCD_EVENT_XFER_COMPLETE: {
  ------------------
  |  Branch (748:7): [True: 0, False: 28.8k]
  ------------------
  749|       |        // Invoke the class callback associated with the endpoint address
  750|      0|        uint8_t const ep_addr = event.xfer_complete.ep_addr;
  751|      0|        uint8_t const epnum = tu_edpt_number(ep_addr);
  752|      0|        uint8_t const ep_dir = tu_edpt_dir(ep_addr);
  753|       |
  754|      0|        TU_LOG_USBD("on EP %02X with %u bytes\r\n", ep_addr, (unsigned int) event.xfer_complete.len);
  755|       |
  756|       |        // Clear busy + claimed
  757|      0|        _usbd_dev.ep_status[epnum][ep_dir] &= (uint8_t) ~(TU_EDPT_STATE_BUSY | TU_EDPT_STATE_CLAIMED);
  ------------------
  |  |   31|      0|#define TU_EDPT_STATE_BUSY    0x01u
  ------------------
                      _usbd_dev.ep_status[epnum][ep_dir] &= (uint8_t) ~(TU_EDPT_STATE_BUSY | TU_EDPT_STATE_CLAIMED);
  ------------------
  |  |   33|      0|#define TU_EDPT_STATE_CLAIMED 0x04u
  ------------------
  758|       |
  759|      0|        if (0 == epnum) {
  ------------------
  |  Branch (759:13): [True: 0, False: 0]
  ------------------
  760|       |          // Not stalled on failure: a DCD refuses an EP0 prime when a newer setup is already
  761|       |          // latched, and EP0 stalls are cleared by hardware when that setup arrives - so a stall
  762|       |          // issued here lands after the auto-clear and would stall the transfer that superseded
  763|       |          // this one. The pending setup re-drives EP0 by itself.
  764|      0|          if (!usbd_control_xfer_cb(event.rhport, ep_addr, (xfer_result_t) event.xfer_complete.result,
  ------------------
  |  Branch (764:15): [True: 0, False: 0]
  ------------------
  765|      0|                                    event.xfer_complete.len)) {
  766|      0|            TU_LOG_USBD("  Control stage not continued\r\n");
  767|      0|          }
  768|      0|        } else {
  769|      0|          usbd_class_driver_t const* driver = get_driver(_usbd_dev.ep2drv[epnum][ep_dir]);
  770|      0|          TU_ASSERT(driver,);
  ------------------
  |  |  112|      0|#define TU_ASSERT(...)                 TU_GET_3RD_ARG(__VA_ARGS__, TU_ASSERT_2ARGS, TU_ASSERT_1ARGS, _dummy)(__VA_ARGS__)
  |  |  ------------------
  |  |  |  |  112|      0|#define TU_GET_3RD_ARG(arg1, arg2, arg3, ...)        arg3
  |  |  |  |  ------------------
  |  |  |  |  |  |  112|      0|#define TU_ASSERT(...)                 TU_GET_3RD_ARG(__VA_ARGS__, TU_ASSERT_2ARGS, TU_ASSERT_1ARGS, _dummy)(__VA_ARGS__)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  109|      0|#define TU_ASSERT_2ARGS(_cond, _ret)   TU_ASSERT_DEFINE(_cond, _ret)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  104|      0|  do {                                                                \
  |  |  |  |  |  |  |  |  |  |  105|      0|    if ( !(_cond) ) { TU_MESS_FAILED(); TU_BREAKPOINT(); return _ret; } \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   54|      0|  #define TU_MESS_FAILED() do {} while (0)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (54:41): [Folded, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |                   if ( !(_cond) ) { TU_MESS_FAILED(); TU_BREAKPOINT(); return _ret; } \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   77|      0|  #define TU_BREAKPOINT() do {} while (0)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (77:40): [Folded, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (105:10): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  106|      0|  } while(0)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (106:11): [Folded, False: 0]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  771|       |
  772|      0|          TU_LOG_USBD("  %s xfer callback\r\n", driver->name);
  773|      0|          driver->xfer_cb(event.rhport, ep_addr, (xfer_result_t) event.xfer_complete.result, event.xfer_complete.len);
  774|      0|        }
  775|      0|        break;
  776|      0|      }
  777|       |
  778|    819|      case DCD_EVENT_SUSPEND:
  ------------------
  |  Branch (778:7): [True: 819, False: 28.0k]
  ------------------
  779|       |        // NOTE: When plugging/unplugging device, the D+/D- state are unstable and
  780|       |        // can accidentally meet the SUSPEND condition ( Bus Idle for 3ms ), which result in a series of event
  781|       |        // e.g suspend -> resume -> unplug/plug. Skip suspend/resume if not connected
  782|    819|        if (_usbd_dev.connected) {
  ------------------
  |  Branch (782:13): [True: 819, False: 0]
  ------------------
  783|    819|          TU_LOG_USBD(": Remote Wakeup = %u\r\n", _usbd_dev.remote_wakeup_en);
  784|    819|          tud_suspend_cb(_usbd_dev.remote_wakeup_en);
  785|    819|        } else {
  786|      0|          TU_LOG_USBD(" Skipped\r\n");
  787|      0|        }
  788|    819|        break;
  789|       |
  790|    588|      case DCD_EVENT_RESUME:
  ------------------
  |  Branch (790:7): [True: 588, False: 28.2k]
  ------------------
  791|    588|        if (_usbd_dev.connected) {
  ------------------
  |  Branch (791:13): [True: 588, False: 0]
  ------------------
  792|    588|          TU_LOG_USBD("\r\n");
  793|    588|          tud_resume_cb();
  794|    588|        } else {
  795|      0|          TU_LOG_USBD(" Skipped\r\n");
  796|      0|        }
  797|    588|        break;
  798|       |
  799|      0|      case USBD_EVENT_FUNC_CALL:
  ------------------
  |  Branch (799:7): [True: 0, False: 28.8k]
  ------------------
  800|      0|        TU_LOG_USBD("\r\n");
  801|      0|        if (event.func_call.func != NULL) {
  ------------------
  |  Branch (801:13): [True: 0, False: 0]
  ------------------
  802|      0|          event.func_call.func(event.func_call.param);
  803|      0|        }
  804|      0|        break;
  805|       |
  806|      0|      case DCD_EVENT_SOF:
  ------------------
  |  Branch (806:7): [True: 0, False: 28.8k]
  ------------------
  807|      0|        if (tu_bit_test(_usbd_dev.sof_consumer, SOF_CONSUMER_USER)) {
  ------------------
  |  Branch (807:13): [True: 0, False: 0]
  ------------------
  808|      0|          TU_LOG_USBD("\r\n");
  809|      0|          tud_sof_cb(event.sof.frame_count);
  810|      0|        }
  811|      0|      break;
  812|       |
  813|      0|      default:
  ------------------
  |  Branch (813:7): [True: 0, False: 28.8k]
  ------------------
  814|      0|        TU_BREAKPOINT();
  ------------------
  |  |   77|      0|  #define TU_BREAKPOINT() do {} while (0)
  |  |  ------------------
  |  |  |  Branch (77:40): [Folded, False: 0]
  |  |  ------------------
  ------------------
  815|      0|        break;
  816|  28.8k|    }
  817|       |
  818|       |    // allow to exit tud_task() if there is no event in the next run
  819|  28.8k|    timeout_ms = 0;
  820|  28.8k|  }
  821|  43.9k|}
tud_control_status:
  867|  2.30k|bool tud_control_status(uint8_t rhport, const tusb_control_request_t* request) {
  868|       |  // _usbd_dev.ctrl_xfer fields are pre-initialized at process_setup_received entry
  869|  2.30k|  (void) request;
  870|  2.30k|  return status_stage_xact(rhport, status_stage_ep(&_usbd_dev.ctrl_xfer.request));
  871|  2.30k|}
tud_control_xfer:
  874|  1.92k|bool tud_control_xfer(uint8_t rhport, const tusb_control_request_t* request, void* buffer, uint16_t len) {
  875|       |  // _usbd_dev.ctrl_xfer.request and reset fields are pre-initialized at process_setup_received entry
  876|  1.92k|  (void) request;
  877|  1.92k|  usbd_control_xfer_t* const ctrl_xfer = &_usbd_dev.ctrl_xfer;
  878|  1.92k|  ctrl_xfer->buffer = (uint8_t*) buffer;
  879|  1.92k|  ctrl_xfer->data_len = tu_min16(len, ctrl_xfer->request.wLength);
  880|       |
  881|  1.92k|  if (ctrl_xfer->request.wLength > 0U) {
  ------------------
  |  Branch (881:7): [True: 1.46k, False: 459]
  ------------------
  882|  1.46k|    if (ctrl_xfer->data_len > 0U) {
  ------------------
  |  Branch (882:9): [True: 1.46k, False: 0]
  ------------------
  883|  1.46k|      TU_ASSERT(buffer);
  ------------------
  |  |  112|  1.46k|#define TU_ASSERT(...)                 TU_GET_3RD_ARG(__VA_ARGS__, TU_ASSERT_2ARGS, TU_ASSERT_1ARGS, _dummy)(__VA_ARGS__)
  |  |  ------------------
  |  |  |  |  112|  1.46k|#define TU_GET_3RD_ARG(arg1, arg2, arg3, ...)        arg3
  |  |  |  |  ------------------
  |  |  |  |  |  |  112|  1.46k|#define TU_ASSERT(...)                 TU_GET_3RD_ARG(__VA_ARGS__, TU_ASSERT_2ARGS, TU_ASSERT_1ARGS, _dummy)(__VA_ARGS__)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  108|  1.46k|#define TU_ASSERT_1ARGS(_cond)         TU_ASSERT_DEFINE(_cond, false)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  104|  1.46k|  do {                                                                \
  |  |  |  |  |  |  |  |  |  |  105|  1.46k|    if ( !(_cond) ) { TU_MESS_FAILED(); TU_BREAKPOINT(); return _ret; } \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   54|      0|  #define TU_MESS_FAILED() do {} while (0)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (54:41): [Folded, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |                   if ( !(_cond) ) { TU_MESS_FAILED(); TU_BREAKPOINT(); return _ret; } \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   77|      0|  #define TU_BREAKPOINT() do {} while (0)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (77:40): [Folded, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (105:10): [True: 0, False: 1.46k]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  106|  1.46k|  } while(0)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (106:11): [Folded, False: 1.46k]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  884|  1.46k|    }
  885|  1.46k|    TU_VERIFY(data_stage_xact(rhport));
  ------------------
  |  |   95|  1.46k|#define TU_VERIFY(...)                 TU_GET_3RD_ARG(__VA_ARGS__, TU_VERIFY_2ARGS, TU_VERIFY_1ARGS, _dummy)(__VA_ARGS__)
  |  |  ------------------
  |  |  |  |  112|  1.46k|#define TU_GET_3RD_ARG(arg1, arg2, arg3, ...)        arg3
  |  |  |  |  ------------------
  |  |  |  |  |  |   95|  1.46k|#define TU_VERIFY(...)                 TU_GET_3RD_ARG(__VA_ARGS__, TU_VERIFY_2ARGS, TU_VERIFY_1ARGS, _dummy)(__VA_ARGS__)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   92|  1.46k|#define TU_VERIFY_1ARGS(_cond)         TU_VERIFY_DEFINE(_cond, false)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   86|  1.46k|  do {                                \
  |  |  |  |  |  |  |  |  |  |   87|  1.46k|    if (!(_cond)) {                   \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (87:9): [True: 1.05k, False: 415]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   88|  1.05k|      return _ret;                    \
  |  |  |  |  |  |  |  |  |  |   89|  1.05k|    }                                 \
  |  |  |  |  |  |  |  |  |  |   90|  1.46k|  } while (0)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (90:12): [Folded, False: 415]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  886|  1.46k|  } else {
  887|       |    // wLength == 0: Status stage is always IN per USB 2.0 §9.3.1
  888|    459|    TU_VERIFY(status_stage_xact(rhport, TU_EP0_IN));
  ------------------
  |  |   95|    459|#define TU_VERIFY(...)                 TU_GET_3RD_ARG(__VA_ARGS__, TU_VERIFY_2ARGS, TU_VERIFY_1ARGS, _dummy)(__VA_ARGS__)
  |  |  ------------------
  |  |  |  |  112|    459|#define TU_GET_3RD_ARG(arg1, arg2, arg3, ...)        arg3
  |  |  |  |  ------------------
  |  |  |  |  |  |   95|    459|#define TU_VERIFY(...)                 TU_GET_3RD_ARG(__VA_ARGS__, TU_VERIFY_2ARGS, TU_VERIFY_1ARGS, _dummy)(__VA_ARGS__)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   92|    459|#define TU_VERIFY_1ARGS(_cond)         TU_VERIFY_DEFINE(_cond, false)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   86|    459|  do {                                \
  |  |  |  |  |  |  |  |  |  |   87|    459|    if (!(_cond)) {                   \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (87:9): [True: 251, False: 208]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   88|    251|      return _ret;                    \
  |  |  |  |  |  |  |  |  |  |   89|    251|    }                                 \
  |  |  |  |  |  |  |  |  |  |   90|    459|  } while (0)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (90:12): [Folded, False: 208]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  889|    459|  }
  890|       |
  891|    623|  return true;
  892|  1.92k|}
dcd_event_handler:
 1403|  32.2k|TU_ATTR_FAST_FUNC void dcd_event_handler(dcd_event_t const* event, bool in_isr) {
 1404|  32.2k|  bool send = false;
 1405|  32.2k|  switch (event->event_id) {
 1406|  4.26k|    case DCD_EVENT_UNPLUGGED:
  ------------------
  |  Branch (1406:5): [True: 4.26k, False: 27.9k]
  ------------------
 1407|  4.26k|      _usbd_dev.connected = 0;
 1408|  4.26k|      _usbd_dev.addressed = 0;
 1409|  4.26k|      _usbd_dev.cfg_num = 0;
 1410|  4.26k|      _usbd_dev.suspended = 0;
 1411|  4.26k|      send = true;
 1412|  4.26k|      break;
 1413|       |
 1414|  2.57k|    case DCD_EVENT_SUSPEND:
  ------------------
  |  Branch (1414:5): [True: 2.57k, False: 29.6k]
  ------------------
 1415|       |      // NOTE: When plugging/unplugging device, the D+/D- state are unstable and
 1416|       |      // can accidentally meet the SUSPEND condition ( Bus Idle for 3ms ).
 1417|       |      // In addition, some MCUs such as SAMD or boards that haven no VBUS detection cannot distinguish
 1418|       |      // suspended vs disconnected. We will skip handling SUSPEND/RESUME event if not currently connected
 1419|  2.57k|      if (_usbd_dev.connected) {
  ------------------
  |  Branch (1419:11): [True: 819, False: 1.75k]
  ------------------
 1420|    819|        _usbd_dev.suspended = 1;
 1421|    819|        send = true;
 1422|    819|      }
 1423|  2.57k|      break;
 1424|       |
 1425|  2.16k|    case DCD_EVENT_RESUME:
  ------------------
  |  Branch (1425:5): [True: 2.16k, False: 30.0k]
  ------------------
 1426|       |      // skip event if not connected (especially required for SAMD)
 1427|  2.16k|      if (_usbd_dev.connected) {
  ------------------
  |  Branch (1427:11): [True: 588, False: 1.57k]
  ------------------
 1428|    588|        _usbd_dev.suspended = 0;
 1429|    588|        send = true;
 1430|    588|      }
 1431|  2.16k|      break;
 1432|       |
 1433|      0|    case DCD_EVENT_SOF:
  ------------------
  |  Branch (1433:5): [True: 0, False: 32.2k]
  ------------------
 1434|       |      // SOF driver handler in ISR context
 1435|      0|      for (uint8_t i = 0; i < TOTAL_DRIVER_COUNT; i++) {
  ------------------
  |  |  369|      0|#define TOTAL_DRIVER_COUNT    ((uint8_t) (_app_driver_count + _builtin_driver_count))
  ------------------
  |  Branch (1435:27): [True: 0, False: 0]
  ------------------
 1436|      0|        usbd_class_driver_t const* driver = get_driver(i);
 1437|      0|        if (driver && driver->sof) {
  ------------------
  |  Branch (1437:13): [True: 0, False: 0]
  |  Branch (1437:23): [True: 0, False: 0]
  ------------------
 1438|      0|          driver->sof(event->rhport, event->sof.frame_count);
 1439|      0|        }
 1440|      0|      }
 1441|       |
 1442|       |      // Some MCUs after running dcd_remote_wakeup() does not have way to detect the end of remote wakeup
 1443|       |      // which last 1-15 ms. DCD can use SOF as a clear indicator that bus is back to operational
 1444|      0|      if (_usbd_dev.suspended) {
  ------------------
  |  Branch (1444:11): [True: 0, False: 0]
  ------------------
 1445|      0|        _usbd_dev.suspended = 0;
 1446|       |
 1447|      0|        dcd_event_t const event_resume = {.rhport = event->rhport, .event_id = DCD_EVENT_RESUME};
 1448|      0|        queue_event(&event_resume, in_isr);
 1449|      0|      }
 1450|       |
 1451|      0|      if (tu_bit_test(_usbd_dev.sof_consumer, SOF_CONSUMER_USER)) {
  ------------------
  |  Branch (1451:11): [True: 0, False: 0]
  ------------------
 1452|      0|        dcd_event_t const event_sof = {.rhport = event->rhport, .event_id = DCD_EVENT_SOF, .sof.frame_count = event->sof.frame_count};
 1453|      0|        queue_event(&event_sof, in_isr);
 1454|      0|      }
 1455|      0|      break;
 1456|       |
 1457|  15.3k|    case DCD_EVENT_SETUP_RECEIVED:
  ------------------
  |  Branch (1457:5): [True: 15.3k, False: 16.8k]
  ------------------
 1458|  15.3k|      _usbd_queued_setup++;
 1459|  15.3k|      send = true;
 1460|  15.3k|      break;
 1461|       |
 1462|      0|    case DCD_EVENT_XFER_COMPLETE: {
  ------------------
  |  Branch (1462:5): [True: 0, False: 32.2k]
  ------------------
 1463|       |      // Invoke the class callback associated with the endpoint address
 1464|      0|      uint8_t const ep_addr = event->xfer_complete.ep_addr;
 1465|      0|      uint8_t const epnum = tu_edpt_number(ep_addr);
 1466|      0|      uint8_t const ep_dir = tu_edpt_dir(ep_addr);
 1467|       |
 1468|      0|      send = true;
 1469|      0|      if(epnum > 0) {
  ------------------
  |  Branch (1469:10): [True: 0, False: 0]
  ------------------
 1470|      0|        usbd_class_driver_t const* driver = get_driver(_usbd_dev.ep2drv[epnum][ep_dir]);
 1471|       |
 1472|      0|        if (driver && driver->xfer_isr) {
  ------------------
  |  Branch (1472:13): [True: 0, False: 0]
  |  Branch (1472:23): [True: 0, False: 0]
  ------------------
 1473|       |          // Clear busy + claimed
 1474|      0|          _usbd_dev.ep_status[epnum][ep_dir] &= (uint8_t) ~(TU_EDPT_STATE_BUSY | TU_EDPT_STATE_CLAIMED);
  ------------------
  |  |   31|      0|#define TU_EDPT_STATE_BUSY    0x01u
  ------------------
                        _usbd_dev.ep_status[epnum][ep_dir] &= (uint8_t) ~(TU_EDPT_STATE_BUSY | TU_EDPT_STATE_CLAIMED);
  ------------------
  |  |   33|      0|#define TU_EDPT_STATE_CLAIMED 0x04u
  ------------------
 1475|       |
 1476|      0|          send = !driver->xfer_isr(event->rhport, ep_addr, (xfer_result_t) event->xfer_complete.result, event->xfer_complete.len);
 1477|       |
 1478|       |          // xfer_isr() is deferred to xfer_cb(), revert busy/claimed status
 1479|      0|          if (send) {
  ------------------
  |  Branch (1479:15): [True: 0, False: 0]
  ------------------
 1480|       |            // set busy + claimed
 1481|      0|            _usbd_dev.ep_status[epnum][ep_dir] |= (TU_EDPT_STATE_BUSY | TU_EDPT_STATE_CLAIMED);
  ------------------
  |  |   31|      0|#define TU_EDPT_STATE_BUSY    0x01u
  ------------------
                          _usbd_dev.ep_status[epnum][ep_dir] |= (TU_EDPT_STATE_BUSY | TU_EDPT_STATE_CLAIMED);
  ------------------
  |  |   33|      0|#define TU_EDPT_STATE_CLAIMED 0x04u
  ------------------
 1482|      0|          }
 1483|      0|        }
 1484|      0|      }
 1485|      0|      break;
 1486|      0|    }
 1487|       |
 1488|  7.86k|    default:
  ------------------
  |  Branch (1488:5): [True: 7.86k, False: 24.3k]
  ------------------
 1489|  7.86k|      send = true;
 1490|  7.86k|      break;
 1491|  32.2k|  }
 1492|       |
 1493|  32.2k|  if (send && !queue_event(event, in_isr)) {
  ------------------
  |  Branch (1493:7): [True: 28.8k, False: 3.32k]
  |  Branch (1493:15): [True: 0, False: 28.8k]
  ------------------
 1494|       |    // event dropped by a full queue: undo state that would otherwise wedge permanently
 1495|      0|    if (event->event_id == DCD_EVENT_SETUP_RECEIVED) {
  ------------------
  |  Branch (1495:9): [True: 0, False: 0]
  ------------------
 1496|       |      // undo the increment, else every later SETUP is skipped as "other SETUP in queue"
 1497|       |      // and EP0 is deaf until re-init
 1498|      0|      _usbd_queued_setup--;
 1499|      0|    } else if (event->event_id == DCD_EVENT_XFER_COMPLETE) {
  ------------------
  |  Branch (1499:16): [True: 0, False: 0]
  ------------------
 1500|       |      // clear busy + claimed, else the endpoint can never be claimed or re-armed again
 1501|      0|      uint8_t const epnum = tu_edpt_number(event->xfer_complete.ep_addr);
 1502|      0|      uint8_t const ep_dir = tu_edpt_dir(event->xfer_complete.ep_addr);
 1503|      0|      _usbd_dev.ep_status[epnum][ep_dir] &= (uint8_t) ~(TU_EDPT_STATE_BUSY | TU_EDPT_STATE_CLAIMED);
  ------------------
  |  |   31|      0|#define TU_EDPT_STATE_BUSY    0x01u
  ------------------
                    _usbd_dev.ep_status[epnum][ep_dir] &= (uint8_t) ~(TU_EDPT_STATE_BUSY | TU_EDPT_STATE_CLAIMED);
  ------------------
  |  |   33|      0|#define TU_EDPT_STATE_CLAIMED 0x04u
  ------------------
 1504|      0|    }
 1505|      0|  }
 1506|  32.2k|}
usbd_int_set:
 1512|   175k|void usbd_int_set(bool enabled) {
 1513|   175k|  if (enabled) {
  ------------------
  |  Branch (1513:7): [True: 87.7k, False: 87.7k]
  ------------------
 1514|  87.7k|    dcd_int_enable(_usbd_rhport);
 1515|  87.7k|  } else {
 1516|  87.7k|    dcd_int_disable(_usbd_rhport);
 1517|  87.7k|  }
 1518|   175k|}
usbd_open_edpt_pair:
 1529|    225|                         uint8_t *ep_in) {
 1530|    225|  for (int i = 0; i < ep_count; i++) {
  ------------------
  |  Branch (1530:19): [True: 225, False: 0]
  ------------------
 1531|    225|    const tusb_desc_endpoint_t *desc_ep = (const tusb_desc_endpoint_t *)p_desc;
 1532|       |
 1533|    225|    TU_ASSERT(TUSB_DESC_ENDPOINT == desc_ep->bDescriptorType && xfer_type == desc_ep->bmAttributes.xfer);
  ------------------
  |  |  112|    225|#define TU_ASSERT(...)                 TU_GET_3RD_ARG(__VA_ARGS__, TU_ASSERT_2ARGS, TU_ASSERT_1ARGS, _dummy)(__VA_ARGS__)
  |  |  ------------------
  |  |  |  |  112|    225|#define TU_GET_3RD_ARG(arg1, arg2, arg3, ...)        arg3
  |  |  |  |  ------------------
  |  |  |  |  |  |  112|    225|#define TU_ASSERT(...)                 TU_GET_3RD_ARG(__VA_ARGS__, TU_ASSERT_2ARGS, TU_ASSERT_1ARGS, _dummy)(__VA_ARGS__)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  108|    225|#define TU_ASSERT_1ARGS(_cond)         TU_ASSERT_DEFINE(_cond, false)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  104|    225|  do {                                                                \
  |  |  |  |  |  |  |  |  |  |  105|    450|    if ( !(_cond) ) { TU_MESS_FAILED(); TU_BREAKPOINT(); return _ret; } \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   54|      0|  #define TU_MESS_FAILED() do {} while (0)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (54:41): [Folded, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |                   if ( !(_cond) ) { TU_MESS_FAILED(); TU_BREAKPOINT(); return _ret; } \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   77|      0|  #define TU_BREAKPOINT() do {} while (0)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (77:40): [Folded, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (105:12): [True: 225, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  Branch (105:12): [True: 225, False: 0]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  106|    225|  } while(0)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (106:11): [Folded, False: 225]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1534|    225|    TU_ASSERT(usbd_edpt_open(rhport, desc_ep));
  ------------------
  |  |  112|    225|#define TU_ASSERT(...)                 TU_GET_3RD_ARG(__VA_ARGS__, TU_ASSERT_2ARGS, TU_ASSERT_1ARGS, _dummy)(__VA_ARGS__)
  |  |  ------------------
  |  |  |  |  112|    225|#define TU_GET_3RD_ARG(arg1, arg2, arg3, ...)        arg3
  |  |  |  |  ------------------
  |  |  |  |  |  |  112|    225|#define TU_ASSERT(...)                 TU_GET_3RD_ARG(__VA_ARGS__, TU_ASSERT_2ARGS, TU_ASSERT_1ARGS, _dummy)(__VA_ARGS__)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  108|    225|#define TU_ASSERT_1ARGS(_cond)         TU_ASSERT_DEFINE(_cond, false)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  104|    225|  do {                                                                \
  |  |  |  |  |  |  |  |  |  |  105|    225|    if ( !(_cond) ) { TU_MESS_FAILED(); TU_BREAKPOINT(); return _ret; } \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   54|    225|  #define TU_MESS_FAILED() do {} while (0)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (54:41): [Folded, False: 225]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |                   if ( !(_cond) ) { TU_MESS_FAILED(); TU_BREAKPOINT(); return _ret; } \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   77|    225|  #define TU_BREAKPOINT() do {} while (0)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (77:40): [Folded, False: 225]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (105:10): [True: 225, False: 0]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  106|    225|  } while(0)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (106:11): [Folded, False: 0]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1535|       |
 1536|      0|    if (tu_edpt_dir(desc_ep->bEndpointAddress) == TUSB_DIR_IN) {
  ------------------
  |  Branch (1536:9): [True: 0, False: 0]
  ------------------
 1537|      0|      (*ep_in) = desc_ep->bEndpointAddress;
 1538|      0|    } else {
 1539|      0|      (*ep_out) = desc_ep->bEndpointAddress;
 1540|      0|    }
 1541|       |
 1542|      0|    p_desc = tu_desc_next(p_desc);
 1543|      0|  }
 1544|       |
 1545|      0|  return true;
 1546|    225|}
usbd_edpt_open:
 1564|    225|bool usbd_edpt_open(uint8_t rhport, tusb_desc_endpoint_t const* desc_ep) {
 1565|    225|  rhport = _usbd_rhport;
 1566|       |
 1567|    225|  TU_ASSERT(tu_edpt_number(desc_ep->bEndpointAddress) < CFG_TUD_ENDPPOINT_MAX);
  ------------------
  |  |  112|    225|#define TU_ASSERT(...)                 TU_GET_3RD_ARG(__VA_ARGS__, TU_ASSERT_2ARGS, TU_ASSERT_1ARGS, _dummy)(__VA_ARGS__)
  |  |  ------------------
  |  |  |  |  112|    225|#define TU_GET_3RD_ARG(arg1, arg2, arg3, ...)        arg3
  |  |  |  |  ------------------
  |  |  |  |  |  |  112|    225|#define TU_ASSERT(...)                 TU_GET_3RD_ARG(__VA_ARGS__, TU_ASSERT_2ARGS, TU_ASSERT_1ARGS, _dummy)(__VA_ARGS__)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  108|    225|#define TU_ASSERT_1ARGS(_cond)         TU_ASSERT_DEFINE(_cond, false)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  104|    225|  do {                                                                \
  |  |  |  |  |  |  |  |  |  |  105|    225|    if ( !(_cond) ) { TU_MESS_FAILED(); TU_BREAKPOINT(); return _ret; } \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   54|    225|  #define TU_MESS_FAILED() do {} while (0)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (54:41): [Folded, False: 225]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |                   if ( !(_cond) ) { TU_MESS_FAILED(); TU_BREAKPOINT(); return _ret; } \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   77|    225|  #define TU_BREAKPOINT() do {} while (0)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (77:40): [Folded, False: 225]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (105:10): [True: 225, False: 0]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  106|    225|  } while(0)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (106:11): [Folded, False: 0]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1568|      0|  TU_ASSERT(tu_edpt_validate(desc_ep, (tusb_speed_t)_usbd_dev.speed));
  ------------------
  |  |  112|      0|#define TU_ASSERT(...)                 TU_GET_3RD_ARG(__VA_ARGS__, TU_ASSERT_2ARGS, TU_ASSERT_1ARGS, _dummy)(__VA_ARGS__)
  |  |  ------------------
  |  |  |  |  112|      0|#define TU_GET_3RD_ARG(arg1, arg2, arg3, ...)        arg3
  |  |  |  |  ------------------
  |  |  |  |  |  |  112|      0|#define TU_ASSERT(...)                 TU_GET_3RD_ARG(__VA_ARGS__, TU_ASSERT_2ARGS, TU_ASSERT_1ARGS, _dummy)(__VA_ARGS__)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  108|      0|#define TU_ASSERT_1ARGS(_cond)         TU_ASSERT_DEFINE(_cond, false)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  104|      0|  do {                                                                \
  |  |  |  |  |  |  |  |  |  |  105|      0|    if ( !(_cond) ) { TU_MESS_FAILED(); TU_BREAKPOINT(); return _ret; } \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   54|      0|  #define TU_MESS_FAILED() do {} while (0)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (54:41): [Folded, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |                   if ( !(_cond) ) { TU_MESS_FAILED(); TU_BREAKPOINT(); return _ret; } \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   77|      0|  #define TU_BREAKPOINT() do {} while (0)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (77:40): [Folded, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (105:10): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  106|      0|  } while(0)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (106:11): [Folded, False: 0]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1569|       |
 1570|      0|  return dcd_edpt_open(rhport, desc_ep);
 1571|      0|}
usbd_edpt_xfer:
 1592|  4.23k|bool usbd_edpt_xfer(uint8_t rhport, uint8_t ep_addr, uint8_t* buffer, uint16_t total_bytes, bool is_isr) {
 1593|  4.23k|  rhport = _usbd_rhport;
 1594|       |
 1595|  4.23k|  uint8_t const epnum = tu_edpt_number(ep_addr);
 1596|  4.23k|  uint8_t const dir = tu_edpt_dir(ep_addr);
 1597|       |
 1598|       |  // TODO skip ready() check for now since enumeration also use this API
 1599|       |  // TU_VERIFY(tud_ready());
 1600|       |
 1601|  4.23k|  TU_LOG_USBD("  Queue EP %02X with %u bytes ...\r\n", ep_addr, total_bytes);
 1602|       |#if CFG_TUD_LOG_LEVEL >= 3
 1603|       |  if(dir == TUSB_DIR_IN) {
 1604|       |    TU_LOG_MEM(CFG_TUD_LOG_LEVEL, buffer, total_bytes, 2);
 1605|       |  }
 1606|       |#endif
 1607|       |
 1608|       |  // Attempt to transfer on a busy endpoint, sound like an race condition !
 1609|  4.23k|  TU_ASSERT((_usbd_dev.ep_status[epnum][dir] & TU_EDPT_STATE_BUSY) == 0);
  ------------------
  |  |  112|  4.23k|#define TU_ASSERT(...)                 TU_GET_3RD_ARG(__VA_ARGS__, TU_ASSERT_2ARGS, TU_ASSERT_1ARGS, _dummy)(__VA_ARGS__)
  |  |  ------------------
  |  |  |  |  112|  4.23k|#define TU_GET_3RD_ARG(arg1, arg2, arg3, ...)        arg3
  |  |  |  |  ------------------
  |  |  |  |  |  |  112|  4.23k|#define TU_ASSERT(...)                 TU_GET_3RD_ARG(__VA_ARGS__, TU_ASSERT_2ARGS, TU_ASSERT_1ARGS, _dummy)(__VA_ARGS__)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  108|  4.23k|#define TU_ASSERT_1ARGS(_cond)         TU_ASSERT_DEFINE(_cond, false)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  104|  4.23k|  do {                                                                \
  |  |  |  |  |  |  |  |  |  |  105|  4.23k|    if ( !(_cond) ) { TU_MESS_FAILED(); TU_BREAKPOINT(); return _ret; } \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   54|      0|  #define TU_MESS_FAILED() do {} while (0)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (54:41): [Folded, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |                   if ( !(_cond) ) { TU_MESS_FAILED(); TU_BREAKPOINT(); return _ret; } \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   77|      0|  #define TU_BREAKPOINT() do {} while (0)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (77:40): [Folded, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (105:10): [True: 0, False: 4.23k]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  106|  4.23k|  } while(0)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (106:11): [Folded, False: 4.23k]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1610|       |
 1611|       |  // Set busy first since the actual transfer can be complete before dcd_edpt_xfer()
 1612|       |  // could return and USBD task can preempt and clear the busy
 1613|  4.23k|  _usbd_dev.ep_status[epnum][dir] |= TU_EDPT_STATE_BUSY;
  ------------------
  |  |   31|  4.23k|#define TU_EDPT_STATE_BUSY    0x01u
  ------------------
 1614|       |
 1615|  4.23k|  if (dcd_edpt_xfer(rhport, ep_addr, buffer, total_bytes, is_isr)) {
  ------------------
  |  Branch (1615:7): [True: 1.53k, False: 2.70k]
  ------------------
 1616|  1.53k|    return true;
 1617|  2.70k|  } else {
 1618|       |    // Driver refused the transfer, mark endpoint as ready to allow next transfer. This is a
 1619|       |    // recoverable condition (e.g. a new setup superseding a control response), not a bug, so
 1620|       |    // do not break into the debugger - TU_BREAKPOINT() halts the CPU whenever a probe is
 1621|       |    // attached, which on a test rig is always.
 1622|  2.70k|    _usbd_dev.ep_status[epnum][dir] &= (uint8_t) ~(TU_EDPT_STATE_BUSY | TU_EDPT_STATE_CLAIMED);
  ------------------
  |  |   31|  2.70k|#define TU_EDPT_STATE_BUSY    0x01u
  ------------------
                  _usbd_dev.ep_status[epnum][dir] &= (uint8_t) ~(TU_EDPT_STATE_BUSY | TU_EDPT_STATE_CLAIMED);
  ------------------
  |  |   33|  2.70k|#define TU_EDPT_STATE_CLAIMED 0x04u
  ------------------
 1623|  2.70k|    TU_LOG_USBD("FAILED\r\n");
 1624|       |    return false;
 1625|  2.70k|  }
 1626|  4.23k|}
usbd_edpt_stalled:
 1712|    624|bool usbd_edpt_stalled(uint8_t rhport, uint8_t ep_addr) {
 1713|    624|  (void) rhport;
 1714|       |
 1715|    624|  uint8_t const epnum = tu_edpt_number(ep_addr);
 1716|    624|  uint8_t const dir = tu_edpt_dir(ep_addr);
 1717|       |
 1718|    624|  return (_usbd_dev.ep_status[epnum][dir] & TU_EDPT_STATE_STALLED) != 0;
  ------------------
  |  |   32|    624|#define TU_EDPT_STATE_STALLED 0x02u
  ------------------
 1719|    624|}
usbd.c:get_driver:
  373|  14.8k|TU_ATTR_ALWAYS_INLINE static inline usbd_class_driver_t const * get_driver(uint8_t drvid) {
  374|  14.8k|  usbd_class_driver_t const *driver = NULL;
  375|  14.8k|  if (drvid < _app_driver_count) {
  ------------------
  |  Branch (375:7): [True: 0, False: 14.8k]
  ------------------
  376|       |    // Application drivers
  377|      0|    driver = &_app_driver[drvid];
  378|  14.8k|  } else{
  379|  14.8k|    drvid -= _app_driver_count;
  380|  14.8k|    if (_builtin_driver_count > 0 && drvid < _builtin_driver_count) {
  ------------------
  |  Branch (380:9): [True: 14.8k, Folded]
  |  Branch (380:38): [True: 12.3k, False: 2.48k]
  ------------------
  381|  12.3k|      driver = &_usbd_driver[drvid];
  382|  12.3k|    }
  383|  14.8k|  }
  384|       |
  385|  14.8k|  return driver;
  386|  14.8k|}
usbd.c:usbd_reset:
  644|  12.1k|static void usbd_reset(uint8_t rhport) {
  645|  12.1k|  configuration_reset(rhport);
  646|       |  // discard any pre-reset SETUP still counted: a stale count skips post-reset SETUPs
  647|  12.1k|  _usbd_queued_setup = 0;
  648|  12.1k|}
usbd.c:configuration_reset:
  632|  12.1k|static void configuration_reset(uint8_t rhport) {
  633|  24.2k|  for (uint8_t i = 0; i < TOTAL_DRIVER_COUNT; i++) {
  ------------------
  |  |  369|  24.2k|#define TOTAL_DRIVER_COUNT    ((uint8_t) (_app_driver_count + _builtin_driver_count))
  ------------------
  |  Branch (633:23): [True: 12.1k, False: 12.1k]
  ------------------
  634|  12.1k|    usbd_class_driver_t const* driver = get_driver(i);
  635|  12.1k|    TU_ASSERT(driver,);
  ------------------
  |  |  112|  12.1k|#define TU_ASSERT(...)                 TU_GET_3RD_ARG(__VA_ARGS__, TU_ASSERT_2ARGS, TU_ASSERT_1ARGS, _dummy)(__VA_ARGS__)
  |  |  ------------------
  |  |  |  |  112|  12.1k|#define TU_GET_3RD_ARG(arg1, arg2, arg3, ...)        arg3
  |  |  |  |  ------------------
  |  |  |  |  |  |  112|  12.1k|#define TU_ASSERT(...)                 TU_GET_3RD_ARG(__VA_ARGS__, TU_ASSERT_2ARGS, TU_ASSERT_1ARGS, _dummy)(__VA_ARGS__)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  109|  12.1k|#define TU_ASSERT_2ARGS(_cond, _ret)   TU_ASSERT_DEFINE(_cond, _ret)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  104|  12.1k|  do {                                                                \
  |  |  |  |  |  |  |  |  |  |  105|  12.1k|    if ( !(_cond) ) { TU_MESS_FAILED(); TU_BREAKPOINT(); return _ret; } \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   54|      0|  #define TU_MESS_FAILED() do {} while (0)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (54:41): [Folded, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |                   if ( !(_cond) ) { TU_MESS_FAILED(); TU_BREAKPOINT(); return _ret; } \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   77|      0|  #define TU_BREAKPOINT() do {} while (0)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (77:40): [Folded, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (105:10): [True: 0, False: 12.1k]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  106|  12.1k|  } while(0)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (106:11): [Folded, False: 12.1k]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  636|  12.1k|    driver->reset(rhport);
  637|  12.1k|  }
  638|       |
  639|  12.1k|  tu_varclr(&_usbd_dev);
  ------------------
  |  |   96|  12.1k|#define tu_varclr(_var)          tu_memclr(_var, sizeof(*(_var)))
  |  |  ------------------
  |  |  |  |   95|  12.1k|#define tu_memclr(buffer, size)  (void) memset((buffer), 0, (size))
  |  |  ------------------
  ------------------
  640|  12.1k|  (void)memset(_usbd_dev.itf2drv, TUSB_INDEX_INVALID_8, sizeof(_usbd_dev.itf2drv)); // invalid mapping
  641|  12.1k|  (void)memset(_usbd_dev.ep2drv, TUSB_INDEX_INVALID_8, sizeof(_usbd_dev.ep2drv));   // invalid mapping
  642|  12.1k|}
usbd.c:status_stage_xact:
  845|  2.76k|TU_ATTR_ALWAYS_INLINE static inline bool status_stage_xact(uint8_t rhport, uint8_t ep_status) {
  846|  2.76k|  return usbd_edpt_xfer(rhport, ep_status, NULL, 0, false);
  847|  2.76k|}
usbd.c:status_stage_ep:
  840|  2.30k|TU_ATTR_ALWAYS_INLINE static inline uint8_t status_stage_ep(const tusb_control_request_t* request) {
  841|  2.30k|  return (request->wLength != 0 && request->bmRequestType_bit.direction) ? TU_EP0_OUT : TU_EP0_IN;
  ------------------
  |  Branch (841:11): [True: 1.13k, False: 1.17k]
  |  Branch (841:36): [True: 51, False: 1.07k]
  ------------------
  842|  2.30k|}
usbd.c:data_stage_xact:
  851|  1.46k|static bool data_stage_xact(uint8_t rhport) {
  852|  1.46k|  usbd_control_xfer_t* const ctrl_xfer = &_usbd_dev.ctrl_xfer;
  853|  1.46k|  const uint16_t xact_len = tu_min16(ctrl_xfer->data_len - ctrl_xfer->total_xferred, CFG_TUD_ENDPOINT0_BUFSIZE);
  ------------------
  |  |  631|  1.46k|  #define CFG_TUD_ENDPOINT0_BUFSIZE  CFG_TUD_ENDPOINT0_SIZE
  |  |  ------------------
  |  |  |  |   90|  1.46k|#define CFG_TUD_ENDPOINT0_SIZE    64
  |  |  ------------------
  ------------------
  854|  1.46k|  uint8_t ep_addr = TU_EP0_OUT;
  855|       |
  856|  1.46k|  if (ctrl_xfer->request.bmRequestType_bit.direction == TUSB_DIR_IN) {
  ------------------
  |  Branch (856:7): [True: 546, False: 922]
  ------------------
  857|    546|    ep_addr = TU_EP0_IN;
  858|    546|    if (0u != xact_len && ctrl_xfer->buffer != _ctrl_epbuf.buf) {
  ------------------
  |  Branch (858:9): [True: 546, False: 0]
  |  Branch (858:27): [True: 546, False: 0]
  ------------------
  859|    546|      TU_VERIFY(0 == tu_memcpy_s(_ctrl_epbuf.buf, CFG_TUD_ENDPOINT0_BUFSIZE, ctrl_xfer->buffer, xact_len));
  ------------------
  |  |   95|    546|#define TU_VERIFY(...)                 TU_GET_3RD_ARG(__VA_ARGS__, TU_VERIFY_2ARGS, TU_VERIFY_1ARGS, _dummy)(__VA_ARGS__)
  |  |  ------------------
  |  |  |  |  112|    546|#define TU_GET_3RD_ARG(arg1, arg2, arg3, ...)        arg3
  |  |  |  |  ------------------
  |  |  |  |  |  |   95|    546|#define TU_VERIFY(...)                 TU_GET_3RD_ARG(__VA_ARGS__, TU_VERIFY_2ARGS, TU_VERIFY_1ARGS, _dummy)(__VA_ARGS__)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   92|    546|#define TU_VERIFY_1ARGS(_cond)         TU_VERIFY_DEFINE(_cond, false)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   86|    546|  do {                                \
  |  |  |  |  |  |  |  |  |  |   87|    546|    if (!(_cond)) {                   \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (87:9): [True: 0, False: 546]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   88|      0|      return _ret;                    \
  |  |  |  |  |  |  |  |  |  |   89|      0|    }                                 \
  |  |  |  |  |  |  |  |  |  |   90|    546|  } while (0)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (90:12): [Folded, False: 546]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  860|    546|    }
  861|    546|  }
  862|       |
  863|  1.46k|  return usbd_edpt_xfer(rhport, ep_addr, xact_len ? _ctrl_epbuf.buf : NULL, xact_len, false);
  ------------------
  |  Branch (863:42): [True: 1.46k, False: 0]
  ------------------
  864|  1.46k|}
usbd.c:process_setup_received:
 1082|  11.4k|static bool process_setup_received(uint8_t rhport, tusb_control_request_t const * p_request) {
 1083|       |  // Initialize control transfer state for this request. The request copy must be
 1084|       |  // visible to usbd_control_xfer_cb when the (asynchronous) status ZLP completes,
 1085|       |  // since the SETUP packet event has already gone out of scope by then.
 1086|  11.4k|  usbd_control_xfer_t* const ctrl_xfer = &_usbd_dev.ctrl_xfer;
 1087|  11.4k|  ctrl_xfer->request = *p_request;
 1088|  11.4k|  ctrl_xfer->buffer = NULL;
 1089|  11.4k|  ctrl_xfer->total_xferred = 0;
 1090|  11.4k|  ctrl_xfer->data_len = 0;
 1091|  11.4k|  ctrl_xfer->complete_cb = NULL;
 1092|       |
 1093|  11.4k|  p_request = &ctrl_xfer->request; // re-direct request pointer to internal copy (modifiable for hacking)
 1094|  11.4k|  TU_ASSERT(p_request->bmRequestType_bit.type < TUSB_REQ_TYPE_INVALID);
  ------------------
  |  |  112|  11.4k|#define TU_ASSERT(...)                 TU_GET_3RD_ARG(__VA_ARGS__, TU_ASSERT_2ARGS, TU_ASSERT_1ARGS, _dummy)(__VA_ARGS__)
  |  |  ------------------
  |  |  |  |  112|  11.4k|#define TU_GET_3RD_ARG(arg1, arg2, arg3, ...)        arg3
  |  |  |  |  ------------------
  |  |  |  |  |  |  112|  11.4k|#define TU_ASSERT(...)                 TU_GET_3RD_ARG(__VA_ARGS__, TU_ASSERT_2ARGS, TU_ASSERT_1ARGS, _dummy)(__VA_ARGS__)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  108|  11.4k|#define TU_ASSERT_1ARGS(_cond)         TU_ASSERT_DEFINE(_cond, false)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  104|  11.4k|  do {                                                                \
  |  |  |  |  |  |  |  |  |  |  105|  11.4k|    if ( !(_cond) ) { TU_MESS_FAILED(); TU_BREAKPOINT(); return _ret; } \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   54|    455|  #define TU_MESS_FAILED() do {} while (0)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (54:41): [Folded, False: 455]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |                   if ( !(_cond) ) { TU_MESS_FAILED(); TU_BREAKPOINT(); return _ret; } \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   77|    455|  #define TU_BREAKPOINT() do {} while (0)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (77:40): [Folded, False: 455]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (105:10): [True: 455, False: 10.9k]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  106|  11.4k|  } while(0)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (106:11): [Folded, False: 10.9k]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1095|       |
 1096|       |  // Vendor request
 1097|  10.9k|  if ( p_request->bmRequestType_bit.type == TUSB_REQ_TYPE_VENDOR ) {
  ------------------
  |  Branch (1097:8): [True: 371, False: 10.6k]
  ------------------
 1098|    371|    ctrl_xfer->complete_cb = tud_vendor_control_xfer_cb;
 1099|    371|    return tud_vendor_control_xfer_cb(rhport, CONTROL_STAGE_SETUP, p_request);
 1100|    371|  }
 1101|       |
 1102|       |#if CFG_TUSB_DEBUG >= CFG_TUD_LOG_LEVEL
 1103|       |  if (TUSB_REQ_TYPE_STANDARD == p_request->bmRequestType_bit.type && p_request->bRequest <= TUSB_REQ_SYNCH_FRAME) {
 1104|       |    TU_LOG_USBD("  %s", tu_str_std_request[p_request->bRequest]);
 1105|       |    if (TUSB_REQ_GET_DESCRIPTOR != p_request->bRequest) {
 1106|       |      TU_LOG_USBD("\r\n");
 1107|       |    }
 1108|       |  }
 1109|       |#endif
 1110|       |
 1111|  10.6k|  switch (p_request->bmRequestType_bit.recipient) { //-V2520
 1112|       |    //------------- Device Requests e.g in enumeration -------------//
 1113|  7.03k|    case TUSB_REQ_RCPT_DEVICE:
  ------------------
  |  Branch (1113:5): [True: 7.03k, False: 3.56k]
  ------------------
 1114|  7.03k|      if ( TUSB_REQ_TYPE_CLASS == p_request->bmRequestType_bit.type ) {
  ------------------
  |  Branch (1114:12): [True: 481, False: 6.55k]
  ------------------
 1115|    481|        uint8_t const itf = tu_u16_low(p_request->wIndex);
 1116|    481|        TU_VERIFY(itf < TU_ARRAY_SIZE(_usbd_dev.itf2drv));
  ------------------
  |  |   95|    481|#define TU_VERIFY(...)                 TU_GET_3RD_ARG(__VA_ARGS__, TU_VERIFY_2ARGS, TU_VERIFY_1ARGS, _dummy)(__VA_ARGS__)
  |  |  ------------------
  |  |  |  |  112|    481|#define TU_GET_3RD_ARG(arg1, arg2, arg3, ...)        arg3
  |  |  |  |  ------------------
  |  |  |  |  |  |   95|    481|#define TU_VERIFY(...)                 TU_GET_3RD_ARG(__VA_ARGS__, TU_VERIFY_2ARGS, TU_VERIFY_1ARGS, _dummy)(__VA_ARGS__)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   92|    481|#define TU_VERIFY_1ARGS(_cond)         TU_VERIFY_DEFINE(_cond, false)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   86|    481|  do {                                \
  |  |  |  |  |  |  |  |  |  |   87|    481|    if (!(_cond)) {                   \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (87:9): [True: 273, False: 208]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   88|    273|      return _ret;                    \
  |  |  |  |  |  |  |  |  |  |   89|    273|    }                                 \
  |  |  |  |  |  |  |  |  |  |   90|    481|  } while (0)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (90:12): [Folded, False: 208]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1117|       |
 1118|    208|        usbd_class_driver_t const * driver = get_driver(_usbd_dev.itf2drv[itf]);
 1119|    208|        TU_VERIFY(driver);
  ------------------
  |  |   95|    208|#define TU_VERIFY(...)                 TU_GET_3RD_ARG(__VA_ARGS__, TU_VERIFY_2ARGS, TU_VERIFY_1ARGS, _dummy)(__VA_ARGS__)
  |  |  ------------------
  |  |  |  |  112|    208|#define TU_GET_3RD_ARG(arg1, arg2, arg3, ...)        arg3
  |  |  |  |  ------------------
  |  |  |  |  |  |   95|    208|#define TU_VERIFY(...)                 TU_GET_3RD_ARG(__VA_ARGS__, TU_VERIFY_2ARGS, TU_VERIFY_1ARGS, _dummy)(__VA_ARGS__)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   92|    208|#define TU_VERIFY_1ARGS(_cond)         TU_VERIFY_DEFINE(_cond, false)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   86|    208|  do {                                \
  |  |  |  |  |  |  |  |  |  |   87|    208|    if (!(_cond)) {                   \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (87:9): [True: 208, False: 0]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   88|    208|      return _ret;                    \
  |  |  |  |  |  |  |  |  |  |   89|    208|    }                                 \
  |  |  |  |  |  |  |  |  |  |   90|    208|  } while (0)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (90:12): [Folded, False: 0]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1120|       |
 1121|       |        // forward to class driver: "non-STD request to Interface"
 1122|      0|        return invoke_class_control(rhport, driver, p_request);
 1123|    208|      }
 1124|       |
 1125|  6.55k|      if (TUSB_REQ_TYPE_STANDARD != p_request->bmRequestType_bit.type) {
  ------------------
  |  Branch (1125:11): [True: 0, False: 6.55k]
  ------------------
 1126|       |        // Non-standard request is not supported
 1127|      0|        TU_BREAKPOINT();
  ------------------
  |  |   77|      0|  #define TU_BREAKPOINT() do {} while (0)
  |  |  ------------------
  |  |  |  Branch (77:40): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1128|      0|        return false;
 1129|      0|      }
 1130|       |
 1131|  6.55k|      return process_std_device_request(rhport, p_request);
 1132|       |
 1133|       |    //------------- Class/Interface Specific Request -------------//
 1134|    491|    case TUSB_REQ_RCPT_INTERFACE: {
  ------------------
  |  Branch (1134:5): [True: 491, False: 10.1k]
  ------------------
 1135|    491|      uint8_t itf;
 1136|       |      #if CFG_TUD_PRINTER
 1137|       |      // Printer GET_DEVICE_ID has a weird wIndex = interface (high) | alt (low)
 1138|       |      // attempt to interpret this as a printer request if matched
 1139|       |      if (TUSB_REQ_TYPE_CLASS == p_request->bmRequestType_bit.type &&
 1140|       |          TUSB_DIR_IN == p_request->bmRequestType_bit.direction &&
 1141|       |          TUSB_PRINTER_REQUEST_GET_DEVICE_ID == p_request->bRequest) {
 1142|       |        itf = tu_u16_high(p_request->wIndex);
 1143|       |        if (itf < TU_ARRAY_SIZE(_usbd_dev.itf2drv)) {
 1144|       |          const usbd_class_driver_t * driver = get_driver(_usbd_dev.itf2drv[itf]);
 1145|       |          if (driver != NULL && driver->control_xfer_cb == printerd_control_xfer_cb) {
 1146|       |            if (invoke_class_control(rhport, driver, p_request)) {
 1147|       |              return true;
 1148|       |            }
 1149|       |          }
 1150|       |        }
 1151|       |      }
 1152|       |      #endif
 1153|    491|      itf = tu_u16_low(p_request->wIndex);
 1154|    491|      TU_VERIFY(itf < TU_ARRAY_SIZE(_usbd_dev.itf2drv));
  ------------------
  |  |   95|    491|#define TU_VERIFY(...)                 TU_GET_3RD_ARG(__VA_ARGS__, TU_VERIFY_2ARGS, TU_VERIFY_1ARGS, _dummy)(__VA_ARGS__)
  |  |  ------------------
  |  |  |  |  112|    491|#define TU_GET_3RD_ARG(arg1, arg2, arg3, ...)        arg3
  |  |  |  |  ------------------
  |  |  |  |  |  |   95|    491|#define TU_VERIFY(...)                 TU_GET_3RD_ARG(__VA_ARGS__, TU_VERIFY_2ARGS, TU_VERIFY_1ARGS, _dummy)(__VA_ARGS__)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   92|    491|#define TU_VERIFY_1ARGS(_cond)         TU_VERIFY_DEFINE(_cond, false)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   86|    491|  do {                                \
  |  |  |  |  |  |  |  |  |  |   87|    491|    if (!(_cond)) {                   \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (87:9): [True: 237, False: 254]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   88|    237|      return _ret;                    \
  |  |  |  |  |  |  |  |  |  |   89|    237|    }                                 \
  |  |  |  |  |  |  |  |  |  |   90|    491|  } while (0)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (90:12): [Folded, False: 254]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1155|       |
 1156|    254|      usbd_class_driver_t const * driver = get_driver(_usbd_dev.itf2drv[itf]);
 1157|    254|      TU_VERIFY(driver);
  ------------------
  |  |   95|    254|#define TU_VERIFY(...)                 TU_GET_3RD_ARG(__VA_ARGS__, TU_VERIFY_2ARGS, TU_VERIFY_1ARGS, _dummy)(__VA_ARGS__)
  |  |  ------------------
  |  |  |  |  112|    254|#define TU_GET_3RD_ARG(arg1, arg2, arg3, ...)        arg3
  |  |  |  |  ------------------
  |  |  |  |  |  |   95|    254|#define TU_VERIFY(...)                 TU_GET_3RD_ARG(__VA_ARGS__, TU_VERIFY_2ARGS, TU_VERIFY_1ARGS, _dummy)(__VA_ARGS__)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   92|    254|#define TU_VERIFY_1ARGS(_cond)         TU_VERIFY_DEFINE(_cond, false)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   86|    254|  do {                                \
  |  |  |  |  |  |  |  |  |  |   87|    254|    if (!(_cond)) {                   \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (87:9): [True: 254, False: 0]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   88|    254|      return _ret;                    \
  |  |  |  |  |  |  |  |  |  |   89|    254|    }                                 \
  |  |  |  |  |  |  |  |  |  |   90|    254|  } while (0)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (90:12): [Folded, False: 0]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1158|       |
 1159|       |      // all requests to Interface (STD or Class) is forwarded to class driver.
 1160|       |      // notable requests are: GET HID REPORT DESCRIPTOR, SET_INTERFACE, GET_INTERFACE
 1161|      0|      if (!invoke_class_control(rhport, driver, p_request)) {
  ------------------
  |  Branch (1161:11): [True: 0, False: 0]
  ------------------
 1162|       |        // For GET_INTERFACE and SET_INTERFACE, it is mandatory to respond even if the class
 1163|       |        // driver doesn't use alternate settings or implement this
 1164|      0|        TU_VERIFY(TUSB_REQ_TYPE_STANDARD == p_request->bmRequestType_bit.type);
  ------------------
  |  |   95|      0|#define TU_VERIFY(...)                 TU_GET_3RD_ARG(__VA_ARGS__, TU_VERIFY_2ARGS, TU_VERIFY_1ARGS, _dummy)(__VA_ARGS__)
  |  |  ------------------
  |  |  |  |  112|      0|#define TU_GET_3RD_ARG(arg1, arg2, arg3, ...)        arg3
  |  |  |  |  ------------------
  |  |  |  |  |  |   95|      0|#define TU_VERIFY(...)                 TU_GET_3RD_ARG(__VA_ARGS__, TU_VERIFY_2ARGS, TU_VERIFY_1ARGS, _dummy)(__VA_ARGS__)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   92|      0|#define TU_VERIFY_1ARGS(_cond)         TU_VERIFY_DEFINE(_cond, false)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   86|      0|  do {                                \
  |  |  |  |  |  |  |  |  |  |   87|      0|    if (!(_cond)) {                   \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (87:9): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   88|      0|      return _ret;                    \
  |  |  |  |  |  |  |  |  |  |   89|      0|    }                                 \
  |  |  |  |  |  |  |  |  |  |   90|      0|  } while (0)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (90:12): [Folded, False: 0]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1165|       |
 1166|       |        // Clear complete callback if driver set since it can also stall the request.
 1167|      0|        ctrl_xfer->complete_cb = NULL;
 1168|       |
 1169|      0|        switch (p_request->bRequest) { //-V2520
 1170|      0|          case TUSB_REQ_GET_INTERFACE: {
  ------------------
  |  Branch (1170:11): [True: 0, False: 0]
  ------------------
 1171|      0|            uint8_t alternate = 0;
 1172|      0|            tud_control_xfer(rhport, p_request, &alternate, 1);
 1173|      0|            break;
 1174|      0|          }
 1175|       |
 1176|      0|          case TUSB_REQ_SET_INTERFACE:
  ------------------
  |  Branch (1176:11): [True: 0, False: 0]
  ------------------
 1177|       |            // A class that implements altsettings handles SET_INTERFACE itself and returns true,
 1178|       |            // so reaching here means the class does not — where only alt 0 is valid. Any non-zero
 1179|       |            // alt (unimplemented, or rejected as invalid by the class) is a Request Error (stall).
 1180|      0|            TU_VERIFY(tu_u16_low(p_request->wValue) == 0);
  ------------------
  |  |   95|      0|#define TU_VERIFY(...)                 TU_GET_3RD_ARG(__VA_ARGS__, TU_VERIFY_2ARGS, TU_VERIFY_1ARGS, _dummy)(__VA_ARGS__)
  |  |  ------------------
  |  |  |  |  112|      0|#define TU_GET_3RD_ARG(arg1, arg2, arg3, ...)        arg3
  |  |  |  |  ------------------
  |  |  |  |  |  |   95|      0|#define TU_VERIFY(...)                 TU_GET_3RD_ARG(__VA_ARGS__, TU_VERIFY_2ARGS, TU_VERIFY_1ARGS, _dummy)(__VA_ARGS__)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   92|      0|#define TU_VERIFY_1ARGS(_cond)         TU_VERIFY_DEFINE(_cond, false)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   86|      0|  do {                                \
  |  |  |  |  |  |  |  |  |  |   87|      0|    if (!(_cond)) {                   \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (87:9): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   88|      0|      return _ret;                    \
  |  |  |  |  |  |  |  |  |  |   89|      0|    }                                 \
  |  |  |  |  |  |  |  |  |  |   90|      0|  } while (0)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (90:12): [Folded, False: 0]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1181|      0|            tud_control_status(rhport, p_request);
 1182|      0|            break;
 1183|       |
 1184|      0|          case TUSB_REQ_GET_STATUS:
  ------------------
  |  Branch (1184:11): [True: 0, False: 0]
  ------------------
 1185|       |            // USB 2.0 9.4.5: interface GET_STATUS returns 2 reserved (zero) bytes
 1186|      0|            TU_VERIFY(process_get_status(rhport, p_request, 0x0000));
  ------------------
  |  |   95|      0|#define TU_VERIFY(...)                 TU_GET_3RD_ARG(__VA_ARGS__, TU_VERIFY_2ARGS, TU_VERIFY_1ARGS, _dummy)(__VA_ARGS__)
  |  |  ------------------
  |  |  |  |  112|      0|#define TU_GET_3RD_ARG(arg1, arg2, arg3, ...)        arg3
  |  |  |  |  ------------------
  |  |  |  |  |  |   95|      0|#define TU_VERIFY(...)                 TU_GET_3RD_ARG(__VA_ARGS__, TU_VERIFY_2ARGS, TU_VERIFY_1ARGS, _dummy)(__VA_ARGS__)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   92|      0|#define TU_VERIFY_1ARGS(_cond)         TU_VERIFY_DEFINE(_cond, false)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   86|      0|  do {                                \
  |  |  |  |  |  |  |  |  |  |   87|      0|    if (!(_cond)) {                   \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (87:9): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   88|      0|      return _ret;                    \
  |  |  |  |  |  |  |  |  |  |   89|      0|    }                                 \
  |  |  |  |  |  |  |  |  |  |   90|      0|  } while (0)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (90:12): [Folded, False: 0]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1187|      0|            break;
 1188|       |
 1189|      0|          default: return false;
  ------------------
  |  Branch (1189:11): [True: 0, False: 0]
  ------------------
 1190|      0|        }
 1191|      0|      }
 1192|      0|      break;
 1193|      0|    }
 1194|       |
 1195|       |    //------------- Endpoint Request -------------//
 1196|  2.25k|    case TUSB_REQ_RCPT_ENDPOINT: {
  ------------------
  |  Branch (1196:5): [True: 2.25k, False: 8.35k]
  ------------------
 1197|  2.25k|      uint8_t const ep_addr = tu_u16_low(p_request->wIndex);
 1198|  2.25k|      uint8_t const ep_num  = tu_edpt_number(ep_addr);
 1199|  2.25k|      uint8_t const ep_dir  = tu_edpt_dir(ep_addr);
 1200|       |
 1201|  2.25k|      TU_ASSERT(ep_num < TU_ARRAY_SIZE(_usbd_dev.ep2drv) );
  ------------------
  |  |  112|  2.25k|#define TU_ASSERT(...)                 TU_GET_3RD_ARG(__VA_ARGS__, TU_ASSERT_2ARGS, TU_ASSERT_1ARGS, _dummy)(__VA_ARGS__)
  |  |  ------------------
  |  |  |  |  112|  2.25k|#define TU_GET_3RD_ARG(arg1, arg2, arg3, ...)        arg3
  |  |  |  |  ------------------
  |  |  |  |  |  |  112|  2.25k|#define TU_ASSERT(...)                 TU_GET_3RD_ARG(__VA_ARGS__, TU_ASSERT_2ARGS, TU_ASSERT_1ARGS, _dummy)(__VA_ARGS__)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  108|  2.25k|#define TU_ASSERT_1ARGS(_cond)         TU_ASSERT_DEFINE(_cond, false)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  104|  2.25k|  do {                                                                \
  |  |  |  |  |  |  |  |  |  |  105|  2.25k|    if ( !(_cond) ) { TU_MESS_FAILED(); TU_BREAKPOINT(); return _ret; } \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   54|    226|  #define TU_MESS_FAILED() do {} while (0)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (54:41): [Folded, False: 226]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |                   if ( !(_cond) ) { TU_MESS_FAILED(); TU_BREAKPOINT(); return _ret; } \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   77|    226|  #define TU_BREAKPOINT() do {} while (0)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (77:40): [Folded, False: 226]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (105:10): [True: 226, False: 2.02k]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  106|  2.25k|  } while(0)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (106:11): [Folded, False: 2.02k]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1202|  2.02k|      usbd_class_driver_t const * driver = get_driver(_usbd_dev.ep2drv[ep_num][ep_dir]);
 1203|       |
 1204|  2.02k|      if (TUSB_REQ_TYPE_STANDARD != p_request->bmRequestType_bit.type) {
  ------------------
  |  Branch (1204:11): [True: 205, False: 1.82k]
  ------------------
 1205|       |        // Forward class request to its driver
 1206|    205|        TU_VERIFY(driver);
  ------------------
  |  |   95|    205|#define TU_VERIFY(...)                 TU_GET_3RD_ARG(__VA_ARGS__, TU_VERIFY_2ARGS, TU_VERIFY_1ARGS, _dummy)(__VA_ARGS__)
  |  |  ------------------
  |  |  |  |  112|    205|#define TU_GET_3RD_ARG(arg1, arg2, arg3, ...)        arg3
  |  |  |  |  ------------------
  |  |  |  |  |  |   95|    205|#define TU_VERIFY(...)                 TU_GET_3RD_ARG(__VA_ARGS__, TU_VERIFY_2ARGS, TU_VERIFY_1ARGS, _dummy)(__VA_ARGS__)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   92|    205|#define TU_VERIFY_1ARGS(_cond)         TU_VERIFY_DEFINE(_cond, false)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   86|    205|  do {                                \
  |  |  |  |  |  |  |  |  |  |   87|    205|    if (!(_cond)) {                   \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (87:9): [True: 205, False: 0]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   88|    205|      return _ret;                    \
  |  |  |  |  |  |  |  |  |  |   89|    205|    }                                 \
  |  |  |  |  |  |  |  |  |  |   90|    205|  } while (0)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (90:12): [Folded, False: 0]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1207|      0|        return invoke_class_control(rhport, driver, p_request);
 1208|  1.82k|      } else {
 1209|       |        // Handle STD request to endpoint
 1210|  1.82k|        switch (p_request->bRequest) { //-V2520
 1211|    624|          case TUSB_REQ_GET_STATUS:
  ------------------
  |  Branch (1211:11): [True: 624, False: 1.19k]
  ------------------
 1212|       |            // USB 2.0 9.4.5: endpoint GET_STATUS bit 0 = Halt
 1213|    624|            TU_VERIFY(process_get_status(rhport, p_request, usbd_edpt_stalled(rhport, ep_addr) ? 0x0001u : 0x0000u));
  ------------------
  |  |   95|    624|#define TU_VERIFY(...)                 TU_GET_3RD_ARG(__VA_ARGS__, TU_VERIFY_2ARGS, TU_VERIFY_1ARGS, _dummy)(__VA_ARGS__)
  |  |  ------------------
  |  |  |  |  112|    624|#define TU_GET_3RD_ARG(arg1, arg2, arg3, ...)        arg3
  |  |  |  |  ------------------
  |  |  |  |  |  |   95|    624|#define TU_VERIFY(...)                 TU_GET_3RD_ARG(__VA_ARGS__, TU_VERIFY_2ARGS, TU_VERIFY_1ARGS, _dummy)(__VA_ARGS__)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   92|    624|#define TU_VERIFY_1ARGS(_cond)         TU_VERIFY_DEFINE(_cond, false)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   86|    624|  do {                                \
  |  |  |  |  |  |  |  |  |  |   87|  1.24k|    if (!(_cond)) {                   \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (87:9): [True: 424, False: 200]
  |  |  |  |  |  |  |  |  |  |  |  Branch (87:11): [True: 0, False: 624]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   88|    424|      return _ret;                    \
  |  |  |  |  |  |  |  |  |  |   89|    424|    }                                 \
  |  |  |  |  |  |  |  |  |  |   90|    624|  } while (0)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (90:12): [Folded, False: 200]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1214|    200|            break;
 1215|       |
 1216|    418|          case TUSB_REQ_CLEAR_FEATURE:
  ------------------
  |  Branch (1216:11): [True: 418, False: 1.40k]
  ------------------
 1217|    977|          case TUSB_REQ_SET_FEATURE: {
  ------------------
  |  Branch (1217:11): [True: 559, False: 1.26k]
  ------------------
 1218|       |            // ENDPOINT_HALT is the only endpoint feature; it exists only on a non-control endpoint
 1219|       |            // that an interface actually owns. Any other selector, the control endpoint (EP0 has no
 1220|       |            // Halt feature, USB 2.0 9.4.9), or an endpoint no driver owns is a Request Error (stall).
 1221|    977|            TU_VERIFY(TUSB_REQ_FEATURE_EDPT_HALT == p_request->wValue);
  ------------------
  |  |   95|    977|#define TU_VERIFY(...)                 TU_GET_3RD_ARG(__VA_ARGS__, TU_VERIFY_2ARGS, TU_VERIFY_1ARGS, _dummy)(__VA_ARGS__)
  |  |  ------------------
  |  |  |  |  112|    977|#define TU_GET_3RD_ARG(arg1, arg2, arg3, ...)        arg3
  |  |  |  |  ------------------
  |  |  |  |  |  |   95|    977|#define TU_VERIFY(...)                 TU_GET_3RD_ARG(__VA_ARGS__, TU_VERIFY_2ARGS, TU_VERIFY_1ARGS, _dummy)(__VA_ARGS__)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   92|    977|#define TU_VERIFY_1ARGS(_cond)         TU_VERIFY_DEFINE(_cond, false)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   86|    977|  do {                                \
  |  |  |  |  |  |  |  |  |  |   87|    977|    if (!(_cond)) {                   \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (87:9): [True: 393, False: 584]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   88|    393|      return _ret;                    \
  |  |  |  |  |  |  |  |  |  |   89|    393|    }                                 \
  |  |  |  |  |  |  |  |  |  |   90|    977|  } while (0)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (90:12): [Folded, False: 584]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1222|    584|            TU_VERIFY(ep_num != 0);
  ------------------
  |  |   95|    584|#define TU_VERIFY(...)                 TU_GET_3RD_ARG(__VA_ARGS__, TU_VERIFY_2ARGS, TU_VERIFY_1ARGS, _dummy)(__VA_ARGS__)
  |  |  ------------------
  |  |  |  |  112|    584|#define TU_GET_3RD_ARG(arg1, arg2, arg3, ...)        arg3
  |  |  |  |  ------------------
  |  |  |  |  |  |   95|    584|#define TU_VERIFY(...)                 TU_GET_3RD_ARG(__VA_ARGS__, TU_VERIFY_2ARGS, TU_VERIFY_1ARGS, _dummy)(__VA_ARGS__)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   92|    584|#define TU_VERIFY_1ARGS(_cond)         TU_VERIFY_DEFINE(_cond, false)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   86|    584|  do {                                \
  |  |  |  |  |  |  |  |  |  |   87|    584|    if (!(_cond)) {                   \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (87:9): [True: 221, False: 363]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   88|    221|      return _ret;                    \
  |  |  |  |  |  |  |  |  |  |   89|    221|    }                                 \
  |  |  |  |  |  |  |  |  |  |   90|    584|  } while (0)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (90:12): [Folded, False: 363]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1223|    363|            TU_VERIFY(driver != NULL);
  ------------------
  |  |   95|    363|#define TU_VERIFY(...)                 TU_GET_3RD_ARG(__VA_ARGS__, TU_VERIFY_2ARGS, TU_VERIFY_1ARGS, _dummy)(__VA_ARGS__)
  |  |  ------------------
  |  |  |  |  112|    363|#define TU_GET_3RD_ARG(arg1, arg2, arg3, ...)        arg3
  |  |  |  |  ------------------
  |  |  |  |  |  |   95|    363|#define TU_VERIFY(...)                 TU_GET_3RD_ARG(__VA_ARGS__, TU_VERIFY_2ARGS, TU_VERIFY_1ARGS, _dummy)(__VA_ARGS__)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   92|    363|#define TU_VERIFY_1ARGS(_cond)         TU_VERIFY_DEFINE(_cond, false)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   86|    363|  do {                                \
  |  |  |  |  |  |  |  |  |  |   87|    363|    if (!(_cond)) {                   \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (87:9): [True: 363, False: 0]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   88|    363|      return _ret;                    \
  |  |  |  |  |  |  |  |  |  |   89|    363|    }                                 \
  |  |  |  |  |  |  |  |  |  |   90|    363|  } while (0)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (90:12): [Folded, False: 0]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1224|       |
 1225|      0|            if ( TUSB_REQ_CLEAR_FEATURE == p_request->bRequest ) {
  ------------------
  |  Branch (1225:18): [True: 0, False: 0]
  ------------------
 1226|      0|              usbd_edpt_clear_stall(rhport, ep_addr);
 1227|      0|            } else {
 1228|      0|              usbd_edpt_stall(rhport, ep_addr);
 1229|      0|            }
 1230|       |
 1231|       |            // Some classes such as USBTMC need to clear/re-init their buffer on CLEAR_FEATURE.
 1232|       |            // Clear complete callback if driver set since it can also stall the request.
 1233|      0|            (void) invoke_class_control(rhport, driver, p_request);
 1234|      0|            ctrl_xfer->complete_cb = NULL;
 1235|       |
 1236|       |            // STD request must always be ACKed; skip ZLP status if driver already did that.
 1237|      0|            if (!(_usbd_dev.ep_status[0][TUSB_DIR_IN] & TU_EDPT_STATE_BUSY)) {
  ------------------
  |  |   31|      0|#define TU_EDPT_STATE_BUSY    0x01u
  ------------------
  |  Branch (1237:17): [True: 0, False: 0]
  ------------------
 1238|      0|              tud_control_status(rhport, p_request);
 1239|      0|            }
 1240|      0|          }
 1241|      0|          break;
 1242|       |
 1243|       |          // Unknown/Unsupported request
 1244|    220|          default:
  ------------------
  |  Branch (1244:11): [True: 220, False: 1.60k]
  ------------------
 1245|    220|            TU_BREAKPOINT();
  ------------------
  |  |   77|    220|  #define TU_BREAKPOINT() do {} while (0)
  |  |  ------------------
  |  |  |  Branch (77:40): [Folded, False: 220]
  |  |  ------------------
  ------------------
 1246|    220|            return false;
 1247|  1.82k|        }
 1248|  1.82k|      }
 1249|    200|      break;
 1250|  2.02k|    }
 1251|       |
 1252|       |    // Unknown recipient
 1253|    822|    default:
  ------------------
  |  Branch (1253:5): [True: 822, False: 9.78k]
  ------------------
 1254|    822|      TU_BREAKPOINT();
  ------------------
  |  |   77|    822|  #define TU_BREAKPOINT() do {} while (0)
  |  |  ------------------
  |  |  |  Branch (77:40): [Folded, False: 822]
  |  |  ------------------
  ------------------
 1255|    822|      return false;
 1256|  10.6k|  }
 1257|       |
 1258|    200|  return true;
 1259|  10.6k|}
usbd.c:process_std_device_request:
  965|  6.55k|static bool process_std_device_request(uint8_t rhport, tusb_control_request_t const * p_request) {
  966|  6.55k|  switch (p_request->bRequest) { //-V2520
  967|    205|    case TUSB_REQ_SET_ADDRESS:
  ------------------
  |  Branch (967:5): [True: 205, False: 6.35k]
  ------------------
  968|       |      // Depending on mcu, status phase could be sent either before or after changing device address,
  969|       |      // or even require stack to not response with status at all
  970|       |      // Therefore DCD must take full responsibility to response and include zlp status packet if needed.
  971|    205|      dcd_set_address(rhport, (uint8_t) p_request->wValue);
  972|    205|      _usbd_dev.addressed = 1;
  973|    205|      return true;
  974|       |
  975|    258|    case TUSB_REQ_GET_CONFIGURATION: {
  ------------------
  |  Branch (975:5): [True: 258, False: 6.29k]
  ------------------
  976|    258|      uint8_t cfg_num = _usbd_dev.cfg_num;
  977|    258|      tud_control_xfer(rhport, p_request, &cfg_num, 1);
  978|    258|      return true;
  979|      0|    }
  980|       |
  981|  1.07k|    case TUSB_REQ_SET_CONFIGURATION: {
  ------------------
  |  Branch (981:5): [True: 1.07k, False: 5.48k]
  ------------------
  982|  1.07k|      uint8_t const cfg_num = (uint8_t) p_request->wValue;
  983|       |
  984|       |      // Only process if new configure is different
  985|  1.07k|      if (_usbd_dev.cfg_num != cfg_num) {
  ------------------
  |  Branch (985:11): [True: 225, False: 847]
  ------------------
  986|    225|        if (_usbd_dev.cfg_num != 0) {
  ------------------
  |  Branch (986:13): [True: 0, False: 225]
  ------------------
  987|       |          // already configured: need to clear all endpoints and driver first
  988|      0|          TU_LOG_USBD("  Clear current Configuration (%u) before switching\r\n", _usbd_dev.cfg_num);
  989|       |
  990|      0|          dcd_sof_enable(rhport, false);
  991|      0|          dcd_edpt_close_all(rhport);
  992|       |
  993|       |          // close all drivers and current configured state except bus speed
  994|      0|          const uint8_t speed = _usbd_dev.speed;
  995|      0|          configuration_reset(rhport);
  996|       |
  997|      0|          _usbd_dev.speed = speed; // restore speed
  998|      0|        }
  999|       |
 1000|    225|        _usbd_dev.cfg_num = cfg_num;
 1001|       |
 1002|       |        // Handle the new configuration
 1003|    225|        if (cfg_num == 0) {
  ------------------
  |  Branch (1003:13): [True: 0, False: 225]
  ------------------
 1004|      0|          tud_umount_cb();
 1005|    225|        } else {
 1006|    225|          if (!process_set_config(rhport, cfg_num)) {
  ------------------
  |  Branch (1006:15): [True: 225, False: 0]
  ------------------
 1007|    225|            _usbd_dev.cfg_num = 0;
 1008|    225|            TU_ASSERT(false);
  ------------------
  |  |  112|    225|#define TU_ASSERT(...)                 TU_GET_3RD_ARG(__VA_ARGS__, TU_ASSERT_2ARGS, TU_ASSERT_1ARGS, _dummy)(__VA_ARGS__)
  |  |  ------------------
  |  |  |  |  112|    225|#define TU_GET_3RD_ARG(arg1, arg2, arg3, ...)        arg3
  |  |  |  |  ------------------
  |  |  |  |  |  |  112|    225|#define TU_ASSERT(...)                 TU_GET_3RD_ARG(__VA_ARGS__, TU_ASSERT_2ARGS, TU_ASSERT_1ARGS, _dummy)(__VA_ARGS__)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  108|    225|#define TU_ASSERT_1ARGS(_cond)         TU_ASSERT_DEFINE(_cond, false)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  104|    225|  do {                                                                \
  |  |  |  |  |  |  |  |  |  |  105|    225|    if ( !(_cond) ) { TU_MESS_FAILED(); TU_BREAKPOINT(); return _ret; } \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   54|    225|  #define TU_MESS_FAILED() do {} while (0)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (54:41): [Folded, False: 225]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |                   if ( !(_cond) ) { TU_MESS_FAILED(); TU_BREAKPOINT(); return _ret; } \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   77|    225|  #define TU_BREAKPOINT() do {} while (0)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (77:40): [Folded, False: 225]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (105:10): [True: 225, Folded]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  106|    225|  } while(0)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (106:11): [Folded, False: 0]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1009|    225|          }
 1010|      0|          tud_mount_cb();
 1011|      0|        }
 1012|    225|      }
 1013|       |
 1014|    847|      tud_control_status(rhport, p_request);
 1015|    847|      return true;
 1016|  1.07k|    }
 1017|       |
 1018|  2.02k|    case TUSB_REQ_GET_DESCRIPTOR:
  ------------------
  |  Branch (1018:5): [True: 2.02k, False: 4.53k]
  ------------------
 1019|  2.02k|      return process_get_descriptor(rhport, p_request);
 1020|       |
 1021|  1.05k|    case TUSB_REQ_SET_FEATURE:
  ------------------
  |  Branch (1021:5): [True: 1.05k, False: 5.50k]
  ------------------
 1022|  1.05k|      switch (p_request->wValue) { //-V2520
 1023|    820|        case TUSB_REQ_FEATURE_REMOTE_WAKEUP:
  ------------------
  |  Branch (1023:9): [True: 820, False: 237]
  ------------------
 1024|    820|          TU_LOG_USBD("    Enable Remote Wakeup\r\n");
 1025|       |          // Host may enable remote wake up before suspending especially HID device
 1026|    820|          _usbd_dev.remote_wakeup_en = 1;
 1027|    820|          tud_control_status(rhport, p_request);
 1028|    820|          return true;
 1029|       |
 1030|       |        #if CFG_TUD_TEST_MODE
 1031|       |        case TUSB_REQ_FEATURE_TEST_MODE: {
 1032|       |          // Only handle the test mode if supported and valid
 1033|       |          TU_VERIFY(0 == tu_u16_low(p_request->wIndex));
 1034|       |
 1035|       |          uint8_t const selector = tu_u16_high(p_request->wIndex);
 1036|       |          TU_VERIFY(TUSB_FEATURE_TEST_J <= selector && selector <= TUSB_FEATURE_TEST_FORCE_ENABLE);
 1037|       |
 1038|       |          _usbd_dev.ctrl_xfer.complete_cb = process_test_mode_cb;
 1039|       |          tud_control_status(rhport, p_request);
 1040|       |          return true;
 1041|       |        }
 1042|       |        #endif
 1043|       |
 1044|       |        // Stall unsupported feature selector
 1045|    237|        default: return false;
  ------------------
  |  Branch (1045:9): [True: 237, False: 820]
  ------------------
 1046|  1.05k|      }
 1047|       |
 1048|    875|    case TUSB_REQ_CLEAR_FEATURE:
  ------------------
  |  Branch (1048:5): [True: 875, False: 5.68k]
  ------------------
 1049|       |      // Only support remote wakeup for device feature
 1050|    875|      TU_VERIFY(TUSB_REQ_FEATURE_REMOTE_WAKEUP == p_request->wValue);
  ------------------
  |  |   95|    875|#define TU_VERIFY(...)                 TU_GET_3RD_ARG(__VA_ARGS__, TU_VERIFY_2ARGS, TU_VERIFY_1ARGS, _dummy)(__VA_ARGS__)
  |  |  ------------------
  |  |  |  |  112|    875|#define TU_GET_3RD_ARG(arg1, arg2, arg3, ...)        arg3
  |  |  |  |  ------------------
  |  |  |  |  |  |   95|    875|#define TU_VERIFY(...)                 TU_GET_3RD_ARG(__VA_ARGS__, TU_VERIFY_2ARGS, TU_VERIFY_1ARGS, _dummy)(__VA_ARGS__)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   92|    875|#define TU_VERIFY_1ARGS(_cond)         TU_VERIFY_DEFINE(_cond, false)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   86|    875|  do {                                \
  |  |  |  |  |  |  |  |  |  |   87|    875|    if (!(_cond)) {                   \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (87:9): [True: 233, False: 642]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   88|    233|      return _ret;                    \
  |  |  |  |  |  |  |  |  |  |   89|    233|    }                                 \
  |  |  |  |  |  |  |  |  |  |   90|    875|  } while (0)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (90:12): [Folded, False: 642]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1051|    642|      TU_LOG_USBD("    Disable Remote Wakeup\r\n");
 1052|       |
 1053|       |      // Host may disable remote wake up after resuming
 1054|    642|      _usbd_dev.remote_wakeup_en = 0;
 1055|    642|      tud_control_status(rhport, p_request);
 1056|    642|      return true;
 1057|       |
 1058|    704|    case TUSB_REQ_GET_STATUS: {
  ------------------
  |  Branch (1058:5): [True: 704, False: 5.85k]
  ------------------
 1059|       |      // Device status bit mask
 1060|       |      // - Bit 0: Self Powered TODO must invoke callback to get actual status
 1061|       |      // - Bit 1: Remote Wakeup enabled
 1062|    704|      return process_get_status(rhport, p_request, (uint16_t) _usbd_dev.dev_state_bm);
 1063|    875|    }
 1064|       |
 1065|    361|    default:
  ------------------
  |  Branch (1065:5): [True: 361, False: 6.19k]
  ------------------
 1066|    361|      TU_BREAKPOINT();
  ------------------
  |  |   77|    361|  #define TU_BREAKPOINT() do {} while (0)
  |  |  ------------------
  |  |  |  Branch (77:40): [Folded, False: 361]
  |  |  ------------------
  ------------------
 1067|       |      return false;
 1068|  6.55k|  }
 1069|  6.55k|}
usbd.c:process_set_config:
 1263|    225|static bool process_set_config(uint8_t rhport, uint8_t cfg_num) {
 1264|       |  // index is cfg_num-1
 1265|    225|  const tusb_desc_configuration_t *desc_cfg =
 1266|    225|    (const tusb_desc_configuration_t *)tud_descriptor_configuration_cb(cfg_num - 1);
 1267|    225|  TU_ASSERT(desc_cfg != NULL && desc_cfg->bDescriptorType == TUSB_DESC_CONFIGURATION);
  ------------------
  |  |  112|    225|#define TU_ASSERT(...)                 TU_GET_3RD_ARG(__VA_ARGS__, TU_ASSERT_2ARGS, TU_ASSERT_1ARGS, _dummy)(__VA_ARGS__)
  |  |  ------------------
  |  |  |  |  112|    225|#define TU_GET_3RD_ARG(arg1, arg2, arg3, ...)        arg3
  |  |  |  |  ------------------
  |  |  |  |  |  |  112|    225|#define TU_ASSERT(...)                 TU_GET_3RD_ARG(__VA_ARGS__, TU_ASSERT_2ARGS, TU_ASSERT_1ARGS, _dummy)(__VA_ARGS__)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  108|    225|#define TU_ASSERT_1ARGS(_cond)         TU_ASSERT_DEFINE(_cond, false)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  104|    225|  do {                                                                \
  |  |  |  |  |  |  |  |  |  |  105|    450|    if ( !(_cond) ) { TU_MESS_FAILED(); TU_BREAKPOINT(); return _ret; } \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   54|      0|  #define TU_MESS_FAILED() do {} while (0)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (54:41): [Folded, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |                   if ( !(_cond) ) { TU_MESS_FAILED(); TU_BREAKPOINT(); return _ret; } \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   77|      0|  #define TU_BREAKPOINT() do {} while (0)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (77:40): [Folded, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (105:12): [True: 225, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  Branch (105:12): [True: 225, False: 0]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  106|    225|  } while(0)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (106:11): [Folded, False: 225]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1268|       |
 1269|       |  // Parse configuration descriptor
 1270|    225|  _usbd_dev.self_powered = (desc_cfg->bmAttributes & TUSB_DESC_CONFIG_ATT_SELF_POWERED) ? 1u : 0u;
  ------------------
  |  Branch (1270:28): [True: 0, False: 225]
  ------------------
 1271|       |
 1272|       |  // Parse interface descriptor
 1273|    225|  const uint8_t *p_desc   = ((const uint8_t *)desc_cfg) + sizeof(tusb_desc_configuration_t);
 1274|    225|  const uint8_t *desc_end = ((const uint8_t *)desc_cfg) + tu_le16toh(desc_cfg->wTotalLength);
  ------------------
  |  |  253|    225|  #define tu_le16toh(u16) (u16)
  ------------------
 1275|       |
 1276|    225|  while (tu_desc_in_bounds(p_desc, desc_end)) {
  ------------------
  |  Branch (1276:10): [True: 225, False: 0]
  ------------------
 1277|       |    // Class will always start with Interface Association (if any) and then Interface descriptor
 1278|    225|    if (TUSB_DESC_INTERFACE_ASSOCIATION == tu_desc_type(p_desc)) {
  ------------------
  |  Branch (1278:9): [True: 0, False: 225]
  ------------------
 1279|      0|      p_desc = tu_desc_next(p_desc); // next to Interface
 1280|      0|      continue;
 1281|      0|    }
 1282|       |
 1283|    225|    TU_ASSERT(TUSB_DESC_INTERFACE == tu_desc_type(p_desc));
  ------------------
  |  |  112|    225|#define TU_ASSERT(...)                 TU_GET_3RD_ARG(__VA_ARGS__, TU_ASSERT_2ARGS, TU_ASSERT_1ARGS, _dummy)(__VA_ARGS__)
  |  |  ------------------
  |  |  |  |  112|    225|#define TU_GET_3RD_ARG(arg1, arg2, arg3, ...)        arg3
  |  |  |  |  ------------------
  |  |  |  |  |  |  112|    225|#define TU_ASSERT(...)                 TU_GET_3RD_ARG(__VA_ARGS__, TU_ASSERT_2ARGS, TU_ASSERT_1ARGS, _dummy)(__VA_ARGS__)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  108|    225|#define TU_ASSERT_1ARGS(_cond)         TU_ASSERT_DEFINE(_cond, false)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  104|    225|  do {                                                                \
  |  |  |  |  |  |  |  |  |  |  105|    225|    if ( !(_cond) ) { TU_MESS_FAILED(); TU_BREAKPOINT(); return _ret; } \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   54|      0|  #define TU_MESS_FAILED() do {} while (0)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (54:41): [Folded, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |                   if ( !(_cond) ) { TU_MESS_FAILED(); TU_BREAKPOINT(); return _ret; } \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   77|      0|  #define TU_BREAKPOINT() do {} while (0)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (77:40): [Folded, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (105:10): [True: 0, False: 225]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  106|    225|  } while(0)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (106:11): [Folded, False: 225]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1284|    225|    const tusb_desc_interface_t *desc_itf = (const tusb_desc_interface_t *)p_desc;
 1285|       |
 1286|       |    // Find driver for this interface
 1287|    225|    const uint16_t remaining_len = (uint16_t)(desc_end - p_desc);
 1288|    225|    uint8_t        drv_id;
 1289|    450|    for (drv_id = 0; drv_id < TOTAL_DRIVER_COUNT; drv_id++) {
  ------------------
  |  |  369|    450|#define TOTAL_DRIVER_COUNT    ((uint8_t) (_app_driver_count + _builtin_driver_count))
  ------------------
  |  Branch (1289:22): [True: 225, False: 225]
  ------------------
 1290|    225|      const usbd_class_driver_t *driver = get_driver(drv_id);
 1291|    225|      TU_ASSERT(driver);
  ------------------
  |  |  112|    225|#define TU_ASSERT(...)                 TU_GET_3RD_ARG(__VA_ARGS__, TU_ASSERT_2ARGS, TU_ASSERT_1ARGS, _dummy)(__VA_ARGS__)
  |  |  ------------------
  |  |  |  |  112|    225|#define TU_GET_3RD_ARG(arg1, arg2, arg3, ...)        arg3
  |  |  |  |  ------------------
  |  |  |  |  |  |  112|    225|#define TU_ASSERT(...)                 TU_GET_3RD_ARG(__VA_ARGS__, TU_ASSERT_2ARGS, TU_ASSERT_1ARGS, _dummy)(__VA_ARGS__)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  108|    225|#define TU_ASSERT_1ARGS(_cond)         TU_ASSERT_DEFINE(_cond, false)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  104|    225|  do {                                                                \
  |  |  |  |  |  |  |  |  |  |  105|    225|    if ( !(_cond) ) { TU_MESS_FAILED(); TU_BREAKPOINT(); return _ret; } \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   54|      0|  #define TU_MESS_FAILED() do {} while (0)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (54:41): [Folded, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |                   if ( !(_cond) ) { TU_MESS_FAILED(); TU_BREAKPOINT(); return _ret; } \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   77|      0|  #define TU_BREAKPOINT() do {} while (0)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (77:40): [Folded, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (105:10): [True: 0, False: 225]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  106|    225|  } while(0)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (106:11): [Folded, False: 225]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1292|    225|      const uint16_t drv_len = driver->open(rhport, desc_itf, remaining_len);
 1293|       |
 1294|    225|      if ((sizeof(tusb_desc_interface_t) <= drv_len) && (drv_len <= remaining_len)) {
  ------------------
  |  Branch (1294:11): [True: 0, False: 225]
  |  Branch (1294:57): [True: 0, False: 0]
  ------------------
 1295|       |        // Open successfully
 1296|      0|        TU_LOG_USBD("  %s opened\r\n", driver->name);
 1297|       |
 1298|       |        // bind found driver to all interfaces and endpoint within drv_len
 1299|      0|        TU_ASSERT(tu_bind_driver_to_ep_itf(drv_id, _usbd_dev.ep2drv, _usbd_dev.itf2drv, CFG_TUD_INTERFACE_MAX, p_desc,
  ------------------
  |  |  112|      0|#define TU_ASSERT(...)                 TU_GET_3RD_ARG(__VA_ARGS__, TU_ASSERT_2ARGS, TU_ASSERT_1ARGS, _dummy)(__VA_ARGS__)
  |  |  ------------------
  |  |  |  |  112|      0|#define TU_GET_3RD_ARG(arg1, arg2, arg3, ...)        arg3
  |  |  |  |  ------------------
  |  |  |  |  |  |  112|      0|#define TU_ASSERT(...)                 TU_GET_3RD_ARG(__VA_ARGS__, TU_ASSERT_2ARGS, TU_ASSERT_1ARGS, _dummy)(__VA_ARGS__)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  108|      0|#define TU_ASSERT_1ARGS(_cond)         TU_ASSERT_DEFINE(_cond, false)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  104|      0|  do {                                                                \
  |  |  |  |  |  |  |  |  |  |  105|      0|    if ( !(_cond) ) { TU_MESS_FAILED(); TU_BREAKPOINT(); return _ret; } \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   54|      0|  #define TU_MESS_FAILED() do {} while (0)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (54:41): [Folded, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |                   if ( !(_cond) ) { TU_MESS_FAILED(); TU_BREAKPOINT(); return _ret; } \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   77|      0|  #define TU_BREAKPOINT() do {} while (0)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (77:40): [Folded, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (105:10): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  106|      0|  } while(0)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (106:11): [Folded, False: 0]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1300|      0|                                           drv_len));
 1301|       |
 1302|      0|        p_desc += drv_len; // next Interface
 1303|      0|        break; // exit driver find loop
 1304|      0|      }
 1305|    225|    }
 1306|       |
 1307|       |    // Failed if there is no supported drivers
 1308|    225|    TU_ASSERT(drv_id < TOTAL_DRIVER_COUNT);
  ------------------
  |  |  112|    225|#define TU_ASSERT(...)                 TU_GET_3RD_ARG(__VA_ARGS__, TU_ASSERT_2ARGS, TU_ASSERT_1ARGS, _dummy)(__VA_ARGS__)
  |  |  ------------------
  |  |  |  |  112|    225|#define TU_GET_3RD_ARG(arg1, arg2, arg3, ...)        arg3
  |  |  |  |  ------------------
  |  |  |  |  |  |  112|    225|#define TU_ASSERT(...)                 TU_GET_3RD_ARG(__VA_ARGS__, TU_ASSERT_2ARGS, TU_ASSERT_1ARGS, _dummy)(__VA_ARGS__)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  108|    225|#define TU_ASSERT_1ARGS(_cond)         TU_ASSERT_DEFINE(_cond, false)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  104|    225|  do {                                                                \
  |  |  |  |  |  |  |  |  |  |  105|    225|    if ( !(_cond) ) { TU_MESS_FAILED(); TU_BREAKPOINT(); return _ret; } \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   54|    225|  #define TU_MESS_FAILED() do {} while (0)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (54:41): [Folded, False: 225]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |                   if ( !(_cond) ) { TU_MESS_FAILED(); TU_BREAKPOINT(); return _ret; } \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   77|    225|  #define TU_BREAKPOINT() do {} while (0)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (77:40): [Folded, False: 225]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (105:10): [True: 225, False: 0]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  106|    225|  } while(0)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (106:11): [Folded, False: 0]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1309|    225|  }
 1310|       |
 1311|      0|  return true;
 1312|    225|}
usbd.c:process_get_descriptor:
 1315|  2.02k|static bool process_get_descriptor(uint8_t rhport, tusb_control_request_t const * p_request) {
 1316|  2.02k|  tusb_desc_type_t const desc_type = (tusb_desc_type_t) tu_u16_high(p_request->wValue);
 1317|  2.02k|  uint8_t const desc_index = tu_u16_low( p_request->wValue );
 1318|       |
 1319|  2.02k|  switch(desc_type) { //-V2520
 1320|    224|    case TUSB_DESC_DEVICE: {
  ------------------
  |  Branch (1320:5): [True: 224, False: 1.80k]
  ------------------
 1321|    224|      TU_LOG_USBD(" Device\r\n");
 1322|       |
 1323|    224|      void *desc_device = (void *)(uintptr_t)tud_descriptor_device_cb();
 1324|    224|      TU_ASSERT(desc_device);
  ------------------
  |  |  112|    224|#define TU_ASSERT(...)                 TU_GET_3RD_ARG(__VA_ARGS__, TU_ASSERT_2ARGS, TU_ASSERT_1ARGS, _dummy)(__VA_ARGS__)
  |  |  ------------------
  |  |  |  |  112|    224|#define TU_GET_3RD_ARG(arg1, arg2, arg3, ...)        arg3
  |  |  |  |  ------------------
  |  |  |  |  |  |  112|    224|#define TU_ASSERT(...)                 TU_GET_3RD_ARG(__VA_ARGS__, TU_ASSERT_2ARGS, TU_ASSERT_1ARGS, _dummy)(__VA_ARGS__)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  108|    224|#define TU_ASSERT_1ARGS(_cond)         TU_ASSERT_DEFINE(_cond, false)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  104|    224|  do {                                                                \
  |  |  |  |  |  |  |  |  |  |  105|    224|    if ( !(_cond) ) { TU_MESS_FAILED(); TU_BREAKPOINT(); return _ret; } \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   54|      0|  #define TU_MESS_FAILED() do {} while (0)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (54:41): [Folded, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |                   if ( !(_cond) ) { TU_MESS_FAILED(); TU_BREAKPOINT(); return _ret; } \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   77|      0|  #define TU_BREAKPOINT() do {} while (0)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (77:40): [Folded, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (105:10): [True: 0, False: 224]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  106|    224|  } while(0)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (106:11): [Folded, False: 224]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1325|       |
 1326|       |      // Only response with exactly 1 Packet if: not addressed and host requested more data than device descriptor has.
 1327|       |      // This only happens with the very first get device descriptor and EP0 size = 8 or 16.
 1328|    224|      if ((CFG_TUD_ENDPOINT0_SIZE < sizeof(tusb_desc_device_t)) && !_usbd_dev.addressed &&
  ------------------
  |  |   90|    224|#define CFG_TUD_ENDPOINT0_SIZE    64
  ------------------
  |  Branch (1328:11): [Folded, False: 224]
  |  Branch (1328:68): [True: 0, False: 0]
  ------------------
 1329|      0|          p_request->wLength > sizeof(tusb_desc_device_t)) {
  ------------------
  |  Branch (1329:11): [True: 0, False: 0]
  ------------------
 1330|       |        // Hack here: we modify the request length to prevent usbd_control response with zlp
 1331|       |        // since we are responding with 1 packet & less data than wLength.
 1332|      0|        ((tusb_control_request_t *)(uintptr_t)p_request)->wLength = CFG_TUD_ENDPOINT0_SIZE;
  ------------------
  |  |   90|      0|#define CFG_TUD_ENDPOINT0_SIZE    64
  ------------------
 1333|      0|        return tud_control_xfer(rhport, p_request, desc_device, CFG_TUD_ENDPOINT0_SIZE);
  ------------------
  |  |   90|      0|#define CFG_TUD_ENDPOINT0_SIZE    64
  ------------------
 1334|    224|      } else {
 1335|    224|        return tud_control_xfer(rhport, p_request, desc_device, sizeof(tusb_desc_device_t));
 1336|    224|      }
 1337|    224|    }
 1338|       |    // break; // unreachable
 1339|       |
 1340|    195|    case TUSB_DESC_BOS: {
  ------------------
  |  Branch (1340:5): [True: 195, False: 1.83k]
  ------------------
 1341|    195|      TU_LOG_USBD(" BOS\r\n");
 1342|       |
 1343|       |      // requested by host if USB > 2.0 ( i.e 2.1 or 3.x )
 1344|    195|      uintptr_t desc_bos = (uintptr_t) tud_descriptor_bos_cb();
 1345|    195|      TU_VERIFY(desc_bos != 0);
  ------------------
  |  |   95|    195|#define TU_VERIFY(...)                 TU_GET_3RD_ARG(__VA_ARGS__, TU_VERIFY_2ARGS, TU_VERIFY_1ARGS, _dummy)(__VA_ARGS__)
  |  |  ------------------
  |  |  |  |  112|    195|#define TU_GET_3RD_ARG(arg1, arg2, arg3, ...)        arg3
  |  |  |  |  ------------------
  |  |  |  |  |  |   95|    195|#define TU_VERIFY(...)                 TU_GET_3RD_ARG(__VA_ARGS__, TU_VERIFY_2ARGS, TU_VERIFY_1ARGS, _dummy)(__VA_ARGS__)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   92|    195|#define TU_VERIFY_1ARGS(_cond)         TU_VERIFY_DEFINE(_cond, false)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   86|    195|  do {                                \
  |  |  |  |  |  |  |  |  |  |   87|    195|    if (!(_cond)) {                   \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (87:9): [True: 195, False: 0]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   88|    195|      return _ret;                    \
  |  |  |  |  |  |  |  |  |  |   89|    195|    }                                 \
  |  |  |  |  |  |  |  |  |  |   90|    195|  } while (0)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (90:12): [Folded, False: 0]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1346|       |
 1347|       |      // Use offsetof to avoid pointer to the odd/misaligned address
 1348|      0|      uint16_t const total_len = tu_le16toh( tu_unaligned_read16((const void*) (desc_bos + offsetof(tusb_desc_bos_t, wTotalLength))) );
  ------------------
  |  |  253|      0|  #define tu_le16toh(u16) (u16)
  ------------------
 1349|       |
 1350|      0|      return tud_control_xfer(rhport, p_request, (void*) desc_bos, total_len);
 1351|    195|    }
 1352|       |    // break; // unreachable
 1353|       |
 1354|    260|    case TUSB_DESC_CONFIGURATION:
  ------------------
  |  Branch (1354:5): [True: 260, False: 1.76k]
  ------------------
 1355|    457|    case TUSB_DESC_OTHER_SPEED_CONFIG: {
  ------------------
  |  Branch (1355:5): [True: 197, False: 1.82k]
  ------------------
 1356|    457|      uintptr_t desc_config;
 1357|       |
 1358|    457|      if ( desc_type == TUSB_DESC_CONFIGURATION ) {
  ------------------
  |  Branch (1358:12): [True: 260, False: 197]
  ------------------
 1359|    260|        TU_LOG_USBD(" Configuration[%u]\r\n", desc_index);
 1360|    260|        desc_config = (uintptr_t) tud_descriptor_configuration_cb(desc_index);
 1361|    260|        TU_ASSERT(desc_config != 0);
  ------------------
  |  |  112|    260|#define TU_ASSERT(...)                 TU_GET_3RD_ARG(__VA_ARGS__, TU_ASSERT_2ARGS, TU_ASSERT_1ARGS, _dummy)(__VA_ARGS__)
  |  |  ------------------
  |  |  |  |  112|    260|#define TU_GET_3RD_ARG(arg1, arg2, arg3, ...)        arg3
  |  |  |  |  ------------------
  |  |  |  |  |  |  112|    260|#define TU_ASSERT(...)                 TU_GET_3RD_ARG(__VA_ARGS__, TU_ASSERT_2ARGS, TU_ASSERT_1ARGS, _dummy)(__VA_ARGS__)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  108|    260|#define TU_ASSERT_1ARGS(_cond)         TU_ASSERT_DEFINE(_cond, false)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  104|    260|  do {                                                                \
  |  |  |  |  |  |  |  |  |  |  105|    260|    if ( !(_cond) ) { TU_MESS_FAILED(); TU_BREAKPOINT(); return _ret; } \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   54|      0|  #define TU_MESS_FAILED() do {} while (0)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (54:41): [Folded, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |                   if ( !(_cond) ) { TU_MESS_FAILED(); TU_BREAKPOINT(); return _ret; } \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   77|      0|  #define TU_BREAKPOINT() do {} while (0)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (77:40): [Folded, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (105:10): [True: 0, False: 260]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  106|    260|  } while(0)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (106:11): [Folded, False: 260]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1362|    260|      }else {
 1363|       |        // Host only request this after getting Device Qualifier descriptor
 1364|    197|        TU_LOG_USBD(" Other Speed Configuration\r\n");
 1365|    197|        desc_config = (uintptr_t) tud_descriptor_other_speed_configuration_cb(desc_index);
 1366|    197|        TU_VERIFY(desc_config != 0);
  ------------------
  |  |   95|    197|#define TU_VERIFY(...)                 TU_GET_3RD_ARG(__VA_ARGS__, TU_VERIFY_2ARGS, TU_VERIFY_1ARGS, _dummy)(__VA_ARGS__)
  |  |  ------------------
  |  |  |  |  112|    197|#define TU_GET_3RD_ARG(arg1, arg2, arg3, ...)        arg3
  |  |  |  |  ------------------
  |  |  |  |  |  |   95|    197|#define TU_VERIFY(...)                 TU_GET_3RD_ARG(__VA_ARGS__, TU_VERIFY_2ARGS, TU_VERIFY_1ARGS, _dummy)(__VA_ARGS__)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   92|    197|#define TU_VERIFY_1ARGS(_cond)         TU_VERIFY_DEFINE(_cond, false)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   86|    197|  do {                                \
  |  |  |  |  |  |  |  |  |  |   87|    197|    if (!(_cond)) {                   \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (87:9): [True: 197, False: 0]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   88|    197|      return _ret;                    \
  |  |  |  |  |  |  |  |  |  |   89|    197|    }                                 \
  |  |  |  |  |  |  |  |  |  |   90|    197|  } while (0)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (90:12): [Folded, False: 0]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1367|    197|      }
 1368|       |
 1369|       |      // Use offsetof to avoid pointer to the odd/misaligned address
 1370|    260|      uint16_t const total_len = tu_le16toh( tu_unaligned_read16((const void*) (desc_config + offsetof(tusb_desc_configuration_t, wTotalLength))) );
  ------------------
  |  |  253|    260|  #define tu_le16toh(u16) (u16)
  ------------------
 1371|       |
 1372|    260|      return tud_control_xfer(rhport, p_request, (void*) desc_config, total_len);
 1373|    457|    }
 1374|       |    // break; // unreachable
 1375|       |
 1376|    713|    case TUSB_DESC_STRING: {
  ------------------
  |  Branch (1376:5): [True: 713, False: 1.31k]
  ------------------
 1377|    713|      TU_LOG_USBD(" String[%u]\r\n", desc_index);
 1378|       |
 1379|       |      // String Descriptor always uses the desc set from user
 1380|    713|      uint8_t const* desc_str = (uint8_t const*) tud_descriptor_string_cb(desc_index, p_request->wIndex);
 1381|    713|      TU_VERIFY(desc_str);
  ------------------
  |  |   95|    713|#define TU_VERIFY(...)                 TU_GET_3RD_ARG(__VA_ARGS__, TU_VERIFY_2ARGS, TU_VERIFY_1ARGS, _dummy)(__VA_ARGS__)
  |  |  ------------------
  |  |  |  |  112|    713|#define TU_GET_3RD_ARG(arg1, arg2, arg3, ...)        arg3
  |  |  |  |  ------------------
  |  |  |  |  |  |   95|    713|#define TU_VERIFY(...)                 TU_GET_3RD_ARG(__VA_ARGS__, TU_VERIFY_2ARGS, TU_VERIFY_1ARGS, _dummy)(__VA_ARGS__)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   92|    713|#define TU_VERIFY_1ARGS(_cond)         TU_VERIFY_DEFINE(_cond, false)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   86|    713|  do {                                \
  |  |  |  |  |  |  |  |  |  |   87|    713|    if (!(_cond)) {                   \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (87:9): [True: 216, False: 497]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   88|    216|      return _ret;                    \
  |  |  |  |  |  |  |  |  |  |   89|    216|    }                                 \
  |  |  |  |  |  |  |  |  |  |   90|    713|  } while (0)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (90:12): [Folded, False: 497]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1382|       |
 1383|       |      // first byte of descriptor is its size
 1384|    497|      return tud_control_xfer(rhport, p_request, (void*) (uintptr_t) desc_str, tu_desc_len(desc_str));
 1385|    713|    }
 1386|       |    // break; // unreachable
 1387|       |
 1388|    194|    case TUSB_DESC_DEVICE_QUALIFIER: {
  ------------------
  |  Branch (1388:5): [True: 194, False: 1.83k]
  ------------------
 1389|    194|      TU_LOG_USBD(" Device Qualifier\r\n");
 1390|    194|      uint8_t const* desc_qualifier = tud_descriptor_device_qualifier_cb();
 1391|    194|      TU_VERIFY(desc_qualifier);
  ------------------
  |  |   95|    194|#define TU_VERIFY(...)                 TU_GET_3RD_ARG(__VA_ARGS__, TU_VERIFY_2ARGS, TU_VERIFY_1ARGS, _dummy)(__VA_ARGS__)
  |  |  ------------------
  |  |  |  |  112|    194|#define TU_GET_3RD_ARG(arg1, arg2, arg3, ...)        arg3
  |  |  |  |  ------------------
  |  |  |  |  |  |   95|    194|#define TU_VERIFY(...)                 TU_GET_3RD_ARG(__VA_ARGS__, TU_VERIFY_2ARGS, TU_VERIFY_1ARGS, _dummy)(__VA_ARGS__)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   92|    194|#define TU_VERIFY_1ARGS(_cond)         TU_VERIFY_DEFINE(_cond, false)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   86|    194|  do {                                \
  |  |  |  |  |  |  |  |  |  |   87|    194|    if (!(_cond)) {                   \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (87:9): [True: 194, False: 0]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   88|    194|      return _ret;                    \
  |  |  |  |  |  |  |  |  |  |   89|    194|    }                                 \
  |  |  |  |  |  |  |  |  |  |   90|    194|  } while (0)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (90:12): [Folded, False: 0]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1392|      0|      return tud_control_xfer(rhport, p_request, (void*) (uintptr_t) desc_qualifier, tu_desc_len(desc_qualifier));
 1393|    194|    }
 1394|       |    // break; // unreachable
 1395|       |
 1396|    242|    default: return false;
  ------------------
  |  Branch (1396:5): [True: 242, False: 1.78k]
  ------------------
 1397|  2.02k|  }
 1398|  2.02k|}
usbd.c:process_get_status:
 1075|  1.32k|static bool process_get_status(uint8_t rhport, tusb_control_request_t const * request, uint16_t status) {
 1076|  1.32k|  TU_VERIFY(request->bmRequestType_bit.direction == TUSB_DIR_IN);
  ------------------
  |  |   95|  1.32k|#define TU_VERIFY(...)                 TU_GET_3RD_ARG(__VA_ARGS__, TU_VERIFY_2ARGS, TU_VERIFY_1ARGS, _dummy)(__VA_ARGS__)
  |  |  ------------------
  |  |  |  |  112|  1.32k|#define TU_GET_3RD_ARG(arg1, arg2, arg3, ...)        arg3
  |  |  |  |  ------------------
  |  |  |  |  |  |   95|  1.32k|#define TU_VERIFY(...)                 TU_GET_3RD_ARG(__VA_ARGS__, TU_VERIFY_2ARGS, TU_VERIFY_1ARGS, _dummy)(__VA_ARGS__)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   92|  1.32k|#define TU_VERIFY_1ARGS(_cond)         TU_VERIFY_DEFINE(_cond, false)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   86|  1.32k|  do {                                \
  |  |  |  |  |  |  |  |  |  |   87|  1.32k|    if (!(_cond)) {                   \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (87:9): [True: 640, False: 688]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   88|    640|      return _ret;                    \
  |  |  |  |  |  |  |  |  |  |   89|    640|    }                                 \
  |  |  |  |  |  |  |  |  |  |   90|  1.32k|  } while (0)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (90:12): [Folded, False: 688]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1077|    688|  return tud_control_xfer(rhport, request, &status, 2);
 1078|  1.32k|}
usbd.c:queue_event:
  410|  28.8k|TU_ATTR_ALWAYS_INLINE static inline bool queue_event(dcd_event_t const * event, bool in_isr) {
  411|  28.8k|  TU_ASSERT(osal_queue_send(_usbd_q, event, in_isr));
  ------------------
  |  |  112|  28.8k|#define TU_ASSERT(...)                 TU_GET_3RD_ARG(__VA_ARGS__, TU_ASSERT_2ARGS, TU_ASSERT_1ARGS, _dummy)(__VA_ARGS__)
  |  |  ------------------
  |  |  |  |  112|  28.8k|#define TU_GET_3RD_ARG(arg1, arg2, arg3, ...)        arg3
  |  |  |  |  ------------------
  |  |  |  |  |  |  112|  28.8k|#define TU_ASSERT(...)                 TU_GET_3RD_ARG(__VA_ARGS__, TU_ASSERT_2ARGS, TU_ASSERT_1ARGS, _dummy)(__VA_ARGS__)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  108|  28.8k|#define TU_ASSERT_1ARGS(_cond)         TU_ASSERT_DEFINE(_cond, false)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  104|  28.8k|  do {                                                                \
  |  |  |  |  |  |  |  |  |  |  105|  28.8k|    if ( !(_cond) ) { TU_MESS_FAILED(); TU_BREAKPOINT(); return _ret; } \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   54|      0|  #define TU_MESS_FAILED() do {} while (0)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (54:41): [Folded, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |                   if ( !(_cond) ) { TU_MESS_FAILED(); TU_BREAKPOINT(); return _ret; } \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   77|      0|  #define TU_BREAKPOINT() do {} while (0)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (77:40): [Folded, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (105:10): [True: 0, False: 28.8k]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  106|  28.8k|  } while(0)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (106:11): [Folded, False: 28.8k]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  412|  28.8k|  tud_event_hook_cb(event->rhport, event->event_id, in_isr);
  413|       |  return true;
  414|  28.8k|}

fuzz.cc:_ZL8tud_taskv:
   76|  43.9k|void tud_task (void) {
   77|       |  tud_task_ext(UINT32_MAX, false);
   78|  43.9k|}

usbd.c:osal_spin_init:
   50|      1|TU_ATTR_ALWAYS_INLINE static inline void osal_spin_init(osal_spinlock_t *ctx) {
   51|      1|  (void) ctx;
   52|      1|}
usbd.c:osal_queue_create:
  176|      1|TU_ATTR_ALWAYS_INLINE static inline osal_queue_t osal_queue_create(osal_queue_def_t* qdef) {
  177|      1|  tu_fifo_clear(&qdef->ff);
  178|      1|  return (osal_queue_t) qdef;
  179|      1|}
usbd.c:osal_queue_receive:
  186|  72.8k|TU_ATTR_ALWAYS_INLINE static inline bool osal_queue_receive(osal_queue_t qhdl, void* data, uint32_t msec) {
  187|  72.8k|  (void) msec; // not used, always behave as msec = 0
  188|       |
  189|  72.8k|  qhdl->interrupt_set(false);
  190|  72.8k|  const bool success = (tu_fifo_read_n(&qhdl->ff, data, qhdl->item_size) > 0);
  191|  72.8k|  qhdl->interrupt_set(true);
  192|       |
  193|  72.8k|  return success;
  194|  72.8k|}
usbd.c:osal_queue_send:
  196|  28.8k|TU_ATTR_ALWAYS_INLINE static inline bool osal_queue_send(osal_queue_t qhdl, void const* data, bool in_isr) {
  197|  28.8k|  if (!in_isr) {
  ------------------
  |  Branch (197:7): [True: 14.9k, False: 13.9k]
  ------------------
  198|  14.9k|    qhdl->interrupt_set(false);
  199|  14.9k|  }
  200|       |
  201|  28.8k|  const bool success = (tu_fifo_write_n(&qhdl->ff, data, qhdl->item_size) > 0);
  202|       |
  203|  28.8k|  if (!in_isr) {
  ------------------
  |  Branch (203:7): [True: 14.9k, False: 13.9k]
  ------------------
  204|  14.9k|    qhdl->interrupt_set(true);
  205|  14.9k|  }
  206|       |
  207|  28.8k|  return success;
  208|  28.8k|}

tusb_rhport_init:
   65|    996|bool tusb_rhport_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
   66|       |  //  backward compatible called with tusb_init(void)
   67|       |  #if defined(TUD_OPT_RHPORT) || defined(TUH_OPT_RHPORT)
   68|       |  if (rh_init == NULL) {
   69|       |    #if CFG_TUD_ENABLED && defined(TUD_OPT_RHPORT)
   70|       |    // init device stack CFG_TUSB_RHPORTx_MODE must be defined
   71|       |    const tusb_rhport_init_t dev_init = {
   72|       |      .role = TUSB_ROLE_DEVICE,
   73|       |      .speed = TUD_OPT_HIGH_SPEED ? TUSB_SPEED_HIGH : TUSB_SPEED_FULL
   74|       |    };
   75|       |    TU_ASSERT ( tud_rhport_init(TUD_OPT_RHPORT, &dev_init) );
   76|       |    _tusb_rhport_role[TUD_OPT_RHPORT] = TUSB_ROLE_DEVICE;
   77|       |    #endif
   78|       |
   79|       |    #if CFG_TUH_ENABLED && defined(TUH_OPT_RHPORT)
   80|       |    // init host stack CFG_TUSB_RHPORTx_MODE must be defined
   81|       |    const tusb_rhport_init_t host_init = {
   82|       |      .role = TUSB_ROLE_HOST,
   83|       |      .speed = TUH_OPT_HIGH_SPEED ? TUSB_SPEED_HIGH : TUSB_SPEED_FULL
   84|       |    };
   85|       |    TU_ASSERT( tuh_rhport_init(TUH_OPT_RHPORT, &host_init) );
   86|       |    _tusb_rhport_role[TUH_OPT_RHPORT] = TUSB_ROLE_HOST;
   87|       |    #endif
   88|       |
   89|       |    return true;
   90|       |  }
   91|       |  #endif
   92|       |
   93|       |  // new API with explicit rhport and role
   94|    996|  TU_ASSERT(rhport < TUP_USBIP_CONTROLLER_NUM && rh_init->role != TUSB_ROLE_INVALID);
  ------------------
  |  |  112|    996|#define TU_ASSERT(...)                 TU_GET_3RD_ARG(__VA_ARGS__, TU_ASSERT_2ARGS, TU_ASSERT_1ARGS, _dummy)(__VA_ARGS__)
  |  |  ------------------
  |  |  |  |  112|    996|#define TU_GET_3RD_ARG(arg1, arg2, arg3, ...)        arg3
  |  |  |  |  ------------------
  |  |  |  |  |  |  112|    996|#define TU_ASSERT(...)                 TU_GET_3RD_ARG(__VA_ARGS__, TU_ASSERT_2ARGS, TU_ASSERT_1ARGS, _dummy)(__VA_ARGS__)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  108|    996|#define TU_ASSERT_1ARGS(_cond)         TU_ASSERT_DEFINE(_cond, false)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  104|    996|  do {                                                                \
  |  |  |  |  |  |  |  |  |  |  105|  1.99k|    if ( !(_cond) ) { TU_MESS_FAILED(); TU_BREAKPOINT(); return _ret; } \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   54|      0|  #define TU_MESS_FAILED() do {} while (0)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (54:41): [Folded, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |                   if ( !(_cond) ) { TU_MESS_FAILED(); TU_BREAKPOINT(); return _ret; } \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   77|      0|  #define TU_BREAKPOINT() do {} while (0)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (77:40): [Folded, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (105:12): [True: 996, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  Branch (105:12): [True: 996, False: 0]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  106|    996|  } while(0)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (106:11): [Folded, False: 996]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   95|    996|  _tusb_rhport_role[rhport] = rh_init->role;
   96|       |
   97|    996|  #if CFG_TUD_ENABLED
   98|    996|  if (rh_init->role == TUSB_ROLE_DEVICE) {
  ------------------
  |  Branch (98:7): [True: 996, False: 0]
  ------------------
   99|    996|    TU_ASSERT(tud_rhport_init(rhport, rh_init));
  ------------------
  |  |  112|    996|#define TU_ASSERT(...)                 TU_GET_3RD_ARG(__VA_ARGS__, TU_ASSERT_2ARGS, TU_ASSERT_1ARGS, _dummy)(__VA_ARGS__)
  |  |  ------------------
  |  |  |  |  112|    996|#define TU_GET_3RD_ARG(arg1, arg2, arg3, ...)        arg3
  |  |  |  |  ------------------
  |  |  |  |  |  |  112|    996|#define TU_ASSERT(...)                 TU_GET_3RD_ARG(__VA_ARGS__, TU_ASSERT_2ARGS, TU_ASSERT_1ARGS, _dummy)(__VA_ARGS__)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  108|    996|#define TU_ASSERT_1ARGS(_cond)         TU_ASSERT_DEFINE(_cond, false)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  104|    996|  do {                                                                \
  |  |  |  |  |  |  |  |  |  |  105|    996|    if ( !(_cond) ) { TU_MESS_FAILED(); TU_BREAKPOINT(); return _ret; } \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   54|      0|  #define TU_MESS_FAILED() do {} while (0)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (54:41): [Folded, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |                   if ( !(_cond) ) { TU_MESS_FAILED(); TU_BREAKPOINT(); return _ret; } \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   77|      0|  #define TU_BREAKPOINT() do {} while (0)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (77:40): [Folded, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (105:10): [True: 0, False: 996]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  106|    996|  } while(0)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (106:11): [Folded, False: 996]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  100|    996|  }
  101|    996|  #endif
  102|       |
  103|       |  #if CFG_TUH_ENABLED
  104|       |  if (rh_init->role == TUSB_ROLE_HOST) {
  105|       |    TU_ASSERT(tuh_rhport_init(rhport, rh_init));
  106|       |  }
  107|       |  #endif
  108|       |
  109|    996|  return true;
  110|    996|}

dcd_init:
   49|      1|bool dcd_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
   50|      1|  UNUSED(rhport);
  ------------------
  |  |   31|      1|#define UNUSED(x) (void)(x)
  ------------------
   51|      1|  UNUSED(rh_init);
  ------------------
  |  |   31|      1|#define UNUSED(x) (void)(x)
  ------------------
   52|      1|  return true;
   53|      1|}
dcd_int_handler:
   55|  43.9k|void dcd_int_handler(uint8_t rhport) {
   56|  43.9k|  assert(_fuzz_data_provider.has_value());
  ------------------
  |  Branch (56:3): [True: 43.9k, False: 0]
  ------------------
   57|       |
   58|  43.9k|  if (!state.interrupts_enabled) {
  ------------------
  |  Branch (58:7): [True: 0, False: 43.9k]
  ------------------
   59|      0|    return;
   60|      0|  }
   61|       |
   62|       |  // Choose if we want to generate a signal based on the fuzzed data.
   63|  43.9k|  if (_fuzz_data_provider->ConsumeBool()) {
  ------------------
  |  Branch (63:7): [True: 8.99k, False: 34.9k]
  ------------------
   64|       |    // Only generate bus signal events that don't carry additional union data.
   65|       |    // DCD_EVENT_XFER_COMPLETE, DCD_EVENT_SOF, and DCD_EVENT_BUS_RESET need
   66|       |    // properly initialized union fields; USBD_EVENT_FUNC_CALL is internal only.
   67|       |    // Valid bus-signal-only events: UNPLUGGED(2), SUSPEND(4), RESUME(5).
   68|  8.99k|    static const dcd_eventid_t bus_signal_events[] = {
   69|  8.99k|        DCD_EVENT_UNPLUGGED, DCD_EVENT_SUSPEND, DCD_EVENT_RESUME};
   70|  8.99k|    uint8_t idx = _fuzz_data_provider->ConsumeIntegralInRange<uint8_t>(0, 2);
   71|  8.99k|    dcd_event_bus_signal(rhport, bus_signal_events[idx],
   72|  8.99k|                         _fuzz_data_provider->ConsumeBool());
   73|  8.99k|  }
   74|       |
   75|       |  // Optionally generate a BUS_RESET event with a valid speed value.
   76|  43.9k|  if (_fuzz_data_provider->ConsumeBool()) {
  ------------------
  |  Branch (76:7): [True: 7.86k, False: 36.1k]
  ------------------
   77|  7.86k|    tusb_speed_t speed = (tusb_speed_t)_fuzz_data_provider->ConsumeIntegralInRange<uint8_t>(
   78|  7.86k|        TUSB_SPEED_FULL, TUSB_SPEED_HIGH);
   79|  7.86k|    dcd_event_bus_reset(rhport, speed, _fuzz_data_provider->ConsumeBool());
   80|  7.86k|  }
   81|       |
   82|  43.9k|  if (_fuzz_data_provider->ConsumeBool()) {
  ------------------
  |  Branch (82:7): [True: 15.3k, False: 28.6k]
  ------------------
   83|  15.3k|    constexpr size_t kSetupFrameLength = 8;
   84|  15.3k|    std::vector<uint8_t> setup =
   85|  15.3k|        _fuzz_data_provider->ConsumeBytes<uint8_t>(kSetupFrameLength);
   86|       |    // Fuzz consumer may return less than requested. If this is the case
   87|       |    // we want to make sure that at least that length is allocated and available
   88|       |    // to the signal handler.
   89|  15.3k|    if (setup.size() != kSetupFrameLength) {
  ------------------
  |  Branch (89:9): [True: 409, False: 14.9k]
  ------------------
   90|    409|      setup.resize(kSetupFrameLength);
   91|    409|    }
   92|  15.3k|    dcd_event_setup_received(rhport, setup.data(),
   93|       |                             // Identify trigger as either an interrupt or a
   94|       |                             // syncrhonous call depending on fuzz data.
   95|  15.3k|                             _fuzz_data_provider->ConsumeBool());
   96|  15.3k|  }
   97|  43.9k|}
dcd_int_enable:
   99|  87.7k|void dcd_int_enable(uint8_t rhport) {
  100|  87.7k|  state.interrupts_enabled = true;
  101|  87.7k|  UNUSED(rhport);
  ------------------
  |  |   31|  87.7k|#define UNUSED(x) (void)(x)
  ------------------
  102|  87.7k|  return;
  103|  87.7k|}
dcd_int_disable:
  105|  87.7k|void dcd_int_disable(uint8_t rhport) {
  106|  87.7k|  state.interrupts_enabled = false;
  107|  87.7k|  UNUSED(rhport);
  ------------------
  |  |   31|  87.7k|#define UNUSED(x) (void)(x)
  ------------------
  108|  87.7k|  return;
  109|  87.7k|}
dcd_set_address:
  111|    205|void dcd_set_address(uint8_t rhport, uint8_t dev_addr) {
  112|    205|  UNUSED(rhport);
  ------------------
  |  |   31|    205|#define UNUSED(x) (void)(x)
  ------------------
  113|    205|  state.address = dev_addr;
  114|       |  // Respond with status.
  115|       |  dcd_edpt_xfer(rhport, tu_edpt_addr(0, TUSB_DIR_IN), NULL, 0, false);
  116|    205|  return;
  117|    205|}
dcd_edpt_xfer:
  171|  4.44k|                   uint16_t total_bytes, bool is_isr) {
  172|  4.44k|  UNUSED(rhport);
  ------------------
  |  |   31|  4.44k|#define UNUSED(x) (void)(x)
  ------------------
  173|  4.44k|  UNUSED(buffer);
  ------------------
  |  |   31|  4.44k|#define UNUSED(x) (void)(x)
  ------------------
  174|  4.44k|  UNUSED(total_bytes);
  ------------------
  |  |   31|  4.44k|#define UNUSED(x) (void)(x)
  ------------------
  175|  4.44k|  UNUSED(is_isr);
  ------------------
  |  |   31|  4.44k|#define UNUSED(x) (void)(x)
  ------------------
  176|       |
  177|  4.44k|  uint8_t const dir = tu_edpt_dir(ep_addr);
  178|       |
  179|  4.44k|  if (dir == TUSB_DIR_IN) {
  ------------------
  |  Branch (179:7): [True: 3.46k, False: 973]
  ------------------
  180|  3.46k|    std::vector<uint8_t> temp =
  181|  3.46k|        _fuzz_data_provider->ConsumeBytes<uint8_t>(total_bytes);
  182|  3.46k|    std::copy(temp.begin(), temp.end(), buffer);
  183|  3.46k|  }
  184|       |  // Ignore output data as it's not useful for fuzzing without a more
  185|       |  // complex fuzzed backend. But we need to make sure it's not
  186|       |  // optimised out.
  187|  4.44k|  volatile uint8_t *dont_optimise0 = buffer;
  188|  4.44k|  volatile uint16_t dont_optimise1 = total_bytes;
  189|  4.44k|  UNUSED(dont_optimise0);
  ------------------
  |  |   31|  4.44k|#define UNUSED(x) (void)(x)
  ------------------
  190|  4.44k|  UNUSED(dont_optimise1);
  ------------------
  |  |   31|  4.44k|#define UNUSED(x) (void)(x)
  ------------------
  191|       |
  192|       |
  193|  4.44k|  return _fuzz_data_provider->ConsumeBool();
  194|  4.44k|}
dcd_edpt_stall:
  202|  16.1k|void dcd_edpt_stall(uint8_t rhport, uint8_t ep_addr) {
  203|       |
  204|  16.1k|  UNUSED(rhport);
  ------------------
  |  |   31|  16.1k|#define UNUSED(x) (void)(x)
  ------------------
  205|  16.1k|  UNUSED(ep_addr);
  ------------------
  |  |   31|  16.1k|#define UNUSED(x) (void)(x)
  ------------------
  206|  16.1k|  return;
  207|  16.1k|}

LLVMFuzzerTestOneInput:
   44|    996|extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
   45|    996|  FuzzedDataProvider provider(Data, Size);
   46|    996|  std::vector<uint8_t> callback_data = provider.ConsumeBytes<uint8_t>(
   47|    996|      provider.ConsumeIntegralInRange<size_t>(0, Size));
   48|    996|  fuzz_init(callback_data.data(), callback_data.size());
   49|    996|  tusb_rhport_init_t dev_init = {
   50|    996|    .role = TUSB_ROLE_DEVICE,
   51|    996|    .speed = TUSB_SPEED_AUTO
   52|    996|  };
   53|    996|  tusb_init(BOARD_TUD_RHPORT, &dev_init);
  ------------------
  |  |  147|    996|#define tusb_init(...)                       TU_FUNC_OPTIONAL_ARG(_tusb_init, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  115|    996|#define TU_FUNC_OPTIONAL_ARG(func, ...)   TU_XSTRCAT(func##_arg, TU_ARGS_NUM(__VA_ARGS__))(__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   15|    996|#define TU_XSTRCAT(a, b)      TU_STRCAT(a, b)     ///< expand then concat
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   13|    996|#define TU_STRCAT(a, b)       a##b                ///< concat without expand
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  146|    996|#define _tusb_init_arg2(_rhport, _rh_init)   tusb_rhport_init(_rhport, _rh_init)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   54|       |
   55|  44.9k|  for (int i = 0; i < FUZZ_ITERATIONS; i++) {
  ------------------
  |  |   42|  44.9k|#define FUZZ_ITERATIONS 500
  ------------------
  |  Branch (55:19): [True: 44.9k, False: 46]
  ------------------
   56|  44.9k|    if (provider.remaining_bytes() == 0) {
  ------------------
  |  Branch (56:9): [True: 950, False: 43.9k]
  ------------------
   57|    950|      return 0;
   58|    950|    }
   59|  43.9k|    tud_int_handler(provider.ConsumeIntegral<uint8_t>());
  ------------------
  |  |   88|  43.9k|#define tud_int_handler   dcd_int_handler
  ------------------
   60|  43.9k|    tud_task(); // tinyusb device task
   61|  43.9k|  }
   62|       |
   63|     46|  return 0;
   64|    996|}

tud_descriptor_device_cb:
   46|    224|uint8_t const *tud_descriptor_device_cb(void) {
   47|    224|  tu_static tusb_desc_device_t const desc_device = {
  ------------------
  |  |   39|    224|  #define tu_static static __thread
  ------------------
   48|    224|      .bLength = sizeof(tusb_desc_device_t),
   49|    224|      .bDescriptorType = TUSB_DESC_DEVICE,
   50|    224|      .bcdUSB = USB_BCD,
  ------------------
  |  |   38|    224|#define USB_BCD 0x0200
  ------------------
   51|       |
   52|       |      // Use Interface Association Descriptor (IAD) for CDC
   53|       |      // As required by USB Specs IAD's subclass must be common class (2) and
   54|       |      // protocol must be IAD (1)
   55|    224|      .bDeviceClass = TUSB_CLASS_MISC,
   56|    224|      .bDeviceSubClass = MISC_SUBCLASS_COMMON,
   57|    224|      .bDeviceProtocol = MISC_PROTOCOL_IAD,
   58|       |
   59|    224|      .bMaxPacketSize0 = CFG_TUD_ENDPOINT0_SIZE,
  ------------------
  |  |   90|    224|#define CFG_TUD_ENDPOINT0_SIZE    64
  ------------------
   60|       |
   61|    224|      .idVendor = USB_VID,
  ------------------
  |  |   37|    224|#define USB_VID 0xCafe
  ------------------
   62|    224|      .idProduct = USB_PID,
  ------------------
  |  |   35|    224|  (0x4000 | PID_MAP(MSC, 0) | PID_MAP(HID, 1) | PID_MAP(MIDI, 2) |          \
  |  |  ------------------
  |  |  |  |   33|    224|#define PID_MAP(itf, n) ((CFG_TUD_##itf) << (n))
  |  |  |  |  ------------------
  |  |  |  |  |  |   95|    224|#define CFG_TUD_MSC              1
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                 (0x4000 | PID_MAP(MSC, 0) | PID_MAP(HID, 1) | PID_MAP(MIDI, 2) |          \
  |  |  ------------------
  |  |  |  |   33|    224|#define PID_MAP(itf, n) ((CFG_TUD_##itf) << (n))
  |  |  |  |  ------------------
  |  |  |  |  |  |   96|    224|#define CFG_TUD_HID              0
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                 (0x4000 | PID_MAP(MSC, 0) | PID_MAP(HID, 1) | PID_MAP(MIDI, 2) |          \
  |  |  ------------------
  |  |  |  |   33|    224|#define PID_MAP(itf, n) ((CFG_TUD_##itf) << (n))
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|    224|#define CFG_TUD_MIDI             0
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   36|    224|   PID_MAP(VENDOR, 3))
  |  |  ------------------
  |  |  |  |   33|    224|#define PID_MAP(itf, n) ((CFG_TUD_##itf) << (n))
  |  |  |  |  ------------------
  |  |  |  |  |  |   98|    224|#define CFG_TUD_VENDOR           0
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   63|    224|      .bcdDevice = 0x0100,
   64|       |
   65|    224|      .iManufacturer = 0x01,
   66|    224|      .iProduct = 0x02,
   67|    224|      .iSerialNumber = 0x03,
   68|       |
   69|    224|      .bNumConfigurations = 0x01};
   70|       |
   71|    224|  return (uint8_t const *)&desc_device;
   72|    224|}
tud_descriptor_configuration_cb:
  161|    485|uint8_t const *tud_descriptor_configuration_cb(uint8_t index) {
  162|    485|  (void)index; // for multiple configurations
  163|       |
  164|       |#if TUD_OPT_HIGH_SPEED
  165|       |  // Although we are highspeed, host may be fullspeed.
  166|       |  return (tud_speed_get() == TUSB_SPEED_HIGH) ? desc_hs_configuration
  167|       |                                              : desc_fs_configuration;
  168|       |#else
  169|    485|  return desc_fs_configuration;
  170|    485|#endif
  171|    485|}
tud_descriptor_string_cb:
  192|    713|uint16_t const *tud_descriptor_string_cb(uint8_t index, uint16_t langid) {
  193|    713|  (void)langid;
  194|       |
  195|    713|  uint8_t chr_count;
  196|       |
  197|    713|  if (index == 0) {
  ------------------
  |  Branch (197:7): [True: 208, False: 505]
  ------------------
  198|    208|    memcpy(&_desc_str[1], string_desc_arr[0], 2);
  199|    208|    chr_count = 1;
  200|    505|  } else {
  201|       |    // Note: the 0xEE index string is a Microsoft OS 1.0 Descriptors.
  202|       |    // https://docs.microsoft.com/en-us/windows-hardware/drivers/usbcon/microsoft-defined-usb-descriptors
  203|       |
  204|    505|    if (!(index < sizeof(string_desc_arr) / sizeof(string_desc_arr[0])))
  ------------------
  |  Branch (204:9): [True: 216, False: 289]
  ------------------
  205|    216|      return NULL;
  206|       |
  207|    289|    const char *str = string_desc_arr[index];
  208|       |
  209|       |    // Cap at max char
  210|    289|    chr_count = (uint8_t)strlen(str);
  211|    289|    if (chr_count > 31)
  ------------------
  |  Branch (211:9): [True: 0, False: 289]
  ------------------
  212|      0|      chr_count = 31;
  213|       |
  214|       |    // Convert ASCII string into UTF-16
  215|  4.26k|    for (uint8_t i = 0; i < chr_count; i++) {
  ------------------
  |  Branch (215:25): [True: 3.97k, False: 289]
  ------------------
  216|  3.97k|      _desc_str[1 + i] = str[i];
  217|  3.97k|    }
  218|    289|  }
  219|       |
  220|       |  // first byte is length (including header), second byte is string type
  221|    497|  _desc_str[0] = (uint16_t)((TUSB_DESC_STRING << 8) | (2 * chr_count + 2));
  222|       |
  223|    497|  return _desc_str;
  224|    713|}

fuzz_init:
   31|    996|extern "C" int fuzz_init(const uint8_t *data, size_t size) {
   32|    996|  _fuzz_data_provider.emplace(data, size);
   33|    996|  return 0;
   34|    996|}

