1、理论教材嵌入式系统开发与应用技术教程部分程序代码嵌入式系统开发与应用实验教程第二版增加的光盘内容:嵌入式系统开发与应用教程/第五章1. 嵌入式系统开发与应用教程/第五章/5.3嵌入式C语言程序设计基础/例程一44blib.h例程一: “44blib.h”以下是“44blib.h”的定义:/* File: 44BLIB.H* Desc: Samsung 44B0X CPU function declare and common define*/#ifndef _44BLIB_H_#define _44BLIB_H_#ifdef _cplusplusextern C #endif/常量本部分内容定
2、义了一些常量#define DebugOut Uart_Printf#define min(x1,x2) (x1x2)? x1:x2)#define ONESEC0 (62500) /16us resolution, max 1.04 sec#define ONESEC1 (31250) /32us resolution, max 2.09 sec#define ONESEC2 (15625) /64us resolution, max 4.19 sec#define ONESEC3 (7812) /128us resolution, max 8.38 sec#define ONESEC4 (
3、MCLK/128/(0xff+1) /60Mhz, 128*4us resolution, max 32.53 sec#define NULL 0#define EnterPWDN(clkcon) (void (*)(int)0xe0)(clkcon)#define DOWNLOAD_ADDRESS _RAM_STARTADDRESS/* 8led control register address */#define LED8ADDR (*(volatile unsigned char *)(0x2140000)#define LCD 0xFF#define UART 0xFE/*44blib
4、.c本部分内容对开发中用到的一些库函数作函数原型定义*/void Delay(int time); /Watchdog Timer is used.void DelayMs(int ms_time);void *malloc(unsigned nbyte); void free(void *pt);void Port_Init(void);void Cache_Flush(void);void ChangeMemCon(unsigned *pMemCfg);void Uart_Select(int ch);void Uart_TxEmpty(int ch);void Uart_Init(int
5、 mclk,int baud);char Uart_Getch(void);char Uart_GetKey(void);int Uart_GetIntNum(void);void Uart_SendByte(int data);void Uart_Printf(char *fmt,.);void Uart_SendString(char *pt);void Timer_Start(int divider); /Watchdog Timer is used.int Timer_Stop(void); /Watchdog Timer is used.void Led_Display(int Le
6、dStatus);void Beep(int BeepStatus);void ChangePllValue(int m,int p,int s);#ifdef _cplusplus#endif#endif /* _44BLIB_H_ */ 44b.h主要是用宏的方式定义了程序中所需的44B0X片上涉及到各模块中各寄存器的宏定义的地址。 44b.h内容如下所示:/* File: 44B.H* Desc: Samsung 44B0X CPU register define*/#ifndef _44B0X_H_#define _44B0X_H_#ifdef _cplusplusextern C #
7、endif#include option.h/* System 本部分内容定义了44b0的系统配置寄存器地址*/#define rSYSCFG (*(volatile unsigned *)0x1c00000)/* Cache本部分定义了44b0中2个不可作Cache存储区的起始与结束地址的寄存器的地址*/#define rNCACHBE0 (*(volatile unsigned *)0x1c00004)#define rNCACHBE1 (*(volatile unsigned *)0x1c00008)/* Bus control 本部分定义了44b0中存储总线控制器的优先级的寄存器地址*
8、/#define rSBUSCON (*(volatile unsigned *)0x1c40000) /* Memory control 本部分定义了44b0中与存储器相关的寄存器地址*/#define rBWSCON (*(volatile unsigned *)0x1c80000)#define rBANKCON0 (*(volatile unsigned *)0x1c80004)#define rBANKCON1 (*(volatile unsigned *)0x1c80008)#define rBANKCON2 (*(volatile unsigned *)0x1c8000c)#de
9、fine rBANKCON3 (*(volatile unsigned *)0x1c80010)#define rBANKCON4 (*(volatile unsigned *)0x1c80014)#define rBANKCON5 (*(volatile unsigned *)0x1c80018)#define rBANKCON6 (*(volatile unsigned *)0x1c8001c)#define rBANKCON7 (*(volatile unsigned *)0x1c80020)#define rREFRESH (*(volatile unsigned *)0x1c8002
10、4)#define rBANKSIZE (*(volatile unsigned *)0x1c80028)#define rMRSRB6 (*(volatile unsigned *)0x1c8002c)#define rMRSRB7 (*(volatile unsigned *)0x1c80030)/* UART 本部分定义了44b0中与UART 相关的寄存器地址*/#define rULCON0 (*(volatile unsigned *)0x1d00000)#define rULCON1 (*(volatile unsigned *)0x1d04000)#define rUCON0 (
11、*(volatile unsigned *)0x1d00004)#define rUCON1 (*(volatile unsigned *)0x1d04004)#define rUFCON0 (*(volatile unsigned *)0x1d00008)#define rUFCON1 (*(volatile unsigned *)0x1d04008)#define rUMCON0 (*(volatile unsigned *)0x1d0000c)#define rUMCON1 (*(volatile unsigned *)0x1d0400c)#define rUTRSTAT0 (*(vol
12、atile unsigned *)0x1d00010)#define rUTRSTAT1 (*(volatile unsigned *)0x1d04010)#define rUERSTAT0 (*(volatile unsigned *)0x1d00014)#define rUERSTAT1 (*(volatile unsigned *)0x1d04014)#define rUFSTAT0 (*(volatile unsigned *)0x1d00018)#define rUFSTAT1 (*(volatile unsigned *)0x1d04018)#define rUMSTAT0 (*(
13、volatile unsigned *)0x1d0001c)#define rUMSTAT1 (*(volatile unsigned *)0x1d0401c)#define rUBRDIV0 (*(volatile unsigned *)0x1d00028)#define rUBRDIV1 (*(volatile unsigned *)0x1d04028)#ifdef _BIG_ENDIAN /当系统定义为大端存储模式时各寄存器的地址#define rUTXH0 (*(volatile unsigned char *)0x1d00023)#define rUTXH1 (*(volatile
14、unsigned char *)0x1d04023)#define rURXH0 (*(volatile unsigned char *)0x1d00027)#define rURXH1 (*(volatile unsigned char *)0x1d04027)#define WrUTXH0(ch) (*(volatile unsigned char *)(0x1d00023)=(unsigned char)(ch)#define WrUTXH1(ch) (*(volatile unsigned char *)(0x1d04023)=(unsigned char)(ch)#define Rd
15、URXH0() (*(volatile unsigned char *)(0x1d00027)#define RdURXH1() (*(volatile unsigned char *)(0x1d04027) #define UTXH0 (0x1d00020+3) /byte_access address by BDMA#define UTXH1 (0x1d04020+3)#define URXH0 (0x1d00024+3)#define URXH1 (0x1d04024+3)#else /Little Endian /当系统定义为小端存储模式时各寄存器的地址#define rUTXH0 (
16、*(volatile unsigned char *)0x1d00020)#define rUTXH1 (*(volatile unsigned char *)0x1d04020)#define rURXH0 (*(volatile unsigned char *)0x1d00024)#define rURXH1 (*(volatile unsigned char *)0x1d04024)#define WrUTXH0(ch) (*(volatile unsigned char *)0x1d00020)=(unsigned char)(ch)#define WrUTXH1(ch) (*(vol
17、atile unsigned char *)0x1d04020)=(unsigned char)(ch)#define RdURXH0() (*(volatile unsigned char *)0x1d00024)#define RdURXH1() (*(volatile unsigned char *)0x1d04024)#define UTXH0 (0x1d00020) /byte_access address by BDMA#define UTXH1 (0x1d04020)#define URXH0 (0x1d00024)#define URXH1 (0x1d04024)#endif/
18、* SIO本部分定义了44b0中与同步I/O口相关的寄存器地址*/#define rSIOCON (*(volatile unsigned *)0x1d14000)#define rSIODAT (*(volatile unsigned *)0x1d14004)#define rSBRDR (*(volatile unsigned *)0x1d14008)#define rIVTCNT (*(volatile unsigned *)0x1d1400c)#define rDCNTZ (*(volatile unsigned *)0x1d14010)/* IIS本部分定义了44b0中与音频播放器I
19、IS相关的寄存器地址*/#define rIISCON (*(volatile unsigned *)0x1d18000)#define rIISMOD (*(volatile unsigned *)0x1d18004)#define rIISPSR (*(volatile unsigned *)0x1d18008)#define rIISFCON (*(volatile unsigned *)0x1d1800c)#ifdef _BIG_ENDIAN#define IISFIF (volatile unsigned short *)0x1d18012)#else /Little Endian#
20、define IISFIF (volatile unsigned short *)0x1d18010)#endif/* I/O PORT本部分定义了44b0中与I/O端口相关的寄存器地址*/#define rPCONA (*(volatile unsigned *)0x1d20000)#define rPDATA (*(volatile unsigned *)0x1d20004)#define rPCONB (*(volatile unsigned *)0x1d20008)#define rPDATB (*(volatile unsigned *)0x1d2000c)#define rPCON
21、C (*(volatile unsigned *)0x1d20010)#define rPDATC (*(volatile unsigned *)0x1d20014)#define rPUPC (*(volatile unsigned *)0x1d20018)#define rPCOND (*(volatile unsigned *)0x1d2001c)#define rPDATD (*(volatile unsigned *)0x1d20020)#define rPUPD (*(volatile unsigned *)0x1d20024)#define rPCONE (*(volatile
22、unsigned *)0x1d20028)#define rPDATE (*(volatile unsigned *)0x1d2002c)#define rPUPE (*(volatile unsigned *)0x1d20030)#define rPCONF (*(volatile unsigned *)0x1d20034)#define rPDATF (*(volatile unsigned *)0x1d20038)#define rPUPF (*(volatile unsigned *)0x1d2003c)#define rPCONG (*(volatile unsigned *)0x1
23、d20040)#define rPDATG (*(volatile unsigned *)0x1d20044)#define rPUPG (*(volatile unsigned *)0x1d20048)#define rSPUCR (*(volatile unsigned *)0x1d2004c)#define rEXTINT (*(volatile unsigned *)0x1d20050)#define rEXTINTPND (*(volatile unsigned *)0x1d20054)/* WATCHDOG本部分定义了44b0中与看门狗定义器相关的寄存器地址*/#define rW
24、TCON (*(volatile unsigned *)0x1d30000)#define rWTDAT (*(volatile unsigned *)0x1d30004)#define rWTCNT (*(volatile unsigned *)0x1d30008)/* ADC本部分定义了44b0中与模数转换器相关的寄存器地址*/#define rADCCON (*(volatile unsigned *)0x1d40000)#define rADCPSR (*(volatile unsigned *)0x1d40004)#define rADCDAT (*(volatile unsigne
25、d *)0x1d40008)/* Timer本部分定义了44b0中与定时器相关的寄存器地址*/#define rTCFG0 (*(volatile unsigned *)0x1d50000)#define rTCFG1 (*(volatile unsigned *)0x1d50004)#define rTCON (*(volatile unsigned *)0x1d50008)#define rTCNTB0 (*(volatile unsigned *)0x1d5000c)#define rTCMPB0 (*(volatile unsigned *)0x1d50010)#define rTCN
26、TO0 (*(volatile unsigned *)0x1d50014)#define rTCNTB1 (*(volatile unsigned *)0x1d50018)#define rTCMPB1 (*(volatile unsigned *)0x1d5001c)#define rTCNTO1 (*(volatile unsigned *)0x1d50020)#define rTCNTB2 (*(volatile unsigned *)0x1d50024)#define rTCMPB2 (*(volatile unsigned *)0x1d50028)#define rTCNTO2 (*
27、(volatile unsigned *)0x1d5002c)#define rTCNTB3 (*(volatile unsigned *)0x1d50030)#define rTCMPB3 (*(volatile unsigned *)0x1d50034)#define rTCNTO3 (*(volatile unsigned *)0x1d50038)#define rTCNTB4 (*(volatile unsigned *)0x1d5003c)#define rTCMPB4 (*(volatile unsigned *)0x1d50040)#define rTCNTO4 (*(volat
28、ile unsigned *)0x1d50044)#define rTCNTB5 (*(volatile unsigned *)0x1d50048)#define rTCNTO5 (*(volatile unsigned *)0x1d5004c)/* IIC本部分定义了44b0中与IIC总线相关的寄存器地址*/#define rIICCON (*(volatile unsigned *)0x1d60000)#define rIICSTAT (*(volatile unsigned *)0x1d60004)#define rIICADD (*(volatile unsigned *)0x1d60
29、008)#define rIICDS (*(volatile unsigned *)0x1d6000c)/* RTC本部分定义了44b0中与实时时钟相关的寄存器地址*/#ifdef _BIG_ENDIAN /*存储模式为大端时各寄存器的地址*/#define rRTCCON (*(volatile unsigned char *)0x1d70043)#define rRTCALM (*(volatile unsigned char *)0x1d70053)#define rALMSEC (*(volatile unsigned char *)0x1d70057)#define rALMMIN (*(volatile unsigned char *)0x1d7005b)#define rALMHOUR (*(volatile unsigned char *)0x1d7005f)#define rALMDAY (*(volatile unsigned char *)0x1d70063)#define rALMMON (*(volatile unsigned char *)0x1d70067)#define rALMYEAR (*(volatil
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1