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|  15.5k|void mscd_reset(uint8_t rhport) {
  348|  15.5k|  (void) rhport;
  349|  15.5k|  tu_memclr(&_mscd_itf, sizeof(mscd_interface_t));
  ------------------
  |  |   95|  15.5k|#define tu_memclr(buffer, size)  (void) memset((buffer), 0, (size))
  ------------------
  350|  15.5k|}
mscd_open:
  352|    212|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|    212|  TU_VERIFY(TUSB_CLASS_MSC    == itf_desc->bInterfaceClass &&
  ------------------
  |  |   95|    212|#define TU_VERIFY(...)                 TU_GET_3RD_ARG(__VA_ARGS__, TU_VERIFY_2ARGS, TU_VERIFY_1ARGS, _dummy)(__VA_ARGS__)
  |  |  ------------------
  |  |  |  |  112|    212|#define TU_GET_3RD_ARG(arg1, arg2, arg3, ...)        arg3
  |  |  |  |  ------------------
  |  |  |  |  |  |   95|    212|#define TU_VERIFY(...)                 TU_GET_3RD_ARG(__VA_ARGS__, TU_VERIFY_2ARGS, TU_VERIFY_1ARGS, _dummy)(__VA_ARGS__)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   93|    212|#define TU_VERIFY_2ARGS(_cond, _ret)   TU_VERIFY_DEFINE(_cond, _ret)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   86|    212|  do {                                \
  |  |  |  |  |  |  |  |  |  |   87|    848|    if (!(_cond)) {                   \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (87:11): [True: 212, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  Branch (87:11): [True: 212, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  Branch (87:11): [True: 212, False: 0]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   88|      0|      return _ret;                    \
  |  |  |  |  |  |  |  |  |  |   89|      0|    }                                 \
  |  |  |  |  |  |  |  |  |  |   90|    212|  } while (0)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (90:12): [Folded, False: 212]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  355|    212|            MSC_SUBCLASS_SCSI == itf_desc->bInterfaceSubClass &&
  356|    212|            MSC_PROTOCOL_BOT  == itf_desc->bInterfaceProtocol, 0);
  357|    212|  uint16_t const drv_len = sizeof(tusb_desc_interface_t) + 2*sizeof(tusb_desc_endpoint_t);
  358|    212|  TU_ASSERT(max_len >= drv_len, 0); // Max length must be at least 1 interface + 2 endpoints
  ------------------
  |  |  112|    212|#define TU_ASSERT(...)                 TU_GET_3RD_ARG(__VA_ARGS__, TU_ASSERT_2ARGS, TU_ASSERT_1ARGS, _dummy)(__VA_ARGS__)
  |  |  ------------------
  |  |  |  |  112|    212|#define TU_GET_3RD_ARG(arg1, arg2, arg3, ...)        arg3
  |  |  |  |  ------------------
  |  |  |  |  |  |  112|    212|#define TU_ASSERT(...)                 TU_GET_3RD_ARG(__VA_ARGS__, TU_ASSERT_2ARGS, TU_ASSERT_1ARGS, _dummy)(__VA_ARGS__)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  109|    212|#define TU_ASSERT_2ARGS(_cond, _ret)   TU_ASSERT_DEFINE(_cond, _ret)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  104|    212|  do {                                                                \
  |  |  |  |  |  |  |  |  |  |  105|    212|    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: 212]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  106|    212|  } while(0)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (106:11): [Folded, False: 212]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  359|       |
  360|    212|  mscd_interface_t * p_msc = &_mscd_itf;
  361|    212|  p_msc->itf_num = itf_desc->bInterfaceNumber;
  362|    212|  p_msc->rhport = rhport;
  363|       |
  364|       |  // Open endpoint pair
  365|    212|  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|    212|#define TU_ASSERT(...)                 TU_GET_3RD_ARG(__VA_ARGS__, TU_ASSERT_2ARGS, TU_ASSERT_1ARGS, _dummy)(__VA_ARGS__)
  |  |  ------------------
  |  |  |  |  112|    212|#define TU_GET_3RD_ARG(arg1, arg2, arg3, ...)        arg3
  |  |  |  |  ------------------
  |  |  |  |  |  |  112|    212|#define TU_ASSERT(...)                 TU_GET_3RD_ARG(__VA_ARGS__, TU_ASSERT_2ARGS, TU_ASSERT_1ARGS, _dummy)(__VA_ARGS__)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  109|    212|#define TU_ASSERT_2ARGS(_cond, _ret)   TU_ASSERT_DEFINE(_cond, _ret)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  104|    212|  do {                                                                \
  |  |  |  |  |  |  |  |  |  |  105|    212|    if ( !(_cond) ) { TU_MESS_FAILED(); TU_BREAKPOINT(); return _ret; } \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   54|    212|  #define TU_MESS_FAILED() do {} while (0)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (54:41): [Folded, False: 212]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |                   if ( !(_cond) ) { TU_MESS_FAILED(); TU_BREAKPOINT(); return _ret; } \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   77|    212|  #define TU_BREAKPOINT() do {} while (0)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (77:40): [Folded, False: 212]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (105:10): [True: 212, False: 0]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  106|    212|  } 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|  35.1k|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: 35.1k, False: 0]
  ------------------
usbd.c:tu_min16:
  187|  2.53k|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.44k, False: 82]
  ------------------
usbd.c:tu_memcpy_s:
  118|    366|TU_ATTR_ALWAYS_INLINE static inline int tu_memcpy_s(void *dest, size_t destsz, const void *src, size_t count) {
  119|    366|  if (dest == NULL) {
  ------------------
  |  Branch (119:7): [True: 0, False: 366]
  ------------------
  120|      0|    return -1;
  121|      0|  }
  122|       |
  123|    366|  if (count == 0u) {
  ------------------
  |  Branch (123:7): [True: 0, False: 366]
  ------------------
  124|      0|    return 0;
  125|      0|  }
  126|       |
  127|    366|  if (src == NULL) {
  ------------------
  |  Branch (127:7): [True: 0, False: 366]
  ------------------
  128|      0|    return -1;
  129|      0|  }
  130|       |
  131|    366|  if (count > destsz) {
  ------------------
  |  Branch (131:7): [True: 0, False: 366]
  ------------------
  132|      0|    return -1;
  133|      0|  }
  134|       |
  135|    366|  (void) memcpy(dest, src, count);
  136|    366|  return 0;
  137|    366|}
usbd.c:tu_u16_low:
  178|  5.10k|TU_ATTR_ALWAYS_INLINE static inline uint8_t tu_u16_low (uint16_t ui16) { return TU_U16_LOW(ui16); }
  ------------------
  |  |   27|  5.10k|#define TU_U16_LOW(_u16)              ((uint8_t) ((uint16_t) (_u16) & 0x00ffu))
  ------------------
usbd.c:tu_desc_in_bounds:
  371|    212|TU_ATTR_ALWAYS_INLINE static inline bool tu_desc_in_bounds(const uint8_t *p_desc, const uint8_t *desc_end) {
  372|    212|  return p_desc < desc_end && tu_desc_next(p_desc) <= desc_end;
  ------------------
  |  Branch (372:10): [True: 212, False: 0]
  |  Branch (372:31): [True: 212, False: 0]
  ------------------
  373|    212|}
usbd.c:tu_desc_type:
  362|    424|TU_ATTR_ALWAYS_INLINE static inline uint8_t tu_desc_type(void const* desc) {
  363|    424|  return ((uint8_t const*) desc)[DESC_OFFSET_TYPE];
  364|    424|}
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|    262|TU_ATTR_ALWAYS_INLINE static inline uint16_t tu_unaligned_read16(const void *mem) {
  253|    262|  tu_unaligned_uint16_t const *ua16 = (tu_unaligned_uint16_t const *) mem;
  254|    262|  return ua16->val;
  255|    262|}
usbd.c:tu_desc_len:
  357|    478|TU_ATTR_ALWAYS_INLINE static inline uint8_t tu_desc_len(void const* desc) {
  358|    478|  return ((uint8_t const*) desc)[DESC_OFFSET_LEN];
  359|    478|}
usbd.c:tu_desc_next:
  351|    212|TU_ATTR_ALWAYS_INLINE static inline uint8_t const * tu_desc_next(void const* desc) {
  352|    212|  uint8_t const* desc8 = (uint8_t const*) desc;
  353|    212|  return desc8 + desc8[DESC_OFFSET_LEN];
  354|    212|}
msc_device.c:tu_desc_next:
  351|    212|TU_ATTR_ALWAYS_INLINE static inline uint8_t const * tu_desc_next(void const* desc) {
  352|    212|  uint8_t const* desc8 = (uint8_t const*) desc;
  353|    212|  return desc8 + desc8[DESC_OFFSET_LEN];
  354|    212|}

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|  77.9k|                                    const tu_hwfifo_access_t *access_mode) {
  445|  77.9k|  uint16_t count = tu_ff_overflow_count(f->depth, wr_idx, rd_idx);
  446|  77.9k|  if (count == 0) {
  ------------------
  |  Branch (446:7): [True: 42.7k, False: 35.1k]
  ------------------
  447|  42.7k|    return 0; // nothing to peek
  448|  42.7k|  }
  449|       |
  450|       |  // Check overflow and correct if required
  451|  35.1k|  if (count > f->depth) {
  ------------------
  |  Branch (451:7): [True: 0, False: 35.1k]
  ------------------
  452|      0|    rd_idx = correct_read_index(f, wr_idx);
  453|      0|    count  = f->depth;
  454|      0|  }
  455|       |
  456|  35.1k|  if (count < n) {
  ------------------
  |  Branch (456:7): [True: 0, False: 35.1k]
  ------------------
  457|      0|    n = count; // limit to available count
  458|      0|  }
  459|       |
  460|  35.1k|  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|  35.1k|  {
  468|  35.1k|    (void)access_mode;
  469|  35.1k|    ff_pull_n(f, p_buffer, n, rd_ptr);
  470|  35.1k|  }
  471|       |
  472|  35.1k|  return n;
  473|  77.9k|}
tu_fifo_read_n_access_mode:
  486|  77.9k|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|  77.9k|  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|  77.9k|  const uint16_t wr_idx = f->wr_idx;
  491|  77.9k|  n         = tu_fifo_peek_n_access_mode(f, buffer, n, wr_idx, f->rd_idx, access_mode);
  492|  77.9k|  f->rd_idx = advance_index(f->depth, f->rd_idx, n);
  493|       |
  494|  77.9k|  ff_unlock(f->mutex_rd);
  495|  77.9k|  return n;
  496|  77.9k|}
tu_fifo_write_n_access_mode:
  500|  35.1k|                                     const tu_hwfifo_access_t *access_mode) {
  501|  35.1k|  if (n == 0) {
  ------------------
  |  Branch (501:7): [True: 0, False: 35.1k]
  ------------------
  502|      0|    return 0;
  503|      0|  }
  504|       |
  505|  35.1k|  ff_lock(f->mutex_wr);
  506|       |
  507|  35.1k|  uint16_t wr_idx = f->wr_idx;
  508|  35.1k|  uint16_t rd_idx = f->rd_idx;
  509|       |
  510|  35.1k|  const uint8_t *buf8 = (const uint8_t *)data;
  511|       |
  512|  35.1k|  TU_LOG(TU_FIFO_DBG, "rd = %3u, wr = %3u, count = %3u, remain = %3u, n = %3u:  ", rd_idx, wr_idx,
  513|  35.1k|         tu_ff_overflow_count(f->depth, wr_idx, rd_idx), tu_ff_remaining_local(f->depth, wr_idx, rd_idx), n);
  514|       |
  515|  35.1k|  if (!f->overwritable) {
  ------------------
  |  Branch (515:7): [True: 35.1k, False: 0]
  ------------------
  516|       |    // limit up to full
  517|  35.1k|    const uint16_t remain = tu_ff_remaining_local(f->depth, wr_idx, rd_idx);
  518|  35.1k|    n                     = tu_min16(n, remain);
  519|  35.1k|  } 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|  35.1k|  if (n) {
  ------------------
  |  Branch (558:7): [True: 35.1k, False: 0]
  ------------------
  559|  35.1k|    const uint16_t wr_ptr = idx2ptr(f->depth, wr_idx);
  560|  35.1k|    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|  35.1k|    {
  568|  35.1k|      ff_push_n(f, buf8, n, wr_ptr);
  569|  35.1k|    }
  570|  35.1k|    f->wr_idx = advance_index(f->depth, wr_idx, n);
  571|       |
  572|  35.1k|    TU_LOG(TU_FIFO_DBG, "\tnew_wr = %u\r\n", f->wr_idx);
  573|  35.1k|  }
  574|       |
  575|  35.1k|  ff_unlock(f->mutex_wr);
  576|       |
  577|  35.1k|  return n;
  578|  35.1k|}
tusb_fifo.c:idx2ptr:
  415|  70.2k|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|   105k|  while (idx >= depth) {
  ------------------
  |  Branch (417:10): [True: 35.1k, False: 70.2k]
  ------------------
  418|  35.1k|    idx -= depth;
  419|  35.1k|  }
  420|  70.2k|  return idx;
  421|  70.2k|}
tusb_fifo.c:ff_pull_n:
  379|  35.1k|static void ff_pull_n(const tu_fifo_t *f, void *app_buf, uint16_t n, uint16_t rd_ptr) {
  380|  35.1k|  uint16_t       lin_bytes  = f->depth - rd_ptr;
  381|  35.1k|  uint16_t       wrap_bytes = n - lin_bytes; // only used if wrapped
  382|  35.1k|  const uint8_t *ff_buf     = f->buffer + rd_ptr;
  383|       |
  384|       |  // single byte access
  385|  35.1k|  if (n <= lin_bytes) {
  ------------------
  |  Branch (385:7): [True: 35.1k, False: 0]
  ------------------
  386|       |    // Linear only
  387|  35.1k|    memcpy(app_buf, ff_buf, n);
  388|  35.1k|  } 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|  35.1k|}
tusb_fifo.c:advance_index:
  401|   113k|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|   113k|  uint16_t new_idx = (uint16_t)(idx + offset);
  406|   113k|  if ((idx > new_idx) || (new_idx >= 2 * depth)) {
  ------------------
  |  Branch (406:7): [True: 0, False: 113k]
  |  Branch (406:26): [True: 2.19k, False: 110k]
  ------------------
  407|  2.19k|    const uint16_t non_used_index_space = (uint16_t)(UINT16_MAX - (2 * depth - 1));
  408|  2.19k|    new_idx                             = (uint16_t)(new_idx + non_used_index_space);
  409|  2.19k|  }
  410|       |
  411|   113k|  return new_idx;
  412|   113k|}
tusb_fifo.c:ff_push_n:
  363|  35.1k|static void ff_push_n(const tu_fifo_t *f, const void *app_buf, uint16_t n, uint16_t wr_ptr) {
  364|  35.1k|  uint16_t lin_bytes  = f->depth - wr_ptr;
  365|  35.1k|  uint16_t wrap_bytes = n - lin_bytes;
  366|  35.1k|  uint8_t *ff_buf     = f->buffer + wr_ptr;
  367|       |
  368|  35.1k|  if (n <= lin_bytes) {
  ------------------
  |  Branch (368:7): [True: 35.1k, False: 0]
  ------------------
  369|       |    // Linear only case
  370|  35.1k|    memcpy(ff_buf, app_buf, n);
  371|  35.1k|  } 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|  35.1k|}

tusb_fifo.c:tu_ff_overflow_count:
  243|   113k|TU_ATTR_ALWAYS_INLINE static inline uint16_t tu_ff_overflow_count(uint16_t depth, uint16_t wr_idx, uint16_t rd_idx) {
  244|   113k|  const int32_t diff = (int32_t)wr_idx - (int32_t)rd_idx;
  245|   113k|  if (diff >= 0) {
  ------------------
  |  Branch (245:7): [True: 110k, False: 2.40k]
  ------------------
  246|   110k|    return (uint16_t)diff;
  247|   110k|  } else {
  248|  2.40k|    return (uint16_t)(2 * depth + diff);
  249|  2.40k|  }
  250|   113k|}
tusb_fifo.c:tu_ff_remaining_local:
  253|  35.1k|TU_ATTR_ALWAYS_INLINE static inline uint16_t tu_ff_remaining_local(uint16_t depth, uint16_t wr_idx, uint16_t rd_idx) {
  254|  35.1k|  const uint16_t ovf_count = tu_ff_overflow_count(depth, wr_idx, rd_idx);
  255|  35.1k|  return (depth > ovf_count) ? (depth - ovf_count) : 0;
  ------------------
  |  Branch (255:10): [True: 35.1k, False: 0]
  ------------------
  256|  35.1k|}
usbd.c:tu_fifo_read_n:
  192|  77.9k|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|  77.9k|}
usbd.c:tu_fifo_write_n:
  205|  35.1k|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|  35.1k|}

usbd.c:tu_edpt_number:
  561|  5.92k|TU_ATTR_ALWAYS_INLINE static inline uint8_t tu_edpt_number(uint8_t addr) {
  562|  5.92k|  return (uint8_t) (addr & TUSB_EPNUM_MASK);
  563|  5.92k|}
usbd.c:tu_edpt_dir:
  556|  5.71k|TU_ATTR_ALWAYS_INLINE static inline tusb_dir_t tu_edpt_dir(uint8_t addr) {
  557|  5.71k|  return (addr & TUSB_DIR_IN_MASK) ? TUSB_DIR_IN : TUSB_DIR_OUT;
  ------------------
  |  Branch (557:10): [True: 3.00k, False: 2.70k]
  ------------------
  558|  5.71k|}
dcd_fuzz.cc:_ZL12tu_edpt_addrhh:
  565|    201|TU_ATTR_ALWAYS_INLINE static inline uint8_t tu_edpt_addr(uint8_t num, uint8_t dir) {
  566|    201|  return (uint8_t) (num | (dir == (uint8_t)TUSB_DIR_IN ? (uint8_t)TUSB_DIR_IN_MASK : 0u));
  ------------------
  |  Branch (566:28): [True: 201, False: 0]
  ------------------
  567|    201|}
dcd_fuzz.cc:_ZL11tu_edpt_dirh:
  556|  3.80k|TU_ATTR_ALWAYS_INLINE static inline tusb_dir_t tu_edpt_dir(uint8_t addr) {
  557|  3.80k|  return (addr & TUSB_DIR_IN_MASK) ? TUSB_DIR_IN : TUSB_DIR_OUT;
  ------------------
  |  Branch (557:10): [True: 2.89k, False: 913]
  ------------------
  558|  3.80k|}

dcd_fuzz.cc:_ZL20dcd_event_bus_signalh13dcd_eventid_tb:
  181|  11.2k|TU_ATTR_ALWAYS_INLINE static inline void dcd_event_bus_signal (uint8_t rhport, dcd_eventid_t eid, bool in_isr) {
  182|  11.2k|  dcd_event_t event;
  183|  11.2k|  event.rhport = rhport;
  184|  11.2k|  event.event_id = eid;
  185|  11.2k|  dcd_event_handler(&event, in_isr);
  186|  11.2k|}
dcd_fuzz.cc:_ZL19dcd_event_bus_reseth12tusb_speed_tb:
  189|  10.3k|TU_ATTR_ALWAYS_INLINE static inline  void dcd_event_bus_reset (uint8_t rhport, tusb_speed_t speed, bool in_isr) {
  190|  10.3k|  dcd_event_t event;
  191|  10.3k|  event.rhport = rhport;
  192|  10.3k|  event.event_id = DCD_EVENT_BUS_RESET;
  193|  10.3k|  event.bus_reset.speed = speed;
  194|  10.3k|  dcd_event_handler(&event, in_isr);
  195|  10.3k|}
dcd_fuzz.cc:_ZL24dcd_event_setup_receivedhPKhb:
  198|  15.1k|TU_ATTR_ALWAYS_INLINE static inline void dcd_event_setup_received(uint8_t rhport, uint8_t const * setup, bool in_isr) {
  199|  15.1k|  dcd_event_t event;
  200|  15.1k|  event.rhport = rhport;
  201|  15.1k|  event.event_id = DCD_EVENT_SETUP_RECEIVED;
  202|  15.1k|  (void) memcpy(&event.setup_received, setup, sizeof(tusb_control_request_t));
  203|       |  // USB wire format is little-endian. Convert multi-byte fields to host byte order
  204|       |  // so the stack always sees correct values regardless of CPU endianness.
  205|  15.1k|  event.setup_received.wValue  = tu_le16toh(event.setup_received.wValue);
  ------------------
  |  |  253|  15.1k|  #define tu_le16toh(u16) (u16)
  ------------------
  206|  15.1k|  event.setup_received.wIndex  = tu_le16toh(event.setup_received.wIndex);
  ------------------
  |  |  253|  15.1k|  #define tu_le16toh(u16) (u16)
  ------------------
  207|  15.1k|  event.setup_received.wLength = tu_le16toh(event.setup_received.wLength);
  ------------------
  |  |  253|  15.1k|  #define tu_le16toh(u16) (u16)
  ------------------
  208|  15.1k|  dcd_event_handler(&event, in_isr);
  209|  15.1k|}

tud_event_hook_cb:
   29|  35.1k|TU_ATTR_WEAK void tud_event_hook_cb(uint8_t rhport, uint32_t eventid, bool in_isr) {
   30|  35.1k|  (void) rhport; (void) eventid; (void) in_isr;
   31|  35.1k|}
tud_descriptor_bos_cb:
   37|    202|TU_ATTR_WEAK uint8_t const* tud_descriptor_bos_cb(void) {
   38|       |  return NULL;
   39|    202|}
tud_descriptor_device_qualifier_cb:
   41|    197|TU_ATTR_WEAK uint8_t const* tud_descriptor_device_qualifier_cb(void) {
   42|       |  return NULL;
   43|    197|}
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|  5.26k|TU_ATTR_WEAK void tud_umount_cb(void) {
   54|  5.26k|}
tud_suspend_cb:
   56|  2.58k|TU_ATTR_WEAK void tud_suspend_cb(bool remote_wakeup_en) {
   57|  2.58k|  (void) remote_wakeup_en;
   58|  2.58k|}
tud_resume_cb:
   60|  1.87k|TU_ATTR_WEAK void tud_resume_cb(void) {
   61|  1.87k|}
tud_vendor_control_xfer_cb:
   63|  1.59k|TU_ATTR_WEAK bool tud_vendor_control_xfer_cb(uint8_t rhport, uint8_t stage, tusb_control_request_t const* request) {
   64|  1.59k|  (void) rhport; (void) stage; (void) request;
   65|       |  return false;
   66|  1.59k|}
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:
  511|  43.7k|bool tud_inited(void) {
  512|  43.7k|  return _usbd_rhport != RHPORT_INVALID;
  513|  43.7k|}
tud_rhport_init:
  519|  1.00k|bool tud_rhport_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
  520|  1.00k|  if (tud_inited()) {
  ------------------
  |  Branch (520:7): [True: 1.00k, False: 1]
  ------------------
  521|  1.00k|    return true; // skip if already initialized
  522|  1.00k|  }
  523|      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]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  524|       | #if CFG_TUSB_DEBUG >= CFG_TUD_LOG_LEVEL
  525|       |  char const* speed_str = 0;
  526|       |  switch (rh_init->speed) {
  527|       |    case TUSB_SPEED_HIGH:
  528|       |      speed_str = "High";
  529|       |    break;
  530|       |    case TUSB_SPEED_FULL:
  531|       |      speed_str = "Full";
  532|       |    break;
  533|       |    case TUSB_SPEED_LOW:
  534|       |      speed_str = "Low";
  535|       |    break;
  536|       |    case TUSB_SPEED_AUTO:
  537|       |      speed_str = "Auto";
  538|       |    break;
  539|       |  default:
  540|       |    break;
  541|       |  }
  542|       |  TU_LOG_USBD("USBD init on controller %u, speed = %s\r\n", rhport, speed_str);
  543|       |  TU_LOG_INT(CFG_TUD_LOG_LEVEL, sizeof(usbd_device_t));
  544|       |  TU_LOG_INT(CFG_TUD_LOG_LEVEL, sizeof(dcd_event_t));
  545|       |  TU_LOG_INT(CFG_TUD_LOG_LEVEL, sizeof(tu_fifo_t));
  546|       |  TU_LOG_INT(CFG_TUD_LOG_LEVEL, sizeof(tu_edpt_stream_t));
  547|       |#endif
  548|       |
  549|      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))
  |  |  ------------------
  ------------------
  550|      1|  _usbd_queued_setup = 0;
  551|       |
  552|      1|  osal_spin_init(&_usbd_spin);
  553|       |
  554|       |#if OSAL_MUTEX_REQUIRED
  555|       |  // Init device mutex
  556|       |  _usbd_mutex = osal_mutex_create(&_ubsd_mutexdef);
  557|       |  TU_ASSERT(_usbd_mutex);
  558|       |#endif
  559|       |
  560|       |  // Init device queue & task
  561|      1|  _usbd_q = osal_queue_create(&_usbd_qdef);
  562|      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]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  563|       |
  564|       |  // Get application driver if available
  565|      1|  _app_driver = usbd_app_driver_get_cb(&_app_driver_count);
  566|      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]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  567|       |
  568|       |  // Init class drivers
  569|      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 (569:23): [True: 1, False: 1]
  ------------------
  570|      1|    usbd_class_driver_t const* driver = get_driver(i);
  571|      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]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  572|      1|    TU_LOG_USBD("%s init\r\n", driver->name);
  573|      1|    driver->init();
  574|      1|  }
  575|       |
  576|      1|  _usbd_rhport = rhport;
  577|       |
  578|       |  // Init device controller driver
  579|      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]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  580|      1|  dcd_int_enable(rhport);
  581|       |
  582|       |  return true;
  583|      1|}
tud_task_ext:
  669|  42.7k|void tud_task_ext(uint32_t timeout_ms, bool in_isr) {
  670|  42.7k|  (void) in_isr; // not implemented yet
  671|       |
  672|       |  // Skip if stack is not initialized
  673|  42.7k|  if (!tud_inited()) {
  ------------------
  |  Branch (673:7): [True: 0, False: 42.7k]
  ------------------
  674|      0|    return;
  675|      0|  }
  676|       |
  677|       |  // Loop until there are no more events in the queue or CFG_TUD_TASK_EVENTS_PER_RUN is reached
  678|  77.9k|  for (unsigned epr = 0;; epr++) {
  679|  77.9k|#if CFG_TUD_TASK_EVENTS_PER_RUN > 0
  680|  77.9k|    if (epr >= CFG_TUD_TASK_EVENTS_PER_RUN) {
  ------------------
  |  |  640|  77.9k|  #define CFG_TUD_TASK_EVENTS_PER_RUN  16
  ------------------
  |  Branch (680:9): [True: 0, False: 77.9k]
  ------------------
  681|      0|      TU_LOG_USBD("USBD event limit (" TU_XSTRING(CFG_TUD_TASK_EVENTS_PER_RUN) ") reached\r\n");
  682|      0|      break;
  683|      0|    }
  684|  77.9k|#endif
  685|  77.9k|    dcd_event_t event;
  686|  77.9k|    if (!osal_queue_receive(_usbd_q, &event, timeout_ms)) {
  ------------------
  |  Branch (686:9): [True: 42.7k, False: 35.1k]
  ------------------
  687|  42.7k|      return;
  688|  42.7k|    }
  689|       |
  690|       |#if CFG_TUSB_DEBUG >= CFG_TUD_LOG_LEVEL
  691|       |    if (event.event_id == DCD_EVENT_SETUP_RECEIVED) {
  692|       |      TU_LOG_USBD("\r\n"); // extra line for setup
  693|       |    }
  694|       |    TU_LOG_USBD("USBD %s ", event.event_id < DCD_EVENT_COUNT ? _usbd_event_str[event.event_id] : "CORRUPTED");
  695|       |#endif
  696|       |
  697|  35.1k|    switch (event.event_id) {
  698|  10.3k|      case DCD_EVENT_BUS_RESET:
  ------------------
  |  Branch (698:7): [True: 10.3k, False: 24.8k]
  ------------------
  699|  10.3k|        TU_LOG_USBD(": %s Speed\r\n", tu_str_speed[event.bus_reset.speed]);
  700|  10.3k|        usbd_reset(event.rhport);
  701|  10.3k|        _usbd_dev.speed = event.bus_reset.speed;
  702|  10.3k|        break;
  703|       |
  704|  5.26k|      case DCD_EVENT_UNPLUGGED:
  ------------------
  |  Branch (704:7): [True: 5.26k, False: 29.8k]
  ------------------
  705|  5.26k|        TU_LOG_USBD("\r\n");
  706|  5.26k|        usbd_reset(event.rhport);
  707|  5.26k|        tud_umount_cb();
  708|  5.26k|        break;
  709|       |
  710|  15.1k|      case DCD_EVENT_SETUP_RECEIVED:
  ------------------
  |  Branch (710:7): [True: 15.1k, False: 20.0k]
  ------------------
  711|  15.1k|        if (_usbd_queued_setup == 0) {
  ------------------
  |  Branch (711:13): [True: 0, False: 15.1k]
  ------------------
  712|      0|          break;
  713|      0|        }
  714|  15.1k|        _usbd_queued_setup--;
  715|  15.1k|        TU_LOG_BUF(CFG_TUD_LOG_LEVEL, &event.setup_received, 8);
  716|  15.1k|        if (_usbd_queued_setup != 0) {
  ------------------
  |  Branch (716:13): [True: 0, False: 15.1k]
  ------------------
  717|      0|          TU_LOG_USBD("  Skipped since there is other SETUP in queue\r\n");
  718|      0|          break;
  719|      0|        }
  720|       |
  721|       |        // Mark as connected after receiving 1st setup packet.
  722|       |        // But it is easier to set it every time instead of wasting time to check then set
  723|  15.1k|        _usbd_dev.connected = 1;
  724|       |
  725|       |        // reset ep state
  726|  15.1k|        _usbd_dev.ep_status[0][TUSB_DIR_OUT] = 0;
  727|  15.1k|        _usbd_dev.ep_status[0][TUSB_DIR_IN] = 0;
  728|       |
  729|       |        // Process control request
  730|  15.1k|        if (!process_setup_received(event.rhport, &event.setup_received)) {
  ------------------
  |  Branch (730:13): [True: 12.0k, False: 3.08k]
  ------------------
  731|  12.0k|          TU_LOG_USBD("  Stall EP0\r\n");
  732|       |          // Failed -> stall both control endpoint IN and OUT
  733|  12.0k|          dcd_edpt_stall(event.rhport, TU_EP0_OUT);
  734|  12.0k|          dcd_edpt_stall(event.rhport, TU_EP0_IN);
  735|  12.0k|        }
  736|  15.1k|        break;
  737|       |
  738|      0|      case DCD_EVENT_XFER_COMPLETE: {
  ------------------
  |  Branch (738:7): [True: 0, False: 35.1k]
  ------------------
  739|       |        // Invoke the class callback associated with the endpoint address
  740|      0|        uint8_t const ep_addr = event.xfer_complete.ep_addr;
  741|      0|        uint8_t const epnum = tu_edpt_number(ep_addr);
  742|      0|        uint8_t const ep_dir = tu_edpt_dir(ep_addr);
  743|       |
  744|      0|        TU_LOG_USBD("on EP %02X with %u bytes\r\n", ep_addr, (unsigned int) event.xfer_complete.len);
  745|       |
  746|       |        // Clear busy + claimed
  747|      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
  ------------------
  748|       |
  749|      0|        if (0 == epnum) {
  ------------------
  |  Branch (749:13): [True: 0, False: 0]
  ------------------
  750|      0|          usbd_control_xfer_cb(event.rhport, ep_addr, (xfer_result_t) event.xfer_complete.result, event.xfer_complete.len);
  751|      0|        } else {
  752|      0|          usbd_class_driver_t const* driver = get_driver(_usbd_dev.ep2drv[epnum][ep_dir]);
  753|      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]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  754|       |
  755|      0|          TU_LOG_USBD("  %s xfer callback\r\n", driver->name);
  756|      0|          driver->xfer_cb(event.rhport, ep_addr, (xfer_result_t) event.xfer_complete.result, event.xfer_complete.len);
  757|      0|        }
  758|      0|        break;
  759|      0|      }
  760|       |
  761|  2.58k|      case DCD_EVENT_SUSPEND:
  ------------------
  |  Branch (761:7): [True: 2.58k, False: 32.5k]
  ------------------
  762|       |        // NOTE: When plugging/unplugging device, the D+/D- state are unstable and
  763|       |        // can accidentally meet the SUSPEND condition ( Bus Idle for 3ms ), which result in a series of event
  764|       |        // e.g suspend -> resume -> unplug/plug. Skip suspend/resume if not connected
  765|  2.58k|        if (_usbd_dev.connected) {
  ------------------
  |  Branch (765:13): [True: 2.58k, False: 0]
  ------------------
  766|  2.58k|          TU_LOG_USBD(": Remote Wakeup = %u\r\n", _usbd_dev.remote_wakeup_en);
  767|  2.58k|          tud_suspend_cb(_usbd_dev.remote_wakeup_en);
  768|  2.58k|        } else {
  769|      0|          TU_LOG_USBD(" Skipped\r\n");
  770|      0|        }
  771|  2.58k|        break;
  772|       |
  773|  1.87k|      case DCD_EVENT_RESUME:
  ------------------
  |  Branch (773:7): [True: 1.87k, False: 33.2k]
  ------------------
  774|  1.87k|        if (_usbd_dev.connected) {
  ------------------
  |  Branch (774:13): [True: 1.87k, False: 0]
  ------------------
  775|  1.87k|          TU_LOG_USBD("\r\n");
  776|  1.87k|          tud_resume_cb();
  777|  1.87k|        } else {
  778|      0|          TU_LOG_USBD(" Skipped\r\n");
  779|      0|        }
  780|  1.87k|        break;
  781|       |
  782|      0|      case USBD_EVENT_FUNC_CALL:
  ------------------
  |  Branch (782:7): [True: 0, False: 35.1k]
  ------------------
  783|      0|        TU_LOG_USBD("\r\n");
  784|      0|        if (event.func_call.func != NULL) {
  ------------------
  |  Branch (784:13): [True: 0, False: 0]
  ------------------
  785|      0|          event.func_call.func(event.func_call.param);
  786|      0|        }
  787|      0|        break;
  788|       |
  789|      0|      case DCD_EVENT_SOF:
  ------------------
  |  Branch (789:7): [True: 0, False: 35.1k]
  ------------------
  790|      0|        if (tu_bit_test(_usbd_dev.sof_consumer, SOF_CONSUMER_USER)) {
  ------------------
  |  Branch (790:13): [True: 0, False: 0]
  ------------------
  791|      0|          TU_LOG_USBD("\r\n");
  792|      0|          tud_sof_cb(event.sof.frame_count);
  793|      0|        }
  794|      0|      break;
  795|       |
  796|      0|      default:
  ------------------
  |  Branch (796:7): [True: 0, False: 35.1k]
  ------------------
  797|      0|        TU_BREAKPOINT();
  ------------------
  |  |   77|      0|  #define TU_BREAKPOINT() do {} while (0)
  |  |  ------------------
  |  |  |  Branch (77:40): [Folded, False: 0]
  |  |  ------------------
  ------------------
  798|      0|        break;
  799|  35.1k|    }
  800|       |
  801|       |    // allow to exit tud_task() if there is no event in the next run
  802|  35.1k|    timeout_ms = 0;
  803|  35.1k|  }
  804|  42.7k|}
tud_control_status:
  850|  2.31k|bool tud_control_status(uint8_t rhport, const tusb_control_request_t* request) {
  851|       |  // _usbd_dev.ctrl_xfer fields are pre-initialized at process_setup_received entry
  852|  2.31k|  (void) request;
  853|  2.31k|  return status_stage_xact(rhport, status_stage_ep(&_usbd_dev.ctrl_xfer.request));
  854|  2.31k|}
tud_control_xfer:
  857|  1.29k|bool tud_control_xfer(uint8_t rhport, const tusb_control_request_t* request, void* buffer, uint16_t len) {
  858|       |  // _usbd_dev.ctrl_xfer.request and reset fields are pre-initialized at process_setup_received entry
  859|  1.29k|  (void) request;
  860|  1.29k|  usbd_control_xfer_t* const ctrl_xfer = &_usbd_dev.ctrl_xfer;
  861|  1.29k|  ctrl_xfer->buffer = (uint8_t*) buffer;
  862|  1.29k|  ctrl_xfer->data_len = tu_min16(len, ctrl_xfer->request.wLength);
  863|       |
  864|  1.29k|  if (ctrl_xfer->request.wLength > 0U) {
  ------------------
  |  Branch (864:7): [True: 1.23k, False: 58]
  ------------------
  865|  1.23k|    if (ctrl_xfer->data_len > 0U) {
  ------------------
  |  Branch (865:9): [True: 1.23k, False: 0]
  ------------------
  866|  1.23k|      TU_ASSERT(buffer);
  ------------------
  |  |  112|  1.23k|#define TU_ASSERT(...)                 TU_GET_3RD_ARG(__VA_ARGS__, TU_ASSERT_2ARGS, TU_ASSERT_1ARGS, _dummy)(__VA_ARGS__)
  |  |  ------------------
  |  |  |  |  112|  1.23k|#define TU_GET_3RD_ARG(arg1, arg2, arg3, ...)        arg3
  |  |  |  |  ------------------
  |  |  |  |  |  |  112|  1.23k|#define TU_ASSERT(...)                 TU_GET_3RD_ARG(__VA_ARGS__, TU_ASSERT_2ARGS, TU_ASSERT_1ARGS, _dummy)(__VA_ARGS__)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  108|  1.23k|#define TU_ASSERT_1ARGS(_cond)         TU_ASSERT_DEFINE(_cond, false)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  104|  1.23k|  do {                                                                \
  |  |  |  |  |  |  |  |  |  |  105|  1.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: 1.23k]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  106|  1.23k|  } while(0)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (106:11): [Folded, False: 1.23k]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  867|  1.23k|    }
  868|  1.23k|    TU_ASSERT(data_stage_xact(rhport));
  ------------------
  |  |  112|  1.23k|#define TU_ASSERT(...)                 TU_GET_3RD_ARG(__VA_ARGS__, TU_ASSERT_2ARGS, TU_ASSERT_1ARGS, _dummy)(__VA_ARGS__)
  |  |  ------------------
  |  |  |  |  112|  1.23k|#define TU_GET_3RD_ARG(arg1, arg2, arg3, ...)        arg3
  |  |  |  |  ------------------
  |  |  |  |  |  |  112|  1.23k|#define TU_ASSERT(...)                 TU_GET_3RD_ARG(__VA_ARGS__, TU_ASSERT_2ARGS, TU_ASSERT_1ARGS, _dummy)(__VA_ARGS__)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  108|  1.23k|#define TU_ASSERT_1ARGS(_cond)         TU_ASSERT_DEFINE(_cond, false)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  104|  1.23k|  do {                                                                \
  |  |  |  |  |  |  |  |  |  |  105|  1.23k|    if ( !(_cond) ) { TU_MESS_FAILED(); TU_BREAKPOINT(); return _ret; } \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   54|    906|  #define TU_MESS_FAILED() do {} while (0)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (54:41): [Folded, False: 906]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |                   if ( !(_cond) ) { TU_MESS_FAILED(); TU_BREAKPOINT(); return _ret; } \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   77|    906|  #define TU_BREAKPOINT() do {} while (0)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (77:40): [Folded, False: 906]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (105:10): [True: 906, False: 330]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  106|  1.23k|  } while(0)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (106:11): [Folded, False: 330]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  869|  1.23k|  } else {
  870|       |    // wLength == 0: Status stage is always IN per USB 2.0 §9.3.1
  871|     58|    TU_ASSERT(status_stage_xact(rhport, TU_EP0_IN));
  ------------------
  |  |  112|     58|#define TU_ASSERT(...)                 TU_GET_3RD_ARG(__VA_ARGS__, TU_ASSERT_2ARGS, TU_ASSERT_1ARGS, _dummy)(__VA_ARGS__)
  |  |  ------------------
  |  |  |  |  112|     58|#define TU_GET_3RD_ARG(arg1, arg2, arg3, ...)        arg3
  |  |  |  |  ------------------
  |  |  |  |  |  |  112|     58|#define TU_ASSERT(...)                 TU_GET_3RD_ARG(__VA_ARGS__, TU_ASSERT_2ARGS, TU_ASSERT_1ARGS, _dummy)(__VA_ARGS__)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  108|     58|#define TU_ASSERT_1ARGS(_cond)         TU_ASSERT_DEFINE(_cond, false)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  104|     58|  do {                                                                \
  |  |  |  |  |  |  |  |  |  |  105|     58|    if ( !(_cond) ) { TU_MESS_FAILED(); TU_BREAKPOINT(); return _ret; } \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   54|     49|  #define TU_MESS_FAILED() do {} while (0)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (54:41): [Folded, False: 49]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |                   if ( !(_cond) ) { TU_MESS_FAILED(); TU_BREAKPOINT(); return _ret; } \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   77|     49|  #define TU_BREAKPOINT() do {} while (0)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (77:40): [Folded, False: 49]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (105:10): [True: 49, False: 9]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  106|     58|  } while(0)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (106:11): [Folded, False: 9]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  872|     58|  }
  873|       |
  874|    339|  return true;
  875|  1.29k|}
dcd_event_handler:
 1386|  36.6k|TU_ATTR_FAST_FUNC void dcd_event_handler(dcd_event_t const* event, bool in_isr) {
 1387|  36.6k|  bool send = false;
 1388|  36.6k|  switch (event->event_id) {
 1389|  5.26k|    case DCD_EVENT_UNPLUGGED:
  ------------------
  |  Branch (1389:5): [True: 5.26k, False: 31.4k]
  ------------------
 1390|  5.26k|      _usbd_dev.connected = 0;
 1391|  5.26k|      _usbd_dev.addressed = 0;
 1392|  5.26k|      _usbd_dev.cfg_num = 0;
 1393|  5.26k|      _usbd_dev.suspended = 0;
 1394|  5.26k|      send = true;
 1395|  5.26k|      break;
 1396|       |
 1397|  3.18k|    case DCD_EVENT_SUSPEND:
  ------------------
  |  Branch (1397:5): [True: 3.18k, False: 33.5k]
  ------------------
 1398|       |      // NOTE: When plugging/unplugging device, the D+/D- state are unstable and
 1399|       |      // can accidentally meet the SUSPEND condition ( Bus Idle for 3ms ).
 1400|       |      // In addition, some MCUs such as SAMD or boards that haven no VBUS detection cannot distinguish
 1401|       |      // suspended vs disconnected. We will skip handling SUSPEND/RESUME event if not currently connected
 1402|  3.18k|      if (_usbd_dev.connected) {
  ------------------
  |  Branch (1402:11): [True: 2.58k, False: 603]
  ------------------
 1403|  2.58k|        _usbd_dev.suspended = 1;
 1404|  2.58k|        send = true;
 1405|  2.58k|      }
 1406|  3.18k|      break;
 1407|       |
 1408|  2.81k|    case DCD_EVENT_RESUME:
  ------------------
  |  Branch (1408:5): [True: 2.81k, False: 33.8k]
  ------------------
 1409|       |      // skip event if not connected (especially required for SAMD)
 1410|  2.81k|      if (_usbd_dev.connected) {
  ------------------
  |  Branch (1410:11): [True: 1.87k, False: 943]
  ------------------
 1411|  1.87k|        _usbd_dev.suspended = 0;
 1412|  1.87k|        send = true;
 1413|  1.87k|      }
 1414|  2.81k|      break;
 1415|       |
 1416|      0|    case DCD_EVENT_SOF:
  ------------------
  |  Branch (1416:5): [True: 0, False: 36.6k]
  ------------------
 1417|       |      // SOF driver handler in ISR context
 1418|      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 (1418:27): [True: 0, False: 0]
  ------------------
 1419|      0|        usbd_class_driver_t const* driver = get_driver(i);
 1420|      0|        if (driver && driver->sof) {
  ------------------
  |  Branch (1420:13): [True: 0, False: 0]
  |  Branch (1420:23): [True: 0, False: 0]
  ------------------
 1421|      0|          driver->sof(event->rhport, event->sof.frame_count);
 1422|      0|        }
 1423|      0|      }
 1424|       |
 1425|       |      // Some MCUs after running dcd_remote_wakeup() does not have way to detect the end of remote wakeup
 1426|       |      // which last 1-15 ms. DCD can use SOF as a clear indicator that bus is back to operational
 1427|      0|      if (_usbd_dev.suspended) {
  ------------------
  |  Branch (1427:11): [True: 0, False: 0]
  ------------------
 1428|      0|        _usbd_dev.suspended = 0;
 1429|       |
 1430|      0|        dcd_event_t const event_resume = {.rhport = event->rhport, .event_id = DCD_EVENT_RESUME};
 1431|      0|        queue_event(&event_resume, in_isr);
 1432|      0|      }
 1433|       |
 1434|      0|      if (tu_bit_test(_usbd_dev.sof_consumer, SOF_CONSUMER_USER)) {
  ------------------
  |  Branch (1434:11): [True: 0, False: 0]
  ------------------
 1435|      0|        dcd_event_t const event_sof = {.rhport = event->rhport, .event_id = DCD_EVENT_SOF, .sof.frame_count = event->sof.frame_count};
 1436|      0|        queue_event(&event_sof, in_isr);
 1437|      0|      }
 1438|      0|      break;
 1439|       |
 1440|  15.1k|    case DCD_EVENT_SETUP_RECEIVED:
  ------------------
  |  Branch (1440:5): [True: 15.1k, False: 21.5k]
  ------------------
 1441|  15.1k|      _usbd_queued_setup++;
 1442|  15.1k|      send = true;
 1443|  15.1k|      break;
 1444|       |
 1445|      0|    case DCD_EVENT_XFER_COMPLETE: {
  ------------------
  |  Branch (1445:5): [True: 0, False: 36.6k]
  ------------------
 1446|       |      // Invoke the class callback associated with the endpoint address
 1447|      0|      uint8_t const ep_addr = event->xfer_complete.ep_addr;
 1448|      0|      uint8_t const epnum = tu_edpt_number(ep_addr);
 1449|      0|      uint8_t const ep_dir = tu_edpt_dir(ep_addr);
 1450|       |
 1451|      0|      send = true;
 1452|      0|      if(epnum > 0) {
  ------------------
  |  Branch (1452:10): [True: 0, False: 0]
  ------------------
 1453|      0|        usbd_class_driver_t const* driver = get_driver(_usbd_dev.ep2drv[epnum][ep_dir]);
 1454|       |
 1455|      0|        if (driver && driver->xfer_isr) {
  ------------------
  |  Branch (1455:13): [True: 0, False: 0]
  |  Branch (1455:23): [True: 0, False: 0]
  ------------------
 1456|       |          // Clear busy + claimed
 1457|      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
  ------------------
 1458|       |
 1459|      0|          send = !driver->xfer_isr(event->rhport, ep_addr, (xfer_result_t) event->xfer_complete.result, event->xfer_complete.len);
 1460|       |
 1461|       |          // xfer_isr() is deferred to xfer_cb(), revert busy/claimed status
 1462|      0|          if (send) {
  ------------------
  |  Branch (1462:15): [True: 0, False: 0]
  ------------------
 1463|       |            // set busy + claimed
 1464|      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
  ------------------
 1465|      0|          }
 1466|      0|        }
 1467|      0|      }
 1468|      0|      break;
 1469|      0|    }
 1470|       |
 1471|  10.3k|    default:
  ------------------
  |  Branch (1471:5): [True: 10.3k, False: 26.3k]
  ------------------
 1472|  10.3k|      send = true;
 1473|  10.3k|      break;
 1474|  36.6k|  }
 1475|       |
 1476|  36.6k|  if (send) {
  ------------------
  |  Branch (1476:7): [True: 35.1k, False: 1.54k]
  ------------------
 1477|  35.1k|    queue_event(event, in_isr);
 1478|  35.1k|  }
 1479|  36.6k|}
usbd_int_set:
 1485|   182k|void usbd_int_set(bool enabled) {
 1486|   182k|  if (enabled) {
  ------------------
  |  Branch (1486:7): [True: 91.2k, False: 91.2k]
  ------------------
 1487|  91.2k|    dcd_int_enable(_usbd_rhport);
 1488|  91.2k|  } else {
 1489|  91.2k|    dcd_int_disable(_usbd_rhport);
 1490|  91.2k|  }
 1491|   182k|}
usbd_open_edpt_pair:
 1502|    212|                         uint8_t *ep_in) {
 1503|    212|  for (int i = 0; i < ep_count; i++) {
  ------------------
  |  Branch (1503:19): [True: 212, False: 0]
  ------------------
 1504|    212|    const tusb_desc_endpoint_t *desc_ep = (const tusb_desc_endpoint_t *)p_desc;
 1505|       |
 1506|    212|    TU_ASSERT(TUSB_DESC_ENDPOINT == desc_ep->bDescriptorType && xfer_type == desc_ep->bmAttributes.xfer);
  ------------------
  |  |  112|    212|#define TU_ASSERT(...)                 TU_GET_3RD_ARG(__VA_ARGS__, TU_ASSERT_2ARGS, TU_ASSERT_1ARGS, _dummy)(__VA_ARGS__)
  |  |  ------------------
  |  |  |  |  112|    212|#define TU_GET_3RD_ARG(arg1, arg2, arg3, ...)        arg3
  |  |  |  |  ------------------
  |  |  |  |  |  |  112|    212|#define TU_ASSERT(...)                 TU_GET_3RD_ARG(__VA_ARGS__, TU_ASSERT_2ARGS, TU_ASSERT_1ARGS, _dummy)(__VA_ARGS__)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  108|    212|#define TU_ASSERT_1ARGS(_cond)         TU_ASSERT_DEFINE(_cond, false)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  104|    212|  do {                                                                \
  |  |  |  |  |  |  |  |  |  |  105|    424|    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: 212, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  Branch (105:12): [True: 212, False: 0]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  106|    212|  } while(0)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (106:11): [Folded, False: 212]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1507|    212|    TU_ASSERT(usbd_edpt_open(rhport, desc_ep));
  ------------------
  |  |  112|    212|#define TU_ASSERT(...)                 TU_GET_3RD_ARG(__VA_ARGS__, TU_ASSERT_2ARGS, TU_ASSERT_1ARGS, _dummy)(__VA_ARGS__)
  |  |  ------------------
  |  |  |  |  112|    212|#define TU_GET_3RD_ARG(arg1, arg2, arg3, ...)        arg3
  |  |  |  |  ------------------
  |  |  |  |  |  |  112|    212|#define TU_ASSERT(...)                 TU_GET_3RD_ARG(__VA_ARGS__, TU_ASSERT_2ARGS, TU_ASSERT_1ARGS, _dummy)(__VA_ARGS__)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  108|    212|#define TU_ASSERT_1ARGS(_cond)         TU_ASSERT_DEFINE(_cond, false)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  104|    212|  do {                                                                \
  |  |  |  |  |  |  |  |  |  |  105|    212|    if ( !(_cond) ) { TU_MESS_FAILED(); TU_BREAKPOINT(); return _ret; } \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   54|    212|  #define TU_MESS_FAILED() do {} while (0)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (54:41): [Folded, False: 212]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |                   if ( !(_cond) ) { TU_MESS_FAILED(); TU_BREAKPOINT(); return _ret; } \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   77|    212|  #define TU_BREAKPOINT() do {} while (0)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (77:40): [Folded, False: 212]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (105:10): [True: 212, False: 0]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  106|    212|  } while(0)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (106:11): [Folded, False: 0]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1508|       |
 1509|      0|    if (tu_edpt_dir(desc_ep->bEndpointAddress) == TUSB_DIR_IN) {
  ------------------
  |  Branch (1509:9): [True: 0, False: 0]
  ------------------
 1510|      0|      (*ep_in) = desc_ep->bEndpointAddress;
 1511|      0|    } else {
 1512|      0|      (*ep_out) = desc_ep->bEndpointAddress;
 1513|      0|    }
 1514|       |
 1515|      0|    p_desc = tu_desc_next(p_desc);
 1516|      0|  }
 1517|       |
 1518|      0|  return true;
 1519|    212|}
usbd_edpt_open:
 1537|    212|bool usbd_edpt_open(uint8_t rhport, tusb_desc_endpoint_t const* desc_ep) {
 1538|    212|  rhport = _usbd_rhport;
 1539|       |
 1540|    212|  TU_ASSERT(tu_edpt_number(desc_ep->bEndpointAddress) < CFG_TUD_ENDPPOINT_MAX);
  ------------------
  |  |  112|    212|#define TU_ASSERT(...)                 TU_GET_3RD_ARG(__VA_ARGS__, TU_ASSERT_2ARGS, TU_ASSERT_1ARGS, _dummy)(__VA_ARGS__)
  |  |  ------------------
  |  |  |  |  112|    212|#define TU_GET_3RD_ARG(arg1, arg2, arg3, ...)        arg3
  |  |  |  |  ------------------
  |  |  |  |  |  |  112|    212|#define TU_ASSERT(...)                 TU_GET_3RD_ARG(__VA_ARGS__, TU_ASSERT_2ARGS, TU_ASSERT_1ARGS, _dummy)(__VA_ARGS__)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  108|    212|#define TU_ASSERT_1ARGS(_cond)         TU_ASSERT_DEFINE(_cond, false)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  104|    212|  do {                                                                \
  |  |  |  |  |  |  |  |  |  |  105|    212|    if ( !(_cond) ) { TU_MESS_FAILED(); TU_BREAKPOINT(); return _ret; } \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   54|    212|  #define TU_MESS_FAILED() do {} while (0)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (54:41): [Folded, False: 212]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |                   if ( !(_cond) ) { TU_MESS_FAILED(); TU_BREAKPOINT(); return _ret; } \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   77|    212|  #define TU_BREAKPOINT() do {} while (0)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (77:40): [Folded, False: 212]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (105:10): [True: 212, False: 0]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  106|    212|  } while(0)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (106:11): [Folded, False: 0]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1541|      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]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1542|       |
 1543|      0|  return dcd_edpt_open(rhport, desc_ep);
 1544|      0|}
usbd_edpt_xfer:
 1565|  3.60k|bool usbd_edpt_xfer(uint8_t rhport, uint8_t ep_addr, uint8_t* buffer, uint16_t total_bytes, bool is_isr) {
 1566|  3.60k|  rhport = _usbd_rhport;
 1567|       |
 1568|  3.60k|  uint8_t const epnum = tu_edpt_number(ep_addr);
 1569|  3.60k|  uint8_t const dir = tu_edpt_dir(ep_addr);
 1570|       |
 1571|       |  // TODO skip ready() check for now since enumeration also use this API
 1572|       |  // TU_VERIFY(tud_ready());
 1573|       |
 1574|  3.60k|  TU_LOG_USBD("  Queue EP %02X with %u bytes ...\r\n", ep_addr, total_bytes);
 1575|       |#if CFG_TUD_LOG_LEVEL >= 3
 1576|       |  if(dir == TUSB_DIR_IN) {
 1577|       |    TU_LOG_MEM(CFG_TUD_LOG_LEVEL, buffer, total_bytes, 2);
 1578|       |  }
 1579|       |#endif
 1580|       |
 1581|       |  // Attempt to transfer on a busy endpoint, sound like an race condition !
 1582|  3.60k|  TU_ASSERT((_usbd_dev.ep_status[epnum][dir] & TU_EDPT_STATE_BUSY) == 0);
  ------------------
  |  |  112|  3.60k|#define TU_ASSERT(...)                 TU_GET_3RD_ARG(__VA_ARGS__, TU_ASSERT_2ARGS, TU_ASSERT_1ARGS, _dummy)(__VA_ARGS__)
  |  |  ------------------
  |  |  |  |  112|  3.60k|#define TU_GET_3RD_ARG(arg1, arg2, arg3, ...)        arg3
  |  |  |  |  ------------------
  |  |  |  |  |  |  112|  3.60k|#define TU_ASSERT(...)                 TU_GET_3RD_ARG(__VA_ARGS__, TU_ASSERT_2ARGS, TU_ASSERT_1ARGS, _dummy)(__VA_ARGS__)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  108|  3.60k|#define TU_ASSERT_1ARGS(_cond)         TU_ASSERT_DEFINE(_cond, false)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  104|  3.60k|  do {                                                                \
  |  |  |  |  |  |  |  |  |  |  105|  3.60k|    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: 3.60k]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  106|  3.60k|  } while(0)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (106:11): [Folded, False: 3.60k]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1583|       |
 1584|       |  // Set busy first since the actual transfer can be complete before dcd_edpt_xfer()
 1585|       |  // could return and USBD task can preempt and clear the busy
 1586|  3.60k|  _usbd_dev.ep_status[epnum][dir] |= TU_EDPT_STATE_BUSY;
  ------------------
  |  |   31|  3.60k|#define TU_EDPT_STATE_BUSY    0x01u
  ------------------
 1587|       |
 1588|  3.60k|  if (dcd_edpt_xfer(rhport, ep_addr, buffer, total_bytes, is_isr)) {
  ------------------
  |  Branch (1588:7): [True: 1.57k, False: 2.03k]
  ------------------
 1589|  1.57k|    return true;
 1590|  2.03k|  } else {
 1591|       |    // DCD error, mark endpoint as ready to allow next transfer
 1592|  2.03k|    _usbd_dev.ep_status[epnum][dir] &= (uint8_t) ~(TU_EDPT_STATE_BUSY | TU_EDPT_STATE_CLAIMED);
  ------------------
  |  |   31|  2.03k|#define TU_EDPT_STATE_BUSY    0x01u
  ------------------
                  _usbd_dev.ep_status[epnum][dir] &= (uint8_t) ~(TU_EDPT_STATE_BUSY | TU_EDPT_STATE_CLAIMED);
  ------------------
  |  |   33|  2.03k|#define TU_EDPT_STATE_CLAIMED 0x04u
  ------------------
 1593|  2.03k|    TU_LOG_USBD("FAILED\r\n");
 1594|  2.03k|    TU_BREAKPOINT();
  ------------------
  |  |   77|  2.03k|  #define TU_BREAKPOINT() do {} while (0)
  |  |  ------------------
  |  |  |  Branch (77:40): [Folded, False: 2.03k]
  |  |  ------------------
  ------------------
 1595|       |    return false;
 1596|  2.03k|  }
 1597|  3.60k|}
usbd_edpt_stalled:
 1683|    236|bool usbd_edpt_stalled(uint8_t rhport, uint8_t ep_addr) {
 1684|    236|  (void) rhport;
 1685|       |
 1686|    236|  uint8_t const epnum = tu_edpt_number(ep_addr);
 1687|    236|  uint8_t const dir = tu_edpt_dir(ep_addr);
 1688|       |
 1689|    236|  return (_usbd_dev.ep_status[epnum][dir] & TU_EDPT_STATE_STALLED) != 0;
  ------------------
  |  |   32|    236|#define TU_EDPT_STATE_STALLED 0x02u
  ------------------
 1690|    236|}
usbd.c:get_driver:
  373|  18.0k|TU_ATTR_ALWAYS_INLINE static inline usbd_class_driver_t const * get_driver(uint8_t drvid) {
  374|  18.0k|  usbd_class_driver_t const *driver = NULL;
  375|  18.0k|  if (drvid < _app_driver_count) {
  ------------------
  |  Branch (375:7): [True: 0, False: 18.0k]
  ------------------
  376|       |    // Application drivers
  377|      0|    driver = &_app_driver[drvid];
  378|  18.0k|  } else{
  379|  18.0k|    drvid -= _app_driver_count;
  380|  18.0k|    if (_builtin_driver_count > 0 && drvid < _builtin_driver_count) {
  ------------------
  |  Branch (380:9): [True: 18.0k, Folded]
  |  Branch (380:38): [True: 15.7k, False: 2.25k]
  ------------------
  381|  15.7k|      driver = &_usbd_driver[drvid];
  382|  15.7k|    }
  383|  18.0k|  }
  384|       |
  385|  18.0k|  return driver;
  386|  18.0k|}
usbd.c:usbd_reset:
  643|  15.5k|static void usbd_reset(uint8_t rhport) {
  644|  15.5k|  configuration_reset(rhport);
  645|  15.5k|}
usbd.c:configuration_reset:
  631|  15.5k|static void configuration_reset(uint8_t rhport) {
  632|  31.1k|  for (uint8_t i = 0; i < TOTAL_DRIVER_COUNT; i++) {
  ------------------
  |  |  369|  31.1k|#define TOTAL_DRIVER_COUNT    ((uint8_t) (_app_driver_count + _builtin_driver_count))
  ------------------
  |  Branch (632:23): [True: 15.5k, False: 15.5k]
  ------------------
  633|  15.5k|    usbd_class_driver_t const* driver = get_driver(i);
  634|  15.5k|    TU_ASSERT(driver,);
  ------------------
  |  |  112|  15.5k|#define TU_ASSERT(...)                 TU_GET_3RD_ARG(__VA_ARGS__, TU_ASSERT_2ARGS, TU_ASSERT_1ARGS, _dummy)(__VA_ARGS__)
  |  |  ------------------
  |  |  |  |  112|  15.5k|#define TU_GET_3RD_ARG(arg1, arg2, arg3, ...)        arg3
  |  |  |  |  ------------------
  |  |  |  |  |  |  112|  15.5k|#define TU_ASSERT(...)                 TU_GET_3RD_ARG(__VA_ARGS__, TU_ASSERT_2ARGS, TU_ASSERT_1ARGS, _dummy)(__VA_ARGS__)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  109|  15.5k|#define TU_ASSERT_2ARGS(_cond, _ret)   TU_ASSERT_DEFINE(_cond, _ret)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  104|  15.5k|  do {                                                                \
  |  |  |  |  |  |  |  |  |  |  105|  15.5k|    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: 15.5k]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  106|  15.5k|  } while(0)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (106:11): [Folded, False: 15.5k]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  635|  15.5k|    driver->reset(rhport);
  636|  15.5k|  }
  637|       |
  638|  15.5k|  tu_varclr(&_usbd_dev);
  ------------------
  |  |   96|  15.5k|#define tu_varclr(_var)          tu_memclr(_var, sizeof(*(_var)))
  |  |  ------------------
  |  |  |  |   95|  15.5k|#define tu_memclr(buffer, size)  (void) memset((buffer), 0, (size))
  |  |  ------------------
  ------------------
  639|  15.5k|  (void)memset(_usbd_dev.itf2drv, TUSB_INDEX_INVALID_8, sizeof(_usbd_dev.itf2drv)); // invalid mapping
  640|  15.5k|  (void)memset(_usbd_dev.ep2drv, TUSB_INDEX_INVALID_8, sizeof(_usbd_dev.ep2drv));   // invalid mapping
  641|  15.5k|}
usbd.c:status_stage_xact:
  828|  2.37k|TU_ATTR_ALWAYS_INLINE static inline bool status_stage_xact(uint8_t rhport, uint8_t ep_status) {
  829|  2.37k|  return usbd_edpt_xfer(rhport, ep_status, NULL, 0, false);
  830|  2.37k|}
usbd.c:status_stage_ep:
  823|  2.31k|TU_ATTR_ALWAYS_INLINE static inline uint8_t status_stage_ep(const tusb_control_request_t* request) {
  824|  2.31k|  return (request->wLength != 0 && request->bmRequestType_bit.direction) ? TU_EP0_OUT : TU_EP0_IN;
  ------------------
  |  Branch (824:11): [True: 1.40k, False: 909]
  |  Branch (824:36): [True: 43, False: 1.36k]
  ------------------
  825|  2.31k|}
usbd.c:data_stage_xact:
  834|  1.23k|static bool data_stage_xact(uint8_t rhport) {
  835|  1.23k|  usbd_control_xfer_t* const ctrl_xfer = &_usbd_dev.ctrl_xfer;
  836|  1.23k|  const uint16_t xact_len = tu_min16(ctrl_xfer->data_len - ctrl_xfer->total_xferred, CFG_TUD_ENDPOINT0_BUFSIZE);
  ------------------
  |  |  631|  1.23k|  #define CFG_TUD_ENDPOINT0_BUFSIZE  CFG_TUD_ENDPOINT0_SIZE
  |  |  ------------------
  |  |  |  |   90|  1.23k|#define CFG_TUD_ENDPOINT0_SIZE    64
  |  |  ------------------
  ------------------
  837|  1.23k|  uint8_t ep_addr = TU_EP0_OUT;
  838|       |
  839|  1.23k|  if (ctrl_xfer->request.bmRequestType_bit.direction == TUSB_DIR_IN) {
  ------------------
  |  Branch (839:7): [True: 366, False: 870]
  ------------------
  840|    366|    ep_addr = TU_EP0_IN;
  841|    366|    if (0u != xact_len && ctrl_xfer->buffer != _ctrl_epbuf.buf) {
  ------------------
  |  Branch (841:9): [True: 366, False: 0]
  |  Branch (841:27): [True: 366, False: 0]
  ------------------
  842|    366|      TU_VERIFY(0 == tu_memcpy_s(_ctrl_epbuf.buf, CFG_TUD_ENDPOINT0_BUFSIZE, ctrl_xfer->buffer, xact_len));
  ------------------
  |  |   95|    366|#define TU_VERIFY(...)                 TU_GET_3RD_ARG(__VA_ARGS__, TU_VERIFY_2ARGS, TU_VERIFY_1ARGS, _dummy)(__VA_ARGS__)
  |  |  ------------------
  |  |  |  |  112|    366|#define TU_GET_3RD_ARG(arg1, arg2, arg3, ...)        arg3
  |  |  |  |  ------------------
  |  |  |  |  |  |   95|    366|#define TU_VERIFY(...)                 TU_GET_3RD_ARG(__VA_ARGS__, TU_VERIFY_2ARGS, TU_VERIFY_1ARGS, _dummy)(__VA_ARGS__)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   92|    366|#define TU_VERIFY_1ARGS(_cond)         TU_VERIFY_DEFINE(_cond, false)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   86|    366|  do {                                \
  |  |  |  |  |  |  |  |  |  |   87|    366|    if (!(_cond)) {                   \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (87:9): [True: 0, False: 366]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   88|      0|      return _ret;                    \
  |  |  |  |  |  |  |  |  |  |   89|      0|    }                                 \
  |  |  |  |  |  |  |  |  |  |   90|    366|  } while (0)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (90:12): [Folded, False: 366]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  843|    366|    }
  844|    366|  }
  845|       |
  846|  1.23k|  return usbd_edpt_xfer(rhport, ep_addr, xact_len ? _ctrl_epbuf.buf : NULL, xact_len, false);
  ------------------
  |  Branch (846:42): [True: 1.23k, False: 0]
  ------------------
  847|  1.23k|}
usbd.c:process_setup_received:
 1065|  15.1k|static bool process_setup_received(uint8_t rhport, tusb_control_request_t const * p_request) {
 1066|       |  // Initialize control transfer state for this request. The request copy must be
 1067|       |  // visible to usbd_control_xfer_cb when the (asynchronous) status ZLP completes,
 1068|       |  // since the SETUP packet event has already gone out of scope by then.
 1069|  15.1k|  usbd_control_xfer_t* const ctrl_xfer = &_usbd_dev.ctrl_xfer;
 1070|  15.1k|  ctrl_xfer->request = *p_request;
 1071|  15.1k|  ctrl_xfer->buffer = NULL;
 1072|  15.1k|  ctrl_xfer->total_xferred = 0;
 1073|  15.1k|  ctrl_xfer->data_len = 0;
 1074|  15.1k|  ctrl_xfer->complete_cb = NULL;
 1075|       |
 1076|  15.1k|  p_request = &ctrl_xfer->request; // re-direct request pointer to internal copy (modifiable for hacking)
 1077|  15.1k|  TU_ASSERT(p_request->bmRequestType_bit.type < TUSB_REQ_TYPE_INVALID);
  ------------------
  |  |  112|  15.1k|#define TU_ASSERT(...)                 TU_GET_3RD_ARG(__VA_ARGS__, TU_ASSERT_2ARGS, TU_ASSERT_1ARGS, _dummy)(__VA_ARGS__)
  |  |  ------------------
  |  |  |  |  112|  15.1k|#define TU_GET_3RD_ARG(arg1, arg2, arg3, ...)        arg3
  |  |  |  |  ------------------
  |  |  |  |  |  |  112|  15.1k|#define TU_ASSERT(...)                 TU_GET_3RD_ARG(__VA_ARGS__, TU_ASSERT_2ARGS, TU_ASSERT_1ARGS, _dummy)(__VA_ARGS__)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  108|  15.1k|#define TU_ASSERT_1ARGS(_cond)         TU_ASSERT_DEFINE(_cond, false)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  104|  15.1k|  do {                                                                \
  |  |  |  |  |  |  |  |  |  |  105|  15.1k|    if ( !(_cond) ) { TU_MESS_FAILED(); TU_BREAKPOINT(); return _ret; } \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   54|  1.45k|  #define TU_MESS_FAILED() do {} while (0)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (54:41): [Folded, False: 1.45k]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |                   if ( !(_cond) ) { TU_MESS_FAILED(); TU_BREAKPOINT(); return _ret; } \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   77|  1.45k|  #define TU_BREAKPOINT() do {} while (0)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (77:40): [Folded, False: 1.45k]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (105:10): [True: 1.45k, False: 13.6k]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  106|  15.1k|  } while(0)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (106:11): [Folded, False: 13.6k]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1078|       |
 1079|       |  // Vendor request
 1080|  13.6k|  if ( p_request->bmRequestType_bit.type == TUSB_REQ_TYPE_VENDOR ) {
  ------------------
  |  Branch (1080:8): [True: 1.59k, False: 12.0k]
  ------------------
 1081|  1.59k|    ctrl_xfer->complete_cb = tud_vendor_control_xfer_cb;
 1082|  1.59k|    return tud_vendor_control_xfer_cb(rhport, CONTROL_STAGE_SETUP, p_request);
 1083|  1.59k|  }
 1084|       |
 1085|       |#if CFG_TUSB_DEBUG >= CFG_TUD_LOG_LEVEL
 1086|       |  if (TUSB_REQ_TYPE_STANDARD == p_request->bmRequestType_bit.type && p_request->bRequest <= TUSB_REQ_SYNCH_FRAME) {
 1087|       |    TU_LOG_USBD("  %s", tu_str_std_request[p_request->bRequest]);
 1088|       |    if (TUSB_REQ_GET_DESCRIPTOR != p_request->bRequest) {
 1089|       |      TU_LOG_USBD("\r\n");
 1090|       |    }
 1091|       |  }
 1092|       |#endif
 1093|       |
 1094|  12.0k|  switch (p_request->bmRequestType_bit.recipient) { //-V2520
 1095|       |    //------------- Device Requests e.g in enumeration -------------//
 1096|  8.12k|    case TUSB_REQ_RCPT_DEVICE:
  ------------------
  |  Branch (1096:5): [True: 8.12k, False: 3.93k]
  ------------------
 1097|  8.12k|      if ( TUSB_REQ_TYPE_CLASS == p_request->bmRequestType_bit.type ) {
  ------------------
  |  Branch (1097:12): [True: 450, False: 7.67k]
  ------------------
 1098|    450|        uint8_t const itf = tu_u16_low(p_request->wIndex);
 1099|    450|        TU_VERIFY(itf < TU_ARRAY_SIZE(_usbd_dev.itf2drv));
  ------------------
  |  |   95|    450|#define TU_VERIFY(...)                 TU_GET_3RD_ARG(__VA_ARGS__, TU_VERIFY_2ARGS, TU_VERIFY_1ARGS, _dummy)(__VA_ARGS__)
  |  |  ------------------
  |  |  |  |  112|    450|#define TU_GET_3RD_ARG(arg1, arg2, arg3, ...)        arg3
  |  |  |  |  ------------------
  |  |  |  |  |  |   95|    450|#define TU_VERIFY(...)                 TU_GET_3RD_ARG(__VA_ARGS__, TU_VERIFY_2ARGS, TU_VERIFY_1ARGS, _dummy)(__VA_ARGS__)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   92|    450|#define TU_VERIFY_1ARGS(_cond)         TU_VERIFY_DEFINE(_cond, false)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   86|    450|  do {                                \
  |  |  |  |  |  |  |  |  |  |   87|    450|    if (!(_cond)) {                   \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (87:9): [True: 231, False: 219]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   88|    231|      return _ret;                    \
  |  |  |  |  |  |  |  |  |  |   89|    231|    }                                 \
  |  |  |  |  |  |  |  |  |  |   90|    450|  } while (0)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (90:12): [Folded, False: 219]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1100|       |
 1101|    219|        usbd_class_driver_t const * driver = get_driver(_usbd_dev.itf2drv[itf]);
 1102|    219|        TU_VERIFY(driver);
  ------------------
  |  |   95|    219|#define TU_VERIFY(...)                 TU_GET_3RD_ARG(__VA_ARGS__, TU_VERIFY_2ARGS, TU_VERIFY_1ARGS, _dummy)(__VA_ARGS__)
  |  |  ------------------
  |  |  |  |  112|    219|#define TU_GET_3RD_ARG(arg1, arg2, arg3, ...)        arg3
  |  |  |  |  ------------------
  |  |  |  |  |  |   95|    219|#define TU_VERIFY(...)                 TU_GET_3RD_ARG(__VA_ARGS__, TU_VERIFY_2ARGS, TU_VERIFY_1ARGS, _dummy)(__VA_ARGS__)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   92|    219|#define TU_VERIFY_1ARGS(_cond)         TU_VERIFY_DEFINE(_cond, false)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   86|    219|  do {                                \
  |  |  |  |  |  |  |  |  |  |   87|    219|    if (!(_cond)) {                   \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (87:9): [True: 219, False: 0]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   88|    219|      return _ret;                    \
  |  |  |  |  |  |  |  |  |  |   89|    219|    }                                 \
  |  |  |  |  |  |  |  |  |  |   90|    219|  } while (0)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (90:12): [Folded, False: 0]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1103|       |
 1104|       |        // forward to class driver: "non-STD request to Interface"
 1105|      0|        return invoke_class_control(rhport, driver, p_request);
 1106|    219|      }
 1107|       |
 1108|  7.67k|      if (TUSB_REQ_TYPE_STANDARD != p_request->bmRequestType_bit.type) {
  ------------------
  |  Branch (1108:11): [True: 0, False: 7.67k]
  ------------------
 1109|       |        // Non-standard request is not supported
 1110|      0|        TU_BREAKPOINT();
  ------------------
  |  |   77|      0|  #define TU_BREAKPOINT() do {} while (0)
  |  |  ------------------
  |  |  |  Branch (77:40): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1111|      0|        return false;
 1112|      0|      }
 1113|       |
 1114|  7.67k|      return process_std_device_request(rhport, p_request);
 1115|       |
 1116|       |    //------------- Class/Interface Specific Request -------------//
 1117|    759|    case TUSB_REQ_RCPT_INTERFACE: {
  ------------------
  |  Branch (1117:5): [True: 759, False: 11.3k]
  ------------------
 1118|    759|      uint8_t itf;
 1119|       |      #if CFG_TUD_PRINTER
 1120|       |      // Printer GET_DEVICE_ID has a weird wIndex = interface (high) | alt (low)
 1121|       |      // attempt to interpret this as a printer request if matched
 1122|       |      if (TUSB_REQ_TYPE_CLASS == p_request->bmRequestType_bit.type &&
 1123|       |          TUSB_DIR_IN == p_request->bmRequestType_bit.direction &&
 1124|       |          TUSB_PRINTER_REQUEST_GET_DEVICE_ID == p_request->bRequest) {
 1125|       |        itf = tu_u16_high(p_request->wIndex);
 1126|       |        if (itf < TU_ARRAY_SIZE(_usbd_dev.itf2drv)) {
 1127|       |          const usbd_class_driver_t * driver = get_driver(_usbd_dev.itf2drv[itf]);
 1128|       |          if (driver != NULL && driver->control_xfer_cb == printerd_control_xfer_cb) {
 1129|       |            if (invoke_class_control(rhport, driver, p_request)) {
 1130|       |              return true;
 1131|       |            }
 1132|       |          }
 1133|       |        }
 1134|       |      }
 1135|       |      #endif
 1136|    759|      itf = tu_u16_low(p_request->wIndex);
 1137|    759|      TU_VERIFY(itf < TU_ARRAY_SIZE(_usbd_dev.itf2drv));
  ------------------
  |  |   95|    759|#define TU_VERIFY(...)                 TU_GET_3RD_ARG(__VA_ARGS__, TU_VERIFY_2ARGS, TU_VERIFY_1ARGS, _dummy)(__VA_ARGS__)
  |  |  ------------------
  |  |  |  |  112|    759|#define TU_GET_3RD_ARG(arg1, arg2, arg3, ...)        arg3
  |  |  |  |  ------------------
  |  |  |  |  |  |   95|    759|#define TU_VERIFY(...)                 TU_GET_3RD_ARG(__VA_ARGS__, TU_VERIFY_2ARGS, TU_VERIFY_1ARGS, _dummy)(__VA_ARGS__)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   92|    759|#define TU_VERIFY_1ARGS(_cond)         TU_VERIFY_DEFINE(_cond, false)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   86|    759|  do {                                \
  |  |  |  |  |  |  |  |  |  |   87|    759|    if (!(_cond)) {                   \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (87:9): [True: 303, False: 456]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   88|    303|      return _ret;                    \
  |  |  |  |  |  |  |  |  |  |   89|    303|    }                                 \
  |  |  |  |  |  |  |  |  |  |   90|    759|  } while (0)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (90:12): [Folded, False: 456]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1138|       |
 1139|    456|      usbd_class_driver_t const * driver = get_driver(_usbd_dev.itf2drv[itf]);
 1140|    456|      TU_VERIFY(driver);
  ------------------
  |  |   95|    456|#define TU_VERIFY(...)                 TU_GET_3RD_ARG(__VA_ARGS__, TU_VERIFY_2ARGS, TU_VERIFY_1ARGS, _dummy)(__VA_ARGS__)
  |  |  ------------------
  |  |  |  |  112|    456|#define TU_GET_3RD_ARG(arg1, arg2, arg3, ...)        arg3
  |  |  |  |  ------------------
  |  |  |  |  |  |   95|    456|#define TU_VERIFY(...)                 TU_GET_3RD_ARG(__VA_ARGS__, TU_VERIFY_2ARGS, TU_VERIFY_1ARGS, _dummy)(__VA_ARGS__)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   92|    456|#define TU_VERIFY_1ARGS(_cond)         TU_VERIFY_DEFINE(_cond, false)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   86|    456|  do {                                \
  |  |  |  |  |  |  |  |  |  |   87|    456|    if (!(_cond)) {                   \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (87:9): [True: 456, False: 0]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   88|    456|      return _ret;                    \
  |  |  |  |  |  |  |  |  |  |   89|    456|    }                                 \
  |  |  |  |  |  |  |  |  |  |   90|    456|  } while (0)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (90:12): [Folded, False: 0]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1141|       |
 1142|       |      // all requests to Interface (STD or Class) is forwarded to class driver.
 1143|       |      // notable requests are: GET HID REPORT DESCRIPTOR, SET_INTERFACE, GET_INTERFACE
 1144|      0|      if (!invoke_class_control(rhport, driver, p_request)) {
  ------------------
  |  Branch (1144:11): [True: 0, False: 0]
  ------------------
 1145|       |        // For GET_INTERFACE and SET_INTERFACE, it is mandatory to respond even if the class
 1146|       |        // driver doesn't use alternate settings or implement this
 1147|      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]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1148|       |
 1149|       |        // Clear complete callback if driver set since it can also stall the request.
 1150|      0|        ctrl_xfer->complete_cb = NULL;
 1151|       |
 1152|      0|        switch (p_request->bRequest) { //-V2520
 1153|      0|          case TUSB_REQ_GET_INTERFACE: {
  ------------------
  |  Branch (1153:11): [True: 0, False: 0]
  ------------------
 1154|      0|            uint8_t alternate = 0;
 1155|      0|            tud_control_xfer(rhport, p_request, &alternate, 1);
 1156|      0|            break;
 1157|      0|          }
 1158|       |
 1159|      0|          case TUSB_REQ_SET_INTERFACE:
  ------------------
  |  Branch (1159:11): [True: 0, False: 0]
  ------------------
 1160|       |            // A class that implements altsettings handles SET_INTERFACE itself and returns true,
 1161|       |            // so reaching here means the class does not — where only alt 0 is valid. Any non-zero
 1162|       |            // alt (unimplemented, or rejected as invalid by the class) is a Request Error (stall).
 1163|      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]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1164|      0|            tud_control_status(rhport, p_request);
 1165|      0|            break;
 1166|       |
 1167|      0|          case TUSB_REQ_GET_STATUS:
  ------------------
  |  Branch (1167:11): [True: 0, False: 0]
  ------------------
 1168|       |            // USB 2.0 9.4.5: interface GET_STATUS returns 2 reserved (zero) bytes
 1169|      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]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1170|      0|            break;
 1171|       |
 1172|      0|          default: return false;
  ------------------
  |  Branch (1172:11): [True: 0, False: 0]
  ------------------
 1173|      0|        }
 1174|      0|      }
 1175|      0|      break;
 1176|      0|    }
 1177|       |
 1178|       |    //------------- Endpoint Request -------------//
 1179|  1.87k|    case TUSB_REQ_RCPT_ENDPOINT: {
  ------------------
  |  Branch (1179:5): [True: 1.87k, False: 10.1k]
  ------------------
 1180|  1.87k|      uint8_t const ep_addr = tu_u16_low(p_request->wIndex);
 1181|  1.87k|      uint8_t const ep_num  = tu_edpt_number(ep_addr);
 1182|  1.87k|      uint8_t const ep_dir  = tu_edpt_dir(ep_addr);
 1183|       |
 1184|  1.87k|      TU_ASSERT(ep_num < TU_ARRAY_SIZE(_usbd_dev.ep2drv) );
  ------------------
  |  |  112|  1.87k|#define TU_ASSERT(...)                 TU_GET_3RD_ARG(__VA_ARGS__, TU_ASSERT_2ARGS, TU_ASSERT_1ARGS, _dummy)(__VA_ARGS__)
  |  |  ------------------
  |  |  |  |  112|  1.87k|#define TU_GET_3RD_ARG(arg1, arg2, arg3, ...)        arg3
  |  |  |  |  ------------------
  |  |  |  |  |  |  112|  1.87k|#define TU_ASSERT(...)                 TU_GET_3RD_ARG(__VA_ARGS__, TU_ASSERT_2ARGS, TU_ASSERT_1ARGS, _dummy)(__VA_ARGS__)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  108|  1.87k|#define TU_ASSERT_1ARGS(_cond)         TU_ASSERT_DEFINE(_cond, false)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  104|  1.87k|  do {                                                                \
  |  |  |  |  |  |  |  |  |  |  105|  1.87k|    if ( !(_cond) ) { TU_MESS_FAILED(); TU_BREAKPOINT(); return _ret; } \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   54|    287|  #define TU_MESS_FAILED() do {} while (0)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (54:41): [Folded, False: 287]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |                   if ( !(_cond) ) { TU_MESS_FAILED(); TU_BREAKPOINT(); return _ret; } \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   77|    287|  #define TU_BREAKPOINT() do {} while (0)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (77:40): [Folded, False: 287]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (105:10): [True: 287, False: 1.58k]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  106|  1.87k|  } while(0)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (106:11): [Folded, False: 1.58k]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1185|  1.58k|      usbd_class_driver_t const * driver = get_driver(_usbd_dev.ep2drv[ep_num][ep_dir]);
 1186|       |
 1187|  1.58k|      if (TUSB_REQ_TYPE_STANDARD != p_request->bmRequestType_bit.type) {
  ------------------
  |  Branch (1187:11): [True: 199, False: 1.38k]
  ------------------
 1188|       |        // Forward class request to its driver
 1189|    199|        TU_VERIFY(driver);
  ------------------
  |  |   95|    199|#define TU_VERIFY(...)                 TU_GET_3RD_ARG(__VA_ARGS__, TU_VERIFY_2ARGS, TU_VERIFY_1ARGS, _dummy)(__VA_ARGS__)
  |  |  ------------------
  |  |  |  |  112|    199|#define TU_GET_3RD_ARG(arg1, arg2, arg3, ...)        arg3
  |  |  |  |  ------------------
  |  |  |  |  |  |   95|    199|#define TU_VERIFY(...)                 TU_GET_3RD_ARG(__VA_ARGS__, TU_VERIFY_2ARGS, TU_VERIFY_1ARGS, _dummy)(__VA_ARGS__)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   92|    199|#define TU_VERIFY_1ARGS(_cond)         TU_VERIFY_DEFINE(_cond, false)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   86|    199|  do {                                \
  |  |  |  |  |  |  |  |  |  |   87|    199|    if (!(_cond)) {                   \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (87:9): [True: 199, False: 0]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   88|    199|      return _ret;                    \
  |  |  |  |  |  |  |  |  |  |   89|    199|    }                                 \
  |  |  |  |  |  |  |  |  |  |   90|    199|  } while (0)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (90:12): [Folded, False: 0]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1190|      0|        return invoke_class_control(rhport, driver, p_request);
 1191|  1.38k|      } else {
 1192|       |        // Handle STD request to endpoint
 1193|  1.38k|        switch (p_request->bRequest) { //-V2520
 1194|    236|          case TUSB_REQ_GET_STATUS:
  ------------------
  |  Branch (1194:11): [True: 236, False: 1.14k]
  ------------------
 1195|       |            // USB 2.0 9.4.5: endpoint GET_STATUS bit 0 = Halt
 1196|    236|            TU_VERIFY(process_get_status(rhport, p_request, usbd_edpt_stalled(rhport, ep_addr) ? 0x0001u : 0x0000u));
  ------------------
  |  |   95|    236|#define TU_VERIFY(...)                 TU_GET_3RD_ARG(__VA_ARGS__, TU_VERIFY_2ARGS, TU_VERIFY_1ARGS, _dummy)(__VA_ARGS__)
  |  |  ------------------
  |  |  |  |  112|    236|#define TU_GET_3RD_ARG(arg1, arg2, arg3, ...)        arg3
  |  |  |  |  ------------------
  |  |  |  |  |  |   95|    236|#define TU_VERIFY(...)                 TU_GET_3RD_ARG(__VA_ARGS__, TU_VERIFY_2ARGS, TU_VERIFY_1ARGS, _dummy)(__VA_ARGS__)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   92|    236|#define TU_VERIFY_1ARGS(_cond)         TU_VERIFY_DEFINE(_cond, false)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   86|    236|  do {                                \
  |  |  |  |  |  |  |  |  |  |   87|    472|    if (!(_cond)) {                   \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (87:9): [True: 236, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  Branch (87:11): [True: 0, False: 236]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   88|    236|      return _ret;                    \
  |  |  |  |  |  |  |  |  |  |   89|    236|    }                                 \
  |  |  |  |  |  |  |  |  |  |   90|    236|  } while (0)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (90:12): [Folded, False: 0]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1197|      0|            break;
 1198|       |
 1199|    482|          case TUSB_REQ_CLEAR_FEATURE:
  ------------------
  |  Branch (1199:11): [True: 482, False: 902]
  ------------------
 1200|    834|          case TUSB_REQ_SET_FEATURE: {
  ------------------
  |  Branch (1200:11): [True: 352, False: 1.03k]
  ------------------
 1201|       |            // ENDPOINT_HALT is the only endpoint feature; it exists only on a non-control endpoint
 1202|       |            // that an interface actually owns. Any other selector, the control endpoint (EP0 has no
 1203|       |            // Halt feature, USB 2.0 9.4.9), or an endpoint no driver owns is a Request Error (stall).
 1204|    834|            TU_VERIFY(TUSB_REQ_FEATURE_EDPT_HALT == p_request->wValue);
  ------------------
  |  |   95|    834|#define TU_VERIFY(...)                 TU_GET_3RD_ARG(__VA_ARGS__, TU_VERIFY_2ARGS, TU_VERIFY_1ARGS, _dummy)(__VA_ARGS__)
  |  |  ------------------
  |  |  |  |  112|    834|#define TU_GET_3RD_ARG(arg1, arg2, arg3, ...)        arg3
  |  |  |  |  ------------------
  |  |  |  |  |  |   95|    834|#define TU_VERIFY(...)                 TU_GET_3RD_ARG(__VA_ARGS__, TU_VERIFY_2ARGS, TU_VERIFY_1ARGS, _dummy)(__VA_ARGS__)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   92|    834|#define TU_VERIFY_1ARGS(_cond)         TU_VERIFY_DEFINE(_cond, false)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   86|    834|  do {                                \
  |  |  |  |  |  |  |  |  |  |   87|    834|    if (!(_cond)) {                   \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (87:9): [True: 389, False: 445]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   88|    389|      return _ret;                    \
  |  |  |  |  |  |  |  |  |  |   89|    389|    }                                 \
  |  |  |  |  |  |  |  |  |  |   90|    834|  } while (0)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (90:12): [Folded, False: 445]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1205|    445|            TU_VERIFY(ep_num != 0);
  ------------------
  |  |   95|    445|#define TU_VERIFY(...)                 TU_GET_3RD_ARG(__VA_ARGS__, TU_VERIFY_2ARGS, TU_VERIFY_1ARGS, _dummy)(__VA_ARGS__)
  |  |  ------------------
  |  |  |  |  112|    445|#define TU_GET_3RD_ARG(arg1, arg2, arg3, ...)        arg3
  |  |  |  |  ------------------
  |  |  |  |  |  |   95|    445|#define TU_VERIFY(...)                 TU_GET_3RD_ARG(__VA_ARGS__, TU_VERIFY_2ARGS, TU_VERIFY_1ARGS, _dummy)(__VA_ARGS__)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   92|    445|#define TU_VERIFY_1ARGS(_cond)         TU_VERIFY_DEFINE(_cond, false)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   86|    445|  do {                                \
  |  |  |  |  |  |  |  |  |  |   87|    445|    if (!(_cond)) {                   \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (87:9): [True: 63, False: 382]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   88|     63|      return _ret;                    \
  |  |  |  |  |  |  |  |  |  |   89|     63|    }                                 \
  |  |  |  |  |  |  |  |  |  |   90|    445|  } while (0)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (90:12): [Folded, False: 382]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1206|    382|            TU_VERIFY(driver != NULL);
  ------------------
  |  |   95|    382|#define TU_VERIFY(...)                 TU_GET_3RD_ARG(__VA_ARGS__, TU_VERIFY_2ARGS, TU_VERIFY_1ARGS, _dummy)(__VA_ARGS__)
  |  |  ------------------
  |  |  |  |  112|    382|#define TU_GET_3RD_ARG(arg1, arg2, arg3, ...)        arg3
  |  |  |  |  ------------------
  |  |  |  |  |  |   95|    382|#define TU_VERIFY(...)                 TU_GET_3RD_ARG(__VA_ARGS__, TU_VERIFY_2ARGS, TU_VERIFY_1ARGS, _dummy)(__VA_ARGS__)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   92|    382|#define TU_VERIFY_1ARGS(_cond)         TU_VERIFY_DEFINE(_cond, false)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   86|    382|  do {                                \
  |  |  |  |  |  |  |  |  |  |   87|    382|    if (!(_cond)) {                   \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (87:9): [True: 382, False: 0]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   88|    382|      return _ret;                    \
  |  |  |  |  |  |  |  |  |  |   89|    382|    }                                 \
  |  |  |  |  |  |  |  |  |  |   90|    382|  } while (0)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (90:12): [Folded, False: 0]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1207|       |
 1208|      0|            if ( TUSB_REQ_CLEAR_FEATURE == p_request->bRequest ) {
  ------------------
  |  Branch (1208:18): [True: 0, False: 0]
  ------------------
 1209|      0|              usbd_edpt_clear_stall(rhport, ep_addr);
 1210|      0|            } else {
 1211|      0|              usbd_edpt_stall(rhport, ep_addr);
 1212|      0|            }
 1213|       |
 1214|       |            // Some classes such as USBTMC need to clear/re-init their buffer on CLEAR_FEATURE.
 1215|       |            // Clear complete callback if driver set since it can also stall the request.
 1216|      0|            (void) invoke_class_control(rhport, driver, p_request);
 1217|      0|            ctrl_xfer->complete_cb = NULL;
 1218|       |
 1219|       |            // STD request must always be ACKed; skip ZLP status if driver already did that.
 1220|      0|            if (!(_usbd_dev.ep_status[0][TUSB_DIR_IN] & TU_EDPT_STATE_BUSY)) {
  ------------------
  |  |   31|      0|#define TU_EDPT_STATE_BUSY    0x01u
  ------------------
  |  Branch (1220:17): [True: 0, False: 0]
  ------------------
 1221|      0|              tud_control_status(rhport, p_request);
 1222|      0|            }
 1223|      0|          }
 1224|      0|          break;
 1225|       |
 1226|       |          // Unknown/Unsupported request
 1227|    314|          default:
  ------------------
  |  Branch (1227:11): [True: 314, False: 1.07k]
  ------------------
 1228|    314|            TU_BREAKPOINT();
  ------------------
  |  |   77|    314|  #define TU_BREAKPOINT() do {} while (0)
  |  |  ------------------
  |  |  |  Branch (77:40): [Folded, False: 314]
  |  |  ------------------
  ------------------
 1229|    314|            return false;
 1230|  1.38k|        }
 1231|  1.38k|      }
 1232|      0|      break;
 1233|  1.58k|    }
 1234|       |
 1235|       |    // Unknown recipient
 1236|  1.30k|    default:
  ------------------
  |  Branch (1236:5): [True: 1.30k, False: 10.7k]
  ------------------
 1237|  1.30k|      TU_BREAKPOINT();
  ------------------
  |  |   77|  1.30k|  #define TU_BREAKPOINT() do {} while (0)
  |  |  ------------------
  |  |  |  Branch (77:40): [Folded, False: 1.30k]
  |  |  ------------------
  ------------------
 1238|  1.30k|      return false;
 1239|  12.0k|  }
 1240|       |
 1241|      0|  return true;
 1242|  12.0k|}
usbd.c:process_std_device_request:
  948|  7.67k|static bool process_std_device_request(uint8_t rhport, tusb_control_request_t const * p_request) {
  949|  7.67k|  switch (p_request->bRequest) { //-V2520
  950|    201|    case TUSB_REQ_SET_ADDRESS:
  ------------------
  |  Branch (950:5): [True: 201, False: 7.47k]
  ------------------
  951|       |      // Depending on mcu, status phase could be sent either before or after changing device address,
  952|       |      // or even require stack to not response with status at all
  953|       |      // Therefore DCD must take full responsibility to response and include zlp status packet if needed.
  954|    201|      dcd_set_address(rhport, (uint8_t) p_request->wValue);
  955|    201|      _usbd_dev.addressed = 1;
  956|    201|      return true;
  957|       |
  958|    271|    case TUSB_REQ_GET_CONFIGURATION: {
  ------------------
  |  Branch (958:5): [True: 271, False: 7.40k]
  ------------------
  959|    271|      uint8_t cfg_num = _usbd_dev.cfg_num;
  960|    271|      tud_control_xfer(rhport, p_request, &cfg_num, 1);
  961|    271|      return true;
  962|      0|    }
  963|       |
  964|  1.00k|    case TUSB_REQ_SET_CONFIGURATION: {
  ------------------
  |  Branch (964:5): [True: 1.00k, False: 6.67k]
  ------------------
  965|  1.00k|      uint8_t const cfg_num = (uint8_t) p_request->wValue;
  966|       |
  967|       |      // Only process if new configure is different
  968|  1.00k|      if (_usbd_dev.cfg_num != cfg_num) {
  ------------------
  |  Branch (968:11): [True: 212, False: 788]
  ------------------
  969|    212|        if (_usbd_dev.cfg_num != 0) {
  ------------------
  |  Branch (969:13): [True: 0, False: 212]
  ------------------
  970|       |          // already configured: need to clear all endpoints and driver first
  971|      0|          TU_LOG_USBD("  Clear current Configuration (%u) before switching\r\n", _usbd_dev.cfg_num);
  972|       |
  973|      0|          dcd_sof_enable(rhport, false);
  974|      0|          dcd_edpt_close_all(rhport);
  975|       |
  976|       |          // close all drivers and current configured state except bus speed
  977|      0|          const uint8_t speed = _usbd_dev.speed;
  978|      0|          configuration_reset(rhport);
  979|       |
  980|      0|          _usbd_dev.speed = speed; // restore speed
  981|      0|        }
  982|       |
  983|    212|        _usbd_dev.cfg_num = cfg_num;
  984|       |
  985|       |        // Handle the new configuration
  986|    212|        if (cfg_num == 0) {
  ------------------
  |  Branch (986:13): [True: 0, False: 212]
  ------------------
  987|      0|          tud_umount_cb();
  988|    212|        } else {
  989|    212|          if (!process_set_config(rhport, cfg_num)) {
  ------------------
  |  Branch (989:15): [True: 212, False: 0]
  ------------------
  990|    212|            _usbd_dev.cfg_num = 0;
  991|    212|            TU_ASSERT(false);
  ------------------
  |  |  112|    212|#define TU_ASSERT(...)                 TU_GET_3RD_ARG(__VA_ARGS__, TU_ASSERT_2ARGS, TU_ASSERT_1ARGS, _dummy)(__VA_ARGS__)
  |  |  ------------------
  |  |  |  |  112|    212|#define TU_GET_3RD_ARG(arg1, arg2, arg3, ...)        arg3
  |  |  |  |  ------------------
  |  |  |  |  |  |  112|    212|#define TU_ASSERT(...)                 TU_GET_3RD_ARG(__VA_ARGS__, TU_ASSERT_2ARGS, TU_ASSERT_1ARGS, _dummy)(__VA_ARGS__)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  108|    212|#define TU_ASSERT_1ARGS(_cond)         TU_ASSERT_DEFINE(_cond, false)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  104|    212|  do {                                                                \
  |  |  |  |  |  |  |  |  |  |  105|    212|    if ( !(_cond) ) { TU_MESS_FAILED(); TU_BREAKPOINT(); return _ret; } \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   54|    212|  #define TU_MESS_FAILED() do {} while (0)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (54:41): [Folded, False: 212]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |                   if ( !(_cond) ) { TU_MESS_FAILED(); TU_BREAKPOINT(); return _ret; } \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   77|    212|  #define TU_BREAKPOINT() do {} while (0)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (77:40): [Folded, False: 212]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (105:10): [True: 212, Folded]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  106|    212|  } while(0)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (106:11): [Folded, False: 0]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  992|    212|          }
  993|      0|          tud_mount_cb();
  994|      0|        }
  995|    212|      }
  996|       |
  997|    788|      tud_control_status(rhport, p_request);
  998|    788|      return true;
  999|  1.00k|    }
 1000|       |
 1001|  2.02k|    case TUSB_REQ_GET_DESCRIPTOR:
  ------------------
  |  Branch (1001:5): [True: 2.02k, False: 5.65k]
  ------------------
 1002|  2.02k|      return process_get_descriptor(rhport, p_request);
 1003|       |
 1004|  1.08k|    case TUSB_REQ_SET_FEATURE:
  ------------------
  |  Branch (1004:5): [True: 1.08k, False: 6.59k]
  ------------------
 1005|  1.08k|      switch (p_request->wValue) { //-V2520
 1006|    840|        case TUSB_REQ_FEATURE_REMOTE_WAKEUP:
  ------------------
  |  Branch (1006:9): [True: 840, False: 242]
  ------------------
 1007|    840|          TU_LOG_USBD("    Enable Remote Wakeup\r\n");
 1008|       |          // Host may enable remote wake up before suspending especially HID device
 1009|    840|          _usbd_dev.remote_wakeup_en = 1;
 1010|    840|          tud_control_status(rhport, p_request);
 1011|    840|          return true;
 1012|       |
 1013|       |        #if CFG_TUD_TEST_MODE
 1014|       |        case TUSB_REQ_FEATURE_TEST_MODE: {
 1015|       |          // Only handle the test mode if supported and valid
 1016|       |          TU_VERIFY(0 == tu_u16_low(p_request->wIndex));
 1017|       |
 1018|       |          uint8_t const selector = tu_u16_high(p_request->wIndex);
 1019|       |          TU_VERIFY(TUSB_FEATURE_TEST_J <= selector && selector <= TUSB_FEATURE_TEST_FORCE_ENABLE);
 1020|       |
 1021|       |          _usbd_dev.ctrl_xfer.complete_cb = process_test_mode_cb;
 1022|       |          tud_control_status(rhport, p_request);
 1023|       |          return true;
 1024|       |        }
 1025|       |        #endif
 1026|       |
 1027|       |        // Stall unsupported feature selector
 1028|    242|        default: return false;
  ------------------
  |  Branch (1028:9): [True: 242, False: 840]
  ------------------
 1029|  1.08k|      }
 1030|       |
 1031|    973|    case TUSB_REQ_CLEAR_FEATURE:
  ------------------
  |  Branch (1031:5): [True: 973, False: 6.70k]
  ------------------
 1032|       |      // Only support remote wakeup for device feature
 1033|    973|      TU_VERIFY(TUSB_REQ_FEATURE_REMOTE_WAKEUP == p_request->wValue);
  ------------------
  |  |   95|    973|#define TU_VERIFY(...)                 TU_GET_3RD_ARG(__VA_ARGS__, TU_VERIFY_2ARGS, TU_VERIFY_1ARGS, _dummy)(__VA_ARGS__)
  |  |  ------------------
  |  |  |  |  112|    973|#define TU_GET_3RD_ARG(arg1, arg2, arg3, ...)        arg3
  |  |  |  |  ------------------
  |  |  |  |  |  |   95|    973|#define TU_VERIFY(...)                 TU_GET_3RD_ARG(__VA_ARGS__, TU_VERIFY_2ARGS, TU_VERIFY_1ARGS, _dummy)(__VA_ARGS__)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   92|    973|#define TU_VERIFY_1ARGS(_cond)         TU_VERIFY_DEFINE(_cond, false)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   86|    973|  do {                                \
  |  |  |  |  |  |  |  |  |  |   87|    973|    if (!(_cond)) {                   \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (87:9): [True: 289, False: 684]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   88|    289|      return _ret;                    \
  |  |  |  |  |  |  |  |  |  |   89|    289|    }                                 \
  |  |  |  |  |  |  |  |  |  |   90|    973|  } while (0)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (90:12): [Folded, False: 684]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1034|    684|      TU_LOG_USBD("    Disable Remote Wakeup\r\n");
 1035|       |
 1036|       |      // Host may disable remote wake up after resuming
 1037|    684|      _usbd_dev.remote_wakeup_en = 0;
 1038|    684|      tud_control_status(rhport, p_request);
 1039|    684|      return true;
 1040|       |
 1041|  1.60k|    case TUSB_REQ_GET_STATUS: {
  ------------------
  |  Branch (1041:5): [True: 1.60k, False: 6.06k]
  ------------------
 1042|       |      // Device status bit mask
 1043|       |      // - Bit 0: Self Powered TODO must invoke callback to get actual status
 1044|       |      // - Bit 1: Remote Wakeup enabled
 1045|  1.60k|      return process_get_status(rhport, p_request, (uint16_t) _usbd_dev.dev_state_bm);
 1046|    973|    }
 1047|       |
 1048|    517|    default:
  ------------------
  |  Branch (1048:5): [True: 517, False: 7.15k]
  ------------------
 1049|    517|      TU_BREAKPOINT();
  ------------------
  |  |   77|    517|  #define TU_BREAKPOINT() do {} while (0)
  |  |  ------------------
  |  |  |  Branch (77:40): [Folded, False: 517]
  |  |  ------------------
  ------------------
 1050|       |      return false;
 1051|  7.67k|  }
 1052|  7.67k|}
usbd.c:process_set_config:
 1246|    212|static bool process_set_config(uint8_t rhport, uint8_t cfg_num) {
 1247|       |  // index is cfg_num-1
 1248|    212|  const tusb_desc_configuration_t *desc_cfg =
 1249|    212|    (const tusb_desc_configuration_t *)tud_descriptor_configuration_cb(cfg_num - 1);
 1250|    212|  TU_ASSERT(desc_cfg != NULL && desc_cfg->bDescriptorType == TUSB_DESC_CONFIGURATION);
  ------------------
  |  |  112|    212|#define TU_ASSERT(...)                 TU_GET_3RD_ARG(__VA_ARGS__, TU_ASSERT_2ARGS, TU_ASSERT_1ARGS, _dummy)(__VA_ARGS__)
  |  |  ------------------
  |  |  |  |  112|    212|#define TU_GET_3RD_ARG(arg1, arg2, arg3, ...)        arg3
  |  |  |  |  ------------------
  |  |  |  |  |  |  112|    212|#define TU_ASSERT(...)                 TU_GET_3RD_ARG(__VA_ARGS__, TU_ASSERT_2ARGS, TU_ASSERT_1ARGS, _dummy)(__VA_ARGS__)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  108|    212|#define TU_ASSERT_1ARGS(_cond)         TU_ASSERT_DEFINE(_cond, false)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  104|    212|  do {                                                                \
  |  |  |  |  |  |  |  |  |  |  105|    424|    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: 212, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  Branch (105:12): [True: 212, False: 0]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  106|    212|  } while(0)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (106:11): [Folded, False: 212]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1251|       |
 1252|       |  // Parse configuration descriptor
 1253|    212|  _usbd_dev.self_powered = (desc_cfg->bmAttributes & TUSB_DESC_CONFIG_ATT_SELF_POWERED) ? 1u : 0u;
  ------------------
  |  Branch (1253:28): [True: 0, False: 212]
  ------------------
 1254|       |
 1255|       |  // Parse interface descriptor
 1256|    212|  const uint8_t *p_desc   = ((const uint8_t *)desc_cfg) + sizeof(tusb_desc_configuration_t);
 1257|    212|  const uint8_t *desc_end = ((const uint8_t *)desc_cfg) + tu_le16toh(desc_cfg->wTotalLength);
  ------------------
  |  |  253|    212|  #define tu_le16toh(u16) (u16)
  ------------------
 1258|       |
 1259|    212|  while (tu_desc_in_bounds(p_desc, desc_end)) {
  ------------------
  |  Branch (1259:10): [True: 212, False: 0]
  ------------------
 1260|       |    // Class will always start with Interface Association (if any) and then Interface descriptor
 1261|    212|    if (TUSB_DESC_INTERFACE_ASSOCIATION == tu_desc_type(p_desc)) {
  ------------------
  |  Branch (1261:9): [True: 0, False: 212]
  ------------------
 1262|      0|      p_desc = tu_desc_next(p_desc); // next to Interface
 1263|      0|      continue;
 1264|      0|    }
 1265|       |
 1266|    212|    TU_ASSERT(TUSB_DESC_INTERFACE == tu_desc_type(p_desc));
  ------------------
  |  |  112|    212|#define TU_ASSERT(...)                 TU_GET_3RD_ARG(__VA_ARGS__, TU_ASSERT_2ARGS, TU_ASSERT_1ARGS, _dummy)(__VA_ARGS__)
  |  |  ------------------
  |  |  |  |  112|    212|#define TU_GET_3RD_ARG(arg1, arg2, arg3, ...)        arg3
  |  |  |  |  ------------------
  |  |  |  |  |  |  112|    212|#define TU_ASSERT(...)                 TU_GET_3RD_ARG(__VA_ARGS__, TU_ASSERT_2ARGS, TU_ASSERT_1ARGS, _dummy)(__VA_ARGS__)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  108|    212|#define TU_ASSERT_1ARGS(_cond)         TU_ASSERT_DEFINE(_cond, false)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  104|    212|  do {                                                                \
  |  |  |  |  |  |  |  |  |  |  105|    212|    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: 212]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  106|    212|  } while(0)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (106:11): [Folded, False: 212]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1267|    212|    const tusb_desc_interface_t *desc_itf = (const tusb_desc_interface_t *)p_desc;
 1268|       |
 1269|       |    // Find driver for this interface
 1270|    212|    const uint16_t remaining_len = (uint16_t)(desc_end - p_desc);
 1271|    212|    uint8_t        drv_id;
 1272|    424|    for (drv_id = 0; drv_id < TOTAL_DRIVER_COUNT; drv_id++) {
  ------------------
  |  |  369|    424|#define TOTAL_DRIVER_COUNT    ((uint8_t) (_app_driver_count + _builtin_driver_count))
  ------------------
  |  Branch (1272:22): [True: 212, False: 212]
  ------------------
 1273|    212|      const usbd_class_driver_t *driver = get_driver(drv_id);
 1274|    212|      TU_ASSERT(driver);
  ------------------
  |  |  112|    212|#define TU_ASSERT(...)                 TU_GET_3RD_ARG(__VA_ARGS__, TU_ASSERT_2ARGS, TU_ASSERT_1ARGS, _dummy)(__VA_ARGS__)
  |  |  ------------------
  |  |  |  |  112|    212|#define TU_GET_3RD_ARG(arg1, arg2, arg3, ...)        arg3
  |  |  |  |  ------------------
  |  |  |  |  |  |  112|    212|#define TU_ASSERT(...)                 TU_GET_3RD_ARG(__VA_ARGS__, TU_ASSERT_2ARGS, TU_ASSERT_1ARGS, _dummy)(__VA_ARGS__)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  108|    212|#define TU_ASSERT_1ARGS(_cond)         TU_ASSERT_DEFINE(_cond, false)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  104|    212|  do {                                                                \
  |  |  |  |  |  |  |  |  |  |  105|    212|    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: 212]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  106|    212|  } while(0)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (106:11): [Folded, False: 212]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1275|    212|      const uint16_t drv_len = driver->open(rhport, desc_itf, remaining_len);
 1276|       |
 1277|    212|      if ((sizeof(tusb_desc_interface_t) <= drv_len) && (drv_len <= remaining_len)) {
  ------------------
  |  Branch (1277:11): [True: 0, False: 212]
  |  Branch (1277:57): [True: 0, False: 0]
  ------------------
 1278|       |        // Open successfully
 1279|      0|        TU_LOG_USBD("  %s opened\r\n", driver->name);
 1280|       |
 1281|       |        // bind found driver to all interfaces and endpoint within drv_len
 1282|      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]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1283|      0|                                           drv_len));
 1284|       |
 1285|      0|        p_desc += drv_len; // next Interface
 1286|      0|        break; // exit driver find loop
 1287|      0|      }
 1288|    212|    }
 1289|       |
 1290|       |    // Failed if there is no supported drivers
 1291|    212|    TU_ASSERT(drv_id < TOTAL_DRIVER_COUNT);
  ------------------
  |  |  112|    212|#define TU_ASSERT(...)                 TU_GET_3RD_ARG(__VA_ARGS__, TU_ASSERT_2ARGS, TU_ASSERT_1ARGS, _dummy)(__VA_ARGS__)
  |  |  ------------------
  |  |  |  |  112|    212|#define TU_GET_3RD_ARG(arg1, arg2, arg3, ...)        arg3
  |  |  |  |  ------------------
  |  |  |  |  |  |  112|    212|#define TU_ASSERT(...)                 TU_GET_3RD_ARG(__VA_ARGS__, TU_ASSERT_2ARGS, TU_ASSERT_1ARGS, _dummy)(__VA_ARGS__)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  108|    212|#define TU_ASSERT_1ARGS(_cond)         TU_ASSERT_DEFINE(_cond, false)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  104|    212|  do {                                                                \
  |  |  |  |  |  |  |  |  |  |  105|    212|    if ( !(_cond) ) { TU_MESS_FAILED(); TU_BREAKPOINT(); return _ret; } \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   54|    212|  #define TU_MESS_FAILED() do {} while (0)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (54:41): [Folded, False: 212]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |                   if ( !(_cond) ) { TU_MESS_FAILED(); TU_BREAKPOINT(); return _ret; } \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   77|    212|  #define TU_BREAKPOINT() do {} while (0)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (77:40): [Folded, False: 212]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (105:10): [True: 212, False: 0]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  106|    212|  } while(0)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (106:11): [Folded, False: 0]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1292|    212|  }
 1293|       |
 1294|      0|  return true;
 1295|    212|}
usbd.c:process_get_descriptor:
 1298|  2.02k|static bool process_get_descriptor(uint8_t rhport, tusb_control_request_t const * p_request) {
 1299|  2.02k|  tusb_desc_type_t const desc_type = (tusb_desc_type_t) tu_u16_high(p_request->wValue);
 1300|  2.02k|  uint8_t const desc_index = tu_u16_low( p_request->wValue );
 1301|       |
 1302|  2.02k|  switch(desc_type) { //-V2520
 1303|    205|    case TUSB_DESC_DEVICE: {
  ------------------
  |  Branch (1303:5): [True: 205, False: 1.81k]
  ------------------
 1304|    205|      TU_LOG_USBD(" Device\r\n");
 1305|       |
 1306|    205|      void *desc_device = (void *)(uintptr_t)tud_descriptor_device_cb();
 1307|    205|      TU_ASSERT(desc_device);
  ------------------
  |  |  112|    205|#define TU_ASSERT(...)                 TU_GET_3RD_ARG(__VA_ARGS__, TU_ASSERT_2ARGS, TU_ASSERT_1ARGS, _dummy)(__VA_ARGS__)
  |  |  ------------------
  |  |  |  |  112|    205|#define TU_GET_3RD_ARG(arg1, arg2, arg3, ...)        arg3
  |  |  |  |  ------------------
  |  |  |  |  |  |  112|    205|#define TU_ASSERT(...)                 TU_GET_3RD_ARG(__VA_ARGS__, TU_ASSERT_2ARGS, TU_ASSERT_1ARGS, _dummy)(__VA_ARGS__)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  108|    205|#define TU_ASSERT_1ARGS(_cond)         TU_ASSERT_DEFINE(_cond, false)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  104|    205|  do {                                                                \
  |  |  |  |  |  |  |  |  |  |  105|    205|    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: 205]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  106|    205|  } while(0)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (106:11): [Folded, False: 205]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1308|       |
 1309|       |      // Only response with exactly 1 Packet if: not addressed and host requested more data than device descriptor has.
 1310|       |      // This only happens with the very first get device descriptor and EP0 size = 8 or 16.
 1311|    205|      if ((CFG_TUD_ENDPOINT0_SIZE < sizeof(tusb_desc_device_t)) && !_usbd_dev.addressed &&
  ------------------
  |  |   90|    205|#define CFG_TUD_ENDPOINT0_SIZE    64
  ------------------
  |  Branch (1311:11): [Folded, False: 205]
  |  Branch (1311:68): [True: 0, False: 0]
  ------------------
 1312|      0|          p_request->wLength > sizeof(tusb_desc_device_t)) {
  ------------------
  |  Branch (1312:11): [True: 0, False: 0]
  ------------------
 1313|       |        // Hack here: we modify the request length to prevent usbd_control response with zlp
 1314|       |        // since we are responding with 1 packet & less data than wLength.
 1315|      0|        ((tusb_control_request_t *)(uintptr_t)p_request)->wLength = CFG_TUD_ENDPOINT0_SIZE;
  ------------------
  |  |   90|      0|#define CFG_TUD_ENDPOINT0_SIZE    64
  ------------------
 1316|      0|        return tud_control_xfer(rhport, p_request, desc_device, CFG_TUD_ENDPOINT0_SIZE);
  ------------------
  |  |   90|      0|#define CFG_TUD_ENDPOINT0_SIZE    64
  ------------------
 1317|    205|      } else {
 1318|    205|        return tud_control_xfer(rhport, p_request, desc_device, sizeof(tusb_desc_device_t));
 1319|    205|      }
 1320|    205|    }
 1321|       |    // break; // unreachable
 1322|       |
 1323|    202|    case TUSB_DESC_BOS: {
  ------------------
  |  Branch (1323:5): [True: 202, False: 1.82k]
  ------------------
 1324|    202|      TU_LOG_USBD(" BOS\r\n");
 1325|       |
 1326|       |      // requested by host if USB > 2.0 ( i.e 2.1 or 3.x )
 1327|    202|      uintptr_t desc_bos = (uintptr_t) tud_descriptor_bos_cb();
 1328|    202|      TU_VERIFY(desc_bos != 0);
  ------------------
  |  |   95|    202|#define TU_VERIFY(...)                 TU_GET_3RD_ARG(__VA_ARGS__, TU_VERIFY_2ARGS, TU_VERIFY_1ARGS, _dummy)(__VA_ARGS__)
  |  |  ------------------
  |  |  |  |  112|    202|#define TU_GET_3RD_ARG(arg1, arg2, arg3, ...)        arg3
  |  |  |  |  ------------------
  |  |  |  |  |  |   95|    202|#define TU_VERIFY(...)                 TU_GET_3RD_ARG(__VA_ARGS__, TU_VERIFY_2ARGS, TU_VERIFY_1ARGS, _dummy)(__VA_ARGS__)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   92|    202|#define TU_VERIFY_1ARGS(_cond)         TU_VERIFY_DEFINE(_cond, false)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   86|    202|  do {                                \
  |  |  |  |  |  |  |  |  |  |   87|    202|    if (!(_cond)) {                   \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (87:9): [True: 202, False: 0]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   88|    202|      return _ret;                    \
  |  |  |  |  |  |  |  |  |  |   89|    202|    }                                 \
  |  |  |  |  |  |  |  |  |  |   90|    202|  } while (0)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (90:12): [Folded, False: 0]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1329|       |
 1330|       |      // Use offsetof to avoid pointer to the odd/misaligned address
 1331|      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)
  ------------------
 1332|       |
 1333|      0|      return tud_control_xfer(rhport, p_request, (void*) desc_bos, total_len);
 1334|    202|    }
 1335|       |    // break; // unreachable
 1336|       |
 1337|    262|    case TUSB_DESC_CONFIGURATION:
  ------------------
  |  Branch (1337:5): [True: 262, False: 1.76k]
  ------------------
 1338|    459|    case TUSB_DESC_OTHER_SPEED_CONFIG: {
  ------------------
  |  Branch (1338:5): [True: 197, False: 1.82k]
  ------------------
 1339|    459|      uintptr_t desc_config;
 1340|       |
 1341|    459|      if ( desc_type == TUSB_DESC_CONFIGURATION ) {
  ------------------
  |  Branch (1341:12): [True: 262, False: 197]
  ------------------
 1342|    262|        TU_LOG_USBD(" Configuration[%u]\r\n", desc_index);
 1343|    262|        desc_config = (uintptr_t) tud_descriptor_configuration_cb(desc_index);
 1344|    262|        TU_ASSERT(desc_config != 0);
  ------------------
  |  |  112|    262|#define TU_ASSERT(...)                 TU_GET_3RD_ARG(__VA_ARGS__, TU_ASSERT_2ARGS, TU_ASSERT_1ARGS, _dummy)(__VA_ARGS__)
  |  |  ------------------
  |  |  |  |  112|    262|#define TU_GET_3RD_ARG(arg1, arg2, arg3, ...)        arg3
  |  |  |  |  ------------------
  |  |  |  |  |  |  112|    262|#define TU_ASSERT(...)                 TU_GET_3RD_ARG(__VA_ARGS__, TU_ASSERT_2ARGS, TU_ASSERT_1ARGS, _dummy)(__VA_ARGS__)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  108|    262|#define TU_ASSERT_1ARGS(_cond)         TU_ASSERT_DEFINE(_cond, false)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  104|    262|  do {                                                                \
  |  |  |  |  |  |  |  |  |  |  105|    262|    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: 262]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  106|    262|  } while(0)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (106:11): [Folded, False: 262]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1345|    262|      }else {
 1346|       |        // Host only request this after getting Device Qualifier descriptor
 1347|    197|        TU_LOG_USBD(" Other Speed Configuration\r\n");
 1348|    197|        desc_config = (uintptr_t) tud_descriptor_other_speed_configuration_cb(desc_index);
 1349|    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]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1350|    197|      }
 1351|       |
 1352|       |      // Use offsetof to avoid pointer to the odd/misaligned address
 1353|    262|      uint16_t const total_len = tu_le16toh( tu_unaligned_read16((const void*) (desc_config + offsetof(tusb_desc_configuration_t, wTotalLength))) );
  ------------------
  |  |  253|    262|  #define tu_le16toh(u16) (u16)
  ------------------
 1354|       |
 1355|    262|      return tud_control_xfer(rhport, p_request, (void*) desc_config, total_len);
 1356|    459|    }
 1357|       |    // break; // unreachable
 1358|       |
 1359|    685|    case TUSB_DESC_STRING: {
  ------------------
  |  Branch (1359:5): [True: 685, False: 1.33k]
  ------------------
 1360|    685|      TU_LOG_USBD(" String[%u]\r\n", desc_index);
 1361|       |
 1362|       |      // String Descriptor always uses the desc set from user
 1363|    685|      uint8_t const* desc_str = (uint8_t const*) tud_descriptor_string_cb(desc_index, p_request->wIndex);
 1364|    685|      TU_VERIFY(desc_str);
  ------------------
  |  |   95|    685|#define TU_VERIFY(...)                 TU_GET_3RD_ARG(__VA_ARGS__, TU_VERIFY_2ARGS, TU_VERIFY_1ARGS, _dummy)(__VA_ARGS__)
  |  |  ------------------
  |  |  |  |  112|    685|#define TU_GET_3RD_ARG(arg1, arg2, arg3, ...)        arg3
  |  |  |  |  ------------------
  |  |  |  |  |  |   95|    685|#define TU_VERIFY(...)                 TU_GET_3RD_ARG(__VA_ARGS__, TU_VERIFY_2ARGS, TU_VERIFY_1ARGS, _dummy)(__VA_ARGS__)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   92|    685|#define TU_VERIFY_1ARGS(_cond)         TU_VERIFY_DEFINE(_cond, false)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   86|    685|  do {                                \
  |  |  |  |  |  |  |  |  |  |   87|    685|    if (!(_cond)) {                   \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (87:9): [True: 207, False: 478]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   88|    207|      return _ret;                    \
  |  |  |  |  |  |  |  |  |  |   89|    207|    }                                 \
  |  |  |  |  |  |  |  |  |  |   90|    685|  } while (0)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (90:12): [Folded, False: 478]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1365|       |
 1366|       |      // first byte of descriptor is its size
 1367|    478|      return tud_control_xfer(rhport, p_request, (void*) (uintptr_t) desc_str, tu_desc_len(desc_str));
 1368|    685|    }
 1369|       |    // break; // unreachable
 1370|       |
 1371|    197|    case TUSB_DESC_DEVICE_QUALIFIER: {
  ------------------
  |  Branch (1371:5): [True: 197, False: 1.82k]
  ------------------
 1372|    197|      TU_LOG_USBD(" Device Qualifier\r\n");
 1373|    197|      uint8_t const* desc_qualifier = tud_descriptor_device_qualifier_cb();
 1374|    197|      TU_VERIFY(desc_qualifier);
  ------------------
  |  |   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]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1375|      0|      return tud_control_xfer(rhport, p_request, (void*) (uintptr_t) desc_qualifier, tu_desc_len(desc_qualifier));
 1376|    197|    }
 1377|       |    // break; // unreachable
 1378|       |
 1379|    274|    default: return false;
  ------------------
  |  Branch (1379:5): [True: 274, False: 1.74k]
  ------------------
 1380|  2.02k|  }
 1381|  2.02k|}
usbd.c:process_get_status:
 1058|  1.84k|static bool process_get_status(uint8_t rhport, tusb_control_request_t const * request, uint16_t status) {
 1059|  1.84k|  TU_VERIFY(request->bmRequestType_bit.direction == TUSB_DIR_IN);
  ------------------
  |  |   95|  1.84k|#define TU_VERIFY(...)                 TU_GET_3RD_ARG(__VA_ARGS__, TU_VERIFY_2ARGS, TU_VERIFY_1ARGS, _dummy)(__VA_ARGS__)
  |  |  ------------------
  |  |  |  |  112|  1.84k|#define TU_GET_3RD_ARG(arg1, arg2, arg3, ...)        arg3
  |  |  |  |  ------------------
  |  |  |  |  |  |   95|  1.84k|#define TU_VERIFY(...)                 TU_GET_3RD_ARG(__VA_ARGS__, TU_VERIFY_2ARGS, TU_VERIFY_1ARGS, _dummy)(__VA_ARGS__)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   92|  1.84k|#define TU_VERIFY_1ARGS(_cond)         TU_VERIFY_DEFINE(_cond, false)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   86|  1.84k|  do {                                \
  |  |  |  |  |  |  |  |  |  |   87|  1.84k|    if (!(_cond)) {                   \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (87:9): [True: 1.76k, False: 78]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   88|  1.76k|      return _ret;                    \
  |  |  |  |  |  |  |  |  |  |   89|  1.76k|    }                                 \
  |  |  |  |  |  |  |  |  |  |   90|  1.84k|  } while (0)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (90:12): [Folded, False: 78]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1060|     78|  return tud_control_xfer(rhport, request, &status, 2);
 1061|  1.84k|}
usbd.c:queue_event:
  410|  35.1k|TU_ATTR_ALWAYS_INLINE static inline bool queue_event(dcd_event_t const * event, bool in_isr) {
  411|  35.1k|  TU_ASSERT(osal_queue_send(_usbd_q, event, in_isr));
  ------------------
  |  |  112|  35.1k|#define TU_ASSERT(...)                 TU_GET_3RD_ARG(__VA_ARGS__, TU_ASSERT_2ARGS, TU_ASSERT_1ARGS, _dummy)(__VA_ARGS__)
  |  |  ------------------
  |  |  |  |  112|  35.1k|#define TU_GET_3RD_ARG(arg1, arg2, arg3, ...)        arg3
  |  |  |  |  ------------------
  |  |  |  |  |  |  112|  35.1k|#define TU_ASSERT(...)                 TU_GET_3RD_ARG(__VA_ARGS__, TU_ASSERT_2ARGS, TU_ASSERT_1ARGS, _dummy)(__VA_ARGS__)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  108|  35.1k|#define TU_ASSERT_1ARGS(_cond)         TU_ASSERT_DEFINE(_cond, false)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  104|  35.1k|  do {                                                                \
  |  |  |  |  |  |  |  |  |  |  105|  35.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: 35.1k]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  106|  35.1k|  } while(0)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (106:11): [Folded, False: 35.1k]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  412|  35.1k|  tud_event_hook_cb(event->rhport, event->event_id, in_isr);
  413|       |  return true;
  414|  35.1k|}

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

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|  77.9k|TU_ATTR_ALWAYS_INLINE static inline bool osal_queue_receive(osal_queue_t qhdl, void* data, uint32_t msec) {
  187|  77.9k|  (void) msec; // not used, always behave as msec = 0
  188|       |
  189|  77.9k|  qhdl->interrupt_set(false);
  190|  77.9k|  const bool success = (tu_fifo_read_n(&qhdl->ff, data, qhdl->item_size) > 0);
  191|  77.9k|  qhdl->interrupt_set(true);
  192|       |
  193|  77.9k|  return success;
  194|  77.9k|}
usbd.c:osal_queue_send:
  196|  35.1k|TU_ATTR_ALWAYS_INLINE static inline bool osal_queue_send(osal_queue_t qhdl, void const* data, bool in_isr) {
  197|  35.1k|  if (!in_isr) {
  ------------------
  |  Branch (197:7): [True: 13.3k, False: 21.7k]
  ------------------
  198|  13.3k|    qhdl->interrupt_set(false);
  199|  13.3k|  }
  200|       |
  201|  35.1k|  const bool success = (tu_fifo_write_n(&qhdl->ff, data, qhdl->item_size) > 0);
  202|       |
  203|  35.1k|  if (!in_isr) {
  ------------------
  |  Branch (203:7): [True: 13.3k, False: 21.7k]
  ------------------
  204|  13.3k|    qhdl->interrupt_set(true);
  205|  13.3k|  }
  206|       |
  207|  35.1k|  return success;
  208|  35.1k|}

tusb_rhport_init:
   65|  1.00k|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|  1.00k|  TU_ASSERT(rhport < TUP_USBIP_CONTROLLER_NUM && rh_init->role != TUSB_ROLE_INVALID);
  ------------------
  |  |  112|  1.00k|#define TU_ASSERT(...)                 TU_GET_3RD_ARG(__VA_ARGS__, TU_ASSERT_2ARGS, TU_ASSERT_1ARGS, _dummy)(__VA_ARGS__)
  |  |  ------------------
  |  |  |  |  112|  1.00k|#define TU_GET_3RD_ARG(arg1, arg2, arg3, ...)        arg3
  |  |  |  |  ------------------
  |  |  |  |  |  |  112|  1.00k|#define TU_ASSERT(...)                 TU_GET_3RD_ARG(__VA_ARGS__, TU_ASSERT_2ARGS, TU_ASSERT_1ARGS, _dummy)(__VA_ARGS__)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  108|  1.00k|#define TU_ASSERT_1ARGS(_cond)         TU_ASSERT_DEFINE(_cond, false)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  104|  1.00k|  do {                                                                \
  |  |  |  |  |  |  |  |  |  |  105|  2.00k|    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.00k, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  Branch (105:12): [True: 1.00k, False: 0]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  106|  1.00k|  } while(0)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (106:11): [Folded, False: 1.00k]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   95|  1.00k|  _tusb_rhport_role[rhport] = rh_init->role;
   96|       |
   97|  1.00k|  #if CFG_TUD_ENABLED
   98|  1.00k|  if (rh_init->role == TUSB_ROLE_DEVICE) {
  ------------------
  |  Branch (98:7): [True: 1.00k, False: 0]
  ------------------
   99|  1.00k|    TU_ASSERT(tud_rhport_init(rhport, rh_init));
  ------------------
  |  |  112|  1.00k|#define TU_ASSERT(...)                 TU_GET_3RD_ARG(__VA_ARGS__, TU_ASSERT_2ARGS, TU_ASSERT_1ARGS, _dummy)(__VA_ARGS__)
  |  |  ------------------
  |  |  |  |  112|  1.00k|#define TU_GET_3RD_ARG(arg1, arg2, arg3, ...)        arg3
  |  |  |  |  ------------------
  |  |  |  |  |  |  112|  1.00k|#define TU_ASSERT(...)                 TU_GET_3RD_ARG(__VA_ARGS__, TU_ASSERT_2ARGS, TU_ASSERT_1ARGS, _dummy)(__VA_ARGS__)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  108|  1.00k|#define TU_ASSERT_1ARGS(_cond)         TU_ASSERT_DEFINE(_cond, false)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  104|  1.00k|  do {                                                                \
  |  |  |  |  |  |  |  |  |  |  105|  1.00k|    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.00k]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  106|  1.00k|  } while(0)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (106:11): [Folded, False: 1.00k]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  100|  1.00k|  }
  101|  1.00k|  #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|  1.00k|  return true;
  110|  1.00k|}

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|  42.7k|void dcd_int_handler(uint8_t rhport) {
   56|  42.7k|  assert(_fuzz_data_provider.has_value());
  ------------------
  |  Branch (56:3): [True: 42.7k, False: 0]
  ------------------
   57|       |
   58|  42.7k|  if (!state.interrupts_enabled) {
  ------------------
  |  Branch (58:7): [True: 0, False: 42.7k]
  ------------------
   59|      0|    return;
   60|      0|  }
   61|       |
   62|       |  // Choose if we want to generate a signal based on the fuzzed data.
   63|  42.7k|  if (_fuzz_data_provider->ConsumeBool()) {
  ------------------
  |  Branch (63:7): [True: 11.2k, False: 31.4k]
  ------------------
   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|  11.2k|    static const dcd_eventid_t bus_signal_events[] = {
   69|  11.2k|        DCD_EVENT_UNPLUGGED, DCD_EVENT_SUSPEND, DCD_EVENT_RESUME};
   70|  11.2k|    uint8_t idx = _fuzz_data_provider->ConsumeIntegralInRange<uint8_t>(0, 2);
   71|  11.2k|    dcd_event_bus_signal(rhport, bus_signal_events[idx],
   72|  11.2k|                         _fuzz_data_provider->ConsumeBool());
   73|  11.2k|  }
   74|       |
   75|       |  // Optionally generate a BUS_RESET event with a valid speed value.
   76|  42.7k|  if (_fuzz_data_provider->ConsumeBool()) {
  ------------------
  |  Branch (76:7): [True: 10.3k, False: 32.4k]
  ------------------
   77|  10.3k|    tusb_speed_t speed = (tusb_speed_t)_fuzz_data_provider->ConsumeIntegralInRange<uint8_t>(
   78|  10.3k|        TUSB_SPEED_FULL, TUSB_SPEED_HIGH);
   79|  10.3k|    dcd_event_bus_reset(rhport, speed, _fuzz_data_provider->ConsumeBool());
   80|  10.3k|  }
   81|       |
   82|  42.7k|  if (_fuzz_data_provider->ConsumeBool()) {
  ------------------
  |  Branch (82:7): [True: 15.1k, False: 27.6k]
  ------------------
   83|  15.1k|    constexpr size_t kSetupFrameLength = 8;
   84|  15.1k|    std::vector<uint8_t> setup =
   85|  15.1k|        _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.1k|    if (setup.size() != kSetupFrameLength) {
  ------------------
  |  Branch (89:9): [True: 403, False: 14.7k]
  ------------------
   90|    403|      setup.resize(kSetupFrameLength);
   91|    403|    }
   92|  15.1k|    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.1k|                             _fuzz_data_provider->ConsumeBool());
   96|  15.1k|  }
   97|  42.7k|}
dcd_int_enable:
   99|  91.2k|void dcd_int_enable(uint8_t rhport) {
  100|  91.2k|  state.interrupts_enabled = true;
  101|  91.2k|  UNUSED(rhport);
  ------------------
  |  |   31|  91.2k|#define UNUSED(x) (void)(x)
  ------------------
  102|  91.2k|  return;
  103|  91.2k|}
dcd_int_disable:
  105|  91.2k|void dcd_int_disable(uint8_t rhport) {
  106|  91.2k|  state.interrupts_enabled = false;
  107|  91.2k|  UNUSED(rhport);
  ------------------
  |  |   31|  91.2k|#define UNUSED(x) (void)(x)
  ------------------
  108|  91.2k|  return;
  109|  91.2k|}
dcd_set_address:
  111|    201|void dcd_set_address(uint8_t rhport, uint8_t dev_addr) {
  112|    201|  UNUSED(rhport);
  ------------------
  |  |   31|    201|#define UNUSED(x) (void)(x)
  ------------------
  113|    201|  state.address = dev_addr;
  114|       |  // Respond with status.
  115|       |  dcd_edpt_xfer(rhport, tu_edpt_addr(0, TUSB_DIR_IN), NULL, 0, false);
  116|    201|  return;
  117|    201|}
dcd_edpt_xfer:
  171|  3.80k|                   uint16_t total_bytes, bool is_isr) {
  172|  3.80k|  UNUSED(rhport);
  ------------------
  |  |   31|  3.80k|#define UNUSED(x) (void)(x)
  ------------------
  173|  3.80k|  UNUSED(buffer);
  ------------------
  |  |   31|  3.80k|#define UNUSED(x) (void)(x)
  ------------------
  174|  3.80k|  UNUSED(total_bytes);
  ------------------
  |  |   31|  3.80k|#define UNUSED(x) (void)(x)
  ------------------
  175|  3.80k|  UNUSED(is_isr);
  ------------------
  |  |   31|  3.80k|#define UNUSED(x) (void)(x)
  ------------------
  176|       |
  177|  3.80k|  uint8_t const dir = tu_edpt_dir(ep_addr);
  178|       |
  179|  3.80k|  if (dir == TUSB_DIR_IN) {
  ------------------
  |  Branch (179:7): [True: 2.89k, False: 913]
  ------------------
  180|  2.89k|    std::vector<uint8_t> temp =
  181|  2.89k|        _fuzz_data_provider->ConsumeBytes<uint8_t>(total_bytes);
  182|  2.89k|    std::copy(temp.begin(), temp.end(), buffer);
  183|  2.89k|  }
  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|  3.80k|  volatile uint8_t *dont_optimise0 = buffer;
  188|  3.80k|  volatile uint16_t dont_optimise1 = total_bytes;
  189|  3.80k|  UNUSED(dont_optimise0);
  ------------------
  |  |   31|  3.80k|#define UNUSED(x) (void)(x)
  ------------------
  190|  3.80k|  UNUSED(dont_optimise1);
  ------------------
  |  |   31|  3.80k|#define UNUSED(x) (void)(x)
  ------------------
  191|       |
  192|       |
  193|  3.80k|  return _fuzz_data_provider->ConsumeBool();
  194|  3.80k|}
dcd_edpt_stall:
  202|  24.0k|void dcd_edpt_stall(uint8_t rhport, uint8_t ep_addr) {
  203|       |
  204|  24.0k|  UNUSED(rhport);
  ------------------
  |  |   31|  24.0k|#define UNUSED(x) (void)(x)
  ------------------
  205|  24.0k|  UNUSED(ep_addr);
  ------------------
  |  |   31|  24.0k|#define UNUSED(x) (void)(x)
  ------------------
  206|  24.0k|  return;
  207|  24.0k|}

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

tud_descriptor_device_cb:
   46|    205|uint8_t const *tud_descriptor_device_cb(void) {
   47|    205|  tu_static tusb_desc_device_t const desc_device = {
  ------------------
  |  |   39|    205|  #define tu_static static __thread
  ------------------
   48|    205|      .bLength = sizeof(tusb_desc_device_t),
   49|    205|      .bDescriptorType = TUSB_DESC_DEVICE,
   50|    205|      .bcdUSB = USB_BCD,
  ------------------
  |  |   38|    205|#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|    205|      .bDeviceClass = TUSB_CLASS_MISC,
   56|    205|      .bDeviceSubClass = MISC_SUBCLASS_COMMON,
   57|    205|      .bDeviceProtocol = MISC_PROTOCOL_IAD,
   58|       |
   59|    205|      .bMaxPacketSize0 = CFG_TUD_ENDPOINT0_SIZE,
  ------------------
  |  |   90|    205|#define CFG_TUD_ENDPOINT0_SIZE    64
  ------------------
   60|       |
   61|    205|      .idVendor = USB_VID,
  ------------------
  |  |   37|    205|#define USB_VID 0xCafe
  ------------------
   62|    205|      .idProduct = USB_PID,
  ------------------
  |  |   35|    205|  (0x4000 | PID_MAP(MSC, 0) | PID_MAP(HID, 1) | PID_MAP(MIDI, 2) |          \
  |  |  ------------------
  |  |  |  |   33|    205|#define PID_MAP(itf, n) ((CFG_TUD_##itf) << (n))
  |  |  |  |  ------------------
  |  |  |  |  |  |   95|    205|#define CFG_TUD_MSC              1
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                 (0x4000 | PID_MAP(MSC, 0) | PID_MAP(HID, 1) | PID_MAP(MIDI, 2) |          \
  |  |  ------------------
  |  |  |  |   33|    205|#define PID_MAP(itf, n) ((CFG_TUD_##itf) << (n))
  |  |  |  |  ------------------
  |  |  |  |  |  |   96|    205|#define CFG_TUD_HID              0
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                 (0x4000 | PID_MAP(MSC, 0) | PID_MAP(HID, 1) | PID_MAP(MIDI, 2) |          \
  |  |  ------------------
  |  |  |  |   33|    205|#define PID_MAP(itf, n) ((CFG_TUD_##itf) << (n))
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|    205|#define CFG_TUD_MIDI             0
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   36|    205|   PID_MAP(VENDOR, 3))
  |  |  ------------------
  |  |  |  |   33|    205|#define PID_MAP(itf, n) ((CFG_TUD_##itf) << (n))
  |  |  |  |  ------------------
  |  |  |  |  |  |   98|    205|#define CFG_TUD_VENDOR           0
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   63|    205|      .bcdDevice = 0x0100,
   64|       |
   65|    205|      .iManufacturer = 0x01,
   66|    205|      .iProduct = 0x02,
   67|    205|      .iSerialNumber = 0x03,
   68|       |
   69|    205|      .bNumConfigurations = 0x01};
   70|       |
   71|    205|  return (uint8_t const *)&desc_device;
   72|    205|}
tud_descriptor_configuration_cb:
  161|    474|uint8_t const *tud_descriptor_configuration_cb(uint8_t index) {
  162|    474|  (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|    474|  return desc_fs_configuration;
  170|    474|#endif
  171|    474|}
tud_descriptor_string_cb:
  192|    685|uint16_t const *tud_descriptor_string_cb(uint8_t index, uint16_t langid) {
  193|    685|  (void)langid;
  194|       |
  195|    685|  uint8_t chr_count;
  196|       |
  197|    685|  if (index == 0) {
  ------------------
  |  Branch (197:7): [True: 202, False: 483]
  ------------------
  198|    202|    memcpy(&_desc_str[1], string_desc_arr[0], 2);
  199|    202|    chr_count = 1;
  200|    483|  } 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|    483|    if (!(index < sizeof(string_desc_arr) / sizeof(string_desc_arr[0])))
  ------------------
  |  Branch (204:9): [True: 207, False: 276]
  ------------------
  205|    207|      return NULL;
  206|       |
  207|    276|    const char *str = string_desc_arr[index];
  208|       |
  209|       |    // Cap at max char
  210|    276|    chr_count = (uint8_t)strlen(str);
  211|    276|    if (chr_count > 31)
  ------------------
  |  Branch (211:9): [True: 0, False: 276]
  ------------------
  212|      0|      chr_count = 31;
  213|       |
  214|       |    // Convert ASCII string into UTF-16
  215|  3.99k|    for (uint8_t i = 0; i < chr_count; i++) {
  ------------------
  |  Branch (215:25): [True: 3.71k, False: 276]
  ------------------
  216|  3.71k|      _desc_str[1 + i] = str[i];
  217|  3.71k|    }
  218|    276|  }
  219|       |
  220|       |  // first byte is length (including header), second byte is string type
  221|    478|  _desc_str[0] = (uint16_t)((TUSB_DESC_STRING << 8) | (2 * chr_count + 2));
  222|       |
  223|    478|  return _desc_str;
  224|    685|}

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

