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

📄 sysgpio.c

📁 au1500开发的应用程序
💻 C
字号:
/* sysGpio.c - system GPIO manipulation routines */

/* Copyright Copyright 2002-2004 Founder Communications, Inc. */

/*
modification history
--------------------
01a,18mar05,fhchen  written
*/

/*
DESCRIPTION

This file contains routines for manipulating the on board GPIO pins.
sys_pinfunc should be correctly initialized.

*/

/* includes */

#include <vxWorks.h>
#include "au1500.h"
#include "sysGpio.h"
#include "au1500Gpio.h"
#include "stdio.h"

/* extern */

IMPORT AU1500_GPIO2 * const gpio2;
IMPORT AU1500_SYS * const sys;

/***********************************************************************
*
* sysGpioInit - initialize V100R001CPE board GPIO pins
*
* This routines initialize the CPE board GPIO pins. Registers are 
* configured to reflect on board settings, please refer to document
* provided by hardware department.
*
* NOTE: 
*
* RETURNS: N/A
*/

void sysGpioInit(void)
    {

    /* call general initialize routine */

    au1500GpioInit();

    /*
     * configure primary GPIO block
     */

    /* sys_pinfunc: U3TXD, U0TXD, MAC1 signals */

    sys->sys_pinfunc = 0x00003025;

    /* sys_pininputen[EN]: enable GPIO input */

    sys->sys_pininputen = 0;

    /* sys_trioutclr: tristating pins except those of UART3 and MAC1 */

    sys->sys_trioutclr = 0x0000FFFF;
    
    /*
     * configure secondary GPIO block
     */

    /* gpio2_inten[EN]: disable GPIO[215:208] interrupt */

    gpio2->gpio2_inten &= 0x00;
    
    /* gpio2_enable[CE]: enable clock to secondary GPIO block */

    gpio2->gpio2_enable |= 0x1;
    
    /* gpio2_enable[MR]: enable secondary GPIO block */

    gpio2->gpio2_enable &= ~0x2;
    
    }

/***********************************************************************
*
* sysGpioRead - read data from a GPIO pin
*
* This routines read the data from a GPIO pin. 
*
* NOTE: 
*
* RETURNS: LOGIC_HIGH/LOGIC_LOW, or ERROR if invalid port/pin
*/

int sysGpioRead
(
    int port,                                /* port to read */
    int pin                                  /* pin to read */
    )
    {

    switch(port)
        {
        case PORT_PRIMARY:
            return au1500PriGpioRead(pin);

        case PORT_SECONDARY:
            return au1500SecGpioRead(pin);

        default:
            return (ERROR);
        }
    }

/***********************************************************************
*
* sysGpioWrite - write data to a GPIO pin
*
* This routines write the data to a GPIO pin. 
*
* NOTE: 
*
* RETURNS: N/A
*/

void sysGpioWrite
(
    int port,                                /* port to write */
    int pin,                                 /* pin to write */
    int level                                /* level to write */
    )
    {

    switch(port)
        {
        case PORT_PRIMARY:
            return au1500PriGpioWrite(pin, level);

        case PORT_SECONDARY:
            return au1500SecGpioWrite(pin, level);
            
        default:
            return;
        }
    }

/***********************************************************************
*
* sysGpioRegShow - show content of gpio related registers 
*
* RETURNS: N/A
*/

void sysGpioRegShow
    (
    int port    /* port to show */
    )
    {

    char *fmt = "%-16.16s0x%-9x\n";
    
    printf("\n");

    printf(fmt, "sys_pinfunc", sys->sys_pinfunc);
    printf(fmt, "sys_pininputen", sys->sys_pininputen);
    printf(fmt, "gpio2_inten", gpio2->gpio2_inten);
    printf(fmt, "gpio2_enable", gpio2->gpio2_enable);
    }

⌨️ 快捷键说明

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