📄 sysserial.c
字号:
/* sysSerial.c - V100R001CPE BSP serial device initialization */
/* Copyright 2002-2004 Founder Communications,Inc. */
/*
modification history
--------------------
01a,14mar05,fhchen adapted from pb1500/sysSerial.c (ver 01a).
*/
/*
DESCRIPTION
This library contains routines for BSP serial device initialization
*/
#include "vxWorks.h"
#include "iv.h"
#include "intLib.h"
#include "config.h"
#include "sysLib.h"
#include "au1500Sio.h"
/* defines */
#define N_UARTS 2 /* Number of serial I/O channels */
#define UART_BAUD_RATE 115200
#define UART_BAUD_CLK_FREQ (CPU_CLOCK_RATE/(SD_DIVISOR * 2))
/* locals */
LOCAL AUSIO_CHAN auSioChan [N_UARTS];
/***************************************************************************
*
* sysSerialHwInit - initialize the BSP serial devices to a quiescent state
*
* This routine initializes the BSP serial device descriptors and puts the
* devices in a quiescent state. It is called from sysHwInit() with
* interrupts locked.
*
* RETURNS: N/A
*
* SEE ALSO: sysHwInit()
*/
void sysSerialHwInit (void)
{
/* UART0 */
auSioChan[0].xtal = UART_BAUD_CLK_FREQ;
auSioChan[0].baudRate = UART_BAUD_RATE;
auSioChan[0].options = CLOCAL;
auSioChan[0].regs = (AU1000_UART *)PHYS_TO_K1(UART0_PHYS_ADDR);
auSioDevInit(&auSioChan[0]);
/* UART3 */
auSioChan[1].xtal = UART_BAUD_CLK_FREQ;
auSioChan[1].baudRate = UART_BAUD_RATE;
auSioChan[1].options = CLOCAL;
auSioChan[1].regs = (AU1000_UART *)PHYS_TO_K1(UART3_PHYS_ADDR);
auSioDevInit(&auSioChan[1]);
}
/***************************************************************************
*
* sysSerialHwInit2 - connect BSP serial device interrupts
*
* This routine connects the BSP serial device interrupts. It is called from
* sysHwInit2().
*
* Serial device interrupts cannot be connected in sysSerialHwInit() because
* the kernel memory allocator was not initialized at that point, and
* intConnect() calls malloc().
*
* RETURNS: N/A
*
* SEE ALSO: sysHwInit2()
*/
void sysSerialHwInit2 (void)
{
/* Connect and enable serial interrupts. */
au1000IntConnect(IV_UART0_VEC, auSioInt, (int)&auSioChan[0], TRUE);
au1000IntConnect(IV_UART3_VEC, auSioInt, (int)&auSioChan[1], TRUE);
}
/***************************************************************************
*
* 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
)
{
if (channel == 0) return ((SIO_CHAN *)&auSioChan[0]);
if (channel == 1) return ((SIO_CHAN *)&auSioChan[1]);
return (NULL);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -