在2440lib.c的文件中有官方给的功能函数,比如我在时钟管理中函数就是在这个文件中,有些功能函数我把它改了一下。
比如
[cpp] view plaincopy
- void SelectFclk(int i)
- {
- U32 mpll_val=0;
- switch ( i ) {
- case 0: //200M
- mpll_val = (92<<12)|(4<<4)|(1);
- break;
- case 1: //300M
- mpll_val = (67<<12)|(1<<4)|(1);
- break;
- case 2: //400M
- mpll_val = (92<<12)|(1<<4)|(1);
- break;
- case 3: //440M!!!
- mpll_val = (102<<12)|(1<<4)|(1);
- break;
- default:
- mpll_val = (92<<12)|(1<<4)|(1);
- break;
- }
- rMPLLCON = mpll_val;
- }
现在贴出一个用功能函数编写的小程序
[cpp] view plaincopy
- #include "2440addr.h"
- #include "2440lib.h"
- void Main()
- {
- char buffer[256];
- SelectFclk(2); //设置系统时钟 400M
- ChangeClockDivider(2, 1); //设置分频 1:4:8
- CalcBusClk(); //计算总线频率
- rGPHCON &=~((3<<4)|(3<<6));
- rGPHCON |=(2<<4)|(2<<6); //GPH2--TXD[0];GPH3--RXD[0]
- rGPHUP=0x00; //使能上拉功能
- Uart_Init(0,115200);
- Uart_Select(0);
- Uart_Printf("\nS3C2440 UART0 Test\n");
- while(1)
- {
- Uart_Printf("Please,press enter later input string\n");
- Uart_GetString(buffer);
- Uart_Printf("you input string: %s\r\n",buffer);
- }
- }
|