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

📄 usb_user.#1

📁 针对TMS320C6000系列的DSP芯片的在线升级的源码
💻 #1
字号:
/*
	File Name	:	USB_USER.C

	Description	: 	Read and Write DSP memory by USB communication.
	              
	Programmer	:	Jack Song

	Make Data	:  2005.6.7 

	Change		:  xxxx...(Name) yyyy,mm.dd(Date)

	Version		:   1.00
*/
#include <c8051f320.h>
#include "USB_REGISTER.h"

#define  c_cUSER
#include <USB_USER.h>



void  Fun_Pro_Main()
{
	g_ucFStatus = FS_CMD;
	g_ucHostCmd = CMD_OTHERS;
	while(1)
	{
		switch (g_ucFStatus)
		{
			case	FS_CMD:
					g_ucHostCmd = g_ucUsbGData[0];
					switch (g_ucHostCmd)
					{
						case	CMD_TEST:
								Fun_Pro_Test();
								POLL_WRITE_BYTE(INDEX, 1);           // Set index to endpoint 1 registers
								Fun_Fifo_Write(FIFO_EP1, 2, &g_ucUsbSData);	
								POLL_WRITE_BYTE(EINCSR1, rbInINPRDY);
								break;
						case	CMD_READ_EINIT:
								Fun_Pro_ReadEinit();
								break;
						case	CMD_WRITE_EINIT:
								Fun_Pro_WriteEInit();
								POLL_WRITE_BYTE(INDEX, 1);           // Set index to endpoint 1 registers
								Fun_Fifo_Write(FIFO_EP1, 2, &g_ucUsbSData);	
								POLL_WRITE_BYTE(EINCSR1, rbInINPRDY);
								break;
						case	CMD_READ_CODE:
								Fun_Pro_ReadCode();
								break;
						case	CMD_WRITE_CODE:
								Fun_Pro_WriteCode();
								break;
						default:    break;
					}				
					break;
			case	FS_DATA:
					break;
			default:	break;	 	
		
		}
	}
}

void	Fun_Pro_Test()
{
	g_ucUsbSData[0] = g_ucHostCmd;
	g_ucUsbSData[1] = 0x00;
}

void	Fun_Pro_ReadEinit()
{

}

void	Fun_Pro_WriteEInit()
{
	Hpi_Write_Word();    //write emif registers
	g_ucUsbSData[0] = g_ucHostCmd;
	g_ucUsbSData[1] = 0x00;

}

void	Fun_Pro_ReadCode()
{}

void	Fun_Pro_WriteCode()
{
	
}	

/************************************************************************ */
/* C6x_write_word */
/* This routine is downloading data from source address to the C6x */
/* dest_address through the C6x Host Port Interface. */ 90
/* This routine accesses the HPID without automatic address increment */
/* */
/* Inputs: */
/* ptr_hpi: pointer to the C6x HPI vase address */
/* source_word: address of the data to transfer to the C6x */ 95
/* dest_address: destination address to write to the C6x HPIA */
/* */
/* (c) Texas Instruments France */
/******************************************************************/
void C6x_write_word(int *ptr_hpi, int source_word, int dest_address) 100
{
	/* Write HPIC with HWOB=1,1st halfword transferred is least significant */
	/* HCNTRL1 HCNTRL0 HHWIL */
	ptr_hpi[0] = 0x0001; /* 1st halfword 0 0 0 */ 105
	ptr_hpi[1] = 0x0001; /* 2nd halfword 0 0 1 */
	/* Write destination address to HPIA, 1st halfword is least significant */
	110
	/* HCNTRL1 HCNTRL0 HHWIL */
	ptr_hpi[2] = (int)(dest_address & 0x0ffff);/* 0 1 0 */
	ptr_hpi[3] = (int)((dest_address>>16)&0x0ffff);/* 0 1 1 */
	115
	Application Report
	SPRA512
	/* Write source_word to HPID without address post-increment */
	/* 1st half-word transferred is least significant */
	/* HCNTRL1 HCNTRL0 HHWIL */
	ptr_hpi[6] = (int)(source_word&0x0ffff); /* 1 1 0 */ 120
	ptr_hpi[7] = (int)((source_word>>16)&0x0ffff);/*1 1 1 */
}
void Fun_Fifo_Write(BYTE addr, unsigned int uNumBytes, BYTE * pData)
{
	int i;
                                          
   // If >0 bytes requested,
   if (uNumBytes) 
   {
      while(USB0ADR & 0x80);              // Wait for BUSY->'0'
                                          // (register available)
      USB0ADR = (addr);                   // Set address (mask out bits7-6)

      // Write <NumBytes> to the selected FIFO
      for(i=0;i<uNumBytes;i++)
      {  
         USB0DAT = pData[i];
         while(USB0ADR & 0x80);           // Wait for BUSY->'0' (data ready)
      }
   }
}

⌨️ 快捷键说明

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