File tree Expand file tree Collapse file tree 1 file changed +17
-13
lines changed
source/hic_hal/nxp/lpc4322 Expand file tree Collapse file tree 1 file changed +17
-13
lines changed Original file line number Diff line number Diff line change @@ -319,6 +319,22 @@ uint32_t GetClockFreq (uint32_t clk_src);
319
319
uint32_t SystemCoreClock = 120000000U ; /* System Clock Frequency (Core Clock) */
320
320
321
321
322
+ #define PLL0_NSEL_MAX (1<<8)
323
+ /* pre-divider: compute ndec from nsel */
324
+ static unsigned ndec_new (unsigned nsel )
325
+ {
326
+ unsigned x = 0x80 , in ;
327
+ switch (nsel )
328
+ {
329
+ case 0 : return 0xFFFFFFFF ;
330
+ case 1 : return 0x302 ;
331
+ case 2 : return 0x202 ;
332
+ default :
333
+ for (in = nsel ; in <= PLL0_NSEL_MAX ; in ++ )
334
+ x = ((x ^ x >>2 ^ x >>3 ^ x >>4 ) & 1 ) << 7 | x >>1 & 0xFF ;
335
+ return x ;
336
+ }
337
+ }
322
338
/******************************************************************************
323
339
* SetClock
324
340
******************************************************************************/
@@ -443,19 +459,7 @@ static void SetClock (void) {
443
459
(x << 0 );
444
460
445
461
/* N divider */
446
- x = 0x80 ;
447
- switch (PLL0USB_N ) {
448
- case 0 : x = 0xFFFFFFFF ;
449
- break ;
450
- case 1 : x = 0x00000302 ;
451
- break ;
452
- case 2 : x = 0x00000202 ;
453
- break ;
454
- default :
455
- for (i = PLL0USB_N ; i <= 0x0100 ; i ++ ) {
456
- x = (((x ^ (x >> 2 ) ^ (x >> 3 ) ^ (x >> 4 )) & 1 ) << 7 ) | ((x >> 1 ) & 0x7F );
457
- }
458
- }
462
+ x = ndec_new (PLL0USB_N );
459
463
LPC_CGU -> PLL0USB_NP_DIV = (x << 12 );
460
464
461
465
/* P divider */
You can’t perform that action at this time.
0 commit comments