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

📄 gpioinline.h

📁 56f8300E系列dsp的BOOTloader
💻 H
📖 第 1 页 / 共 2 页
字号:
/*******************************************************************************
*
* Motorola Inc.
* (c) Copyright 2002 Motorola, Inc.
* ALL RIGHTS RESERVED.
*
* $Element:  $ 
* $Author: saa $ 
* $Revision: /main/2 $ 
* $VOB: /project/dsp568_sdk $ 
* $OS: solaris $ 
*
* Description:       source file for the 56838 GPIO device driver 
*
* Notes:  
*
******************************************************************************/
#ifndef __GPIOINLINE_H
#define __GPIOINLINE_H

#include "port.h"
#include "bsp.h"
#include "periph.h"
#include "arch.h"

#define gpioIoctl(Addr,Cmd,Pin) gpioIoctl##Cmd(Addr,Pin)


#if !defined(gpioPin)
#define gpioPin(Bit) ((unsigned short)(0x01 << Bit))
#endif /* !defined(gpioPin) */


/* registry offsets */
#define GPIO_PULLUP_REG_OFFSET            0x00
#define GPIO_DATA_REG_OFFSET              0x01
#define GPIO_DATA_DIRECTION_REG_OFFSET    0x02
#define GPIO_PERIPHERAL_ENABLE_REG_OFFSET 0x03
#define GPIO_INT_ASSERT_REG_OFFSET        0x04
#define GPIO_INT_ENABLE_REG_OFFSET        0x05
#define GPIO_INT_POLARITY_REG_OFFSET      0x06
#define GPIO_INT_PENDING_REG_OFFSET       0x07
#define GPIO_INT_EDGE_SENS_REG_OFFSET     0x08


/*****************************************************************************
*                             Ioctl functions
*****************************************************************************/

/*****************************************************************************
*
* Module:         gpioIoctlGPIO_SET()
*
* Description:    Set pin to "1". 
*                 
* Returns:        None
*                 
* Arguments:      arch_gpio -  arch hardware device offset
*                 Mask - bit mask
*
* Range Issues:   None
*
* Test Method:    gpio.mcp
*
*****************************************************************************/
inline void gpioIoctlGPIO_SET( register volatile arch_sPort * arch_gpio, register unsigned short Mask )
{
	register unsigned short Value; 

	asm(move.w  x:(arch_gpio + BSP_PERIPH_BASE + 1), Value); /* Address + (data_reg offset) */
	asm(or.w    Mask, Value); 
	asm(move.w  Value,  x:(arch_gpio + BSP_PERIPH_BASE + 1));
}

/*****************************************************************************
*
* Module:         gpioIoctlGPIO_CLEAR()
*
* Description:    Set pin to "0". 
*                 
* Returns:        None
*                 
* Arguments:      arch_gpio -  arch hardware device offset
*                 Mask - pin bit mask
*
* Range Issues:   None
*
* Test Method:    gpio.mcp
*
*****************************************************************************/
inline void gpioIoctlGPIO_CLEAR( register volatile arch_sPort * arch_gpio, register unsigned short Mask )
{
	register unsigned short Value;

	asm(move.w  x:(arch_gpio + BSP_PERIPH_BASE + 1), Value); /* Address + (data_reg offset) */
	asm(not.w   Mask);
	asm(and.w   Mask, Value);
	asm(move.w  Value,  x:(arch_gpio + BSP_PERIPH_BASE + 1));
}

/*****************************************************************************
*
* Module:         gpioIoctlGPIO_TOGGLE()
*
* Description:    Change pin logical state. 
*                 
* Returns:        None
*                 
* Arguments:      arch_gpio -  arch hardware device offset
*                 Mask - pin bit mask
*
* Range Issues:   None
*
* Test Method:    gpio.mcp
*
*****************************************************************************/
inline void gpioIoctlGPIO_TOGGLE( register volatile arch_sPort * arch_gpio, register unsigned short Mask )
{
	register unsigned short Value;

	asm(move.w  x:(arch_gpio+BSP_PERIPH_BASE + 1), Value); /* Address + (data_reg offset) */
	asm(eor.w   Mask, Value);
	asm(move.w  Value,  x:(arch_gpio+BSP_PERIPH_BASE + 1));
}

/*****************************************************************************
*
* Module:         gpioIoctlGPIO_DISABLE_PULLUP()
*
* Description:    Disable pull-up in PUR register. 
*                 
* Returns:        None
*                 
* Arguments:      arch_gpio -  arch hardware device offset
*                 Mask - pin bit mask
*
* Range Issues:   None
*
* Test Method:    gpio.mcp
*
*****************************************************************************/
inline void gpioIoctlGPIO_DISABLE_PULLUP( register volatile arch_sPort * arch_gpio, register unsigned short Mask )
{
	register unsigned short Value;

	asm(move.w  x:(arch_gpio+BSP_PERIPH_BASE + 0), Value); /* Address + (pullup_reg offset) */
	asm(not.w   Mask);
	asm(and.w   Mask, Value);
	asm(move.w  Value,  x:(arch_gpio+BSP_PERIPH_BASE + 0));
}

/*****************************************************************************
*
* Module:         gpioIoctlGPIO_ENABLE_PULLUP()
*
* Description:    Enable pull-up in PUR register. 
*                 
* Returns:        None
*                 
* Arguments:      arch_gpio -  arch hardware device offset
*                 Mask - pin bit mask
*
* Range Issues:   None
*
* Test Method:    gpio.mcp
*
*****************************************************************************/
inline void gpioIoctlGPIO_ENABLE_PULLUP( register volatile arch_sPort * arch_gpio, register unsigned short Mask )
{
	register unsigned short Value;
	
	asm(move.w  x:(arch_gpio + BSP_PERIPH_BASE + 0), Value); /* Address + (pullup_reg offset) */
	asm(or.w    Mask, Value);
	asm(move.w  Value, x:(arch_gpio + BSP_PERIPH_BASE + 0));
   
}
        
/*****************************************************************************
*
* Module:         gpioIoctlGPIO_SETAS_INPUT()
*
* Description:    Sets a gpio pin as an input in DDR register. 
*                 
* Returns:        None
*                 
* Arguments:      arch_gpio -  arch hardware device offset
*                 Mask - pin bit mask
*
* Range Issues:   None
*
* Test Method:    gpio.mcp
*
*****************************************************************************/
inline void gpioIoctlGPIO_SETAS_INPUT( register volatile arch_sPort * arch_gpio, register unsigned short Mask )
{
	register unsigned short Value;

	asm(move.w  x:(arch_gpio + BSP_PERIPH_BASE + 2), Value); /* Address + (data_direction_reg offset) */
	asm(not.w   Mask);
	asm(and.w   Mask, Value);
	asm(move.w  Value, x:(arch_gpio + BSP_PERIPH_BASE + 2));
}

/*****************************************************************************
*
* Module:         gpioIoctlGPIO_SETAS_OUTPUT()
*
* Description:    Sets a gpio pin as an output in DDR register. 
*                 
* Returns:        None
*                 
* Arguments:      arch_gpio -  arch hardware device offset
*                 Mask - pin bit mask
*
* Range Issues:   None
*
* Test Method:    gpio.mcp
*
*****************************************************************************/
inline void gpioIoctlGPIO_SETAS_OUTPUT( register volatile arch_sPort * arch_gpio, register unsigned short Mask )
{
	register unsigned short Value;
	
	asm(move.w  x:(arch_gpio + BSP_PERIPH_BASE + 2), Value); /* Address + (data_direction_reg offset) */
	asm(or.w    Mask, Value);
	asm(move.w  Value, x:(arch_gpio + BSP_PERIPH_BASE + 2));
}

/*****************************************************************************
*
* Module:         gpioIoctlGPIO_SETAS_GPIO()
*
* Description:    When peripheral disabled, 
*                 DDR determines direction of data flow in PER register. 
*                 
* Returns:        None
*                 
* Arguments:      arch_gpio -  arch hardware device offset
*                 Mask - pin bit mask
*
* Range Issues:   None
*
* Test Method:    gpio.mcp
*
*****************************************************************************/
inline void gpioIoctlGPIO_SETAS_GPIO( register volatile arch_sPort * arch_gpio, register unsigned short Mask )

⌨️ 快捷键说明

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