📄 system.h
字号:
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
// cpsr/spsr
#define Mode_USR 0x10
#define Mode_FIQ 0x11
#define Mode_IRQ 0x12
#define Mode_SVC 0x13
#define Mode_ABT 0x17
#define Mode_UNDEF 0x1B
#define Mode_SYS 0x1F
#define I_Bit 0x80
#define F_Bit 0x40
//////////////////////////////////////////////////////////////////////////////
// General
#define CR 0x0D
#define LF 0x0A
//////////////////////////////////////////////////////////////////////////////
// memory map
#define DRAM_CONTROL 0x200b0000
#define BASE_SYSTEM 0x20000000
#define BASE_UserRAM 0x10000000
//---------------------------------- total size
#define LEN_UserRam 0x100fffff
//---------------------------------- stack offset
#define LEN_SvcStack 0x10020000
#define LEN_AbtStack 0x10010000
#define LEN_UndefStack 0x10002000
#define LEN_IrqStack 0x10020000
#define LEN_FiqStack 0x10020000
#define LEN_UsrStack 0x10020000
//Interrupt map
#define INT_Status 0x0014
#define INT_Unmask 0x0018
#define FLASH_BIT 0x00000800
#define SDRAM_BIT 0x00000400
#define GPIO_TIMER_BIT 0x00000200
#define M3G_BIT 0x00000100
#define UART_BIT 0x00000080
#define USB_BIT 0x00000040
#define DSP_BIT 0x00000020
#define LCD_BIT 0x00000010
#define GRAPHICS_BIT 0x00000006
#define IMAGE_BIT 0x00000004
#define JPEG_BIT 0x00000002
#define RESERED_BIT 0x00000001
//GPIO AND TIMER
#define BASE_GPIO_TIMER 0x20090000
#define GPIO_DIR 0x0000
#define GPIO_INTE 0x0004
#define GPIO_INTP 0x0008
#define GPIO_IN 0x000C
#define GPIO_OUT 0x0010
#define TIM_1 0x0014
#define GPIO_EDGE 0x0108
#define TIM1_ENAMBLE 0x80000000 @enable time1
#define TIM1_INT 0x40000000 @time1 interrupt status
#define TIM_2 0x0018
#define TIM2_ENAMBLE 0x80000000 @enable time2
#define TIM2_INT 0x40000000 @time2 interrupt status
//UART register mapping
#define URT_SERIAL1_BASE 0x20060000#define URT_SERIAL2_BASE 0x20061000#define UART_BASE URT_SERIAL1_BASE#define URT_BASE UART_BASE#define UAT_BASE URT_SERIAL1_BASE/*/These register holds the data to be sent and data to be recived*/#define URT_XMIT_DATA 0x00#define URT_RECV_DATA 0x00/*/These register holds the lower and upper of 16 bit baud rate divisor*/#define URT_BAUD_LO 0x04#define URT_BAUD_HI 0x08/*/the value of BAUD_REG*///*#define BAUD_RATE_38400_LO 0x61#define BAUD_RATE_38400_HI 0x00
#define XMIT_FIFO_FULL 0x4#define URT_STAT 0x0c#define XMIT_BUSY_MASK 0x0001 /*/this bit high means data is being sent over UART*/#define RECV_AVAIL_MASK 0x0100 /*/this bit high means data is being recv by UART*//*/this register holds the mode of int*/#define URT_INT_MODE 0x10#define XMIT_MODE_MASK 0x0F#define RECV_MODE_MASK 0XF0/*/this register enable the UART interrupt*/#define URT_INT_ENA 0x14#define XMIT_ENA_MASK 0x01#define RECV_ENA_MASK 0x02
#define SERIAL1_BASE 0x20060000
#define SERIAL_BASE SERIAL1_BASE
#define SERIAL2_BASE 0x20061000
//data to transmitted, write only
#define XMIT_DAT_REG 0x00
//data to receive , read only
#define REC_DAT_REG 0x00
//band_rate register
/*
Baud_rate_divisor = sys_clk
---------------
(16*2*baud_rate)
BAUD_REG_LO = Baud_rate_divisor % 256
BAUD_REG_HI = (Baud_rate_divisor - BAUD_REG_LO)/2
*/
#define SYS_CLOCL 0x7a1200 //8M
#define BAUD_REG_LO 0x04
#define BAUD_REG_HI 0x08
#define BAUD_RATE_2400_LO 0x68
#define BAUD_RATE_2400_HI 0x00
#define BAUD_RATE_19200_LO 0x0c
#define BAUD_RATE_19200_HI 0x00
#define STAT_REG 0x0c
#define XMIT_EMPT 0x01 //can not trasmit
#define REV_AVAIL 0x02 //have not received
#define INT_STAT_REG 0x10
#define STAT_XMIT_EMPT 0x01
#define STAT_REV_AVAIL 0x02
#define INT_ENB_REG 0x14
#define EN_XMIT_EMPT 0x01
#define EN_REV_AVAIL 0x02
//////////////////////////////////////////////////////////////////////////////
// end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -