Merge pull request #8183 from Qyriad/features/samx5x-external-clock

samx5x: support external clock sources
This commit is contained in:
Scott Shawcroft 2023-07-19 09:59:27 -07:00 committed by GitHub
commit 12d1181c64
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 27 additions and 3 deletions

View File

@ -173,6 +173,30 @@
#define BOARD_HAS_CRYSTAL (0)
#endif
#ifndef BOARD_XOSC_FREQ_HZ
// 0 Indicates XOSC is not used.
#define BOARD_XOSC_FREQ_HZ (0)
#else
// For now, only allow external clock sources that divide cleanly into
// the system clock frequency of 120 MHz.
#if (120000000 % BOARD_XOSC_FREQ_HZ) != 0
#error "BOARD_XOSC_FREQ_HZ must be an integer factor of 120 MHz"
#endif
#endif
#if BOARD_XOSC_FREQ_HZ != 0
// External clock sources are currently not implemented for SAMD21 chips.
#ifdef SAMD21
#error "BOARD_XOSC_FREQ_HZ is non-zero but external clock sources are not yet supported for SAMD21 chips"
#endif
#ifndef BOARD_XOSC_IS_CRYSTAL
#error "BOARD_XOSC_IS_CRYSTAL must be defined to 0 or 1 if BOARD_XOSC_FREQ_HZ is not 0"
#endif
#else
// It doesn't matter what the value is in this case.
#define BOARD_XOSC_IS_CRYSTAL (0)
#endif
// if CALIBRATE_CRYSTALLESS is requested, make room for storing
// calibration data generated from external USB.
#ifndef CIRCUITPY_INTERNAL_CONFIG_SIZE

@ -1 +1 @@
Subproject commit baca4c084334aa8625f525a4032d66a397199ea6
Subproject commit 82e514b6e0d1a2b09dc73be9973663b6b837a817

View File

@ -353,10 +353,10 @@ safe_mode_t port_init(void) {
if (strcmp((char *)CIRCUITPY_INTERNAL_CONFIG_START_ADDR, "CIRCUITPYTHON1") == 0) {
fine = ((uint16_t *)CIRCUITPY_INTERNAL_CONFIG_START_ADDR)[8];
}
clock_init(BOARD_HAS_CRYSTAL, fine);
clock_init(BOARD_HAS_CRYSTAL, BOARD_XOSC_FREQ_HZ, BOARD_XOSC_IS_CRYSTAL, fine);
#else
// Use a default fine value
clock_init(BOARD_HAS_CRYSTAL, DEFAULT_DFLL48M_FINE_CALIBRATION);
clock_init(BOARD_HAS_CRYSTAL, BOARD_XOSC_FREQ_HZ, BOARD_XOSC_IS_CRYSTAL, DEFAULT_DFLL48M_FINE_CALIBRATION);
#endif
rtc_init();