📄 sysserial.c
字号:
/* sysSerial.c - MPC860T SMC/SCC UART BSP serial device initialization *//* Copyright 1984-2000 Wind River Systems, Inc. *//* Copyright 1997-2000 Motorola, Inc., All Rights Reserved *//*modification history--------------------01f,05dec00,rhk WRS code standards cleanup.01e,09jun99,srr changed to support cpv3060.01d,16dec98,rhk changed interrupt enabling to use intEnable call instead of hardcoded CPM register access.01c,30sep98,rhk added additional bit configurations for Ports B and C.01b,03sep98,rhk removed COM port setup, added SCC2 capability, disabled Tx/Rx lines for unused port.01a,27aug98,rhk ported to CPV3160 from MBX version 01c.*//*DESCRIPTIONThis module provides code to initialize the serial port for the CPV3060.Two calls exist for the inialization, sysSerialHwInit and sysSerialHwInit2. They are called by sysHwInit and sysHwInit2, respectivelyin sysLib.c. The routine sysSerialHwInit sets up the necessary datastructures: PPC860SMC_CHAN and the tranmit and receive buffers. sysSerialHwInit2 connects the serial interrupt and enables it.The routine sysSerialChanGet is called by bootConfig.c and usrConfig.cas part of the generic serial driver setup ( when INCLUDE_TTY_DEV isdefined). This instantiates a specific serial device configuration onthe CPV3060 into the generic TTY driver.The routine sysSerialReset is called by sysToMonitor in sysLib.c and willreset the serial port.*/#include "vxWorks.h"#include "iv.h"#include "intLib.h"#include "config.h"#include "sysLib.h"#include "drv/sio/ppc860Sio.h"#include "drv/multi/ppc860Cpm.h"#if (SERIAL_PORT == SERIAL_PORT_SMC)static PPC860SMC_CHAN ppc860Chan;#endif /* SERIAL_PORT == SERIAL_PORT_SMC */#if (SERIAL_PORT == SERIAL_PORT_SCC)static PPC860SCC_CHAN ppc860Chan;#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.** Data Parameter Ram layout:**.CS* -----------------------------* | | DPRAM base (address = 0x2000)* | |* | |* |---------------------------|* | 8 bytes per descriptor | Tx Buffer Descriptor (0x2200)* |---------------------------|* | |* |---------------------------|* | 16 descriptors @ | Rx Buffer Descriptors (0x2210)* | 8 bytes per descriptor | * | |* |---------------------------|* | | end Rx BDs (0x2290)* | |* | |* |---------------------------|* | 80 bytes allowed | Tx Buffer (0x2300)* |---------------------------|* | one receive char/buffer | Rx Buffer (0x2380)* |---------------------------|* | |* | |* | |* |---------------------------|* | 66 hex bytes of parameter | SCC2 Parameter Area (0x3d00)* | info including Rx and Tx |* | BD pointers, func codes |* | etc... |* |---------------------------|* | |* |---------------------------|* | 3A hex bytes of parameter | SMC1 Parameter Area (0x3e80)* | info including Rx and Tx | * | BD pointers, func codes |* | etc... |* |---------------------------|**.CE** RETURNS: N/A*/ void sysSerialHwInit (void) {#if (SERIAL_PORT == SERIAL_PORT_SMC) /* intialize the chips device descriptors */ ppc860Chan.clockRate = brgClkFreq; /* BRGCLK freq (Hz) */ ppc860Chan.regBase = vxImmrGet(); /* IMMR reg has base adr */ ppc860Chan.bgrNum = 1; /* use BRG1 */ ppc860Chan.uart.smcNum = 1; /* SMC1 wired for rs232 */ ppc860Chan.uart.txBdNum = 1; /* use 1 transmit BD */ ppc860Chan.uart.rxBdNum = 0x10; /* use 16 receive BD */ /* setup the transmit buffer descriptor base addr */ ppc860Chan.uart.txBdBase = (SMC_BUF *) TX_BUF_DESC_BA; /* setup the receive buffer descriptor base addr */ ppc860Chan.uart.rxBdBase = (SMC_BUF *) RX_BUF_DESC_BA; ppc860Chan.uart.txBufBase = (u_char *) (MPC860_DPRAM_BASE(ppc860Chan.regBase) + TX_BUFFER); /* tx buf base */ ppc860Chan.uart.rxBufBase = (u_char *) (MPC860_DPRAM_BASE(ppc860Chan.regBase) + RX_BUFFER); /* rx buf base */ /* we may want to increase the buffer sizes */ ppc860Chan.uart.txBufSize = 0x1; /* transmit buffer size */ ppc860Chan.uart.pSmc = (SMC *) ((UINT32) PPC860_DPR_SMC1( MPC860_DPRAM_BASE(ppc860Chan.regBase) )); /* SMC1 DPRAM addr params */ ppc860Chan.uart.pSmcReg = (SMC_REG *) ((UINT32) MPC860_SMCMR1(ppc860Chan.regBase)); /* SMCMR1 for SMC1 */ /* disable the Port A pins for SCC2 */ *MPC860_PAPAR(ppc860Chan.regBase) &= ~PORT_A_PINS_SER; *MPC860_PADIR(ppc860Chan.regBase) &= ~PORT_A_PINS_SER; /* configure the port lines */ *MPC860_PBPAR(ppc860Chan.regBase) |= PORT_B_PINS_SER; *MPC860_PBDIR(ppc860Chan.regBase) &= ~PORT_B_PINS_SER; *MPC860_PBODR(ppc860Chan.regBase) &= ~PORT_B_PINS_SER; /* * configure the modem control lines (DTR, RTS, et.al.), * console transceiver control, and assert them. */ *MPC860_PBPAR(ppc860Chan.regBase) &= ~PORT_B_PINS_CTL; *MPC860_PBDIR(ppc860Chan.regBase) |= PORT_B_PINS_CTL; *MPC860_PBODR(ppc860Chan.regBase) &= ~PORT_B_PINS_CTL; *MPC860_PBDAT(ppc860Chan.regBase) &= ~PORT_B_PINS_CTL; /* configure the modem status lines (CTS,CD ) */ *MPC860_PCPAR(ppc860Chan.regBase) &= ~(PORT_C_PINS_CD | PORT_C_PINS_CTS); *MPC860_PCDIR(ppc860Chan.regBase) &= ~(PORT_C_PINS_CD | PORT_C_PINS_CTS); *MPC860_PCSO(ppc860Chan.regBase) &= ~(PORT_C_PINS_CD | PORT_C_PINS_CTS); ppc860Chan.pBaud = (UINT32 *) MPC860_BRGC1(ppc860Chan.regBase); ppc860Chan.channelMode = 0; *MPC860_SDCR(ppc860Chan.regBase) = 1; /* reset the chip */ ppc860DevInit(&ppc860Chan);#endif /* SERIAL_PORT == SERIAL_PORT_SMC */#if (SERIAL_PORT == SERIAL_PORT_SCC) /* intialize the chips device descriptors */ ppc860Chan.clockRate = brgClkFreq; /* BRGCLK freq (Hz) */ ppc860Chan.regBase = vxImmrGet(); /* IMMR reg has base adr */ ppc860Chan.bgrNum = 1; /* use BRG1 */ ppc860Chan.uart.sccNum = 2; /* SCC2 wired for rs232 */ ppc860Chan.uart.txBdNum = 1; /* use 1 transmit BD */ ppc860Chan.uart.rxBdNum = 0x10; /* use 16 receive BD */ /* setup the transmit buffer descriptor base addr */ ppc860Chan.uart.txBdBase = (SCC_BUF *) TX_BUF_DESC_BA; /* setup the receive buffer descriptor base addr */ ppc860Chan.uart.rxBdBase = (SCC_BUF *) RX_BUF_DESC_BA; ppc860Chan.uart.txBufBase = (u_char *) (MPC860_DPRAM_BASE(ppc860Chan.regBase) + TX_BUFFER); /* tx buf base */ ppc860Chan.uart.rxBufBase = (u_char *) (MPC860_DPRAM_BASE(ppc860Chan.regBase) + RX_BUFFER); /* rx buf base */ /* we may want to increase the buffer sizes */ ppc860Chan.uart.txBufSize = 0x1; /* transmit buffer size */ ppc860Chan.uart.pScc = (SCC *) ((UINT32) PPC860_DPR_SCC2( MPC860_DPRAM_BASE(ppc860Chan.regBase) )); /* SCC2 DPRAM addr params */ ppc860Chan.uart.pSccReg = (SCC_REG *) ((UINT32) MPC860_GSMR_L2(ppc860Chan.regBase)); /* GSMR_L for SCC2 */ /* disable the Port B pins */ *MPC860_PBPAR(ppc860Chan.regBase) &= ~PORT_B_PINS_SER; *MPC860_PBDIR(ppc860Chan.regBase) &= ~PORT_B_PINS_SER; /* configure the port lines */ *MPC860_PAPAR(ppc860Chan.regBase) |= PORT_A_PINS_SER; *MPC860_PADIR(ppc860Chan.regBase) &= ~PORT_A_PINS_SER; *MPC860_PAODR(ppc860Chan.regBase) &= ~PORT_A_PINS_SER; /* * configure the modem control lines (DTR, RTS, et.al.), * console transceiver control, and assert them. */ *MPC860_PBPAR(ppc860Chan.regBase) &= ~PORT_B_PINS_CTL; *MPC860_PBDIR(ppc860Chan.regBase) |= PORT_B_PINS_CTL; *MPC860_PBODR(ppc860Chan.regBase) &= ~PORT_B_PINS_CTL; *MPC860_PBDAT(ppc860Chan.regBase) &= ~PORT_B_PINS_CTL; /* configure the modem status lines (CTS,CD ) */ *MPC860_PCPAR(ppc860Chan.regBase) &= ~(PORT_C_PINS_CD | PORT_C_PINS_CTS); *MPC860_PCDIR(ppc860Chan.regBase) &= ~(PORT_C_PINS_CD | PORT_C_PINS_CTS); *MPC860_PCSO(ppc860Chan.regBase) &= ~(PORT_C_PINS_CD | PORT_C_PINS_CTS); ppc860Chan.pBaud = (UINT32 *) MPC860_BRGC1(ppc860Chan.regBase); ppc860Chan.channelMode = 0; *MPC860_SDCR(ppc860Chan.regBase) = 1; /* reset the chip */ ppc860SccDevInit(&ppc860Chan);#endif /* SERIAL_PORT == SERIAL_PORT_SCC */ }/******************************************************************************** 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 */#if (SERIAL_PORT == SERIAL_PORT_SMC) (void) intConnect (IV_SMC1, (VOIDFUNCPTR) ppc860Int, (int) &ppc860Chan); intEnable (IVEC_TO_INUM(IV_SMC1));#endif /* SERIAL_PORT == SERIAL_PORT_SMC */#if (SERIAL_PORT == SERIAL_PORT_SCC) (void) intConnect (IV_SCC2, (VOIDFUNCPTR) ppc860SccInt, (int) &ppc860Chan); intEnable (IVEC_TO_INUM(IV_SCC2));#endif /* SERIAL_PORT == SERIAL_PORT_SCC */ }/******************************************************************************** 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 */ ) { switch (channel) { case SMC1_SCC2_NUM: return ((SIO_CHAN *) &ppc860Chan); default: return ((SIO_CHAN *) ERROR); } }/********************************************************************************* sysSerialReset - reset the serial device ** This function calls sysSerialHwInit() to reset the serial device** RETURNS: N/A*/void sysSerialReset (void) { sysSerialHwInit (); }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -