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

📄 sysserial.c

📁 WINDRIVER ADS8260 BSP
💻 C
字号:
/* sysSerial.c -  M8260 SCC UART BSP serial device initialization *//* Copyright 1984-2002 Wind River Systems, Inc. */#include "copyright_wrs.h"/*modification history--------------------01h,17oct01,jrs  Upgrade to veloce		 corrected SCC2 initialization in sysSerialHwInit() - SPR #64407		 removed useless init of baud rate generators - SPR #8898901g,09sep99,ms_  change bsp name from vads8260 to ads826001f,15jul99,ms_  make compliant with our coding standards01e,19apr99,ms_  adhere to coding conventions01d,14apr99,ms_  switch from using interrupt vectors to interrupt numbers01c,08apr99,ms_  upgrade to multiple channels01b,05apr99,ms_  upgrade to support two channels01a,21jan99,ms_  adapted from sysSerial.c for ads860 *//*DESCRIPTIONThis library contains routines for M8260 SMC UART BSP serial deviceinitialization*/#include "vxWorks.h"#include "iv.h"#include "intLib.h"#include "config.h"#include "sysLib.h"#include "drv/sio/m8260Scc.h"#include "drv/sio/m8260Sio.h"#include "drv/parallel/m8260IOPort.h"#include "drv/sio/m8260Brg.h"#include "ads8260.h"IMPORT    UINT32  vxImmrGet (void);LOCAL M8260_SCC_CHAN m8260SccChan1;LOCAL M8260_SCC_CHAN m8260SccChan2;/******************************************************************************** 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.** Buffers and Buffer Descriptors for the two channels:* * .CS*                                                   Address per SCC*                                               ---------------------------* field                                 size    SCC1            SCC2* ------                                ------- -----------     -----------* Receive Buffer Descriptor             8 bytes 0x0470_0000     0x0470_0100* Receive Buffer Status                 2 bytes 0x0470_0000     0x0470_0100* Receive Buffer Length                 2 bytes 0x0470_0002     0x0470_0102* Pointer to Receive Buffer             4 bytes 0x0470_0004     0x0470_0104* Receive Buffer                        1 bytes 0x0470_0040     0x0470_0140** Transmit Buffer Descriptor            8 bytes 0x0470_0008     0x0470_0108* Transmit Buffer Status                2 bytes 0x0470_0008     0x0470_0108* Transmit Buffer Length                2 bytes 0x0470_000A     0x0470_010A* Transmit to Receive Buffer            4 bytes 0x0470_000C     0x0470_010C* Transmit Buffer                       1 bytes 0x0470_0060     0x0470_0160* .CE**** RETURNS: N/A*/ void sysSerialHwInit (void)    {    int immrVal = vxImmrGet();    /* reset the parallel ports */    * M8260_IOP_PADIR(immrVal) = 0x00000000;    * M8260_IOP_PAPAR(immrVal) = 0x00000000;    * M8260_IOP_PASO(immrVal) = 0x00000000;    * M8260_IOP_PAODR(immrVal) = 0x00000000;    * M8260_IOP_PADAT(immrVal) = 0x00000000;    * M8260_IOP_PBDIR(immrVal) = 0x00000000;    * M8260_IOP_PBPAR(immrVal) = 0x00000000;    * M8260_IOP_PBSO(immrVal) = 0x00000000;    * M8260_IOP_PBODR(immrVal) = 0x00000000;    * M8260_IOP_PBDAT(immrVal) = 0x00000000;    * M8260_IOP_PCDIR(immrVal) = 0x00000000;    * M8260_IOP_PCPAR(immrVal) = 0x00000000;    * M8260_IOP_PCSO(immrVal) = 0x00000000;    * M8260_IOP_PCODR(immrVal) = 0x00000000;    * M8260_IOP_PCDAT(immrVal) = 0x00000000;    * M8260_IOP_PDDIR(immrVal) = 0x00000000;    * M8260_IOP_PDPAR(immrVal) = 0x00000000;    * M8260_IOP_PDSO(immrVal) = 0x00000000;    * M8260_IOP_PDODR(immrVal) = 0x00000000;    * M8260_IOP_PDDAT(immrVal) = 0x00000000;    * M8260_IOP_PCDIR(immrVal) &= 0xFFFDFFFF;    * M8260_IOP_PCDIR(immrVal) &= ~0x000A0000; /* clr bits 12, 13 for CD in */    * M8260_IOP_PCPAR(immrVal) |= 0x00020000;    * M8260_IOP_PCPAR(immrVal) |= 0x000A0000; /* set bits 12, 14 for CD in */    * M8260_IOP_PCSO(immrVal) &= 0xFFFDFFFF;    * M8260_IOP_PCSO(immrVal) &= ~0x000A0000; /* clr bits 12, 14 for CD in */    * M8260_IOP_PCODR(immrVal) &= 0xFFFDFFFF;    * M8260_IOP_PCDAT(immrVal) = 0x00000000;    * M8260_IOP_PDDIR(immrVal) &= 0xFFFFFFFC;   	/* clear first */    * M8260_IOP_PDDIR(immrVal) |= 0x00000002;   	/* TXD pin 30| RXD pin 31 */    * M8260_IOP_PDDIR(immrVal) |= 0x00000010;   	/* set bit 27 for SCC2 */    * M8260_IOP_PDDIR(immrVal) &= ~0x00000008;   	/* clear bit 28 for SCC2 */    * M8260_IOP_PDPAR(immrVal) |= 0x00000003;   	/* TXD pin 30| RXD pin 31 */    * M8260_IOP_PDPAR(immrVal) |= 0x00000018;   	/* set bits 27, 28 for SCC2*/    * M8260_IOP_PDPAR(immrVal) |= 0x00000004;   	/* set bit 29 for SCC2*/    * M8260_IOP_PDPAR(immrVal) |= 0x00000020;   	/* set bit 26 for SCC2*/    * M8260_IOP_PDSO(immrVal) &= 0xFFFFFFF8; 	/* clear first */    * M8260_IOP_PDSO(immrVal) |= 0x00000002; 	/* TXD pin 30 and RXD pin 31 */    * M8260_IOP_PDSO(immrVal) &= ~0x00000018; 	/* clear bits 27, 28 for SCC2 */    * M8260_IOP_PDSO(immrVal) &= ~0x00000020; 	/* clear bit 26 for SCC2 */    * M8260_IOP_PDODR(immrVal) &= 0xFFFFFFED;	/* TXD pin 30| TXD pin 27 */    * M8260_IOP_PDDAT(immrVal) = 0x00000000;    /* CPM muxs */    /* for the value of 0x0009121B:     * field    description     SCC1    SCC2    SCC3    SCC4     * GR       Grant Support   <-----always asserted------>     * SC       SCC connection  <---not connected to TSA--->     * RSxCS    Rcv Clk Source  BRG1    BRG2    BRG3    BRG4     * TSxCS    Tx Clk Source   BRG1    BRG2    BRG3    BRG4     */    * M8260_CMXSCR(immrVal) = 0x0009121B;    /* enable both RS232 ports on the board */    *BCSR1 &= ~(BCSR1_RS232EN_1_L);    *BCSR1 &= ~(BCSR1_RS232EN_2_L);/* intialize the two serial channels *//* this is in order of the structure contents */    /* indicate that this is a fresh device */    m8260SccChan1.channelMode = 0;    m8260SccChan2.channelMode = 0;    m8260SccChan1.baudRate = DEFAULT_BAUD;    m8260SccChan2.baudRate = DEFAULT_BAUD;    m8260SccChan1.sccNum = 1;    m8260SccChan2.sccNum = 2;    m8260SccChan1.immrVal = immrVal;    m8260SccChan2.immrVal = immrVal;    m8260SccChan1.pBdBase = (char *) 0x4700000;    m8260SccChan1.rcvBufferAddr = (char *) 0x04700040;    m8260SccChan1.txBufferAddr = (char *) 0x04700060;    m8260SccChan2.pBdBase = (char *) 0x4700100;    m8260SccChan2.rcvBufferAddr = (char *) 0x04700140;    m8260SccChan2.txBufferAddr = (char *) 0x04700160;    /* disable interrupts from SCC1 and SCC2 */    m8260IntDisable(INUM_SCC1);    if (NUM_TTY >= 2)	m8260IntDisable(INUM_SCC2);    /* reset the channel */    m8260SioDevInit(&m8260SccChan1);    if (NUM_TTY >= 2)	m8260SioDevInit(&m8260SccChan2);    }/******************************************************************************** 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().** RETURNS: N/A*/ void sysSerialHwInit2 (void)    {    /* connect serial interrupts */    (void) intConnect (INUM_TO_IVEC(INUM_SCC1), 		      (VOIDFUNCPTR) m8260SioInt, (int) &m8260SccChan1);    if (NUM_TTY >= 2)	(void) intConnect (INUM_TO_IVEC(INUM_SCC2), 			  (VOIDFUNCPTR) m8260SioInt, (int) &m8260SccChan2);    }/******************************************************************************** sysSerialChanGet - get the SIO_CHAN device associated with a serial channel** This routine gets the SIO_CHAN device associated with a specified 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		/* serial channel */    )    {    if (channel == 0)	return ((SIO_CHAN *) &m8260SccChan1);     else if (channel == 1)	return ((SIO_CHAN *) &m8260SccChan2);     else 	return ((SIO_CHAN *) ERROR);    }/********************************************************************************* sysSerialReset - reset the serail device ** This function calls sysSerialHwInit() to reset the serail device** RETURNS: N/A**/void sysSerialReset (void)    {    sysSerialHwInit ();    }

⌨️ 快捷键说明

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