⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main.c

📁 基于arm9的,usb设备(u盘)的读写操作实现.
💻 C
字号:
#include "mx_types.h"
#include "System.h"
#include <stdio.h>

#include "rtc.h"
#include "sdi.h"

#include "main.h"

unsigned char MIDI_flg = 0;
unsigned char *MIDIaddress;
unsigned long file_length=0;

u_8 testtest = 0;

u_8 USBD_flg=0;//0:8051 usb device; 1:U-disk

void Main(void)
{
	RTC_Time rTime;
	u_8 Tmp = 0xfb;

	System_initial();

	Uart_Printf("	Key1: Test_SDI\n");
	Uart_Printf("	Key2: Change to U-Disk device\n");
	Uart_Printf("	Key9: Change to 8051 USB device\n");
	while(1)
	{
		while(MIDI_flg==0)
		{
			System_Waiting();
			Delay(500);
		}
		if(MIDI_flg == 1)
		{
			Test_SDI();
			MIDI_flg = 0;
		}
		else if(MIDI_flg == 2)
		{
			Test_Init();
			Uart_Printf("\nfor usb mass storage\n");
			USBD_flg = 1;
			UsbdMain();
			Uart_Printf("Please push the usb reset key...\n");
			MIDI_flg = 0;
		}
		else if(MIDI_flg == 9)
		{
			Uart_Printf("\nfor 8051 test board\n");
			USBD_flg = 0;
			UsbdMain();
			Uart_Printf("Please push the usb reset key...\n");
			MIDI_flg = 0;
		}
	}
}

void __irq Isr_Eint2(void)
{
	ClearPending(BIT_EINT2);//Clear INT2 flag.  
	
}

void __irq Isr_Eint8_23(void) //EINT8_23
{
   
	switch(rEINTPEND)
       {
        case 0x000100://key1
		Delay(3000);
		MIDI_flg = 1;
		rEINTPEND=(1<<8);
		break;
		
        case 0x000800://key2
		Delay(3000);
		MIDI_flg = 2;
       	rEINTPEND=(1<<11);
        break;
		
        case 0x080000://key9
		Delay(3000);
		MIDI_flg = 9;
		rEINTPEND=(1<<19);
		break;
	
	 case 0x002000:
 		Delay(300);

      		rEINTPEND=(1<<13);
		break;

        case 0x004000:
        	Delay(300);

		rEINTPEND=(1<<14);
       	break;

	case 0x008000:
		Delay(3000);

		rEINTPEND=(1<<15);
        	break;

	case 0x010000:
		Delay(3000);

		rEINTPEND=(1<<16);
        	break;

	case 0x020000:
		Delay(3000);

		rEINTPEND=(1<<17);
        	break;
	case 0x040000:
		Delay(3000);

		rEINTPEND=(1<<18);
        	break;
        default:

		rEINTPEND = 0xFFFFF0; //Clear External Interrupt Pending Register .
            	break;
				
        }
	ClearPending(BIT_EINT8_23);
}


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -