📄 board.c
字号:
/* * Copyright 2002 (C) Ken Treis; Key Technology, Inc. * ktreis@keyww.com */#include "arch.h"#include "mcfuart.h"#include "ledstate.h"char ident[] = "Key Technology 70318";char copyright[] = "(C) 2002 Key Technology, Inc.";extern unsigned int downloadPort;extern unsigned int image_size;extern unsigned char *xfer_addr;extern unsigned char *down_addr;extern unsigned char *dest_addr;extern unsigned char *source_addr;extern unsigned int consoleBase;void configureConsole(){ consoleBase = MCFUART_BASE2; configureSerial(consoleBase, 19200, 60000000);}void configureAuxSerial() {}void setLED(int state){ unsigned char bits; switch(state) { case LED_STATUS_INIT: bits = 0; break; case LED_STATUS_MEM: bits = 0x06; break; case LED_STATUS_LOADIMG: // Failed decompression, waiting for serial image bits = 0x04; break; case LED_STATUS_ENSWT: // Enable Watchdog Timer, just before booting bits = 0; break; case LED_STATUS_DDECOMPRESS: // start of decompress() bits = 0x02; break; case LED_STATUS_ENCACHE: // about to enable cache for decompression bits = 0x66; break; default: // leave alone otherwise return; } *(volatile unsigned short *)(MCF_MBAR + MCFSIM_PADAT) = (unsigned short)(bits<<8);}void setImageParams(){ downloadPort = 1; image_size = 0x001c0000; source_addr = (unsigned char *)0xf0040000; down_addr = (unsigned char *)0xf0040000; xfer_addr = (unsigned char *)0x20000; dest_addr = (unsigned char *)0x20000;}void setupBoard(){ volatile unsigned char *mbar; mbar = (volatile unsigned char *) MCF_MBAR; // stuff that was added for dbug compliance (sim_init) mbar_writeShort(MCFSIM_SCR, 0x0003); mbar_writeShort(MCFSIM_SPR, 0xFFFF); mbar_writeLong(MCFSIM_ICR1, 0x88888888); mbar_writeLong(MCFSIM_ICR2, 0x88888888); mbar_writeLong(MCFSIM_ICR3, 0x88888888); mbar_writeLong(MCFSIM_ICR4, 0x88880000); mbar_writeLong(MCFSIM_PITR, 0x00000000); mbar_writeByte(MCFSIM_PIVR, 0x00000040); mbar_writeLong(MCFSIM_PACNT, 0x00000000); // Digital outputs are all on Port A // 2r0111011100000000 // 16r 7 7 0 0 mbar_writeShort(MCFSIM_PADDR, 0x7700); setLED(0); mbar_writeLong(MCFSIM_PBCNT, 0x55550000); // Enable Ethernet // Set port D to enable INT 4 and second UART // (See p. 17-8 in 5272 User's Manual) // 2r00000000000000000000111010101010 // 16r 0 0 0 0 0 e a a mbar_writeLong(MCFSIM_PDCNT, 0x00000eaa); // CS0: FLASH mbar_writeLong(MCFSIM_CSBR0, 0xF0000201); mbar_writeLong(MCFSIM_CSOR0, 0xFFE00014); // CS7: SDRAM // Match = 0x003xxxxx, SDRAM = 0x400, Cache Line = 0x300, Enable = 1 mbar_writeLong(MCFSIM_CSBR7, 0x00000701); mbar_writeLong(MCFSIM_CSOR7, 0xFFC0007C); // CS1, CS2, CS3, CS4, CS5, and CS6 are unused on this board. // CS2 is the only one of these which might ever be used; // it would be used for external SRAM. mbar_writeLong(MCFSIM_CSBR1, 0); mbar_writeLong(MCFSIM_CSOR1, 0); mbar_writeLong(MCFSIM_CSBR3, 0); mbar_writeLong(MCFSIM_CSOR3, 0); mbar_writeLong(MCFSIM_CSBR4, 0); mbar_writeLong(MCFSIM_CSOR4, 0); mbar_writeLong(MCFSIM_CSBR5, 0); mbar_writeLong(MCFSIM_CSOR5, 0); mbar_writeLong(MCFSIM_CSBR6, 0); mbar_writeLong(MCFSIM_CSOR6, 0);}void setupDRAM(){ volatile unsigned char *mbar = (unsigned char *)MCF_MBAR; mbar_writeLong(MCFSIM_SDTR, 0xF539); mbar_writeLong(MCFSIM_SDCR, 0x4211); // Dummy write to start SDRAM *((volatile unsigned long *)0) = 0;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -