Sfoglia il codice sorgente

Use USB clock recovery when running USB from IRC48M oscillator

main
PaulStoffregen 8 anni fa
parent
commit
27fa2e2a52
2 ha cambiato i file con 17 aggiunte e 1 eliminazioni
  1. +11
    -0
      teensy3/kinetis.h
  2. +6
    -1
      teensy3/usb_dev.c

+ 11
- 0
teensy3/kinetis.h Vedi File

@@ -3882,6 +3882,17 @@ typedef struct {
#define USB_USBTRC_SYNC_DET ((uint8_t)0x02) //
#define USB_USBTRC_USB_RESUME_INT ((uint8_t)0x01) //
#define USB0_USBFRMADJUST (*(volatile uint8_t *)0x40072114) // Frame Adjust Register
#define USB0_CLK_RECOVER_CTRL (*(volatile uint8_t *)0x40072140) // USB Clock recovery control
#define USB_CLK_RECOVER_CTRL_CLOCK_RECOVER_EN ((uint8_t)0x80)
#define USB_CLK_RECOVER_CTRL_RESET_RESUME_ROUGH_EN ((uint8_t)0x40)
#define USB_CLK_RECOVER_CTRL_RESTART_IFRTRIM_EN ((uint8_t)0x20)
#define USB0_CLK_RECOVER_IRC_EN (*(volatile uint8_t *)0x40072144) // IRC48M oscillator enable
#define USB_CLK_RECOVER_IRC_EN_IRC_EN ((uint8_t)0x02)
#define USB_CLK_RECOVER_IRC_EN_REG_EN ((uint8_t)0x01)
#define USB0_CLK_RECOVER_INT_EN (*(volatile uint8_t *)0x40072154) // Clock recovery combined interrupt enable
#define USB_CLK_RECOVER_INT_EN_OVF_ERROR_EN ((uint8_t)0x10)
#define USB0_CLK_RECOVER_INT_STATUS (*(volatile uint8_t *)0x4007215C) // Clock recovery separated interrupt status
#define USB_CLK_RECOVER_INT_STATUS_OVF_ERROR ((uint8_t)0x10)


// USB Device Charger Detection Module (USBDCD)

+ 6
- 1
teensy3/usb_dev.c Vedi File

@@ -1111,7 +1111,12 @@ void usb_init(void)
#ifdef HAS_KINETIS_MPU
MPU_RGDAAC0 |= 0x03000000;
#endif

#if F_CPU == 180000000 || F_CPU == 216000000
// if using IRC48M, turn on the USB clock recovery hardware
USB0_CLK_RECOVER_IRC_EN = USB_CLK_RECOVER_IRC_EN_IRC_EN | USB_CLK_RECOVER_IRC_EN_REG_EN;
USB0_CLK_RECOVER_CTRL = USB_CLK_RECOVER_CTRL_CLOCK_RECOVER_EN |
USB_CLK_RECOVER_CTRL_RESTART_IFRTRIM_EN;
#endif
// reset USB module
//USB0_USBTRC0 = USB_USBTRC_USBRESET;
//while ((USB0_USBTRC0 & USB_USBTRC_USBRESET) != 0) ; // wait for reset to end

Loading…
Annulla
Salva