📄 init.c
字号:
#include "../Include/type.h"#include "../Include/mx1.h"// To set the iA bit and the nF bit of CP15 register 1.void SetAsynchMode(void){ __asm__( "mrc p15,0,r0,c1,c0,0\n\t" "mov r2, #0xC0000000\n\t" "orr r0,r2,r0\n\t" "mcr p15,0,r0,c1,c0,0\n\t" );}void init(){ U32 dummy; // IO pad driving strength _reg_SYS_GPCR = 0x000003AB; // Sync-flash initialization dummy = _reg_SDRC_SDCTL1; // read control register _reg_SDRC_SDCTL1 = 0x81020300; // set normal mode _reg_SDRC_SDCTL1 = 0xB1020300; // set load mode register dummy = *((U32 *)0x0C08CC00); // special read to FLASH _reg_SDRC_SDCTL1 = 0x91020300; // set pre-charge mode dummy = *((U32 *)0x0C100000); // special read to FLASH _reg_SDRC_SDCTL1 = 0x81020300; // set normal mode // SRAM initialization _reg_CS1_CTRLH = 0x00000A00; _reg_CS1_CTRLL = 0x11110601; // set FCLK to 150 MHz, BCLK to 48 MHz _reg_CCM_CSCR = 0xAF008403; // Set PD=0, MFD=99, MFI=6, MFN=10 150M _reg_CCM_MPCTL0 = 0x04632410; // Trigger the restart bit(bit 21) _reg_CCM_CSCR |= 0x00200000; // Program PRESC bit(bit 15) to 0 to divide-by-1 _reg_CCM_CSCR &= 0xFFFF7FFF; SetAsynchMode(); // all sources selected as normal interrupt _reg_AITC_INTTYPEH = 0; _reg_AITC_INTTYPEL = 0; // set PERCLKs dummy = _reg_CCM_PCDR; dummy &= ~0x000000FF; dummy |= 0x00000055; _reg_CCM_PCDR = dummy; // PERCLK3 is only used by SSI so the SSI driver can set it any value it likes // PERCLK1 and PERCLK2 are shared so DO NOT change it in any other place // all sources selected as normal interrupt}void cs8900MX1Init(void){ volatile U16 tmp; // assume ext UART 20MHz max access time with no wait states // set up wait state of CS4 //_reg_CS4_CTRLL |= 0x00001B01; // Data port sized is D[7:0], EBC set //_reg_CS4_CTRLH |= 0x00000500; // if HCLK(BCLK) is 96MHz, add 5 wait states // set up the GPIO muxing to use Chip Select 4 //_reg_PTA_GIUS &= 0xFF3FFFFF; //_reg_PTA_GPR &= 0xFF3FFFFF; *(volatile P_U32)(0x00220020) = 0x00000F00; *(volatile P_U32)(0x00220024) = 0x00001501; *(volatile P_U32)(0x0021C020) &= 0xFF3FFFFF; *(volatile P_U32)(0x0021C038) &= 0xFF3FFFFF; tmp = *(P_U16)(0x1500000C);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -