1/71《嵌入式系统开发与应用实验教程第二版》增加的光盘内容:《嵌入式系统开发与应用教程》/第五章1.《嵌入式系统开发与应用教程》/第五章/5.3嵌入式C语言程序设计基础/例程一44blib.h例例程程一一::“44blib.h”以下是“44blib.h”的定义:/***********************************************************************File:44BLIB.H*Desc:Samsung44B0XCPUfunctiondeclareandcommondefine**********************************************************************/#ifndef__44BLIB_H__#define__44BLIB_H__#ifdef__cplusplusexternC{#endif//常量本部分内容定义了一些常量#defineDebugOutUart_Printf#definemin(x1,x2)((x1x2)?x1:x2)#definemax(x1,x2)((x1x2)?x1:x2)#defineONESEC0(62500)//16usresolution,max1.04sec#defineONESEC1(31250)//32usresolution,max2.09sec#defineONESEC2(15625)//64usresolution,max4.19sec#defineONESEC3(7812)//128usresolution,max8.38sec#defineONESEC4(MCLK/128/(0xff+1))//@60Mhz,128*4usresolution,max32.53sec#defineNULL0#defineEnterPWDN(clkcon)((void(*)(int))0xe0)(clkcon)#defineDOWNLOAD_ADDRESS_RAM_STARTADDRESS/*8ledcontrolregisteraddress*/#defineLED8ADDR(*(volatileunsignedchar*)(0x2140000))#defineLCD0xFF#defineUART0xFE/*44blib.c本部分内容对开发中用到的一些库函数作函数原型定义*/voidDelay(inttime);//WatchdogTimerisused.voidDelayMs(intms_time);void*malloc(unsignednbyte);2/71voidfree(void*pt);voidPort_Init(void);voidCache_Flush(void);voidChangeMemCon(unsigned*pMemCfg);voidUart_Select(intch);voidUart_TxEmpty(intch);voidUart_Init(intmclk,intbaud);charUart_Getch(void);charUart_GetKey(void);intUart_GetIntNum(void);voidUart_SendByte(intdata);voidUart_Printf(char*fmt,...);voidUart_SendString(char*pt);voidTimer_Start(intdivider);//WatchdogTimerisused.intTimer_Stop(void);//WatchdogTimerisused.voidLed_Display(intLedStatus);voidBeep(intBeepStatus);voidChangePllValue(intm,intp,ints);#ifdef__cplusplus}#endif#endif/*__44BLIB_H__*/44b.h主要是用宏的方式定义了程序中所需的44B0X片上涉及到各模块中各寄存器的宏定义的地址。44b.h内容如下所示:/*******************************************************************************File:44B.H*Desc:Samsung44B0XCPUregisterdefine******************************************************************************/#ifndef__44B0X_H__#define__44B0X_H__#ifdef__cplusplusexternC{#endif#includeoption.h/*System本部分内容定义了44b0的系统配置寄存器地址*/#definerSYSCFG(*(volatileunsigned*)0x1c00000)/*Cache本部分定义了44b0中2个不可作Cache存储区的起始与结束地址的寄存器的地址*/#definerNCACHBE0(*(volatileunsigned*)0x1c00004)3/71#definerNCACHBE1(*(volatileunsigned*)0x1c00008)/*Buscontrol本部分定义了44b0中存储总线控制器的优先级的寄存器地址*/#definerSBUSCON(*(volatileunsigned*)0x1c40000)/*Memorycontrol本部分定义了44b0中与存储器相关的寄存器地址*/#definerBWSCON(*(volatileunsigned*)0x1c80000)#definerBANKCON0(*(volatileunsigned*)0x1c80004)#definerBANKCON1(*(volatileunsigned*)0x1c80008)#definerBANKCON2(*(volatileunsigned*)0x1c8000c)#definerBANKCON3(*(volatileunsigned*)0x1c80010)#definerBANKCON4(*(volatileunsigned*)0x1c80014)#definerBANKCON5(*(volatileunsigned*)0x1c80018)#definerBANKCON6(*(volatileunsigned*)0x1c8001c)#definerBANKCON7(*(volatileunsigned*)0x1c80020)#definerREFRESH(*(volatileunsigned*)0x1c80024)#definerBANKSIZE(*(volatileunsigned*)0x1c80028)#definerMRSRB6(*(volatileunsigned*)0x1c8002c)#definerMRSRB7(*(volatileunsigned*)0x1c80030)/*UART本部分定义了44b0中与UART相关的寄存器地址*/#definerULCON0(*(volatileunsigned*)0x1d00000)#definerULCON1(*(volatileunsigned*)0x1d04000)#definerUCON0(*(volatileunsigned*)0x1d00004)#definerUCON1(*(volatileunsigned*)0x1d04004)#definerUFCON0(*(volatileunsigned*)0x1d00008)#definerUFCON1(*(volatileunsigned*)0x1d04008)#definerUMCON0(*(volatileunsigned*)0x1d0000c)#definerUMCON1(*(volatileunsigned*)0x1d0400c)#definerUTRSTAT0(*(volatileunsigned*)0x1d00010)#definerUTRSTAT1(*(volatileunsigned*)0x1d04010)#definerUERSTAT0(*(volatileunsigned*)0x1d00014)#definerUERSTAT1(*(volatileunsigned*)0x1d04014)#definerUFSTAT0(*(volatileunsigned*)0x1d00018)#definerUFSTAT1(*(volatileunsigned*)0x1d04018)#definerUMSTAT0(*(volatileunsigned*)0x1d0001c)#definerUMSTAT1(*(volatileunsigned*)0x1d0401c)#definerUBRDIV0(*(volatileunsigned*)0x1d00028)#definerUBRDIV1(*(volatileunsigned*)0x1d04028)#ifdef__BIG_ENDIAN//当系统定义为大端存储模式时各寄存器的地址#definerUTXH0(*(volatileunsignedchar*)0x1d00023)#definerUTXH1(*(volatileunsignedchar*)0x1d04023)4/71#definerURXH0(*(volatileunsignedchar*)0x1d00027)#definerURXH1(*(volatileunsignedchar*)0x1d04027)#defineWrUTXH0(ch)(*(volatileunsignedchar*)(0x1d00023))=(unsignedchar)(ch)#defineWrUTXH1(ch)(*(volatileunsignedchar*)(0x1d04023))=(unsignedchar)(ch)#defineRdURXH0()(*(volatileunsignedchar*)(0x1d00027))#defineRdURXH1()(*(volatileunsignedchar*)(0x1d04027))#defineUTXH0(0x1d00020+3)//byte_accessaddressbyBDMA#defineUTXH1(0x1d04020+3)#defineURXH0(0x1d00024+3)#defineURXH1(0x1d04024+3)#else//LittleEndian//当系统定义为小端存储模式时各寄存器的地址#definerUTXH0(*(volatileunsignedchar*)0x1d00020)#definerUTXH1(*(volatileunsignedchar*)0x1d04020)#definerURXH0(*(volatileunsignedchar*)0x1d00024)#definerURXH1(*(volatileunsignedchar*)0x1d04024)#defineWrUTXH0(ch)(*(volatileunsignedchar*)0x1d00020)=(unsignedchar)(ch)#defineWrUTXH1(ch)(*(volatileunsignedchar*)0x1d04020)=(unsignedchar)(ch)#defineRdURXH0()(*(volatileunsignedchar*)0x1d00024)#defineRdURXH1()(*(volatileunsignedchar*)0x1d04024)#defineUTXH0(0x1d00020)//byte_accessaddressbyBDMA#defineUTXH1(0x1d0402