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

📄 iekc64_pci.h

📁 一个小的测试程序
💻 H
字号:

#ifndef _iekc64_pci_h_
#define _iekc64_pci_h_

#include "csl_stdinc.h"
#include <csl_edma.h>
#include "iekc64_error.h"

#ifdef __cplusplus
extern "C" {
#endif

/*=======================================================================*//*!
\defgroup PCI PCI - PCI interface management module

	\brief This module manages PCI interface on IEK board
  
  This module is related to manage :
  \li messages,
  \li DMA transferts

  between PC and DSP.

  <b> General </b>

    A CommDesc section is defined in internal DSP memory to reserve 3 spaces :
    \li DMA descriptor space
    \li message to PC descriptor space
    \li message from PC descriptor space

  Descriptors are mapped in DSP memory on a continguous 4MB page memory.


  <b> Message </b>
  
    Message descriptors contain few sections like :
    \li Markers (used by SDK only, must be unchanged),
    \li Parameters ( internal read index, internal write index, fifosize )
    \li Fifo message,
    
    If message identifiers are needed, they must be implemented in message itself, cause internal markers are not seen by users.

    Fifo message are limited to 16kB in each direction (PC to DSP / DSP to PC). 
  This value can be modified in the header file "defpcdsp.h". The iekc64_pci.lib 
  file must be recompilated in that case.


 	<b> DMA transfert </b>

    DMA descriptors contain few sections like :
    \li Markers (use by SDK only, must be unchanged),
    \li Parameters ( internal status, Buffer address, current count of bytes transferred )
    \li Page descriptor,

	DMA transfer are limited to 1MB in each direction (PC to DSP / DSP to PC). 
  This value cannot be modified.

</P>*//*==============================================================*//*@{*/

/*--------------------------------------------------------------------------*/
/*! Defines the pci error code possibilities
*/

enum
{
	//! Invalid pointer 
  IEKC64_PCI_ERR_BAD_PTR      		= IEKC64_ERR_CODE( IEKC64_PCI,  1 ),
	//! Invalid memory mapping
  IEKC64_PCI_ERR_MAP_FIFO_MSG   	= IEKC64_ERR_CODE( IEKC64_PCI,  2 ),
 	//! No message available
  IEKC64_PCI_ERR_NO_MSG	    		= IEKC64_ERR_CODE( IEKC64_PCI,  3 ),
 	//! Buffer size too small
  IEKC64_PCI_ERR_SIZE_BUFFER    	= IEKC64_ERR_CODE( IEKC64_PCI,  4 ),
 	//! Invalid message 
  IEKC64_PCI_ERR_MSG		       	= IEKC64_ERR_CODE( IEKC64_PCI,  5 ),
  //! Invalid pci configuration structure size
  IEKC64_PCI_ERR_CFG_SIZE  			= IEKC64_ERR_CODE( IEKC64_PCI,  6 ),
  //! Invalid DMA size
  IEKC64_PCI_ERR_DMA_SIZE  			= IEKC64_ERR_CODE( IEKC64_PCI,  7 )
};


/*--------------------------------------------------------------------------*/
/*! Initialization parameters for PCI_init().
	 All fields have to be intialized with the default configuration, 
	 IEKC64_PCI_CONFIG_DEFAULT . Then needed fields could be modified before the 
	 PCI_init() function call.
*/
typedef struct 
{
	/*! This field must contains the IEKC64_PCI_CONFIG structure size */
	Uint32 dwSize;
	/*! This field defines the size, in bytes, of PCI DMA transfert. It must 
	be a multiple of 4 bytes and lower or eaqual than 4096 */
	Uint32 dwPciDmaSize;	
} IEKC64_PCI_CONFIG;

/*--------------------------------------------------------------------------*/
/*! 
	This varaible contains the PCI default configuration
*/
extern const IEKC64_PCI_CONFIG IEKC64_PCI_CONFIG_DEFAULT;

/*--------------------------------------------------------------------------*/
/*! Initializes the PCI interface 

	\param pPciConfig
		This parameter defines the PCI module configuration. If it is set to
		NULL, the default configuration is used.

 	\return	A IEKC64_STATUS. If the call succeeds, the value will be IEKC64_OK.
				Otherwise it holds an error code. The status code can be tested by
				the IEKC64_SUCCESS(return code) macro that is true is the value
				represents a successful call.

  You can find usage of this function in <a target="_blank" href="../../example/pci/message/messageDsp">example/pci/message/messageDsp</a>
  /<a target="_blank" href="../../example/pci/message/messageDsp/messageDspAsync.c">messageDspAsync.c</a>.


*/

IEKC64_STATUS PCI_init( IEKC64_PCI_CONFIG *pPciConfig);

/*--------------------------------------------------------------------------*/
/*! Send a message to PC 

	\param dwflag
         This parameter is needed to send a DMA request to PC.
         
  \param dwSize
         This specify the number of bytes to send to PC.
				
  \param pMessage
 				This should point to a Buffer that will be send to PC.

 	\return	A IEKC64_STATUS. If the call succeeds, the value will be IEKC64_OK.
				Otherwise it holds an error code. The status code can be tested by
				the IEKC64_SUCCESS(return code) macro that is true is the value
				represents a successful call.

  You can find usage of this function in <a target="_blank" href="../../example/pci/message/messageDsp">example/pci/message/messageDsp</a>
  /<a target="_blank" href="../../example/pci/message/messageDsp/messageDspAsync.c">messageDspAsync.c</a>.

*/

IEKC64_STATUS PCI_sendMessage( Uint32 dwflag, Uint32 dwsize, void* pMessage );

/*--------------------------------------------------------------------------*/
/*! Gets a message from PC 

	\param pflag
         This parameter is reserved.
  
  \param pBytesRead
				 A UINT32 passed by reference to receive the number of read bytes.
      
  \param dwSize
         This specifies the number of bytes to read.
				
  \param pMessage
 				 This should point to a Buffer that will be filled
				 by the call with message.

 	\return	A IEKC64_STATUS. If the call succeeds, the value will be IEKC64_OK.
				Otherwise it holds an error code. The status code can be tested by
				the IEKC64_SUCCESS(return code) macro that is true is the value
				represents a successful call.

  You can find usage of this function in <a target="_blank" href="../../example/pci/message/messageDsp">example/pci/message/messageDsp</a>
  /<a target="_blank" href="../../example/pci/message/messageDsp/messageDspAsync.c">messageDspAsync.c</a>.

*/

IEKC64_STATUS PCI_getMessage(  Uint32 *pflag, Uint32 *pBytesRead, Uint32 dwsize, void* pMessage  );

/*--------------------------------------------------------------------------*/
/*! Sets a callback function to be launched on message reception from PC 

  \param pFunction
 				This should point to a Function that will be launched if a
 				message is received from PC.
 				It can be NULL, to disable the call to the function on event.

 	\return	A IEKC64_STATUS. If the call succeeds, the value will be IEKC64_OK.
				Otherwise it holds an error code. The status code can be tested by
				the IEKC64_SUCCESS(return code) macro that is true is the value
				represents a successful call.

  You can find usage of this function in <a target="_blank" href="../../example/pci/callback/SoftDsp">example/pci/callback/SoftDsp</a>
  /<a target="_blank" href="../../example/pci/callback/SoftDsp/softDsp.c">softDsp.c</a>.

*/

IEKC64_STATUS PCI_OnReceiveMsgCallback( void (*pFunction)(void) );


/*--------------------------------------------------------------------------*/
/*! Sets a callback function to be launched on acknowledge message reception from PC 
	due to an indirect message request
  \param pFunction
 				This should point to a Function that will be launched if an
 				acknowledge message is received from PC.
 				It can be NULL, to disable the call to the function on event.

 	\return	A IEKC64_STATUS. If the call succeeds, the value will be IEKC64_OK.
				Otherwise it holds an error code. The status code can be tested by
				the IEKC64_SUCCESS(return code) macro that is true is the value
				represents a successful call.

*/

IEKC64_STATUS PCI_OnReceiveAckIndMsgCallback( void (*pFunction)(void) );


/*@}*//* end of group PCI */

#ifdef __cplusplus
}
#endif

#endif /* #ifndef _iekc64_pci_h_ */

/* Fin du fichier iekc64_pci.H */

⌨️ 快捷键说明

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