Exemplo n.º 1
0
void GPIO_InitIO(unsigned int dir, unsigned int pin)
{  
    unsigned int no,remainder;
    no = pin >>4;
    remainder = pin & 0xf;

    if (dir == OUTPUT)
    {   
        DRV_WriteReg16(GPIO_PULLEN_SET(no),(1 << remainder));
        DRV_WriteReg16(GPIO_DIR_SET(no),(1 << remainder));
    }
    else
    {   
        DRV_WriteReg16(GPIO_PULLEN_CLR(no),(1 << remainder));
        DRV_WriteReg16(GPIO_DIR_CLR(no),(1 << remainder));
    }
    I2C_DUMMY_DELAY(100);
}
Exemplo n.º 2
0
/*
* FUNCTION                                                            
*	GPIO_InitIO
*
* DESCRIPTION                                                           
*   	This function is to initialize one GPIO pin as INPUT or OUTPUT
*
* CALLS  
*	Initialize one GPIO pin as INPUT or OUTPUT
*
* PARAMETERS
*	direction: INPUT or OUTPUT
*	port: pin number
*	
* RETURNS
*	None
*
* GLOBALS AFFECTED
*   external_global
*/
void GPIO_InitIO(char direction, char port)
{
#ifdef MT6205
   if (direction == OUTPUT)
	{
	   if (port < 16)
		   DRV_Reg(GPIO_DIR) |= (1 << port);
      else
         DRV_Reg(GPIO_DIR2) |= (1 << (port-16));
	}
	else
	{
	   if (port < 16)
		   DRV_Reg(GPIO_DIR) &= ~(1 << port);
		else
		   DRV_Reg(GPIO_DIR2) &= ~(1 << (port-16));
	}
#endif /*(MT6205)*/

#ifdef MT6205B
extern UINT32 SRVAPI DRV_GpioSetDirection(UINT8, UINT8);
DRV_GpioSetDirection(port, direction);
/*
   if (direction == OUTPUT)
	{
	   if (port < 16)
	      DRV_WriteReg(GPIO_DIR_SET,(1 << port));
      else
         DRV_WriteReg(GPIO_DIR2_SET,(1 << (port-16)));
	}
	else
	{
	   if (port < 16)
		   DRV_WriteReg(GPIO_DIR_CLR,(1 << port));
		else
		   DRV_WriteReg(GPIO_DIR2_CLR,(1 << (port-16)));
	}
	*/
#endif    

#if ( (defined(MT6218)) || (defined(MT6218B))|| (defined(MT6219))|| (defined(MT6217))|| (defined(MT6228))|| defined(MT6229))|| (defined(MT6226))|| (defined(MT6227)) 
   kal_uint16 no;
   kal_uint16 remainder;
      
   no = port/16;
   remainder = port % 16;
   if (direction == OUTPUT)
      DRV_WriteReg(GPIO_DIR_SET(no),(1 << remainder));
	else
      DRV_WriteReg(GPIO_DIR_CLR(no),(1 << remainder));
#endif    

#if ( (defined(MT6208)))
	if (direction == OUTPUT)
	{
		DRV_Reg(GPIO_DIR) |= (1 << port);
	}
	else
	{
		DRV_Reg(GPIO_DIR) &= ~(1 << port);
	}
#endif    
}