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

📄 ta_read.c

📁 NXP LPC系列AMR7的开发程序源码(LCD
💻 C
字号:
// -------------------------------------------------------------------
// -----------------------LPC2106 low level read----------------------
// -------------------------------------------------------------------
// Written for TinyARM MB40 development board by PASAT using IAR template
// -------------------------------------------------------------------
// THIS FILE IS PROVIDED AS IS WITH NO WARRANTY OF ANY KIND, INCLUDING THE
// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
// -------------------------------------------------------------------

/*******************
 *
 * Copyright 1998-2003 IAR Systems.  All rights reserved.
 *
 * $Revision: 5609 $
 *
 * This is a template implementation of the "__read" function used by
 * the standard library.  Replace it with a system-specific
 * implementation.
 *
 * The "__read" function reads a number of bytes, at most "size" into
 * the memory area pointed to by "buffer".  It returns the number of
 * bytes read, 0 at the end of the file, or _LLIO_ERROR if failure
 * occurs.
 *
 * The template implementation below assumes that the application
 * provides the function "MyLowLevelGetchar".  It should return a
 * character value, or -1 on failure.
 *
 ********************/

#include <yfuns.h>

#include "ma_tgt.h"     /* Target specific header file */
#include "key_api.h"

_STD_BEGIN

#pragma module_name = "?__read"

//int MyLowLevelGetchar();

size_t __read(int handle, unsigned char * buffer, size_t size)
{
  /* Remove the #if #endif pair to enable the implementation */
//#if 0    

  int nChars = 0;

  /* This template only reads from "standard in", for all other file
   * handles it returns failure. */
  if (handle != _LLIO_STDIN)
  {
    return _LLIO_ERROR;
  }

  for (/* Empty */; size > 0; --size)
  {
    int c = Get_Char_Keyboard();
    if (c < 0)
      break;

    *buffer++ = c;
    ++nChars;
  }

  return nChars;

//#else

//  /* Always return error code when implementation is disabled. */
//  return _LLIO_ERROR;

//#endif
}

_STD_END

⌨️ 快捷键说明

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