📄 dm642main.c
字号:
/********************************************************************/
/* Copyright 2004 by SEED Incorporated. */
/* All rights reserved. Property of SEED Incorporated. */
/* Restricted rights to use, duplicate or disclose this code are */
/* granted through contract. */
/* */
/********************************************************************/
#include <stdio.h>
#include <csl.h>
#include <std.h>
#include <csl_emifa.h>
#include <csl_irq.h>
#include <csl_chip.h>
#include <csl_timer.h>
#include "seeddm642.h"
#include "SEEDVMP642_fat32.h"
void SEEDDM642_wait(Uint32 delay);
/*SEEDDM642的emifa的设置结构*/
EMIFA_Config Seeddm642ConfigA ={
0x00052078,/*gblctl EMIFA(B)global control register value */
/*将CLK6、4、1使能;将MRMODE置1;使能EK2EN,EK2RATE*/
0xffffffd3,/*cectl0 CE0 space control register value*/
/*将CE0空间设为SDRAM*/
0x73a28e01,/*cectl1 CE1 space control register value*/
/*Read hold: 1 clock;
MTYPE : 0000,选择8位的异步接口
Read strobe :001110;14个clock宽度
TA:2 clock; Read setup 2 clock;
Write hold :2 clock; Write strobe: 14 clock
Write setup :7 clock
-- ---------------
\ 14c /1c
\----------------/ */
0xac2ab02f, /*cectl2 CE2 space control register value*/
/*Read hold :
*/
0x22a28a42, /*cectl3 CE3 space control register value*/
0x57115000, /*sdctl SDRAM control register value*/
0x0000081b, /*sdtim SDRAM timing register value*/
0x001faf4d, /*sdext SDRAM extension register value*/
0x00000002, /*cesec0 CE0 space secondary control register value*/
0x00000002, /*cesec1 CE1 space secondary control register value*/
0x00000002, /*cesec2 CE2 space secondary control register value*/
0x00000073 /*cesec3 CE3 space secondary control register value*/
};
CHIP_Config SEEDDM642percfg = {
CHIP_VP2+\
CHIP_VP1+\
CHIP_VP0+\
CHIP_I2C+\
CHIP_MCASP0
};
Uint32 read_buffer[500],write_buffer[500];
char view[30];
extern far void vectors();
void main()
{
Uint32 i;
fat32_file_handle fp;
Bool j;
/*-------------------------------------------------------*/
/* perform all initializations */
/*-------------------------------------------------------*/
/*Initialise CSL,初始化CSL库*/
CSL_init();
CHIP_config(&SEEDDM642percfg);
/*----------------------------------------------------------*/
/*EMIFA的初始化,将CE0设为SDRAM空间,CE1设为异步空间
注,DM642支持的是EMIFA,而非EMIF*/
EMIFA_config(&Seeddm642ConfigA);
/*----------------------------------------------------------*/
/*中断向量表的初始化*/
//Point to the IRQ vector table
IRQ_setVecs(vectors);
IRQ_nmiEnable();
/*----------------------------------------------------------*/
for(i = 0;i<500;i++)
{
read_buffer[i] = 0;
write_buffer[i] = i;
}
/*----------文件函数测试------------------------------------------*/
j=fat32_install ();
if(j==FALSE)
for(;;){}
j=fat32_create("test1.txt" );
fp=fat32_file_open("test1.txt");
i=fp;
i=fat32_file_write(fp,(Byte *)write_buffer,2000);
if(i!=2000)
for(;;){}
i=fat32_file_seek(fp,0,1,0);
i=fat32_file_read(fp,(Byte *)read_buffer,500);
i=fat32_file_read(fp,(Byte *)read_buffer,1000);
i=fat32_file_read(fp,(Byte *)read_buffer,1500);
i=fat32_file_seek(fp,0,1,0);
i=fat32_file_read(fp,(Byte *)read_buffer,500);
i=fat32_file_seek(fp,0,1,1);
i=fat32_file_read(fp,(Byte *)read_buffer,500);
i=fat32_file_seek(fp,1,1,1);
i=fat32_file_read(fp,(Byte *)read_buffer,500);
i=fat32_file_seek(fp,2,1,0);
i=fat32_file_seek(fp,2,-1,100);
i=fat32_file_read(fp,(Byte *)read_buffer,500);
j=fat32_file_close(fp);
GPIO_RSET(GPGC,0x0);/*将GPIO0不做为GPINT使用*/
GPIO_RSET(GPEN,0x108);
GPIO_RSET(GPDIR,0x108);/*将GPIO0做为输出*/
for(;;)
{
/*GPIO3输出为高*/
GPIO_RSET(GPVAL,0x8);
SEEDDM642_wait(0x200000);
/*GPIO3输出为低*/
GPIO_RSET(GPVAL,0x0);
SEEDDM642_wait(0x200000);
/*GPIO8输出为高*/
GPIO_RSET(GPVAL,0x100);
SEEDDM642_wait(0x200000);
/*GPIO8输出为低*/
GPIO_RSET(GPVAL,0x0);
SEEDDM642_wait(0x200000);
}
}
void SEEDDM642_wait(Uint32 delay)
{
volatile Uint32 i, n;
n = 0;
for (i = 0; i < delay; i++)
{
n = n + 1;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -