CHAPTER 5 APPLICATION EXAMPLES
Application Note U17121EJ1V1AN
76
5.5.4 PCI configuration space access sample program list
/////////////////////////////////////////////////////////////////////////
// PCI configuration space access sample //
// Overview: Configuration space is accessed using procedure //
// shown below. //
// 1) Write 32-bit value indicating PCI device, function //
// number, and register number to be accessed to //
// PCI_CONFIG_ADD register of PCI Host Bridge Macro. //
// 2) When reading configuration space register, read //
// (word access) 32-bit value in PCI_CONFIG_DATA //
// register of PCI Host Bridge Macro. //
// When writing to configuration space register, write //
// (word access) 32-bit value to PCI_CONFIG_DATA register //
// of PCI Host Bridge Macro. //
// //
// This procedure is combined in functions PCI_ConfigRead //
// and PCI_ConfigWrite shown below. //
// Function PCI_Config_BaseAddressInit uses function //
// PCI_ConfigWrite to set base address register in //
// configuration space. //
// //
/////////////////////////////////////////////////////////////////////////
//////////////////////
// Type declaration //
//////////////////////
typedef
char
BYTE;
typedef
short
int
HWORD;
typedef
int
WORD;
typedef unsigned char
UBYTE;
typedef unsigned short int
UHWORD;
typedef
unsigned
int UWORD;
typedef volatile unsigned char
VUBYTE;
typedef volatile unsigned short int
VUHWORD;
typedef volatile unsigned int
VUWORD;
/////////////////////////////////////////////////////////////////
// Function name: PCI_ConfigRead //
// Function: Reads 32-bit value in PCI configuration space. //
// Argument: ConfigAdd: Register address of configuration space//
// Return value: Read configuration space register data //
/////////////////////////////////////////////////////////////////
UWORD PCI_ConfigRead(UWORD ConfigAdd)
{
V850EME2_REGW(PHBMR_PCI_CONFIG_ADD) = ConfigAdd;
return
V850EME2_REGW(PHBMR_PCI_CONFIG_DATA);
}