📄 gpiodrv.c
字号:
* Arguments: hndl - device context
* Params - bit mask
*
* Range Issues: None
*
* Test Method: gpio.mcp
*
*****************************************************************************/
unsigned short gpioIoctlGPIO_CLEAR( handle_t hndl, unsigned long params )
{
sGpioDevice * pHandle = (sGpioDevice *)hndl;
periphBitClear( (unsigned short)params, (unsigned short *)(pHandle->Base + GPIO_DATA_REG_OFFSET));
}
/*****************************************************************************
*
* Module: gpioIoctlGPIO_TOGGLE()
*
* Description: Change pins logical state.
*
* Returns: None
*
* Arguments: hndl - device context
* Params - bit mask
*
* Range Issues: None
*
* Test Method: gpio.mcp
*
*****************************************************************************/
unsigned short gpioIoctlGPIO_TOGGLE( handle_t hndl, unsigned long params )
{
sGpioDevice * pHandle = (sGpioDevice *)hndl;
periphBitChange( (unsigned short)params, (unsigned short *)(pHandle->Base + GPIO_DATA_REG_OFFSET));
}
/*****************************************************************************
*
* Module: gpioIoctlGPIO_DISABLE_PULLUP()
*
* Description: Disable pull-up in PUR register.
*
* Returns: None
*
* Arguments: hndl - device context
* Params - bit mask
*
* Range Issues: None
*
* Test Method: gpio.mcp
*
*****************************************************************************/
unsigned short gpioIoctlGPIO_DISABLE_PULLUP( handle_t hndl, unsigned long params )
{
sGpioDevice * pHandle = (sGpioDevice *)hndl;
periphBitClear( (unsigned short)params, (unsigned short *)(pHandle->Base + GPIO_PULLUP_REG_OFFSET));
}
/*****************************************************************************
*
* Module: gpioIoctlGPIO_ENABLE_PULLUP()
*
* Description: Enable pull-up in PUR register.
*
* Returns: None
*
* Arguments: hndl - device context
* Params - bit mask
*
* Range Issues: None
*
* Test Method: gpio.mcp
*
*****************************************************************************/
unsigned short gpioIoctlGPIO_ENABLE_PULLUP( handle_t hndl, unsigned long params )
{
sGpioDevice * pHandle = (sGpioDevice *)hndl;
periphBitSet( (unsigned short)params, (unsigned short *)(pHandle->Base + GPIO_PULLUP_REG_OFFSET));
}
/*****************************************************************************
*
* Module: gpioIoctlGPIO_SETAS_INPUT()
*
* Description: Sets a gpio pin as an input in DDR register.
*
* Returns: None
*
* Arguments: hndl - device context
* Params - bit mask
*
* Range Issues: None
*
* Test Method: gpio.mcp
*
*****************************************************************************/
unsigned short gpioIoctlGPIO_SETAS_INPUT( handle_t hndl, unsigned long params )
{
sGpioDevice * pHandle = (sGpioDevice *)hndl;
periphBitClear( (unsigned short)params, (unsigned short *)(pHandle->Base + GPIO_DATA_DIRECTION_REG_OFFSET));
}
/*****************************************************************************
*
* Module: gpioIoctlGPIO_SETAS_OUTPUT()
*
* Description: Sets a gpio pin as an output in DDR register.
*
* Returns: None
*
* Arguments: hndl - device context
* Params - bit mask
*
* Range Issues: None
*
* Test Method: gpio.mcp
*
*****************************************************************************/
unsigned short gpioIoctlGPIO_SETAS_OUTPUT( handle_t hndl, unsigned long params )
{
sGpioDevice * pHandle = (sGpioDevice *)hndl;
periphBitSet( (unsigned short)params, (unsigned short *)(pHandle->Base + GPIO_DATA_DIRECTION_REG_OFFSET));
}
/*****************************************************************************
*
* Module: gpioIoctlGPIO_SETAS_GPIO()
*
* Description: When peripheral disabled,
* DDR determines direction of data flow in PER register.
*
* Returns: None
*
* Arguments: hndl - device context
* Params - bit mask
*
* Range Issues: None
*
* Test Method: gpio.mcp
*
*****************************************************************************/
unsigned short gpioIoctlGPIO_SETAS_GPIO( handle_t hndl, unsigned long params )
{
sGpioDevice * pHandle = (sGpioDevice *)hndl;
periphBitClear( (unsigned short)params, (unsigned short *)(pHandle->Base + GPIO_PERIPHERAL_ENABLE_REG_OFFSET));
}
/*****************************************************************************
*
* Module: gpioIoctlGPIO_SETAS_PERIPHERAL()
*
* Description: A peripheral masters the gpio pin in PER register.
*
* Returns: None
*
* Arguments: hndl - device context
* Params - bit mask
*
* Range Issues: None
*
* Test Method: gpio.mcp
*
*****************************************************************************/
unsigned short gpioIoctlGPIO_SETAS_PERIPHERAL( handle_t hndl, unsigned long params )
{
sGpioDevice * pHandle = (sGpioDevice *)hndl;
periphBitSet( (unsigned short)params, (unsigned short *)(pHandle->Base + GPIO_PERIPHERAL_ENABLE_REG_OFFSET));
}
/*****************************************************************************
*
* Module: gpioIoctlGPIO_INTERRUPT_ASSERT_DISABLE()
*
* Description: Disables an interrupt assert in IAR register.
*
* Returns: None
*
* Arguments: hndl - device context
* Params - bit mask
*
* Range Issues: None
*
* Test Method: gpio.mcp
*
*****************************************************************************/
unsigned short gpioIoctlGPIO_INTERRUPT_ASSERT_DISABLE( handle_t hndl, unsigned long params )
{
sGpioDevice * pHandle = (sGpioDevice *)hndl;
periphBitClear( (unsigned short)params, (unsigned short *)(pHandle->Base + GPIO_INT_ASSERT_REG_OFFSET));
}
/*****************************************************************************
*
* Module: gpioIoctlGPIO_INTERRUPT_ASSERT_ENABLE()
*
* Description: Enables an interrupt assert,
* used only in software testing, in IAR register.
*
* Returns: None
*
* Arguments: hndl - device context
* Params - bit mask
*
* Range Issues: None
*
* Test Method: gpio.mcp
*
*****************************************************************************/
unsigned short gpioIoctlGPIO_INTERRUPT_ASSERT_ENABLE( handle_t hndl, unsigned long params )
{
sGpioDevice * pHandle = (sGpioDevice *)hndl;
periphBitSet( (unsigned short)params, (unsigned short *)(pHandle->Base + GPIO_INT_ASSERT_REG_OFFSET));
}
/*****************************************************************************
*
* Module: gpioIoctlGPIO_INTERRUPT_DISABLE()
*
* Description: Disables edge detection for any
* incoming interrupt in IENR register.
*
* Returns: None
*
* Arguments: hndl - device context
* Params - bit mask
*
* Range Issues: None
*
* Test Method: gpio.mcp
*
*****************************************************************************/
unsigned short gpioIoctlGPIO_INTERRUPT_DISABLE( handle_t hndl, unsigned long params )
{
sGpioDevice * pHandle = (sGpioDevice *)hndl;
periphBitClear( (unsigned short)params, (unsigned short *)(pHandle->Base + GPIO_INT_ENABLE_REG_OFFSET));
}
/*****************************************************************************
*
* Module: gpioIoctlGPIO_INTERRUPT_ENABLE()
*
* Description: Enables edge detection for any
* incoming interrupt in IENR register.
*
* Returns: None
*
* Arguments: hndl - device context
* Params - bit mask
*
* Range Issues: None
*
* Test Method: gpio.mcp
*
*****************************************************************************/
unsigned short gpioIoctlGPIO_INTERRUPT_ENABLE( handle_t hndl, unsigned long params )
{
sGpioDevice * pHandle = (sGpioDevice *)hndl;
periphBitSet( (unsigned short)params, (unsigned short *)(pHandle->Base + GPIO_INT_ENABLE_REG_OFFSET));
}
/*****************************************************************************
*
* Module: gpioIoctlGPIO_INTERRUPT_DETECTION_ACTIVE_HIGH()
*
* Description: The interrupt seen at the PAD is active high.
*
* Returns: None
*
* Arguments: hndl - device context
* Params - bit mask
*
* Range Issues: None
*
* Test Method: gpio.mcp
*
*****************************************************************************/
unsigned short gpioIoctlGPIO_INTERRUPT_DETECTION_ACTIVE_HIGH( handle_t hndl, unsigned long params )
{
sGpioDevice * pHandle = (sGpioDevice *)hndl;
periphBitClear( (unsigned short)params, (unsigned short *)(pHandle->Base + GPIO_INT_POLARITY_REG_OFFSET));
}
/*****************************************************************************
*
* Module: gpioIoctlGPIO_INTERRUPT_DETECTION_ACTIVE_LOW()
*
* Description: The interrupt seen at the PAD is active low.
*
* Returns: None
*
* Arguments: hndl - device context
* Params - bit mask
*
* Range Issues: None
*
* Test Method: gpio.mcp
*
*****************************************************************************/
unsigned short gpioIoctlGPIO_INTERRUPT_DETECTION_ACTIVE_LOW( handle_t hndl, unsigned long params )
{
sGpioDevice * pHandle = (sGpioDevice *)hndl;
periphBitSet( (unsigned short)params, (unsigned short *)(pHandle->Base + GPIO_INT_POLARITY_REG_OFFSET));
}
/*****************************************************************************
*
* Module: gpioIoctlGPIO_CLEAR_INTERRUPT_PEND_REGISTER()
*
* Description: By writing ones to this register, the IPR is cleared.
*
* Returns: None
*
* Arguments: hndl - device context
* Params - bit mask
*
* Range Issues: None
*
* Test Method: gpio.mcp
*
*****************************************************************************/
unsigned short gpioIoctlGPIO_CLEAR_INTERRUPT_PEND_REGISTER( handle_t hndl, unsigned long params )
{
sGpioDevice * pHandle = (sGpioDevice *)hndl;
periphBitSet( (unsigned short)params, (unsigned short *)(pHandle->Base + GPIO_INT_EDGE_SENS_REG_OFFSET));
}
/*****************************************************************************
*
* Module: gpioIoctlGPIO_READ()
*
* Description: Reads the value of an input pin.
*
* Returns: Value of an input pin; 0 or 1 value
*
* Arguments: hndl - device context
* Params - bit mask
*
* Range Issues: None
*
* Test Method: gpio.mcp
*
*****************************************************************************/
unsigned short gpioIoctlGPIO_READ( handle_t hndl, unsigned long params )
{
sGpioDevice * pHandle = (sGpioDevice *)hndl;
return (periphMemRead( (unsigned short *)(pHandle->Base + GPIO_DATA_REG_OFFSET) ) & (unsigned short)params) ? 1 : 0;
}
/*****************************************************************************
* Ioctl functions for pins
*****************************************************************************/
/*****************************************************************************
*
* Module: gpiopinIoctlGPIO_SET()
*
* Description: Set pin to "1".
*
* Returns: None
*
* Arguments: hndl - device context
* Params - Not used
*
* Range Issues: None
*
* Test Method: gpio.mcp
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -