Hi
We are using nRF9160 DK and I am able to transfer my data to BL652 via UART with P0.10 And P0.11 with use of This Example
But I get only One byte at a time so I read This Thread and suggestion for use this example uart_async_api
But I don't know how to use it.
Pls, tell me what API are used for receiving large packets.
Here's My code for Uart.
/*
* Copyright (c) 2012-2014 Wind River Systems, Inc.
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <zephyr.h>
#include <misc/printk.h>
#include <uart.h>
#include <string.h>
#include <stdlib.h>
/* nRF9160 DK voltage = 3.0V
* non sucure
* board name: nrf9160_pca10090ns
* nrf9160_pca10090.overlay */
static u8_t uart_buf[1024];
static K_FIFO_DEFINE(fifo_uart_tx_data);
static K_FIFO_DEFINE(fifo_uart_rx_data);
struct uart_data_t {
void *fifo_reserved;
u8_t data[1024];
u16_t len;
};
void uart_sendCOM(struct device *x, u8_t *Cont)
{
u16_t len = strlen(Cont);
uart_fifo_fill(x, Cont,len );
uart_irq_tx_enable(x);
}
void uart_cb(struct device *x)
{
uart_irq_update(x);
int data_length = 0;
if (uart_irq_rx_ready(x)) {
data_length = uart_fifo_read(x, uart_buf, sizeof(uart_buf));
uart_buf[data_length] = 0;
}
printk("%s", uart_buf);
if (uart_irq_tx_ready(x)) {
struct uart_data_t *buf =
k_fifo_get(&fifo_uart_tx_data, K_NO_WAIT);
u16_t written = 0;
/* Nothing in the FIFO, nothing to send */
if (!buf) {
uart_irq_tx_disable(x);
return;
}
while (buf->len > written) {
written += uart_fifo_fill(x,
&buf->data[written],
buf->len - written);
}
while (!uart_irq_tx_complete(x)) {
/* Wait for the last byte to get
* shifted out of the module
*/
}
if (k_fifo_is_empty(&fifo_uart_tx_data)) {
uart_irq_tx_disable(x);
}
k_free(buf);
}
}
void main(void)
{
struct device *uart1 = device_get_binding("UART_1");
uart_irq_rx_enable(uart1);
uart_irq_callback_set(uart1, uart_cb);
uart_sendCOM(uart1,"ATZ\r");
k_sleep(1500);
uart_sendCOM(uart1,"AT\r");
k_sleep(1500);
uart_sendCOM(uart1,"AT+LADV\r");
}