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

📄 termio12.c

📁 EEPROM 24LC08 accessed via IIC on a HCS12
💻 C
字号:
/*****************************************************
  Demo files: Terminal port defintion
 ----------------------------------------------------
   Copyright (c) HIWARE AG, Basel, Switzerland
               All rights reserved
                  Do not modify!
 *****************************************************/

/************************************************************************
   This example shows how to access a virtual on chip IO.
   Calls for terminal output is done via on chip SCI.
   
**************************************************************************/

#include <hidef.h>
#include <termio.h>

#define NOCHAR  -1

typedef struct {
    unsigned char SCxBDH;
    unsigned char SCxBDL;
    unsigned char SCxCR1;
    unsigned char SCxCR2;
    unsigned char SCxSR1;
    unsigned char SCxSR2;
    unsigned char SCxDRH;
    unsigned char SCxDRL;
} SCIStruct;

/* terminal.wnd */
#define SCI_ADDR 0x00c8
#define  SCI (*((SCIStruct*)(SCI_ADDR))) 
 

int TERMIO_GetBusyChar(void) {
   /* checks if there's a character from the terminal channel           */	   	
   if (!(SCI.SCxSR1 & 0x20)) return NOCHAR; /* if any returs the character  */
   return SCI.SCxDRL;                    /*  if not returns EOF  */
 }

char TERMIO_GetChar(void) {
  /* receives character from the terminal channel */
    while (!(SCI.SCxSR1 & 0x20)); /* wait for input */
    return SCI.SCxDRL;
 
}

void TERMIO_PutChar(char ch) {
  /* sends a character to the terminal channel */
    while (!(SCI.SCxSR1 & 0x80));  /* wait for output buffer empty */
    SCI.SCxDRL = ch;
}

void TERMIO_Init(void) {
  /* initializes the communication channel */ 
#if 1 /* this may need to be adapted to your baudrate and target speed */
    SCI.SCxBDL  =   26;   /* baud rate 9600 at 8 MHz */
#else
    SCI.SCxBDL  =   1;    /* for the simulator we use this small divisor to speed up the output. On hardware please use the real value. */     
#endif
    SCI.SCxCR2 = 0x0C;    /* 8 bit, TE and RE set */   
 
}


⌨️ 快捷键说明

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