连续签到天数:1天 | 签到总天数:66天 | 签到总奖励:421金币 |
|
马上注册,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册 
×
不同板子的出现的概率不一样,有些挺高的,有些则很低。但对方发送的数据又不在缓冲区,应该是丢数据。
测量波形,没有异常,纯粹是、5120这边收不到而已。
代码如下:
- void uartInit(void)
- {
- uint8 i;
- UART_PIO uart_pios[] = {{PIO_UART_RX, UART_RX},
- {PIO_UART_TX, UART_TX}};
- for (i = 0; i < ARRAY_DIM(uart_pios); i++)
- {
- uint16 pio = uart_pios.pio;
- uint16 bank = PBANK(pio);
- uint32 mask = POFFM(pio);
- /* Setup uart PIOs with strong pull-up */
- PanicNotZero(PioSetMapPins32Bank(bank, mask, 0));
- PanicFalse(PioSetFunction(pio, uart_pios.func));
- PanicNotZero(PioSetDir32Bank(bank, mask, 0));
- PanicNotZero(PioSet32Bank(bank, mask, mask));
- PanicNotZero(PioSetStrongBias32Bank(bank, mask, mask));
- }
- /* Assign task message handler */
- theUARTStreamTask.task.handler = uartMessageHandler;
- /* Get the sink for the uart */
- theUARTStreamTask.uart_sink = StreamUartSink();
- if(theUARTStreamTask.uart_sink != 0)
- {
- PanicNull(theUARTStreamTask.uart_sink);
- }
- /* Get the source for the uart */
- theUARTStreamTask.uart_source = StreamUartSource();
- if(theUARTStreamTask.uart_source != 0)
- {
- PanicNull(theUARTStreamTask.uart_source);
- }
- StreamConfigure(VM_STREAM_UART_CONFIG, VM_STREAM_UART_THROUGHPUT);
- StreamConfigure(VM_STREAM_UART_SLEEP_TIMEOUT, 0);
- /* Configure uart settings */
- StreamUartConfigure(VM_UART_RATE_9K6, VM_UART_STOP_ONE, VM_UART_PARITY_NONE);
- /* Register uart source with task */
- MessageStreamTaskFromSink(StreamSinkFromSource(theUARTStreamTask.uart_source), &theUARTStreamTask.task);
- }
复制代码- void uartRxdata(Source src)
- {
- uint8 i;
- uint16 length = 0;
- const uint8 *data = NULL;
- /* Get the number of bytes in the specified source before the next packet boundary */
- if(!(length = SourceBoundary(src)))
- {
- return;
- }
-
- /* Maps the specified source into the address map */
- data = SourceMap(src);
- PanicNull((void*)data);
- /* Transmit the received data */
- /*uart_data_stream_tx_data(data, length);*/
- UART_DEBUG(("UART: Rx: length %d", length));
- for(i = 0; i < length; i++)
- {
- UART_DEBUG((" data[%d] [%x]", i, data));
- }
- UART_DEBUG(("\n"));
- /* Discards the specified amount of bytes from the front of the specified source */
- SourceDrop(src, length);
- }
复制代码
- void uartMessageHandler (Task pTask, MessageId pId, Message pMessage)
- {
- UNUSED((pTask));
- switch (pId)
- {
- case MESSAGE_MORE_DATA:
- {
- uartRxdata(((MessageMoreData *)pMessage)->source);
- }
- break;
- default:
- break;
- }
- }
复制代码
|
|