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

📄 nios_uart.c

📁 ALTERA的NIOS处理器!文件直接可以打开直接选择器件重新编译!
💻 C
字号:
/*

	file: nios_uart.c

	contents: the tiniest routines, which
	          talk to printf and debug uarts.
	author: david van brink \ altera corporation

*/

#include "excalibur.h"

// +---------------------------
// | printf uart routines
// |

static void r_ensure_printf_init(void)
	{
	static int inited = 0;

	if(!inited)
		{
#ifdef nm_printf_initialize
		nm_printf_initialize(nasys_printf_uart);
#endif
		inited = 1;
		}
	}

#ifdef nm_printf_txchar
void nr_txchar(int c)
	{
	r_ensure_printf_init();
	nm_printf_txchar(c,nasys_printf_uart);
	}

void nr_txstring(char *s)
	{
	while(*s)
		nr_txchar(*s++);
	}
#endif

#ifdef nm_printf_rxchar
int nr_rxchar(void)
	{
	r_ensure_printf_init();
	return nm_printf_rxchar(nasys_printf_uart);
	}
#endif

// +---------------------------
// | debug uart routines
// |

#ifdef nasys_debug_uart

static void r_ensure_debug_init(void)
	{
	static int inited = 0;

	if(!inited)
		{
#ifdef nm_debug_initialize
		nm_debug_initialize(nasys_debug_uart);
#endif
		inited = 1;
		}
	}

#ifdef nm_debug_txchar
void nr_debug_txchar(int c)
	{
	r_ensure_debug_init();
	nm_debug_txchar(c,nasys_debug_uart);
	}

void nr_debug_txstring(char *s)
	{
	while(*s)
		nr_debug_txchar(*s++);
	}
#endif

#ifdef nm_debug_rxchar
int nr_debug_rxchar(void)
	{
	r_ensure_debug_init();
	return nm_debug_rxchar(nasys_debug_uart);
	}
#endif

#endif // nasys_debug_uart

// end of file

⌨️ 快捷键说明

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