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

📄 serial_init.c

📁 zilog z80f91串口通用函数
💻 C
字号:
 /*
 * Copyright 2001, Metro Link, Inc.
 * All Rights Reserved
 *
 * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Metro Link, Inc. and may
 * contain proprietary, confidential and trade secret information of
 * Metro Link, Inc. and/or its partners.
 *  
 * The contents of this file may not be disclosed to third parties, copied or
 * duplicated in any form, in whole or in part, without the prior written
 * permission of Metro Link, Inc.
 *
 */
/*
 * File			:	serial_init.c
 *
 * Description	:	Contains implementation of serial initialization function.
 *					
 * Copyright 2003, ZiLOG Inc.
 * All Rights Reserved
 *
 * This is UNPUBLISHED PROPRIETARY SOURCE CODE of ZiLOG Inc., and might
 * contain proprietary, confidential and trade secret information of
 * ZiLOG, our partners and parties from which this code has been licensed.
 * 
 * The contents of this file may not be disclosed to third parties, copied or
 * duplicated in any form, in whole or in part, without the prior written
 * permission of ZiLOG Inc.
 */ 

#ifdef _IAR_CODE

#ifdef _EZ80F91
#include <ioez80f91.h>
#endif

#ifdef _EZ80F92
#include <ioez80f92.h>
#endif

#ifdef _EZ80F93
#include <ioez80f92.h>
#endif

#ifdef _EZ80L92
#include <ioez80l92.h>
#endif

#ifdef _EZ80190
#include <ioez80190.h>
#endif

#endif

#include <stdio.h>
#include "serial.h"
#include "_ez80.h"
#include "ZTypes.h"
#include "ZSysgen.h"
#include "ZDevice.h"
#include "ZThread.h"
#include "ZSemaphore.h"
#include "ZInterrupt.h"

extern UINT8	b_uart0_iv;
extern UINT8	b_uart1_iv;
extern DDF_STATUS_t IONULL( void ) ;
extern DDF_STATUS_t IOERR( void );

UINT8	UART0RxBuff[UART_RX_BUF_SIZE] ;
UINT8	UART1RxBuff[UART_RX_BUF_SIZE] ;


UART_DVIOBLK						Uart0_Blk = 
{
	SERIAL_STATE_UNINITIALIZED,
	NULL,
  	&serparams[0],
	0,
	NULL,
	NULL,
	NULL,
	NULL,
	0,
	0,
	NULL,
	NULL,
	NULL,
	UART0
};
UART_DVIOBLK						Uart1_Blk = 
{
	SERIAL_STATE_UNINITIALIZED,
	NULL,
  	&serparams[1],
	0,
	NULL,
	NULL,
	NULL,
	NULL,
	0,
	0,
	NULL,
	NULL,
	NULL,
	UART1
};






DDF_STATUS_t
UARTInit
(
	RZK_DEVICE_CB_t *		pDev
)
{
	UART_DVIOBLK *					pDevBlk = (UART_DVIOBLK *) pDev->dvinputoutput;
	UINT8								b_serial_iv;


	switch( pDev->dvminor )
	{
		case( 0 ):
		{
			b_serial_iv = b_uart0_iv;
			break;
		}
		case( 1 ):
		{
			b_serial_iv = b_uart1_iv;
			break;
		}
		default:
		{
			//printf( "Invalid Minor code (%x) on Serial Init\n", pDev->dvminor );
			return( UARTDEV_ERR_INIT_FAILED );
		}
	}

	if( pDevBlk->State == SERIAL_STATE_UNINITIALIZED )
	{
		pDevBlk->State 	= SERIAL_STATE_CLOSED;
		pDevBlk->pDev		= pDev;
		if(pDev->dvminor == 0)
		{
			pDevBlk->pRxBuf   = UART0RxBuff ;	
		}
		else
		{
			pDevBlk->pRxBuf   = UART1RxBuff ;	
		}
			

		pDev->dvivec = b_serial_iv;

		return( UARTDEV_ERR_SUCCESS );
	}
	else
	{
		return( UARTDEV_ERR_INIT_FAILED );
	}
}

⌨️ 快捷键说明

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