📄 sysserial.c
字号:
/* sysSerial.c - KS8695P demo board serial device initialization *//*modification history--------------------9/22/2003 Ritter Yeh created */#include "vxWorks.h"#include "iv.h"#include "intLib.h"#include "config.h"#include "sysLib.h"#include "ks8695Sio.h"LOCAL KS8695P_CHAN ks8695pChan[N_KS8695P_UART_CHANNELS];/* * Array of pointers to all serial channels configured in system. * See sioChanGet(). It is this array that maps channel pointers * to standard device names. The first entry will become "/tyCo/0", * the second "/tyCo/1", and so forth. */SIO_CHAN * sysSioChans [] = { &ks8695pChan[0].sio, /* /tyCo/0 */ };/* forward declarations *//******************************************************************************** sysSerialHwInit - initialize the BSP serial devices to a quiescent 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** SEE ALSO: sysHwInit()*/void sysSerialHwInit (void) { int i; for (i = 0; i < N_KS8695P_UART_CHANNELS; i++) { ks8695pChan[i].regs = (UINT32 *)UART_0_BASE_ADR; ks8695pChan[i].baudRate = CONSOLE_BAUD_RATE; ks8695pChan[i].xtal = KS8695P_SYSCLK; ks8695pChan[i].levelRx = INT_LVL_URS; ks8695pChan[i].levelTx = INT_LVL_UTS; /* * Initialise driver functions, getTxChar, putRcvChar and channelMode * and initialise UART */ ks8695pSioDevInit(&ks8695pChan[i]); } }/******************************************************************************** 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() may call malloc().** RETURNS: N/A** SEE ALSO: sysHwInit2()*/void sysSerialHwInit2 (void) { int i; for (i = 0; i < N_KS8695P_UART_CHANNELS; i++) { /* * Connect and enable the interrupt. */ (void) intConnect (INUM_TO_IVEC(INT_LVL_URS), ks8695pSioIntRx, (int) &ks8695pChan[i] ); (void) intConnect (INUM_TO_IVEC(INT_LVL_UTS), ks8695pSioIntTx, (int) &ks8695pChan[i] ); (void) intConnect (INUM_TO_IVEC(INT_LVL_ULES), ks8695pSioIntErr, (int) &ks8695pChan[i] ); intEnable (INT_LVL_URS); intEnable (INT_LVL_UTS); intEnable (INT_LVL_ULES); } }/******************************************************************************** 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 /* serial channel */ ) { if (channel < 0 || channel >= (int)(NELEMENTS(sysSioChans))) return (SIO_CHAN *)ERROR; return sysSioChans[channel]; }/******************************************************************************** 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 to the boot ROMs.** RETURNS: N/A.*/void sysSerialReset (void) { int i; for (i = 0; i < N_KS8695P_UART_CHANNELS; i++) { /* disable serial interrupts */ intDisable (INT_LVL_UTS); intDisable (INT_LVL_URS); intDisable (INT_LVL_ULES); } }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -