File tree Expand file tree Collapse file tree 1 file changed +17
-7
lines changed
source/hic_hal/nxp/lpc4322 Expand file tree Collapse file tree 1 file changed +17
-7
lines changed Original file line number Diff line number Diff line change @@ -369,6 +369,22 @@ static unsigned mdec_new (unsigned msel)
369
369
return x ;
370
370
}
371
371
}
372
+
373
+ /* bandwidth: compute seli from msel */
374
+ unsigned anadeci_new (unsigned msel )
375
+ {
376
+ unsigned tmp ;
377
+ if (msel > 16384 ) return 1 ;
378
+ if (msel > 8192 ) return 2 ;
379
+ if (msel > 2048 ) return 4 ;
380
+ if (msel >= 501 ) return 8 ;
381
+ if (msel >= 60 )
382
+ {
383
+ tmp = 1024 /(msel + 9 );
384
+ return ( 1024 == ( tmp * (msel + 9 )) ) == 0 ? tmp * 4 : (tmp + 1 )* 4 ;
385
+ }
386
+ return (msel & 0x3c ) + 4 ;
387
+ }
372
388
/******************************************************************************
373
389
* SetClock
374
390
******************************************************************************/
@@ -469,13 +485,7 @@ static void SetClock (void) {
469
485
470
486
if (PLL0USB_M < 60 ) selp = (PLL0USB_M >> 1 ) + 1 ;
471
487
else selp = 31 ;
472
-
473
- if (PLL0USB_M > 16384 ) seli = 1 ;
474
- else if (PLL0USB_M > 8192 ) seli = 2 ;
475
- else if (PLL0USB_M > 2048 ) seli = 4 ;
476
- else if (PLL0USB_M >= 501 ) seli = 8 ;
477
- else if (PLL0USB_M >= 60 ) seli = 4 * (1024 / (PLL0USB_M + 9 ));
478
- else seli = (PLL0USB_M & 0x3C ) + 4 ;
488
+ seli = anadeci_new (PLL0USB_M );
479
489
LPC_CGU -> PLL0USB_MDIV = (selp << 17 ) |
480
490
(seli << 22 ) |
481
491
(x << 0 );
You can’t perform that action at this time.
0 commit comments