1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-12-25 14:33:52 +01:00

cpu/lpc2387: allow use of other XTALs

Currently the cpu/lpc2387 init code hard-codes a 16 MHz
external oscillator.
Instead, calculate the PLL multiplier based on the board define
and also allow to run without an external oscillator.
This commit is contained in:
Benjamin Valentin 2019-10-27 00:47:40 +02:00 committed by Benjamin Valentin
parent 3ecf7a0430
commit d6ca62576d
2 changed files with 12 additions and 2 deletions

View File

@ -23,6 +23,7 @@
#include <string.h>
#include "board.h"
#include "cpu.h"
#include "periph_conf.h"
#include "lpc2387.h"
#define CL_CPU_DIV 4
@ -68,11 +69,17 @@ static void init_clks1(void)
while (!(SCS & 0x40)); /* Wait until main OSC is usable */
/* select main OSC, 16MHz, as the PLL clock source */
#ifdef XTAL_HZ
/* select main OSC (XTAL_HZ) as the PLL clock source */
CLKSRCSEL = 0x0001;
#else
/* use the internal RC OSC as the PLL clock source */
#define XTAL_HZ F_RC_OSCILLATOR
#endif
/* Setting Multiplier and Divider values */
PLLCFG = 0x0008; /* M=9 N=1 Fcco = 288 MHz */
/* Fcco = (2 * Fin * M)/ N = 288 MHz */
PLLCFG = PLLCFG_M(F_CCO/(XTAL_HZ)) | PLLCFG_N(2);
pllfeed();
/* Enabling the PLL */

View File

@ -26,6 +26,9 @@ extern "C" {
#define VIC_SIZE 32
#define PLLCFG_N(n) ((n - 1) << 16)
#define PLLCFG_M(m) (m - 1)
#define GPIO_INT 17
#define IRQP_GPIO 4