开启CSR8675 UART
本节主要做的是一个电脑使用串口工具,向CSR8675发送数据,然后CSR8675发送回来,串
口助手回显的一个功能
1、首先,可以参阅官方关于配置串口的文档,和一些技术博客
I2C and UART Serial Interface Code Examples, CS-327754-AN-1
2、首先打开工程,然后将Project Properties 的 Transport 修改成 Raw。
3、然后打开 Pstool,搜索 Uart,设置波特率为38400,并关闭硬件流控
第 1 页
4、之后回到xIDE,添加两个文件 sink_uart.c ,sink_uart.h
5、sink_uart.h代码如下
#ifndef _SINK_UART_H_
#define _SINK_UART_H_
#include
#include
#include
#include
#include
#include
#include
typedef struct
{
TaskData task;
Sink uart_sink;
Source uart_source;
} UARTStreamTaskData;
extern UARTStreamTaskData theUARTStreamTask;
extern void uart_data_stream_init(void);
#endif
6、sink_uart.c代码如下
#include
#include
#include
第 2 页
VM_UART_PARITY_NONE);
/* Get the sink for the uart */
theUARTStreamTask.uart_sink = StreamUartSink();
PanicNull(theUARTStreamTask.uart_sink);
/* Get the source for the uart */
theUARTStreamTask.uart_source = StreamUartSource();
PanicNull(theUARTStreamTask.uart_source);
/* Register uart source with task */
MessageSinkTask(StreamSinkFromSource(theUARTStreamTask.uart_source),
&theUARTStreamTask.task);
}
7、最后在main.c ,添加 sink_uart.h 头文件
然后在main函数内,添加void uart_data_stream_init()即可
8、关于开发板的接线
第 4 页
9、最后在电脑打开串口助手,选择38400波特率,无奇偶校验,1位停止位,8位数据位
然后发送任意数据,就会收到我们发出去的数据
第 5 页