File tree Expand file tree Collapse file tree 1 file changed +18
-13
lines changed
source/hic_hal/nxp/lpc4322 Expand file tree Collapse file tree 1 file changed +18
-13
lines changed Original file line number Diff line number Diff line change @@ -335,6 +335,23 @@ static unsigned ndec_new(unsigned nsel)
335
335
return x ;
336
336
}
337
337
}
338
+
339
+ #define PLL0_PSEL_MAX (1<<5)
340
+ /* post-divider: compute pdec from psel */
341
+ static unsigned pdec_new (unsigned psel )
342
+ {
343
+ unsigned x = 0x10 , ip ;
344
+ switch (psel )
345
+ {
346
+ case 0 : return 0xFFFFFFFF ;
347
+ case 1 : return 0x62 ;
348
+ case 2 : return 0x42 ;
349
+ default :
350
+ for (ip = psel ; ip <= PLL0_PSEL_MAX ; ip ++ )
351
+ x = ((x ^ x >>2 ) & 1 ) << 4 | x >>1 & 0x3F ;
352
+ return x ;
353
+ }
354
+ }
338
355
/******************************************************************************
339
356
* SetClock
340
357
******************************************************************************/
@@ -463,19 +480,7 @@ static void SetClock (void) {
463
480
LPC_CGU -> PLL0USB_NP_DIV = (x << 12 );
464
481
465
482
/* P divider */
466
- x = 0x10 ;
467
- switch (PLL0USB_P ) {
468
- case 0 : x = 0xFFFFFFFF ;
469
- break ;
470
- case 1 : x = 0x00000062 ;
471
- break ;
472
- case 2 : x = 0x00000042 ;
473
- break ;
474
- default :
475
- for (i = PLL0USB_P ; i <= 0x200 ; i ++ ) {
476
- x = (((x ^ (x >> 2 )) & 1 ) << 4 ) | ((x >> 1 ) & 0x0F );
477
- }
478
- }
483
+ x = pdec_new (PLL0USB_P );
479
484
LPC_CGU -> PLL0USB_NP_DIV |= x ;
480
485
481
486
LPC_CGU -> PLL0USB_CTRL = (PLL0USB_CLK_SEL << 24 ) | /* Clock source sel */
You can’t perform that action at this time.
0 commit comments