www.pudn.com > S3c2410bsp.rar > sysSerial.c
/* sysSerial.c - Samsung SBC ARM9 serial device initialization */
/* Copyright 1984-2001 Wind River Systems, Inc. */
#include "copyright_wrs.h"
#include "vxWorks.h"
#include "iv.h"
#include "intLib.h"
#include "config.h"
#include "sysLib.h"
#include "s3c2410xSio.h"
#include "wrSbcArm9.h"
#include "s3c2410xSio.c"
/* device initialization structure */
typedef struct
{
UINT vector;
UINT32 *baseAdrs;
UINT regSpace;
UINT intLevel;
} SBCARM9_CHAN_PARAS;
/* Local data structures */
LOCAL SBCARM9_CHAN_PARAS devParas[] =
{
{INT_VEC_UART0, (UINT32 *)SERIAL_A_BASE_ADR, UART_REG_ADDR_INTERVAL, INT_LVL_UART0},
{INT_VEC_UART1, (UINT32 *)SERIAL_B_BASE_ADR, UART_REG_ADDR_INTERVAL, INT_LVL_UART1 },
};
LOCAL S3C2410X_CHAN s3c2410xChan[N_SBCARM9_UART_CHANNELS];
SIO_CHAN * sysSioChans [] =
{
&s3c2410xChan[0].sio, /* /tyCo/0 */
&s3c2410xChan[1].sio, /* /tyCo/1 */
};
void sysHwTestSnd(char sndChar)
{
s3c2410xPollOutput((SIO_CHAN *)&s3c2410xChan[0] , sndChar);
}
void sysHwTestRecv(char *recv)
{
s3c2410xPollInput((SIO_CHAN *)&s3c2410xChan[0] , recv);
}
/******************************************************************************
*
* sysSerialHwInit - initialize the BSP serial devices to a quiesent state
*
*
* RETURNS: N/A
*
* SEE ALSO: sysHwInit()
*/
void sysSerialHwInit (void)
{
int i;
for (i = 0; i < N_SBCARM9_UART_CHANNELS; i++)
{
s3c2410xChan[i].regDelta = devParas[i].regSpace;
s3c2410xChan[i].regs = devParas[i].baseAdrs;
s3c2410xChan[i].baudRate = CONSOLE_BAUD_RATE;
s3c2410xChan[i].intLevelRx = devParas[i].intLevel;
s3c2410xChan[i].intLevelTx = devParas[i].intLevel;
s3c2410xDevInit(&s3c2410xChan[i]);
}
}
/******************************************************************************
*
* sysSerialHwInit2 - connect BSP serial device interrupts
*
*
* RETURNS: N/A
*
* SEE ALSO: sysHwInit2()
*/
void sysSerialHwInit2 (void)
{
int i;
for (i = 0; i < N_SBCARM9_UART_CHANNELS; i++)
{
(void) intConnect (INUM_TO_IVEC(devParas[i].vector),
s3c2410xInt, (int) &s3c2410xChan[i] );
s3c2410xDevInit2(&s3c2410xChan[i]);
intEnable (devParas[i].intLevel);
}
}
/******************************************************************************
*
* sysSerialChanGet - get the SIO_CHAN device associated with a 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
*
*
* RETURNS: N/A.
*/
void sysSerialReset (void)
{
int i;
for (i = 0; i < N_SBCARM9_UART_CHANNELS; i++)
{
/* disable serial interrupts */
intDisable (devParas[i].intLevel);
}
}