sysclock.c

来自「阿根廷教授编写的嵌入式internet的实验教程的高质量代码」· C语言 代码 · 共 40 行

C
40
字号
/******************************************************************************************
   sysClock.c (v1.0)
-------------------------------------------------------------------------------------
This code is from the book:
"Embedded Internet: TCP/IP Basics, Implementation and Applications" by Sergio Scaglia
[Pearson Education, 2006 - ISBN: 0-32-130638-4]

This code is copyright (c) 2006 by Sergio Scaglia, and it may only be used for educational
purposes.  For commercial use, please contact me at sscaglia@intramarket.com.ar
For more information and updates, please visit www.embeddedinternet.org
******************************************************************************************/

#include <iolpc2129.h>
#include "hardware.h"

unsigned int cClkFreq(void) {

  return (OSC_CLOCK_FREQ * (PLLSTAT & 0x400 ? (PLLSTAT & 0x1F) + 1 : 1));
}


unsigned int pClkFreq(void) {
  unsigned int divider=0;

   divider = VPBDIV;
   switch (VPBDIV & 3)		/* We read VPBDIV twice to avoid problems...*/
    {
      case 0:
        divider = 4;
        break;
      case 1:
        divider = 1;
        break;
      case 2:
        divider = 2;
        break;	
    }
  return (cClkFreq() / divider);
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?