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

📄 sysserial.c

📁 博创PXA270-S开发箱的VxWorks BSP驱动(含注释)
💻 C
字号:
/* sysSerial.c - pxa270 BSP serial device initialization */

/* Copyright 2002 Wind River Systems, Inc. */

#include "copyright_wrs.h"

/*
TODO -  Remove the pxa270 modification history and begin a new history
        starting with version 01a and growing the history upward with
        each revision.

modification history
--------------------
01a,21may02,scm written.
*/

/*
   TODO - Fill in this file with I/O addresses and related constants for the
          pxa270 BSP. Anything with "pxa270" as a prefix needs to examined 
          and re-named to id the BSP (i.e. iq80321, iq80310, etc.) 
*/

/*
DESCRIPTION

This file contains the board-specific routines for serial channel
initialization.
*/

#include "vxWorks.h"
#include "iv.h"
#include "intLib.h"
#include "config.h"
#include "sysLib.h"
#include "drv/sio/ns16552Sio.h"

/* local data */

/* TODO - flush out pxa270 defines... */

static NS16550_CHAN ns16550Chan[pxa270_UART_N_UARTS];

/******************************************************************************
*
* sysSerialHwInit - initialize the BSP serial devices to a quiesent state
*
* This routine initializes the BSP serial device descriptors and puts the
* devices in a quiesent state.  It is called from sysHwInit() with
* interrupts locked.
*
* RETURNS: N/A
*/

void sysSerialHwInit (void)
    {
    /*
     * TODO - Do any special board-specific init of hardware to shut down
     * any hardware that may be active (dma, interrupting, etc).
     *
     * Any code called here cannot use malloc/free, or do any intConnect
     * type functions.
     */
	memset(ns16550Chan, 0, sizeof(NS16550_CHAN));
    /* intialize the chips device descriptors */

     ns16550Chan[0].regs      = (UINT8 *)pxa270_UART0_REG;
     ns16550Chan[0].level     = IRQ_FFUART;
     ns16550Chan[0].regDelta  = pxa270_UART_REG_DELTA;
     ns16550Chan[0].xtal      = pxa270_UART_XTAL;
     ns16550Chan[0].baudRate  = UART_DEFAULT_BAUD;

#ifdef SECOND_UART
     ns16550Chan[1].regs      = (UINT8 *)pxa270_UART1_REG;/*UART 1 base address */
     ns16550Chan[1].level     = IRQ_BTUART;
     ns16550Chan[1].regDelta  = pxa270_UART_REG_DELTA;
     ns16550Chan[1].xtal      = pxa270_UART_XTAL;
     ns16550Chan[1].baudRate  = UART_DEFAULT_BAUD;
     *((UINT32*)0x41300004) |= 0x80;/*BTUART Unit Clock Enable*/
#endif

    /* reset the chips */

     ns16550DevInit (&ns16550Chan[0]);
#ifdef SECOND_UART
     ns16550DevInit (&ns16550Chan[1]);
#endif
    }

/******************************************************************************
*
* sysSerialHwInit2 - connect BSP serial device interrupts
*
* This routine connects the BSP serial device interrupts.  It is called from
* sysHwInit2().
* Serial device interrupts could not be connected in sysSerialHwInit() because 
* the kernel memory allocator was not initialized at that point, and intConnect() 
* calls malloc().
*
* This is where most device driver modules get called and devices are created.
*
* RETURNS: N/A
*/

void sysSerialHwInit2 (void)
    {
    /* now connect the serial device interrupts */
    /* Connect serial interrupts. */

    (void) intConnect (INUM_TO_IVEC((UINT32)ns16550Chan[0].level),
                       (VOIDFUNCPTR) ns16550Int, (int)&ns16550Chan[0]);
#ifdef SECOND_UART
    (void) intConnect (INUM_TO_IVEC((UINT32)ns16550Chan[1].level),
                       (VOIDFUNCPTR) ns16550Int, (int)&ns16550Chan[1]);
#endif

    /* Enable the UART interrupt */

    intEnable (ns16550Chan[0].level);
#ifdef SECOND_UART
    intEnable (ns16550Chan[1].level);
#endif
    }

/******************************************************************************
*
* sysSerialChanGet - get the SIO_CHAN device associated with a serial channel
*
* This routine returns a pointer to the SIO_CHAN device associated
* with a specified serial channel.  It is called by usrRoot() to obtain
* pointers when creating the system serial devices, `/tyCo/x'.  It
* is also used by the WDB agent to locate its serial channel.
*
* RETURNS: A pointer to the SIO_CHAN structure for the channel, or ERROR
* if the channel is invalid.
*/

SIO_CHAN * sysSerialChanGet
    (
    int channel
    )
    {
    switch (channel)
	{
	case 0:
	    return ((SIO_CHAN *)&ns16550Chan[0]);

#ifdef SECOND_UART
	case 1:
	    return ((SIO_CHAN *)&ns16550Chan[1]);
#endif

	default:
	    return ((SIO_CHAN *)ERROR);
	}
    }

/******************************************************************************
*
* sysSerialReset - reset the sio devices to a quiet state
*
* Reset all devices to prevent them from generating interrupts.
*
* This is called from sysToMonitor() to shutdown the system gracefully
* before transferring control to the boot ROM.
*
* RETURNS: N/A.
*/

void sysSerialReset (void)
    {
    /* Disable the UART interrupt */

    intDisable (ns16550Chan[0].level);
#ifdef SECOND_UART
    intDisable (ns16550Chan[1].level);
#endif
    }

⌨️ 快捷键说明

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