Skip to content

Commit

Permalink
Correct handling of SOF interrupt
Browse files Browse the repository at this point in the history
  • Loading branch information
skuep committed Oct 30, 2022
1 parent a19a5ee commit 5cb3ed5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
2 changes: 2 additions & 0 deletions src/class/audio/audio_device.c
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,8 @@ static bool audiod_verify_itf_exists(uint8_t itf, uint8_t *func_id);
static bool audiod_verify_ep_exists(uint8_t ep, uint8_t *func_id);
static uint8_t audiod_get_audio_fct_idx(audiod_function_t * audio);

static bool set_fb_params_freq(audiod_function_t* audio, uint32_t sample_freq, uint32_t mclk_freq);

#if CFG_TUD_AUDIO_ENABLE_ENCODING || CFG_TUD_AUDIO_ENABLE_DECODING
static void audiod_parse_for_AS_params(audiod_function_t* audio, uint8_t const * p_desc, uint8_t const * p_desc_end, uint8_t const as_itf);

Expand Down
21 changes: 10 additions & 11 deletions src/portable/st/stm32_fsdev/dcd_stm32_fsdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -141,12 +141,6 @@
# define DCD_STM32_BTABLE_LENGTH (PMA_LENGTH - DCD_STM32_BTABLE_BASE)
#endif

// Since TinyUSB doesn't use SOF for now, and this interrupt too often (1ms interval)
// We disable SOF for now until needed later on
#ifndef USE_SOF
# define USE_SOF 0
#endif

/***************************************************
* Checks, structs, defines, function definitions, etc.
*/
Expand Down Expand Up @@ -251,7 +245,7 @@ void dcd_init (uint8_t rhport)
pcd_set_endpoint(USB,i,0u);
}

USB->CNTR |= USB_CNTR_RESETM | (USE_SOF ? USB_CNTR_SOFM : 0) | USB_CNTR_ESOFM | USB_CNTR_CTRM | USB_CNTR_SUSPM | USB_CNTR_WKUPM;
USB->CNTR |= USB_CNTR_RESETM | USB_CNTR_ESOFM | USB_CNTR_CTRM | USB_CNTR_SUSPM | USB_CNTR_WKUPM;
dcd_handle_bus_reset();

// Enable pull-up if supported
Expand Down Expand Up @@ -296,7 +290,14 @@ void dcd_sof_enable(uint8_t rhport, bool en)
(void) rhport;
(void) en;

// TODO implement later
if (en)
{
USB->CNTR |= USB_CNTR_SOFM;
}
else
{
USB->CNTR &= (uint16_t) ~USB_CNTR_SOFM;
}
}

// Enable device interrupt
Expand Down Expand Up @@ -645,12 +646,10 @@ void dcd_int_handler(uint8_t rhport) {
dcd_event_bus_signal(0, DCD_EVENT_SUSPEND, true);
}

#if USE_SOF
if(int_status & USB_ISTR_SOF) {
clear_istr_bits(USB_ISTR_SOF);
dcd_event_bus_signal(0, DCD_EVENT_SOF, true);
dcd_event_sof(0, USB->FNR & USB_FNR_FN, true);
}
#endif

if(int_status & USB_ISTR_ESOF) {
if(remoteWakeCountdown == 1u)
Expand Down

0 comments on commit 5cb3ed5

Please sign in to comment.