Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions examples/device/uac2_speaker_fb/src/audio_debug.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@
# Install python3 HID package https://pypi.org/project/hid/
# Install python3 matplotlib package https://pypi.org/project/matplotlib/

from ctypes import *
from ctypes import Structure, c_uint32, c_uint8, c_int8, c_int16, c_uint16
import signal
try:
import hid
import matplotlib.pyplot as plt
import matplotlib.animation as animation
except:
print("Missing import, please try 'pip install hid matplotlib' or consult your OS's python package manager.")
exit(1)

# Example must be compiled with CFG_AUDIO_DEBUG=1
VID = 0xcafe
Expand All @@ -29,6 +31,7 @@ class audio_debug_info_t (Structure):
dev = hid.Device(VID, PID)

if dev:
signal.signal(signal.SIGINT, signal.SIG_DFL)
# Create figure for plotting
fig = plt.figure()
ax = fig.add_subplot(1, 1, 1)
Expand Down Expand Up @@ -61,10 +64,10 @@ def animate(i):
ax.set_ylim(bottom=0, top=info.fifo_size)

# Format plot
plt.title('FIFO information')
plt.grid()
ax.set_title('FIFO information')
ax.grid(True)

print(f'Sample rate:{info.sample_rate} | Alt settings:{info.alt_settings} | Volume:{info.volume[:]}')

ani = animation.FuncAnimation(fig, animate, interval=10)
plt.show()
ani = animation.FuncAnimation(fig, animate, interval=10, cache_frame_data=False) # type: ignore
plt.show(block=True)
4 changes: 3 additions & 1 deletion src/common/tusb_fifo.h
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,9 @@ bool tu_fifo_full(const tu_fifo_t *f);
bool tu_fifo_overflowed(const tu_fifo_t *f);

TU_ATTR_ALWAYS_INLINE static inline bool tu_fifo_empty(const tu_fifo_t *f) {
return f->wr_idx == f->rd_idx;
uint16_t wr_idx = f->wr_idx;
uint16_t rd_idx = f->rd_idx;
return wr_idx == rd_idx;
}

TU_ATTR_ALWAYS_INLINE static inline uint16_t tu_fifo_depth(const tu_fifo_t *f) {
Expand Down
3 changes: 1 addition & 2 deletions src/portable/st/stm32_fsdev/fsdev_stm32.h
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,7 @@
#include "stm32u0xx.h"
#define FSDEV_PMA_SIZE (1024u)
#define FSDEV_BUS_32BIT
// Disable SBUF_ISO on U0 for now due to bad performance (audio glitching)
#define FSDEV_HAS_SBUF_ISO 0
#define FSDEV_HAS_SBUF_ISO 1
#define USB USB_DRD_FS

#define USB_EP_CTR_RX USB_EP_VTRX
Expand Down
Loading