#include <stdarg.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <ctype.h>
#include "uhal.h"
#include "def.h"
#include "isr.h"
#include "44b.h"
//MCLK= 50000000
//50000000hz/256/32= 6103.51hz
#define _TICK 1000 // 1/1000 sec
//#define _TICK 100 // 1/100 sec
//#define _TICK 10 // 1/10 sec
#define _CLOCK (61035/(_TICK/10))
//#define _CLOCK 61035 // 1 sec
#define MAX_TBUF 10000
char tbuf[MAX_TBUF]= {0, };
int delayLoopCount= 400;
//int whichUart= 0;
#define SIO_START 0x08 //SIO Start
//void timer0_handler();
void (*restart)(void)=(void (*)(void))0x0;
//void (*run)(void)=(void (*)(void))DOWNLOAD_ADDRESS;
void Delay(int time)//ok eric rong
// time=0: adjust the Delay function by WatchDog timer.
// time>0: the number of loop time
// 100us resolution.
{
int i,adjust=0;
if(time==0)
{
time=200;
adjust=1;
delayLoopCount=400;
rWTCON=((MCLK/1000000-1)<<8)|(2<<3); // 1M/64,Watch-dog,nRESET,interrupt disable
rWTDAT=0xffff;
rWTCNT=0xffff;
rWTCON=((MCLK/1000000-1)<<8)|(2<<3)|(1<<5); // 1M/64,Watch-dog enable,nRESET,interrupt disable
}
for(;time>0;time--)
for(i=0;i<delayLoopCount;i++);
if(adjust==1)
{
rWTCON=((MCLK/1000000-1)<<8)|(2<<3);
i=0xffff-rWTCNT; // 1count/16us?????????
delayLoopCount=8000000/(i*64); //400*100/(i*64/200)
}
}
void Led_Display(int data)//ok eric rong
{
// rPDATE=(rPDATE & 0x13f) | ((data & 0x03)<<6);
}//Led_Display
//Output through LCD or serial port to print information.
int uHALr_printf(const char *format, ...)
{
va_list v_list;
char *ptr;
int i= 0;
va_start(v_list, format); // Initialize variable arguments.
vsprintf(tbuf, format, v_list );
va_end(v_list);
ptr= tbuf;
while( (*ptr) && i<MAX_TBUF) {
Uart_SendByte(0,*ptr);
ptr++; i++;
}//while
return 1;
}//uHALr_printf
void BreakPoint(void)
{
uHALr_printf("!!!Enter break point.");
while(1) {
Led_Display(0xf);
Delay(1000);
Led_Display(0x0);
Delay(1000);
}//while
}//BreakPoint
/*** Called by ARMTargetInit() ***/
//Reset memory management unit.
void uHALr_ResetMMU(void)
{
}//uHALrResetMMU
void OutDebug(unsigned int num)
{
uHALr_printf("\r\n***STACK***:%d\r\n", num);
}//OutDebug
//Define pre & post-process routines for Interrupt.
void uHALir_DefineIRQ(void *is, void *iq, void *n)
{
}//uHALir_DefineIRQ
//Initialze interrupts.
void uHALr_InitInterrupts(void)
{
// Non-vectored,IRQ disable,FIQ disable
rINTCON=0x0;
// All=IRQ mode
rINTMOD=0x0;
// All interrupt is masked.
rINTMSK=BIT_GLOBAL;
}//uHALr_InitInterrupts
//Initialize timer that is used OS.
void uHALr_InitTimers(void)//use timer1
{
//the following code is for 44B0X
rTCFG0=0x0f0f0f;
rTCFG1=0x11111;
rTCNTB1= _CLOCK;
rTCMPB1= 0x0;
rTCON=(0x2<<8); //update mode for TCNTB1 and TCMPB1.
rTCON=(0x9<<8); //timer1 = auto reload, start
}//uHALr_InitTimers
int I_COUNT=0;
void DebugUNDEF(void)
{
uHALr_printf("!!!Enter UNDEFINED. %d\r\n", I_COUNT);
while(1) {
Led_Display(0xf);
Delay(1000);
Led_Display(0x0);
Delay(1000);
}//while
}//BreakPoint
void DebugSWI(void)
{
uHALr_printf("!!!Enter SWI. %d\r\n", I_COUNT);
while(1) {
Led_Display(0xf);
Delay(1000);
Led_Display(0x0);
Delay(1000);
}//while
}
void DebugABORT(void)
{
uHALr_printf("!!!Enter ABORT %d\r\n", I_COUNT);
while(1) {
Led_Display(0xf);
Delay(1000);
Led_Display(0x0);
Delay(1000);
}//while
}
void DebugFIQ(void)
{
uHALr_printf("!!!Enter FIQ. %d\r\n", I_COUNT);
while(1) {
Led_Display(0xf);
Delay(1000);
Led_Display(0x0);
Delay(1000);
}//while
}
extern void IRQ_Handler(void);
void uHALr_InterruptRequestInit()
{
pISR_UNDEF= (unsigned) DebugUNDEF;
pISR_SWI= (unsigned) DebugSWI;
pISR_PABORT= (unsigned) DebugABORT;
pISR_DABORT= (unsigned) DebugABORT;
// pISR_RESERVED
pISR_IRQ= (unsigned) IRQ_Handler; //irq interrupt
pISR_FIQ= (unsigned) DebugFIQ;
//SetISR_Interrupt(INT_TIMER1_OFFSET,OSTimeTick,NULL);
///////////////////////No use////////////////////////
pISR_ADC= (unsigned) BreakPoint;
pISR_RTC= (unsigned) BreakPoint;
pISR_UTXD1= (unsigned) BreakPoint;
pISR_UTXD0= (unsigned) BreakPoint;
pISR_SIO= (unsigned) BreakPoint;
pISR_IIC= (unsigned) BreakPoint;
pISR_URXD1= (unsigned) BreakPoint;
pISR_URXD0= (unsigned) BreakPoint;
//remove by eric rong// pISR_EINT67= (unsigned) BreakPoint;
pISR_WDT= (unsigned) BreakPoint;
pISR_TIMER3= (unsigned) BreakPoint;
pISR_TIMER2= (unsigned) BreakPoint;
pISR_TIMER1= (unsigned) BreakPoint;
// pISR_TIMER0= (unsigned) BreakPoint;
//remove by eric rong// pISR_UERR1= (unsigned) BreakPoint;
//remove by eric rong// pISR_UERR0= (unsigned) BreakPoint;
pISR_BDMA1= (unsigned) BreakPoint;
pISR_BDMA0= (unsigned) BreakPoint;
pISR_ZDMA1= (unsigned) BreakPoint;
pISR_ZDMA0= (unsigned) BreakPoint;
//remove by eric rong// pISR_EINT5= (unsigned) BreakPoint;
//remove by eric rong// pISR_EINT4= (unsigned) BreakPoint;
pISR_EINT3= (unsigned) BreakPoint;
pISR_EINT2= (unsigned) BreakPoint;
pISR_EINT1= (unsigned) BreakPoint;
pISR_EINT0= (unsigned) BreakPoint;
/////////////////////////////////////////////////////
}
//Start system timer & enable the interrupt.
void uHALr_InstallSystemTimer(void)
{
//Non-vectored,IRQ enable,FIQ disable
rINTCON=0x5;
//Non maksed TIMER0 .
rI_ISPC=BIT_TIMER1;
rINTMSK=~(BIT_TIMER1 | BIT_GLOBAL); //Default value=0x7ffffff
}//uHALr_InstallSystemTimer
/************************* PORTS ****************************/
void Port_Init(void)//add by eric rong
{
//CAUTION:Follow the configuration order for setting the ports.
// 1) setting value
// 2) setting control register
// 3) configure pull-up resistor.
//16bit data bus configuration
// PORT A GROUP
/* BIT 9 8 7 6 5 4 3 2 1 0 */
/* ADDR24 ADDR23 ADDR22 ADDR21 ADDR20 ADDR19 ADDR18 ADDR17 ADDR16 ADDR0 */
/* 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 */
rPCONA = 0x3ff;
// PORT B GROUP
/* BIT 10 9 8 7 6 5 4 3 2 1 0*/
/* /CS5 /CS4 /CS3 /CS2 /CS1 nWBE3 nWBE2 /SRAS /SCAS SCLK SCKE*/
/* rtl8019 (Reserve)(Reserve)FLASH D12 Out Out Sdram Sdram Sdram Sdram*/
/* 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1*/
rPDATB = 0x7ff;
rPCONB = 0x7cf;
//PORT C GROUP
//BUSWIDTH=16*/
/* PC 15 14 13 12 11 10 9 8 */
/* O O RXD1 TXD1 O O O O*/
/* Nand-CE UDA-CE Uart1 Uart1 NandCLE NandALE L3DATA L3CLK*/
/* 01 01 11 11 01 01 01 01 */
/* PC 7 6 5 4 3 2 1 0*/
/* O O O I IISCLK IISDI IISDO IISLRCK*/
/* VD4 VD5 VD6 VD7 [ for UDA1341 ]*/
/* 11 11 11 11 11 11 11 11*/
rPDATC = 0x3fff; //All IO is high
rPCONC = 0x5f55ffff;
rPUPC = 0x3000; //PULL UP RESISTOR should be enabled to I/O
//PORT D GROUP for LCD
/*BIT 7 6 5 4 3 2 1 0*/
/* VF VM VLINE VCLK VD3 VD2 VD1 VD0*/
/* 10 10 10 10 10 10 10 10*/
rPDATD= 0xff;
rPCOND= 0xaaaa;
rPUPD = 0x0;
//PORT E GROUP
/* Bit 8 7 6 5 4 3 2 1 0 */
/* CODECLK TOUT4 TOUT3 TOUT2 TOUT1 TOUT0 RXD0 TXD0 SMRB(I) */
/* 10 10 10 10 10 10 10 10 00 */
rPDATE = 0x1ff;
rPCONE = 0x2aaa8;
rPUPE = 0x106;
//PORT F GROUP
/* Bit 8 7 6 5 4 3 2 1 0*/
/* SIOCLK SIORxD 7843CS SIOTxD [Input(DMA) ] Output IICSDA IICSCL*/
/* 011 011 001 011 00 00 01 10 10*/
rPDATF = 0x1fb; //GPF2=0
rPCONF = 0x1B2C1A; //0x9241A;
rPUPF = 0x3;
//PORT G GROUP
/*BIT 7 6 5 4 3 2 1 0*/
/* INT7 INT6 INT5 INT4 INT3 INT2 INT1 INT0*/
/* 11 11 11 11 11 11 11 11
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
ARM键盘及LED 驱动实验.rar (45个子文件)
www.pudn.com.txt 218B
Exp4
Exp4.IAB 24KB
Exp4.PR 6KB
Exp4.IMD 408B
Exp4.IMB 8KB
Exp4.PFI 68B
Exp4.PRI 32KB
Exp4.PO 776B
Exp4.IAD 568B
Exp4.PS 83KB
Exp4.WK3 31KB
startup
BITOPS.H 879B
UHAL.c 11KB
EXIO.h 399B
KeyBoard.c 579B
44BINIT.S 13KB
OPTION.S 1003B
DEF.H 444B
uhal.h 1KB
OPTION.H 2KB
KeyBoard.h 85B
Main.c 865B
Maro.h 164B
ISR.c 1KB
EXIO.c 29B
ISR.H 1KB
44B.H 15KB
MyUart.h 229B
MEMCFG.S 3KB
MyUart.c 2KB
Zlg7289.h 1KB
zlg7289.c 390B
Exp4.apj 8KB
Debug
UHAL.o 38KB
MyUart.o 18KB
44BINIT.o 4KB
zlg7289.o 16KB
ISR.o 17KB
EXIO.o 2KB
system.bin 36KB
Main.o 17KB
KeyBoard.o 16KB
MEMCFG.o 212B
EuCos.axf 85KB
OPTION.o 212B
共 45 条
- 1
资源评论
- xjdx0512012-03-22ARM 键盘及LED 驱动实验这个没有说明是基于那个平台的ARM,只能作为一个参考,因为不同平台直接编译是不成功的,我现在用的是ARM11发现编译不过,所以只能作参考
jxquanming
- 粉丝: 3
- 资源: 5
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- Screenshot_2024-05-21-17-06-42-64_2332cb9b27b851b548ba47a91682926c.jpg
- 毕业设计参考 - 基于树莓派、OpenCV及Python的人脸识别
- node-v18.20.2-linux-arm64
- 222222222222
- 16张相机标定图片,可复现本文畸变矫正
- dbeaver-ce-23.3.1-x86_64-setup.zip
- 基于X86 AVX2指令的快速卷积实现
- VMware-ESXi-7.0U3n-21930508-depot.zip文件
- MySQL 在 Windows 系统下的安装教程.zip
- Access文件数据库访问的客户端
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功