寄存器使用结构体进行空间地址的映射
2012-10-25 16:45
423 查看
方式一:
typedef struct
{
union {
__I uint8_t RBR; //RBR THR DLL 三个寄存器都占用空间 0x4001 0000
__O uint8_t THR;
__IO uint8_t DLL;
uint32_t RESERVED0;
};
union {
__IO uint8_t DLM; //DLM IER 都占用空间 0x4001 0004
__IO uint32_t IER;
};
union {
__I uint32_t IIR; //IIR FCR 都占用空间 0x4001 0008
__O uint8_t FCR;
};
__IO uint8_t LCR; //0x4001 000C
uint8_t RESERVED1[3];
__IO uint8_t MCR; //0x4001 0010
uint8_t RESERVED2[3];
__I uint8_t LSR; // 0x4001 0014
uint8_t RESERVED3[3];
__I uint8_t MSR; //0x4001 0018
uint8_t RESERVED4[3];
__IO uint8_t SCR; //0x4001 001C
uint8_t RESERVED5[3];
__IO uint32_t ACR; //0x4001 0020
uint32_t RESERVED6;
__IO uint32_t FDR; //0x4001 0028
uint32_t RESERVED7;
__IO uint8_t TER; //0x4001 0030
uint8_t RESERVED8[27];
__IO uint8_t RS485CTRL; //0x4001 004C
uint8_t RESERVED9[3];
__IO uint8_t ADRMATCH; //0x4001 0050
uint8_t RESERVED10[3];
__IO uint8_t RS485DLY; //0x4001 0054
uint8_t RESERVED11[3];
__I uint8_t FIFOLVL; //0x4001 0058
} LPC_UART1_TypeDef;
#define LPC_APB0_BASE (0x40000000UL)
#define LPC_UART1_BASE (LPC_APB0_BASE + 0x10000)
#define LPC_UART1 ((LPC_UART1_TypeDef *) LPC_UART1_BASE )
方式二:
/*********************************************************************************************************
** UART1
*********************************************************************************************************/
#define U1RBRTHR (*(volatile unsigned long *)0x40010000) /* U1DLL, U1RBR and U1THR */
#define U1DLL U1RBRTHR /* share the same address */
#define U1RBR U1RBRTHR
#define U1THR U1RBRTHR
#define U1IER (*(volatile unsigned long *)0x40010004) /* U1DLM and U1IER */
#define U1DLM U1IER /* share the same address */
#define U1FCR (*(volatile unsigned long *)0x40010008) /* U1FCR and U1IIR */
#define U1IIR U1FCR /* share the same address */
#define U1LCR (*(volatile unsigned long *)0x4001000C)
#define U1MCR (*(volatile unsigned long *)0x40010010)
#define U1LSR (*(volatile unsigned long *)0x40010014)
#define U1MSR (*(volatile unsigned long *)0x40010018)
#define U1SCR (*(volatile unsigned long *)0x4001001C)
#define U1ACR (*(volatile unsigned long *)0x40010020)
#define U1FDR (*(volatile unsigned long *)0x40010028)
#define U1TER (*(volatile unsigned long *)0x40010030)
#define U1RS485CTRL (*(volatile unsigned long *)0x4001004C)
#define U1ADRMATCH (*(volatile unsigned long *)0x40010050)
#define U1RS485DLY (*(volatile unsigned long *)0x40010054)
#define U1FIFOLVL (*(volatile unsigned long *)0x40010058)
typedef struct
{
union {
__I uint8_t RBR; //RBR THR DLL 三个寄存器都占用空间 0x4001 0000
__O uint8_t THR;
__IO uint8_t DLL;
uint32_t RESERVED0;
};
union {
__IO uint8_t DLM; //DLM IER 都占用空间 0x4001 0004
__IO uint32_t IER;
};
union {
__I uint32_t IIR; //IIR FCR 都占用空间 0x4001 0008
__O uint8_t FCR;
};
__IO uint8_t LCR; //0x4001 000C
uint8_t RESERVED1[3];
__IO uint8_t MCR; //0x4001 0010
uint8_t RESERVED2[3];
__I uint8_t LSR; // 0x4001 0014
uint8_t RESERVED3[3];
__I uint8_t MSR; //0x4001 0018
uint8_t RESERVED4[3];
__IO uint8_t SCR; //0x4001 001C
uint8_t RESERVED5[3];
__IO uint32_t ACR; //0x4001 0020
uint32_t RESERVED6;
__IO uint32_t FDR; //0x4001 0028
uint32_t RESERVED7;
__IO uint8_t TER; //0x4001 0030
uint8_t RESERVED8[27];
__IO uint8_t RS485CTRL; //0x4001 004C
uint8_t RESERVED9[3];
__IO uint8_t ADRMATCH; //0x4001 0050
uint8_t RESERVED10[3];
__IO uint8_t RS485DLY; //0x4001 0054
uint8_t RESERVED11[3];
__I uint8_t FIFOLVL; //0x4001 0058
} LPC_UART1_TypeDef;
#define LPC_APB0_BASE (0x40000000UL)
#define LPC_UART1_BASE (LPC_APB0_BASE + 0x10000)
#define LPC_UART1 ((LPC_UART1_TypeDef *) LPC_UART1_BASE )
方式二:
/*********************************************************************************************************
** UART1
*********************************************************************************************************/
#define U1RBRTHR (*(volatile unsigned long *)0x40010000) /* U1DLL, U1RBR and U1THR */
#define U1DLL U1RBRTHR /* share the same address */
#define U1RBR U1RBRTHR
#define U1THR U1RBRTHR
#define U1IER (*(volatile unsigned long *)0x40010004) /* U1DLM and U1IER */
#define U1DLM U1IER /* share the same address */
#define U1FCR (*(volatile unsigned long *)0x40010008) /* U1FCR and U1IIR */
#define U1IIR U1FCR /* share the same address */
#define U1LCR (*(volatile unsigned long *)0x4001000C)
#define U1MCR (*(volatile unsigned long *)0x40010010)
#define U1LSR (*(volatile unsigned long *)0x40010014)
#define U1MSR (*(volatile unsigned long *)0x40010018)
#define U1SCR (*(volatile unsigned long *)0x4001001C)
#define U1ACR (*(volatile unsigned long *)0x40010020)
#define U1FDR (*(volatile unsigned long *)0x40010028)
#define U1TER (*(volatile unsigned long *)0x40010030)
#define U1RS485CTRL (*(volatile unsigned long *)0x4001004C)
#define U1ADRMATCH (*(volatile unsigned long *)0x40010050)
#define U1RS485DLY (*(volatile unsigned long *)0x40010054)
#define U1FIFOLVL (*(volatile unsigned long *)0x40010058)
相关文章推荐
- 【C语言】【unix c】使用mmap将文件映射到进程的虚拟地址空间,然后对内存的操作直接反应到文件中
- 关于PHP程序使用file_get_content()函数进行抓取PHP程序与smarty结合编译过程中产生的静态文件,抓取不了?连接超时?(地址映射)
- 关于PHP程序使用file_get_content()函数进行抓取PHP程序与smarty结合编译过程中产生的静态文件,抓取不了?连接超时?(地址映射)
- 关于PHP程序使用file_get_content()函数进行抓取PHP程序与smarty结合编译过程中产生的静态文件,抓取不了?连接超时?(地址映射)
- cpu为什么使用虚拟地址到物理地址的空间映射,解决了什么样的问题?
- MFC 对于使用自己的线进行启动其他进程的虚拟地址映射问题
- 关于PHP程序使用file_get_content()函数进行抓取PHP程序与smarty结合编译过程中产生的静态文件,抓取不了?连接超时?(地址映射)
- 使用Fluent API进行实体映射【Code-First系列】
- 使用Hibernate注解Annotations进行对象映射的异常处理
- 使用shell脚本进行服务器系统监控——页面调度与交换空间监控
- SpringMvc 地址映射使用配置文件信息
- Boost.Interprocess使用手册翻译之五:独立于映射地址的指针:offset_pt (Mapping Address Independent Pointer: offset_ptr)
- 用VMQuery查询虚拟地址空间(虚拟内存)的使用情况
- 结构体在使用之前必须申请空间,即为此分配内存
- [转]使用Spatial Adjustment工具进行空间数据校正
- 使用mmap函数进行内核空间和用户空间的共享内存通信
- 【Windows核心编程】一个使用内存映射文件进行进程间通信的例子
- [汇编语言]-第九章 根据位移进行转移的jmp指令 段内短转移 段内近转移 段间转移(远转移) 转移的目的地址在指令中,在寄存器中,在内存中的jmp指令
- 如何使用Fluent Nhibernate中的Automapping进行OR Mapping映射
- 3389端口映射-使用mstsc进行远程协助