Sfoglia il codice sorgente

FCPU 256MHz

teensy4-core
Frank Bösing 6 anni fa
parent
commit
11bd76352d
11 ha cambiato i file con 62 aggiunte e 23 eliminazioni
  1. +3
    -1
      teensy3/core_pins.h
  2. +8
    -2
      teensy3/kinetis.h
  3. +29
    -6
      teensy3/mk20dx128.c
  4. +3
    -1
      teensy3/pins_teensy.c
  5. +1
    -1
      teensy3/usb_dev.c
  6. +3
    -2
      teensy3/usb_joystick.c
  7. +3
    -2
      teensy3/usb_keyboard.c
  8. +3
    -2
      teensy3/usb_midi.c
  9. +3
    -2
      teensy3/usb_mouse.c
  10. +3
    -2
      teensy3/usb_seremu.c
  11. +3
    -2
      teensy3/usb_serial.c

+ 3
- 1
teensy3/core_pins.h Vedi File

@@ -2023,7 +2023,9 @@ uint32_t micros(void);
static inline void delayMicroseconds(uint32_t) __attribute__((always_inline, unused));
static inline void delayMicroseconds(uint32_t usec)
{
#if F_CPU == 240000000
#if F_CPU == 256000000
uint32_t n = usec * 85;
#elif F_CPU == 240000000
uint32_t n = usec * 80;
#elif F_CPU == 216000000
uint32_t n = usec * 72;

+ 8
- 2
teensy3/kinetis.h Vedi File

@@ -761,8 +761,14 @@ enum IRQ_NUMBER_t {

#endif // end of board-specific definitions


#if (F_CPU == 240000000)
#if (F_CPU == 256000000)
#define F_PLL 256000000
#ifndef F_BUS
#define F_BUS 64000000
//#define F_BUS 128000000 // all the usual overclocking caveats apply...
#endif
#define F_MEM 32000000
#elif (F_CPU == 240000000)
#define F_PLL 240000000
#ifndef F_BUS
#define F_BUS 60000000

+ 29
- 6
teensy3/mk20dx128.c Vedi File

@@ -841,7 +841,9 @@ void ResetHandler(void)
SMC_PMCTRL = SMC_PMCTRL_RUNM(3); // enter HSRUN mode
while (SMC_PMSTAT != SMC_PMSTAT_HSRUN) ; // wait for HSRUN
#endif
#if F_CPU == 240000000
#if F_CPU == 256000000
MCG_C6 = MCG_C6_PLLS | MCG_C6_VDIV0(16);
#elif F_CPU == 240000000
MCG_C5 = MCG_C5_PRDIV0(0);
MCG_C6 = MCG_C6_PLLS | MCG_C6_VDIV0(14);
#elif F_CPU == 216000000
@@ -900,7 +902,18 @@ void ResetHandler(void)
#endif
#endif
// now program the clock dividers
#if F_CPU == 240000000
#if F_CPU == 256000000
// config divisors: 256 MHz core, 64 MHz bus, 32 MHz flash, USB = IRC48M
// TODO: gradual ramp-up for HSRUN mode
#if F_BUS == 64000000
SIM_CLKDIV1 = SIM_CLKDIV1_OUTDIV1(0) | SIM_CLKDIV1_OUTDIV2(3) | SIM_CLKDIV1_OUTDIV4(7);
#elif F_BUS == 128000000
SIM_CLKDIV1 = SIM_CLKDIV1_OUTDIV1(0) | SIM_CLKDIV1_OUTDIV2(1) | SIM_CLKDIV1_OUTDIV4(7);
#else
#error "This F_CPU & F_BUS combination is not supported"
#endif
SIM_CLKDIV2 = SIM_CLKDIV2_USBDIV(0);
#elif F_CPU == 240000000
// config divisors: 240 MHz core, 60 MHz bus, 30 MHz flash, USB = 240 / 5
// TODO: gradual ramp-up for HSRUN mode
#if F_BUS == 60000000
@@ -921,7 +934,8 @@ void ResetHandler(void)
#elif F_BUS == 72000000
SIM_CLKDIV1 = SIM_CLKDIV1_OUTDIV1(0) | SIM_CLKDIV1_OUTDIV2(2) | SIM_CLKDIV1_OUTDIV4(7);
#elif F_BUS == 108000000
SIM_CLKDIV1 = SIM_CLKDIV1_OUTDIV1(0) | SIM_CLKDIV1_OUTDIV2(1) | SIM_CLKDIV1_OUTDIV4(7);
SIM_CLKDIV1 = SIM_CLKDIV1_OUTDIV1(0) | SIM_CLKDIV1_OUTDIV2(1) | SIM_CLKDIV1_OUTDIV4(7);
#else
#error "This F_CPU & F_BUS combination is not supported"
#endif
@@ -1057,7 +1071,7 @@ void ResetHandler(void)
// now we're in PEE mode
// USB uses PLL clock, trace is CPU clock, CLKOUT=OSCERCLK0
#if defined(KINETISK)
#if F_CPU == 216000000 || F_CPU == 180000000
#if F_CPU == 256000000 || F_CPU == 216000000 || F_CPU == 180000000
SIM_SOPT2 = SIM_SOPT2_USBSRC | SIM_SOPT2_IRC48SEL | SIM_SOPT2_TRACECLKSEL | SIM_SOPT2_CLKOUTSEL(6);
#else
SIM_SOPT2 = SIM_SOPT2_USBSRC | SIM_SOPT2_PLLFLLSEL | SIM_SOPT2_TRACECLKSEL | SIM_SOPT2_CLKOUTSEL(6);
@@ -1128,6 +1142,7 @@ void ResetHandler(void)

startup_late_hook();
main();
while (1) ;
}

@@ -1259,7 +1274,11 @@ int kinetis_hsrun_disable(void)
// the peripheral speed (F_BUS). Serial1 & Serial2 baud
// rates will be impacted, but most other peripherals
// will continue functioning at the same speed.
#if F_CPU == 240000000 && F_BUS == 60000000
#if F_CPU == 256000000 && F_BUS == 64000000
SIM_CLKDIV1 = SIM_CLKDIV1_OUTDIVS(1, 3, 1, 7); // TODO: TEST
#elif F_CPU == 256000000 && F_BUS == 128000000
SIM_CLKDIV1 = SIM_CLKDIV1_OUTDIVS(1, 1, 1, 7); // TODO: TEST
#elif F_CPU == 240000000 && F_BUS == 60000000
SIM_CLKDIV1 = SIM_CLKDIV1_OUTDIVS(1, 3, 1, 7); // ok
#elif F_CPU == 240000000 && F_BUS == 80000000
SIM_CLKDIV1 = SIM_CLKDIV1_OUTDIVS(2, 2, 2, 8); // ok
@@ -1305,7 +1324,11 @@ int kinetis_hsrun_enable(void)
SMC_PMCTRL = SMC_PMCTRL_RUNM(3);
while (SMC_PMSTAT != SMC_PMSTAT_HSRUN) {;} // wait
// Then configure clock for full speed
#if F_CPU == 240000000 && F_BUS == 60000000
#if F_CPU == 256000000 && F_BUS == 64000000
SIM_CLKDIV1 = SIM_CLKDIV1_OUTDIVS(0, 3, 0, 7);
#elif F_CPU == 256000000 && F_BUS == 128000000
SIM_CLKDIV1 = SIM_CLKDIV1_OUTDIVS(0, 1, 0, 7);
#elif F_CPU == 240000000 && F_BUS == 60000000
SIM_CLKDIV1 = SIM_CLKDIV1_OUTDIVS(0, 3, 0, 7);
#elif F_CPU == 240000000 && F_BUS == 80000000
SIM_CLKDIV1 = SIM_CLKDIV1_OUTDIVS(0, 2, 0, 7);

+ 3
- 1
teensy3/pins_teensy.c Vedi File

@@ -1206,7 +1206,9 @@ void delay(uint32_t ms)
}

// TODO: verify these result in correct timeouts...
#if F_CPU == 240000000
#if F_CPU == 256000000
#define PULSEIN_LOOPS_PER_USEC 34
#elif F_CPU == 240000000
#define PULSEIN_LOOPS_PER_USEC 33
#elif F_CPU == 216000000
#define PULSEIN_LOOPS_PER_USEC 31

+ 1
- 1
teensy3/usb_dev.c Vedi File

@@ -1129,7 +1129,7 @@ void usb_init(void)
#ifdef HAS_KINETIS_MPU
MPU_RGDAAC0 |= 0x03000000;
#endif
#if F_CPU == 180000000 || F_CPU == 216000000
#if F_CPU == 180000000 || F_CPU == 216000000 || F_CPU == 256000000
// 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 |

+ 3
- 2
teensy3/usb_joystick.c Vedi File

@@ -48,8 +48,9 @@ static uint8_t transmit_previous_timeout=0;

// When the PC isn't listening, how long do we wait before discarding data?
#define TX_TIMEOUT_MSEC 30

#if F_CPU == 240000000
#if F_CPU == 256000000
#define TX_TIMEOUT (TX_TIMEOUT_MSEC * 1706)
#elif F_CPU == 240000000
#define TX_TIMEOUT (TX_TIMEOUT_MSEC * 1600)
#elif F_CPU == 216000000
#define TX_TIMEOUT (TX_TIMEOUT_MSEC * 1440)

+ 3
- 2
teensy3/usb_keyboard.c Vedi File

@@ -496,8 +496,9 @@ static uint8_t transmit_previous_timeout=0;

// When the PC isn't listening, how long do we wait before discarding data?
#define TX_TIMEOUT_MSEC 50

#if F_CPU == 240000000
#if F_CPU == 256000000
#define TX_TIMEOUT (TX_TIMEOUT_MSEC * 1706)
#elif F_CPU == 240000000
#define TX_TIMEOUT (TX_TIMEOUT_MSEC * 1600)
#elif F_CPU == 216000000
#define TX_TIMEOUT (TX_TIMEOUT_MSEC * 1440)

+ 3
- 2
teensy3/usb_midi.c Vedi File

@@ -76,8 +76,9 @@ static uint8_t tx_noautoflush=0;

// When the PC isn't listening, how long do we wait before discarding data?
#define TX_TIMEOUT_MSEC 40

#if F_CPU == 240000000
#if F_CPU == 256000000
#define TX_TIMEOUT (TX_TIMEOUT_MSEC * 1706)
#elif F_CPU == 240000000
#define TX_TIMEOUT (TX_TIMEOUT_MSEC * 1600)
#elif F_CPU == 216000000
#define TX_TIMEOUT (TX_TIMEOUT_MSEC * 1440)

+ 3
- 2
teensy3/usb_mouse.c Vedi File

@@ -116,8 +116,9 @@ static uint8_t transmit_previous_timeout=0;

// When the PC isn't listening, how long do we wait before discarding data?
#define TX_TIMEOUT_MSEC 30

#if F_CPU == 240000000
#if F_CPU == 256000000
#define TX_TIMEOUT (TX_TIMEOUT_MSEC * 1706)
#elif F_CPU == 240000000
#define TX_TIMEOUT (TX_TIMEOUT_MSEC * 1600)
#elif F_CPU == 216000000
#define TX_TIMEOUT (TX_TIMEOUT_MSEC * 1440)

+ 3
- 2
teensy3/usb_seremu.c Vedi File

@@ -138,8 +138,9 @@ void usb_seremu_flush_input(void)
// too short, we risk losing data during the stalls that are common with ordinary desktop
// software. If it's too long, we stall the user's program when no software is running.
#define TX_TIMEOUT_MSEC 30

#if F_CPU == 240000000
#if F_CPU == 256000000
#define TX_TIMEOUT (TX_TIMEOUT_MSEC * 1706)
#elif F_CPU == 240000000
#define TX_TIMEOUT (TX_TIMEOUT_MSEC * 1600)
#elif F_CPU == 216000000
#define TX_TIMEOUT (TX_TIMEOUT_MSEC * 1440)

+ 3
- 2
teensy3/usb_serial.c Vedi File

@@ -148,8 +148,9 @@ void usb_serial_flush_input(void)
// too short, we risk losing data during the stalls that are common with ordinary desktop
// software. If it's too long, we stall the user's program when no software is running.
#define TX_TIMEOUT_MSEC 70

#if F_CPU == 240000000
#if F_CPU == 256000000
#define TX_TIMEOUT (TX_TIMEOUT_MSEC * 1706)
#elif F_CPU == 240000000
#define TX_TIMEOUT (TX_TIMEOUT_MSEC * 1600)
#elif F_CPU == 216000000
#define TX_TIMEOUT (TX_TIMEOUT_MSEC * 1440)

Loading…
Annulla
Salva