#define INTERNAL_MEM_MAP_ADDR 0x0xxx
/* I/O Port Configuration Registers */
/*** Port A data direction reg ***/
#define M8260_IOP_PADIR(base) ((VINT32 *) ((base) + 0x010D00))
/*** Port A pin assign reg ***/
#define M8260_IOP_PAPAR(base) ((VINT32 *) ((base) + 0x010D04))
/*** Port A special options reg ***/
#define M8260_IOP_PASO(base) ((VINT32 *) ((base) + 0x010D08))
/*** Port A open drain reg ***/
#define M8260_IOP_PAODR(base) ((VINT32 *) ((base) + 0x010D0C))
/*** Port A data reg ***/
#define M8260_IOP_PADAT(base) ((VINT32 *) ((base) + 0x010D10))
/*** Port B data direction reg ***/
#define M8260_IOP_PBDIR(base) ((VINT32 *) ((base) + 0x010D20))
/*** Port B pin assign reg ***/
#define M8260_IOP_PBPAR(base) ((VINT32 *) ((base) + 0x010D24))
/*** Port B special options reg ***/
#define M8260_IOP_PBSO(base) ((VINT32 *) ((base) + 0x010D28))
/*** Port B open drain reg ***/
#define M8260_IOP_PBODR(base) ((VINT32 *) ((base) + 0x010D2C))
/*** Port B Data register ***/
#define M8260_IOP_PBDAT(base) ((VINT32 *) ((base) + 0x010D30))
/*** Port C data direction reg ***/
#define M8260_IOP_PCDIR(base) ((VINT32 *) ((base) + 0x010D40))
/*** Port C pin assign reg ***/
#define M8260_IOP_PCPAR(base) ((VINT32 *) ((base) + 0x010D44))
/*** Port C special options reg ***/
#define M8260_IOP_PCSO(base) ((VINT32 *) ((base) + 0x010D48))
/*** Port C open drain reg ***/
#define M8260_IOP_PCODR(base) ((VINT32 *) ((base) + 0x010D4C))
/*** Port C data reg ***/
#define M8260_IOP_PCDAT(base) ((VINT32 *) ((base) + 0x010D50))
/*** Port D data direction reg ***/
#define M8260_IOP_PDDIR(base) ((VINT32 *) ((base) + 0x010D60))
/*** Port D pin assign reg ***/
#define M8260_IOP_PDPAR(base) ((VINT32 *) ((base) + 0x010D64))
/*** Port D special options reg ***/
#define M8260_IOP_PDSO(base) ((VINT32 *) ((base) + 0x010D68))
/*** Port D open drain reg ***/
#define M8260_IOP_PDODR(base) ((VINT32 *) ((base) + 0x010D6C))
/*** Port D data reg ***/
#define M8260_IOP_PDDAT(base) ((VINT32 *) ((base) + 0x010D70))
/* forward declaration */
void sysIOPortWritePin (char port, UINT8 pin, BOOL high);
STATUS sysIOPortReadPin (char port, UINT8 pin);
UINT32 sysIOPortGetPortAdrs (char port, UINT8 portNum);
/***********************************************************************
*
* sysIOPortWritePin - write to pin
*
* This routine write to the I/O pin.
*
* RETURNS: None
*/
void sysIOPortWritePin
(
char port,
UINT8 pin,
BOOL high
)
{
UINT32 pinAdrs;
pinAdrs = sysIOPortGetPortAdrs (port, 32 - pin);
switch (port)
{
case 'A':
case 'a':
*M8260_IOP_PAPAR(INTERNAL_MEM_MAP_ADDR) &= ~pinAdrs;
*M8260_IOP_PASO (INTERNAL_MEM_MAP_ADDR) &= ~pinAdrs;
*M8260_IOP_PADIR(INTERNAL_MEM_MAP_ADDR) |= pinAdrs;
if (high)
*M8260_IOP_PADAT(INTERNAL_MEM_MAP_ADDR) |= pinAdrs;
else
*M8260_IOP_PADAT(INTERNAL_MEM_MAP_ADDR) &= ~pinAdrs;
break;
case 'B':
case 'b':
*M8260_IOP_PBPAR(INTERNAL_MEM_MAP_ADDR) &= ~pinAdrs;
*M8260_IOP_PBSO (INTERNAL_MEM_MAP_ADDR) &= ~pinAdrs;
*M8260_IOP_PBDIR(INTERNAL_MEM_MAP_ADDR) |= pinAdrs;
if (high)
*M8260_IOP_PBDAT(INTERNAL_MEM_MAP_ADDR) |= pinAdrs;
else
*M8260_IOP_PBDAT(INTERNAL_MEM_MAP_ADDR) &= ~pinAdrs;
break;
case 'C':
case 'c':
*M8260_IOP_PCPAR(INTERNAL_MEM_MAP_ADDR) &= ~pinAdrs;
*M8260_IOP_PCSO (INTERNAL_MEM_MAP_ADDR) &= ~pinAdrs;
*M8260_IOP_PCDIR(INTERNAL_MEM_MAP_ADDR) |= pinAdrs;
if (high)
*M8260_IOP_PCDAT(INTERNAL_MEM_MAP_ADDR) |= pinAdrs;
else
*M8260_IOP_PCDAT(INTERNAL_MEM_MAP_ADDR) &= ~pinAdrs;
break;
case 'D':
case 'd':
*M8260_IOP_PDPAR(INTERNAL_MEM_MAP_ADDR) &= ~pinAdrs;
*M8260_IOP_PDSO (INTERNAL_MEM_MAP_ADDR) &= ~pinAdrs;
*M8260_IOP_PDDIR(INTERNAL_MEM_MAP_ADDR) |= pinAdrs;
if (high)
*M8260_IOP_PDDAT(INTERNAL_MEM_MAP_ADDR) |= pinAdrs;
else
*M8260_IOP_PDDAT(INTERNAL_MEM_MAP_ADDR) &= ~pinAdrs;
break;
default:
break;
}
}
/***********************************************************************
*
* sysIOPortReadPin - read from pin
*
* This routine read the data from an I/O pin.
*
* RETURNS: OK or ERROR
*/
STATUS sysIOPortReadPin
(
char port,
UINT8 pin
)
{
UINT32 pinAdrs;
STATUS retVal = ERROR;
pin = 32 - pin;
pinAdrs = sysIOPortGetPortAdrs (port, pin);
switch (port)
{
case 'A':
case 'a':
*M8260_IOP_PAPAR(INTERNAL_MEM_MAP_ADDR) &= ~pinAdrs;
*M8260_IOP_PASO (INTERNAL_MEM_MAP_ADDR) &= ~pinAdrs;
*M8260_IOP_PADIR(INTERNAL_MEM_MAP_ADDR) &= ~pinAdrs;
if (*M8260_IOP_PADAT(INTERNAL_MEM_MAP_ADDR) & pinAdrs)
retVal = OK;
break;
case 'B':
case 'b':
*M8260_IOP_PBPAR(INTERNAL_MEM_MAP_ADDR) &= ~pinAdrs;
*M8260_IOP_PBSO (INTERNAL_MEM_MAP_ADDR) &= ~pinAdrs;
*M8260_IOP_PBDIR(INTERNAL_MEM_MAP_ADDR) &= ~pinAdrs;
if (*M8260_IOP_PBDAT(INTERNAL_MEM_MAP_ADDR) & pinAdrs)
retVal = OK;
break;
case 'C':
case 'c':
*M8260_IOP_PCPAR(INTERNAL_MEM_MAP_ADDR) &= ~pinAdrs;
*M8260_IOP_PCSO (INTERNAL_MEM_MAP_ADDR) &= ~pinAdrs;
*M8260_IOP_PCDIR(INTERNAL_MEM_MAP_ADDR) &= ~pinAdrs;
if (*M8260_IOP_PCDAT(INTERNAL_MEM_MAP_ADDR) & pinAdrs)
retVal = OK;
break;
case 'D':
case 'd':
*M8260_IOP_PDPAR(INTERNAL_MEM_MAP_ADDR) &= ~pinAdrs;
*M8260_IOP_PDSO (INTERNAL_MEM_MAP_ADDR) &= ~pinAdrs;
*M8260_IOP_PDDIR(INTERNAL_MEM_MAP_ADDR) &= ~pinAdrs;
if (*M8260_IOP_PDDAT(INTERNAL_MEM_MAP_ADDR) & pinAdrs)
retVal = OK;
break;
default:
break;
}
return (retVal);
}
/***********************************************************************
*
* sysIOPortGetPortAdrs - get port address
*
* This routine get the port address.
*
* RETURNS: Port address
*/
UINT32 sysIOPortGetPortAdrs
(
char port,
UINT8 portNum
)
{
UINT32 adrs = 0x00000000;
switch (port)
{
case 'A':
case 'a':
if (portNum < 32)
adrs = PA0 >> portNum;
else
printf("Invalid port number for port A!/n");
break;
case 'B':
case 'b':
if (portNum < 32 && portNum > 3)
adrs = PB4 >> portNum;
else
printf("Invalid port number for port B!/n");
break;
case 'C':
case 'c':
if (portNum < 32)
adrs = PC0 >> portNum;
else
printf("Invalid port number for port C!/n");
break;
case 'D':
case 'd':
if (portNum < 32 && portNum > 3)
adrs = PD4 >> portNum;
else
printf("Invalid port number for port D!/n");
break;
default:
printf("Invalid port specified!/n");
break;
}
return (adrs);
}