nios_uart.c

来自「ALTERA的NIOS处理器!文件直接可以打开直接选择器件重新编译!」· C语言 代码 · 共 96 行

C
96
字号
/*

	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 + =
减小字号Ctrl + -
显示快捷键?