⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sysserial.c

📁 Vxworks下BSP源码
💻 C
字号:
/* sysSerial.c - Samsung SBC ARM7 serial device initialization *//* Copyright 1984-2001 Wind River Systems, Inc. */#include "copyright_wrs.h"/*modification history--------------------01c,10jul01,g_h  add #include "sngks32cSio.c" instead of the makefile01b,26apr01,m_h  convert tabs to spaces for readability01a,12apr01,m_h  created from snds100 template.*//*DESCRIPTIONThis file contains the board-specific routines for serial channelinitialization of the Samsung SBC ARM7 development board.INCLUDES:sngks32cSio.hSEE ALSO:<Samsung KS32C50100 Microcontroller User's Manual>*/#include "vxWorks.h"#include "iv.h"#include "intLib.h"#include "config.h"#include "sysLib.h"#include "sngks32cSio.h"#include "wrSbcArm7.h"#include "sngks32cSio.c"/*void myDelay();*//* local defines  */#ifndef AT91C_REG_READ#define AT91C_REG_READ(reg, result) \    ((result) = *(volatile UINT32 *)(reg))#endif #ifndef AT91C_REG_WRITE#define AT91C_REG_WRITE(reg, data) \    (*((volatile UINT32 *)(reg)) = (data))#endif /* device initialization structure */typedef struct    {    UINT  intVector;    UINT32 *baseAdrs;    UINT  regSpace;    UINT  intLevel;	    UINT32 *PIO_PDR;    UINT32 *PIO_ASR;    UINT32 value;	/*value for pio register*//*RS485*/    char mode;/*rs485/232*/    UINT32 pioBaseAdrs;    UINT32 pinValue;	    } ATARM920T_CHAN_PARAS;/* Local data structures */LOCAL ATARM920T_CHAN_PARAS devParas[] =    {      {INT_VEC_SYSIRQ, (UINT32 *)AT91C_DBGU_BASE_ADR, UART_REG_ADDR_INTERVAL,  INT_LVL_SYSIRQ,	  (UINT32 *)AT91C_PIOA_PDR,(UINT32 *)AT91C_PIOA_ASR,AT91C_PA31_DTXD|AT91C_PA30_DRXD,	MODE_RS232,0,0	},      {INT_VEC_US0, (UINT32 *)AT91C_US0_BASE_ADR, UART_REG_ADDR_INTERVAL, INT_LVL_US0,      (UINT32 *)AT91C_PIOA_PDR,(UINT32 *)AT91C_PIOA_ASR,AT91C_PA17_TXD0 |AT91C_PA18_RXD0 ,	MODE_RS485,AT91C_PIOB_BASE_ADR,AT91C_PIO14	}    }; LOCAL AT91C_CHAN at91cChan[N_ATARM920T_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 [] =    {    &at91cChan[0].sio, /* /tyCo/0 --debug*/    &at91cChan[1].sio, /* /tyCo/1 --uart0*/    };/* forward declarations *//******************************************************************************** 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.** RETURNS: N/A** SEE ALSO: sysHwInit()*/void sysSerialHwInit (void)    {    int i;    for (i = 0; i < N_ATARM920T_UART_CHANNELS; i++)        {        at91cChan[i].regDelta = devParas[i].regSpace;        at91cChan[i].regs = devParas[i].baseAdrs;        at91cChan[i].baudRate = CONSOLE_BAUD_RATE;        at91cChan[i].intLevel = devParas[i].intLevel;	at91cChan[i].UARTmode = devParas[i].mode;	if(devParas[i].mode == MODE_RS485)	{		at91cChan[i].pioBaseAdrs = devParas[i].pioBaseAdrs;		at91cChan[i].pinValue = devParas[i].pinValue;	}        /*         * Initialize driver functions, getTxChar, putRcvChar and channelMode         * and initialize UART         */        at91cDevInit(&at91cChan[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_ATARM920T_UART_CHANNELS; i++)        {        /*         * Connect and enable the interrupt.         * We would like to check the return value from this and log a message         * if it failed. However, logLib has not been initialized yet, so we         * cannot log a message, so there's little point in checking it.         */	AT91C_REG_WRITE(devParas[i].PIO_ASR,devParas[i].value);/*TX & RX --PIO pin set*/	AT91C_REG_WRITE(devParas[i].PIO_PDR,devParas[i].value);	if(devParas[i].mode == MODE_RS485)	{		*(volatile UINT32*)((UINT32)AT91C_PIOB_BASE_ADR + AT91C_PIO_PER) = devParas[i].pinValue;		*(volatile UINT32*)((UINT32)AT91C_PIOB_BASE_ADR + AT91C_PIO_OER) = devParas[i].pinValue;		*(volatile UINT32*)((UINT32)AT91C_PIOB_BASE_ADR + AT91C_PIO_CODR) = devParas[i].pinValue;	/*--RS485默认状态RX--*/	}		if(i==0)	{        (void) intConnect (INUM_TO_IVEC(devParas[i].intVector),                           sysIntHandler, (int) &at91cChan[i] );	}	else	{        (void) intConnect (INUM_TO_IVEC(devParas[i].intVector),                           at91cInt, (int) &at91cChan[i] );	}			intEnable (devParas[i].intLevel);        at91cDevInit2(&at91cChan[i]);/*Before this routine is called only polled mode operations should be allowed*/        }	    }/******************************************************************************** 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 bootroms.** RETURNS: N/A.*/void sysSerialReset (void)    {    int i;    for (i = 0; i < N_ATARM920T_UART_CHANNELS; i++)        {        /* disable serial interrupts */        intDisable (devParas[i].intLevel);        }    }#if 0void myDelay(){	int i;		*(volatile UINT32 *)0xfffff800 = 0x35;	*(volatile UINT32 *)0xfffff810 = 0x35;		while(1)	{	*(volatile UINT32 *)0xfffff834 = 0x35;/*lit*/		for(i=0;i<1000000;i++);		*(volatile UINT32 *)0xfffff830 = 0x35;		for(i=0;i<1000000;i++);		}}#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -