?? sysserial.c
字號(hào):
/* sysSerial.c - IXP425 UART bsp serial device initialization *//* Copyright 2002 Wind River Systems, Inc. */#include "copyright_wrs.h"/*modification history--------------------01a,05jun02,jb initial version...*//*DESCRIPTIONSerial initialisation routines.*/#include "vxWorks.h"#include "iv.h"#include "intLib.h"#include "config.h"#include "sysLib.h"#include "ixp425.h"#include "ixp425Sio.h"#include "ixp425Sio.c"void printfxu(char *str);void printpxu(char *nameptr, unsigned int value);/* * UART2 should not be used as a very low level debug port therefore only enable it * if debug support is turned off. */#ifdef INCLUDE_UART2_SUPPORT #ifdef INCLUDE_IXP425_UART_DEBUG #undef INCLUDE_UART2_SUPPORT #endif#endif /* INCLUDE_UART2_SUPPORT *//* local data */static IXP425_SIO_CHAN ixp425Chan[IXP425_NUM_UARTS];/******************************************************************************** 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*/void sysSerialHwInit (void) { /* intialize the chips device descriptors */#ifdef INCLUDE_UART1_SUPPORT ixp425Chan[0].regs = (UINT8 *)IXP425_UART1_BASE; ixp425Chan[0].level = INT_VEC_UART1; ixp425Chan[0].regDelta = IXP425_UART_REG_DELTA; ixp425Chan[0].xtal = IXP425_UART_XTAL; ixp425Chan[0].baudRate = UART_DEFAULT_BAUD; ixp425Chan[0].options = 0;#endif#ifdef INCLUDE_UART2_SUPPORT ixp425Chan[1].regs = (UINT8 *)IXP425_UART2_BASE; ixp425Chan[1].level = INT_VEC_UART2; ixp425Chan[1].regDelta = IXP425_UART_REG_DELTA; ixp425Chan[1].xtal = IXP425_UART_XTAL; ixp425Chan[1].baudRate = UART_DEFAULT_BAUD; ixp425Chan[1].options = 0;#endif /* reset the chips */#ifdef INCLUDE_UART1_SUPPORT ixp425SioDevInit (&ixp425Chan[0]);#endif#ifdef INCLUDE_UART2_SUPPORT ixp425SioDevInit (&ixp425Chan[1]);#endif }/******************************************************************************** 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() calls malloc().** RETURNS: N/A*/void sysSerialHwInit2 (void) { /* now connect the serial device interrupts */#ifdef INCLUDE_UART1_SUPPORT (void) intConnect ((VOIDFUNCPTR *)((UINT32)ixp425Chan[0].level), (VOIDFUNCPTR) ixp425SioInt, (int)&ixp425Chan[0]);#endif#ifdef INCLUDE_UART2_SUPPORT (void) intConnect ((VOIDFUNCPTR *)((UINT32)ixp425Chan[1].level), (VOIDFUNCPTR) ixp425SioInt, (int)&ixp425Chan[1]);#endif#ifdef INCLUDE_UART1_SUPPORT /* Enable the UART interrupt */ intEnable (ixp425Chan[0].level);#endif#ifdef INCLUDE_UART2_SUPPORT intEnable (ixp425Chan[1].level);#endif }/******************************************************************************** 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 ) { switch (channel) {#ifdef INCLUDE_UART1_SUPPORT case 0: return ((SIO_CHAN *)&ixp425Chan[0]);#endif#ifdef INCLUDE_UART2_SUPPORT case 1: return ((SIO_CHAN *)&ixp425Chan[1]);#endif default: return ((SIO_CHAN *)ERROR); } }/******************************************************************************** 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) { /* Disable the UART interrupt */#ifdef INCLUDE_UART1_SUPPORT intDisable (ixp425Chan[0].level);#endif#ifdef INCLUDE_UART2_SUPPORT intDisable (ixp425Chan[1].level);#endif }/******************************************************************************** sysSerialShow - display serial statistics** RETURNS: N/A.*/void sysSerialShow () { int i=0; for (i=0; i<IXP425_NUM_UARTS; i++) { printf("\nChannel (%d):", i); ixp425SioStatsShow(&ixp425Chan[i]); } }#define RS232_BASE 0xc8000000#define RS232_LINE_STATUS 0x14void printfxu(char *str){ #if 1 volatile UINT8 status = 0; for(;*str;) { status = 0; while (status == 0) status = *(UINT32*)(RS232_BASE + RS232_LINE_STATUS); *(int *)RS232_BASE = *str++; } /* *(int *)0xC8000000 = 'S' */ #endif}void printpxu(char *nameptr, unsigned int value){ char ch[16] = {'0', '1', '2', '3', '4', '5', '6', '7', \ '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'}; char temp1[100], temp2[100]; unsigned int vl = value; int i; for(i=0; i<8; i++) { temp2[i] = ch[(vl>>((7-i)*4))&0xf]; } temp2[i] = 0; strcpy(temp1, nameptr); strcat(temp1, " = 0x"); strcat(temp1, temp2); printfxu(temp1);}
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -