Other Parts Discussed in Thread: C2000WARE
最近在看以前买的开发板的例程,程序中使用了printf函数通过SCI输出到串口调试助手,不是很明白,前来请教。
程序中有这么一段:
SCI_Init();
open_uart_debug();
printf("\r\n\r\n DSP SCI DEBUG!");
这个open_uart_debug()函数具体如下:里面调用的都是ti自带的一些函数(在file.h里可以找到相关定义),不知道是干什么用的,
void open_uart_debug (void)
{
int status;
status = add_device("uart", _MSA, my_open, my_close, my_read, my_write, my_lseek, my_unlink, my_rename);
if (status == 0) {
freopen("uart:", "w", stdout); // open uart and redirect stdout to UART
setvbuf(stdout, NULL, _IONBF, 0); // disable buffering for stdout
}
}
int my_open(const char *path, unsigned flags, int fno)
{
//scia_fifo_init();
//scia_echoback_init();
path = path;
flags = flags;
fno = fno;
return 0;
}
int my_close(int fno)
{
fno =fno;
return 0;
}
int my_read(int fno, char *buffer, unsigned count)
{
fno = fno;
buffer = buffer;
count = count;
return 0;
}
int my_write(int fno, const char *buffer, unsigned count)
{
int i=0;
fno = fno;
while(count-- > 0) {
scia_xmit(buffer[i++]);
}
return count;
}
off_t my_lseek(int fno, off_t offset, int origin)
{
fno = fno; offset = offset; origin = origin;
return 0;
}
int my_unlink(const char *path)
{
path = path;
return 0;
}
int my_rename(const char *old_name, const char *new_name)
{
old_name = old_name;
new_name = new_name;
return 0;
}
我想问的是这个使用printf前为什么要调用这些函数,这个相关的文档是在哪个pdf里的