Added improvements with regards to SOF timing jitter

This commit is contained in:
Simon Kueppers 2022-11-06 12:40:14 +01:00 committed by Mengsk
parent 76413a95d4
commit 1d37f5ef9b
2 changed files with 10 additions and 5 deletions

View File

@ -627,6 +627,13 @@ void dcd_int_handler(uint8_t rhport) {
// dcd_ep_ctr_handler(), so less need to loop here. The other interrupts shouldn't
// be triggered repeatedly.
/* Put SOF flag at the beginning of ISR in case to get least amount of jitter if it is used for timing purposes */
if(int_status & USB_ISTR_SOF) {
clear_istr_bits(USB_ISTR_SOF);
if (tu_stm32_sof_cb) tu_stm32_sof_cb();
dcd_event_sof(0, USB->FNR & USB_FNR_FN, true);
}
if(int_status & USB_ISTR_RESET) {
// USBRST is start of reset.
clear_istr_bits(USB_ISTR_RESET);
@ -664,11 +671,6 @@ void dcd_int_handler(uint8_t rhport) {
dcd_event_bus_signal(0, DCD_EVENT_SUSPEND, true);
}
if(int_status & USB_ISTR_SOF) {
clear_istr_bits(USB_ISTR_SOF);
dcd_event_sof(0, USB->FNR & USB_FNR_FN, true);
}
if(int_status & USB_ISTR_ESOF) {
if(remoteWakeCountdown == 1u)
{

View File

@ -130,6 +130,9 @@ static __IO uint16_t * const pma = (__IO uint16_t*)USB_PMAADDR;
// this callback and defining a custom mapping in your application
TU_ATTR_WEAK uint8_t tu_stm32_edpt_number_cb(uint8_t addr);
// This callback is called on SOF and can be used to e.g. capture a timer value for timing purposes
TU_ATTR_WEAK void tu_stm32_sof_cb(void);
// prototypes
TU_ATTR_ALWAYS_INLINE static inline __IO uint16_t* pcd_ep_rx_cnt_ptr(USB_TypeDef * USBx, uint32_t bEpNum);
TU_ATTR_ALWAYS_INLINE static inline __IO uint16_t* pcd_ep_tx_cnt_ptr(USB_TypeDef * USBx, uint32_t bEpNum);