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

📄 sysserial.c

📁 motorola 8260 CPU上面
💻 C
字号:
/* sysSerial.c -  M8260 SCC UART BSP serial device initialization *//* Copyright 1984-1996 Wind River Systems, Inc. */#include "copyright_wrs.h"/*modification history--------------------01g,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 "8260pc.h"IMPORT    UINT32  vxImmrGet (void);LOCAL M8260_SCC_CHAN m8260SccChan1;/* 8260pc */#if WITH_SCC2LOCAL M8260_SCC_CHAN m8260SccChan2;#endif/******************************************************************************** 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;/* 8260pc */#if WITH_SCC2    * M8260_IOP_PCDIR(immrVal) &= ~0x000C0000;       /* clr bits 12, 13 for SCC2 */    * M8260_IOP_PCPAR(immrVal) |= 0x000C0000;	/* set bits 12, 13 for SCC2 */    * M8260_IOP_PCSO(immrVal) &= ~0x000C0000;       /* clr bits 12, 13 for SCC2 */#endif    * M8260_IOP_PCDIR(immrVal) &= 0xFFFDFFFF;    * M8260_IOP_PCPAR(immrVal) |= 0x00020000;    * M8260_IOP_PCSO(immrVal) &= 0xFFFDFFFF;    * 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 *//* 8260pc */#if WITH_SCC2    * M8260_IOP_PDDIR(immrVal) |= 0x00000010;   	/* set bit 27 for SCC2 */    * M8260_IOP_PDDIR(immrVal) &= ~0x00000020;   	/* clear bit 28 for SCC2 */    * M8260_IOP_PDDIR(immrVal) |= 0x00000020;   	/* set bit 26 for SCC2 */#endif    * M8260_IOP_PDPAR(immrVal) |= 0x00000003;   	/* TXD pin 30| RXD pin 31 *//* 8260pc */#if WITH_SCC2    * M8260_IOP_PDPAR(immrVal) |= 0x00000018;   	/* set bits 27, 28 for SCC2*/    * M8260_IOP_PDPAR(immrVal) |= 0x00000020;   	/* set bit 26 for SCC2*/#endif    * M8260_IOP_PDSO(immrVal) &= 0xFFFFFFFC; 	/* clear first */    * M8260_IOP_PDSO(immrVal) |= 0x00000002; 	/* TXD pin 30 and RXD pin 31 *//* 8260pc */#if WITH_SCC2    * M8260_IOP_PDSO(immrVal) &= ~0x00000018; 	/* clear bits 27, 28 for SCC2 */    * M8260_IOP_PDSO(immrVal) &= ~0x00000020; 	/* clear bit 26 for SCC2 */#endif    * M8260_IOP_PDODR(immrVal) &= 0xFFFFFFFC;	/* TXD pin 30| RXD pin 31 */    * 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;    /* initialize baud rate generators to 9600 buad */    M8260_BRGC_WR(0x00010084, 1)	/* initialize BRGC1 to 9600 buad *//* 8260pc */#if WITH_SCC2    M8260_BRGC_WR(0x00010084, 2)	/* initialize BRGC2 to 9600 buad */#endif#if 0    M8260_BRGC_WR(0x000100d6, 1)	/* initialize BRGC1 to 9600 buad */    M8260_BRGC_WR(0x000100d6, 2)	/* initialize BRGC2 to 9600 buad */#endif/* intialize the two serial channels *//* this is in order of the structure contents */    /* indicate that this is a fresh device */    m8260SccChan1.channelMode = 0;    m8260SccChan1.baudRate = DEFAULT_BAUD;    m8260SccChan1.sccNum = 1;    m8260SccChan1.immrVal = immrVal;/* 8260pc */#if WITH_SCC2    m8260SccChan2.channelMode = 0;    m8260SccChan2.baudRate = DEFAULT_BAUD;    m8260SccChan2.sccNum = 2;    m8260SccChan2.immrVal = immrVal;#endif#if 0    m8260SccChan1.pBdBase = (char *) 0xf0000000;    m8260SccChan1.rcvBufferAddr = (char *) 0xf0000040;    m8260SccChan1.txBufferAddr = (char *) 0xf0000060;    m8260SccChan2.pBdBase = (char *) 0xf0000100;    m8260SccChan2.rcvBufferAddr = (char *) 0xf0000140;    m8260SccChan2.txBufferAddr = (char *) 0xf0000160;#endif/* 8260PC: using IMMR = 0x04700000 */    m8260SccChan1.pBdBase = (char *) 0x4700000;    m8260SccChan1.rcvBufferAddr = (char *) 0x04700040;    m8260SccChan1.txBufferAddr = (char *) 0x04700060;/* 8260pc */#if WITH_SCC2    m8260SccChan2.pBdBase = (char *) 0x4700100;    m8260SccChan2.rcvBufferAddr = (char *) 0x04700140;    m8260SccChan2.txBufferAddr = (char *) 0x04700160;#endif    /* disable interrupts from SCC1 and SCC2 */    m8260IntDisable(INUM_SCC1);/* 8260pc */#if WITH_SCC2    if (NUM_TTY >= 2)	m8260IntDisable(INUM_SCC2);#endif    /* reset the channel */    m8260SioDevInit(&m8260SccChan1);/* 8260pc */#if WITH_SCC2    if (NUM_TTY >= 2)	m8260SioDevInit(&m8260SccChan2);#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().** RETURNS: N/A*/ void sysSerialHwInit2 (void)    {    /* connect serial interrupts */    (void) intConnect (INUM_TO_IVEC(INUM_SCC1), 		      (VOIDFUNCPTR) m8260SioInt, (int) &m8260SccChan1);/* 8260pc */#if WITH_SCC2	    if (NUM_TTY >= 2)	(void) intConnect (INUM_TO_IVEC(INUM_SCC2), 			  (VOIDFUNCPTR) m8260SioInt, (int) &m8260SccChan2);#endif    }/******************************************************************************** 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); /* 8260pc */#if WITH_SCC2    else if (channel == 1)	return ((SIO_CHAN *) &m8260SccChan2); #endif    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 ();    }/* 8260pc : set up PC15 for CTS1*//********************************************************************************* sysConfigCTS - configure the PC15 as CTS1** This function configure PC15 as CTS1.  User need to close JP12 on 8560pc** RETURNS: N/A**/void sysConfigCTS (UINT32 immrVal)    {    * M8260_IOP_PCDIR(immrVal) &= ~(0x00010000); /* ~(15)*/    * M8260_IOP_PCPAR(immrVal) |= 0x00010000; /*(15)*/    * M8260_IOP_PCSO(immrVal) &= ~(0x00010000); /* ~(15)*/    * M8260_IOP_PCODR(immrVal) &= ~(0x00010000); /* ~(15)*/    }

⌨️ 快捷键说明

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