uprintf.c

来自「单片机实现打印功能串口发送字符.可用于各种单片机。」· C语言 代码 · 共 54 行

C
54
字号
//--------------------------------------------------
//this is the function of send string by serial com
//no longer than MAX_DIS_NUM bytes every time
//CPU Freescale MC68HC908
//--------------------------------------------------
#include <MC68HC908MR16.h> /* include peripheral declarations */
#include <stdarg.h>
#include <stdio.h>
#include "UPrintf.h"

//EXAMPLE
//UPrintf("/*----------------*/\n\r");
//UPrintf("请选择测试的功能项:\n\r");
//UPrintf("%d\n\r",Number);

char string[MAX_DIS_NUM];
/*-------------------------------------------------*/
//Send char by the usart port
//you can change the code by diffirent type CPU
/*-------------------------------------------------*/
void Uart_SendString(char *pt)
{
 while(*pt)
  {
   while (!(SCS1_SCTE)); 
   SCS1_SCTE=0;
   SCDR = (*pt++);
     //TXBUF0=(*pt++);
  }
}

/*-------------------------------------------------*/
//put char by uart
/*-------------------------------------------------*/
void UPrintf(char *fmt,...)
{
    va_list ap;
    va_start(ap,fmt);
    (void)vsprintf(string,fmt,ap);
    Uart_SendString(string);
    va_end(ap);
}

/*-------------------------------------------------*/
//get char from uart
/*-------------------------------------------------*/
unsigned char UGetchar(void) 
{
 unsigned char getch;
	while (!(SCS1_SCRF));
	getch = SCDR;
	return getch;
}

⌨️ 快捷键说明

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