📄 sysserial.c
字号:
/* sysSerial.c - Atmel AT91EB01 serial device initialisation */
/* Copyright 1999 ARM Limited */
/*
modification history
--------------------
01b,15jul99,jpd minor comments changes.
01a,25jun99,jpd created.
*/
/*
DESCRIPTION
This file contains the board-specific routines for serial channel
initialisation of the UARTs built in to the AT91M40400 chip on the
AT91EB01 board.
SEE ALSO:
.I "Atmel AT91M40400 16/32-Bit Microcontroller, Data Sheet,"
.I "Atmel AT91EB01 Evaluation Board, User Guide."
*/
/* includes */
#include "vxWorks.h"
#include "iv.h"
#include "intLib.h"
#include "config.h"
#include "sysLib.h"
#include "at91Sio.h"
#include "at91Sio.c"
#ifdef INCLUDE_SERIAL
/* device initialisation structure */
typedef struct
{
UINT vector;
UINT32 * baseAdrs;
UINT intLevel;
} AT91_CHAN_PARAS;
/* Local data structures */
LOCAL AT91_CHAN_PARAS devParas[] =
{
{INT_VEC_USART_0, (UINT32 *)AT91_USART_0_BASE_ADRS, INT_LVL_USART_0 },
{INT_VEC_USART_1, (UINT32 *)AT91_USART_1_BASE_ADRS, INT_LVL_USART_1 },
};
LOCAL AT91_SIO_CHAN at91SioChan[N_AT91_USART_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 [] =
{
&at91SioChan[0].sio, /* /tyCo/0 */
&at91SioChan[1].sio, /* /tyCo/1 */
};
/******************************************************************************
*
* sysSerialHwInit - initialise the BSP serial devices to a quiescent state
*
* This routine initialises 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)
{
int i;
for (i = 0; i < N_AT91_USART_CHANNELS; i++)
{
at91SioChan[i].regs = devParas[i].baseAdrs;
at91SioChan[i].baudRate = CONSOLE_BAUD_RATE;
at91SioChan[i].xtal = AT91_USART_FREQ;
at91SioChan[i].level = devParas[i].intLevel;
/* Set USART to be clocked from MCKI */
AT91_USART_REG_WRITE (&at91SioChan[i], AT91_US_MR, 0);
/*
* Initialise driver functions, getTxChar, putRcvChar and channelMode
* and otherwise initialise UART
*/
at91SioDevInit(&at91SioChan[i]);
}
}
/******************************************************************************
*
* 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
* initialised at that point, and intConnect() may call malloc().
*
* RETURNS: N/A
*
* SEE ALSO: sysHwInit2()
*/
void sysSerialHwInit2 (void)
{
int i;
for (i = 0; i < N_AT91_USART_CHANNELS; i++)
{
/*
* We would like to check the return value from this and log a message
* if it failed. However, logLib has not been initialised yet, so we
* cannot log a message, so there's little point in checking it.
*/
/* connect and enable interrupts */
(void) intConnect (INUM_TO_IVEC(devParas[i].vector),
at91SioInt, (int) &at91SioChan[i]);
intEnable (devParas[i].intLevel);
}
}
/******************************************************************************
*
* 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 control to the boot ROM.
*
* RETURNS: N/A.
*/
void sysSerialReset (void)
{
int i;
for (i = 0; i < N_AT91_USART_CHANNELS; i++)
{
/* disable interrupts */
intDisable (devParas[i].intLevel);
}
return;
}
#endif /* INCLUDE_SERIAL */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -