ez80eval.c

来自「zilog的实时操作系统RZK,可以移植到多种处理器上」· C语言 代码 · 共 127 行

C
127
字号
/*
 * File       : eZ80eval.c
 *
 * Description: This file contains routines that are used to print the character
 *              onto the console and to initialize the UART port.
 *
 * Copyright 2004 ZiLOG Inc.  ALL RIGHTS RESERVED.
 *
 * This file contains unpublished confidential and proprietary information
 * of ZiLOG, Inc.
 * NO PART OF THIS WORK MAY BE DUPLICATED, STORED, PUBLISHED OR DISCLOSED 
 * IN ANY FORM WITHOUT THE PRIOR WRITTEN CONSENT OF ZiLOG, INC.
 * This is not a license and no use of any kind of this work is authorized
 * in the absence of a written license granted by ZiLOG, Inc. in ZiLOG's 
 * sole discretion 
 */

#include "ZTypes.h"
#include "ZSysgen.h"
#include "ZDevice.h"
#include "ZInterrupt.h"
#include "serial.h"

extern RZK_DEVICE_CB_t *CONSOLE ;
 

/* Function			:	putch
*
* Description		:	puts characters to terminal
* 
* Inputs			:	int
*							
* Outputs			:	int
*
* Dependencies		:	Serial driver.
*/

INT
putch(INT nch)
{
DDF_STATUS_t        nStatus ;
RZK_DEVICE_CB_t     *pDev ;
UINTRMASK           uIntmask ;

	uIntmask = RZKDisableInterrupts() ;
	pDev = CONSOLE ;
	RZKEnableInterrupts(uIntmask) ;
	
	if(pDev)
	{
		nStatus = pDev->fnWrite(pDev, 
                               (RZK_DEV_BUFFER_t *) &nch,
                               1 
                               ) ;

		if ((UINT8)nch == '\n')
		{
			nch = (UINT8)'\r' ;
			nStatus = pDev->fnWrite(pDev, 
                                    (RZK_DEV_BUFFER_t *)&nch, 
                                    1 
                                    ) ;
		}
	}
	
	return nStatus ;
}

INT putchar(INT ch)
{
  putch(ch);
  return ch;
}

/* Function			:	getch
*
* Description		:	gets characters from terminal   
* 
* Inputs			:	void
*							
* Outputs			:	int
*
* Dependencies		:	Serial Driver.
*/
INT
getch(void)
{

INT                 nCh ;
RZK_DEVICE_CB_t     *pDev ;
UINTRMASK           uIntmask ;

	uIntmask = RZKDisableInterrupts() ;
	pDev = CONSOLE ;
	RZKEnableInterrupts(uIntmask) ;
	if(pDev)
	{
		pDev->fnRead(pDev, (RZK_DEV_BUFFER_t *) &nCh, 1) ;
	}
	return nCh ;

}

/* Function			:	InitUART
*
* Description		:	Initializes UART
* 
* Inputs			:	void
*							
* Outputs			:	void
*							
*
* Dependencies		:	Serial Driver.
*/
void InitUART ( void ) 
{ 

    INT8 cMode ;

    AddUART0() ;

    CONSOLE = RZKDevOpen( 
			 (RZK_DEV_NAME_t *)"SERIAL0",
			 &cMode
			 );
}

⌨️ 快捷键说明

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