image_pci.c

来自「该代码实现了 两次下载法在dspC6713平台上 烧写flash的操作过程」· C语言 代码 · 共 180 行

C
180
字号
/*****************************************************************************
* File name :     IMAGE_PCI.c
* Description:
******************************************************************************/
#ifndef MASTER_FILE
#define C6711_GLOBALS
#include "includes.h"
#endif

#include "PCI.H"

/*---------------------------------------------------------------------------------*
* Importended registers needed to be saved during interrupts                      
*---------------------------------------------------------------------------------*/
struct PCI_MailBox
   {
    char byte0;
    char byte1;
   } *PCI_accept,*PCI_post;
   
/*---------------------------------------------------------------------------------*
* Function:    PCI_init()                                                          
* Description:                                                                     
*---------------------------------------------------------------------------------*/
void PCI_init()
{

}

/*---------------------------------------------------------------------------------*
* Function:    PCI_FIFO_read()                                                          
* Description:                                                                     
*---------------------------------------------------------------------------------*/
void PCI_FIFO_read()
{

}

/*---------------------------------------------------------------------------------*
* Function:    PCI_FIFO_write()                                                          
* Description:                                                                     
*---------------------------------------------------------------------------------*/
void PCI_FIFO_write()
{

}

/*---------------------------------------------------------------------------------*
* Function:    PCI_I2C_read()                                                          
* Description:                                                                     
*---------------------------------------------------------------------------------*/
int PCI_I2C_read(
                  unsigned int device_addr,
                  unsigned int memory_addr,
                  unsigned char read_type
                )
{
 I2C_DEVADDR_WRITE(device_addr);   /* Write device address           */
 I2C_MEMADDR_WRITE(memory_addr);   /* Write memory address           */
 i2c_read_type(read_type);         /* Set read type: 4-byte read;    */
 i2c_start_operation(1);               /* start read operation           */
 
 while(!I2C_DONE_POLL)             /* waiting for operation finished */
 {}
 
 if(I2C_ACK_POLL==0)               /* polling the ACK status bits    */
    return (I2C_DATA_READ);        /* read data register NVREAD      */
 else 
    return 0;
    
}

/*---------------------------------------------------------------------------------*
* Function:    PCI_I2C_write()                                                          
* Description:                                                                     
*---------------------------------------------------------------------------------*/
BOOLEAN PCI_I2C_write(
                      unsigned int device_addr, 
                      unsigned int memory_addr,
                      unsigned int write_data
                     )
{
 I2C_DEVADDR_WRITE(device_addr);   /* Write device address           */
 I2C_MEMADDR_WRITE(memory_addr);   /* Write memory address           */
 I2C_DATA_WRITE(write_data);       /* write WRITE DATA in NVCMD      */
 i2c_start_operation(0);               /* start write operation          */
 
 while(!I2C_DONE_POLL)             /* waiting for operation finished */
 {}
 
 if(I2C_ACK_POLL==0)               /* polling the ACK status bits    */
    return TRUE;                   /* read data register NVREAD      */
 else 
    return FALSE;
}

/*---------------------------------------------------------------------------------*
* Function:    PCIMbox_accept()                                                    
* Description: Accept data from Host through Host to local Data Mailbox            
*                                                                                 
* HLDATA Bit Description:                                                          
* bit[24]-Interrupt to Local.This bit enables the host to send an interrupt to the 
*         Local. When it is set to 1 by the host, it triggers a mailbox interrupt 
*         to the local processor.The interrupt remains active until it is cleared  
*         by writing to the Local Interrupt Control and Status Register(LINT).     
* bit[15:8]-Byte 1,bit[ 7:0]-Byte 0 :Data byte. Two bytes of data that can be      
*         written by the host and read by the local processor .                   
*---------------------------------------------------------------------------------*/
void PCIMbox_accept( )
{
/*clear the Host to Local mailbox Interrupt Event Status bit by writing '1' to it */
 LOCAL_INTR_CLR(3);
 
 PCI_accept->byte0 = GET_FIELD((PCI_BASIC+HLDATA),0,8); /*Get byte0 of HLDATA*/
 PCI_accept->byte1 = GET_FIELD((PCI_BASIC+HLDATA),8,8); /*Get byte1 of HLDATA*/
 
}

/*---------------------------------------------------------------------------------*
* Function:    PCIMbox_post()                                                      
* Description: Post data to Host through Local to Host Data Mailbox                
*                                                                                 
* LHDATA Bit Description:                                                          
* bit[24]-Interrupt to Host.When this bit is written to 1 by the local processor,  
*        it causes a mailbox interrupt to the host. The interrupt will remain     
*        active until it is cleared by the host in the Host Interrupt Control     
*        and Status Register ( HINT).                                             
* bit[15:8]-Byte 1,bit[ 7:0]-Byte 0 :Data byte. Two bytes of data that can be      
*         written by the local processor and read by the host.                    
*---------------------------------------------------------------------------------*/
BOOLEAN PCIMbox_post()
{
 if(HOST_INTR_POLL(3)==0)
  {
   LOAD_FIELD((PCI_BASIC+LHDATA),(PCI_post->byte0),0,8); /*Assign byte0 of LHDATA*/
   LOAD_FIELD((PCI_BASIC+LHDATA),(PCI_post->byte1),8,8); /*Assign byte1 of LHDATA*/
   return TRUE;
  }
 else
  {
   return FALSE;
  }
}

/*---------------------------------------------------------------------------------*
* Function:    PCI_command()                                                          
* Description: Interpretate PCI commands and configure corresponding FPGA register. 
*              Get command from HOST through PCI_mailbox;
*              Get configuring data from a specified address in 16k shared memory.                                                                  
*---------------------------------------------------------------------------------*/
void PCI_command()
{
 /*First  step: get command type from PCI_mailbox */
 /*Second step: get configuring data from shared memory */
 /*Third  step: interpretating command */
 /*Fourth step: configuring FPGA registers */
 
}

/*---------------------------------------------------------------------------------*
* Function:    PCIdata_write()                                                      
* Description: Transmit data from DSP to Host through 16K shared memory.           
*---------------------------------------------------------------------------------*/
void PCIdata_write(unsigned int src_addr, unsigned int dst_addr, int page_size)
{

}

/*---------------------------------------------------------------------------------*
* Function:    PCIdata_read()                                                      
* Description: Read data from host  through 16K shared memory.                     
*---------------------------------------------------------------------------------*/
void PCIdata_read(unsigned int src_addr, unsigned int dst_addr, int page_size)
{

}


/* END OF FILE */

⌨️ 快捷键说明

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