putchar.c

来自「该应用软件可以实现大多数单片机的仿真实验」· C语言 代码 · 共 44 行

C
44
字号
 /*                     - PUTCHAR.C -

  $Id: putchar.c 1.2 1997/09/23 15:12:31 dan Exp $

  The ANSI "putchar" function delivered here is supposed to be tailored
  for the actual target hardware.  This version of putchar writes
  the argument character to a port assumed to be initiated elsewhere.
*/


#include <io6811.h>


/*
 * Use built-in serial port SCI:
 */

#define TDRE            (0x80) /* TX data empty */


/*
 * This routine must be tailored to suit the specific hardware.
 */

static int _low_level_putc(int c)
 { if (c == '\n')
      c = '\r';     

  while ((SCSR & TDRE) == 0)
    ;
  SCDR = (char) c;
  return(c);
}

/*
 * The putchar routine:
 */


int putchar(int value)
  {
    return(_low_level_putc(value));
  }

⌨️ 快捷键说明

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