#include <FreeRTOS.h>
#include <task.h>
#include <timers.h>
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#include <lwip/tcpip.h>
#include <bl602_glb.h>
#include <bl_sys.h>
#include <bl_uart.h>
#include <cli.h>
//////////////////////////////////
#include "wifi_interface.h"
#include <../wifi_mgmr.h>
#include "blufi.h"
#include "blufi_api.h"
#include "blufi_hal.h"
#include "blufi_init.h"
#include "axk_blufi.h"
#include "ble_interface.h"
#include "blufi_security.h"
#include <blog.h>
#include <aos/yloop.h>
#include <aos/kernel.h>
#include <lwip/sockets.h>
#include <wifi_mgmr_ext.h>
#include <hal_wifi.h>
#include <lwip/init.h>
#include <hosal_uart.h>
#include <hosal_dma.h>
// #include "tcp_example.h"
//////////////////////////////////
uint8_t msg_head[] = {0xDC, 0xFF, 0xEE, 0xFF};
uint8_t msg_end[] = {0xA6, 0xFC, 0xBB, 0xFF};
static int scan_counter;
static bool ble_is_connected = false;
static bool gl_sta_connected = false;
blufi_config_t g_blufi_config = {0};
#define TCP_CLIENT_BUFF 2048
static struct sockaddr_in dest;
#define RX_DATA_SIZE 512
static uint8_t data_buf[RX_DATA_SIZE + 1];
hosal_uart_dev_t uart_dev_int = {
.config = {
.uart_id = 0,
.tx_pin = 16, // TXD GPIO
.rx_pin = 7, // RXD GPIO
.cts_pin = 255,
.rts_pin = 255,
.baud_rate = 115200,
.data_width = HOSAL_DATA_WIDTH_8BIT,
.parity = HOSAL_NO_PARITY,
.stop_bits = HOSAL_STOP_BITS_1,
.mode = HOSAL_UART_MODE_POLL,
},
};
static uint8_t rx_data_buffer[RX_DATA_SIZE + 1];
static uint8_t tx_data_buffer[RX_DATA_SIZE + 1];
static hosal_uart_dma_cfg_t txdam_cfg = {
.dma_buf = tx_data_buffer,
.dma_buf_size = RX_DATA_SIZE + 1,
};
static hosal_uart_dma_cfg_t rxdam_cfg = {
.dma_buf = rx_data_buffer,
.dma_buf_size = RX_DATA_SIZE + 1,
};
static int __uart_tx_callback(void *p_arg)
{
static uint8_t tx_counts = 0;
char buf[] = "TX interrupt TEST\r\n";
hosal_uart_dev_t *p_dev = (hosal_uart_dev_t *)p_arg;
printf("__uart_tx_callback\r\n");
if (tx_counts < sizeof(buf))
{
hosal_uart_send(p_dev, &buf[tx_counts++], 1);
}
else
{
hosal_uart_ioctl(p_dev, HOSAL_UART_TX_TRIGGER_OFF, NULL);
}
return 0;
}
static int __uart_rx_callback(void *p_arg)
{
int ret;
hosal_uart_dev_t *p_dev = (hosal_uart_dev_t *)p_arg;
ret = hosal_uart_receive(&uart_dev_int, data_buf, sizeof(data_buf));
printf("__uart_rx_callback : %d\r\n", ret);
for (int i = 0; i < ret; i++)
{
printf("rx num : %d 0x%02x\r\n", i, data_buf[i]);
}
return 0;
}
static void uart_init(void)
{
hosal_uart_init(&uart_dev_int);
hosal_uart_ioctl(&uart_dev_int, HOSAL_UART_MODE_SET, (void *)HOSAL_UART_MODE_INT);
hosal_uart_callback_set(&uart_dev_int, HOSAL_UART_RX_CALLBACK,
__uart_rx_callback, &uart_dev_int);
hosal_uart_callback_set(&uart_dev_int, HOSAL_UART_TX_CALLBACK,
__uart_tx_callback, &uart_dev_int);
hosal_uart_ioctl(&uart_dev_int, HOSAL_UART_TX_TRIGGER_ON, NULL);
}
int num;
static void uart_task(void *params)
{
uart_init();
while (true)
{
vTaskDelay(3 * 1000);
}
}
void main()
{
xTaskCreate(uart_task, "uart_task", 1024, NULL, 15, NULL);
}
使用串口助手发送数据ATSOCKETSENDasdqwertyuiopzxcvbnm123456789,接收到的只有__uart_rx_callback : 1
rx num : 0 0x41__uart_rx_callback : 8rx num : 0 0x54rx num : 1 0x53rx num : 2 0x4frx num : 3 0x43rx num : 4 0x4brx num : 5 0x45rx num : 6 0x54rx num : 7 0x53__uart_rx_callback : 32rx num : 0 0x45rx num : 1 0x4erx num : 2 0x44rx num : 3 0x61rx num : 4 0x73rx num : 5 0x64rx num : 6 0x71rx num : 7 0x77rx num : 8 0x65rx num : 9 0x72rx num : 10 0x74rx num : 11 0x79rx num : 12 0x75rx num : 13 0x69rx num : 14 0x6frx num : 15 0x70rx num : 16 0x7arx num : 17 0x78rx num : 18 0x63rx num : 19 0x76rx num : 20 0x62rx num : 21 0x6erx num : 22 0x6drx num : 23 0x31rx num : 24 0x32rx num : 25 0x33rx num : 26 0x34rx num : 27 0x35rx num : 28 0x36rx num : 29 0x37rx num : 30 0x38rx num : 31 0x39__uart_rx_callback : 0__uart_rx_callback : 0blufi demo test 260
不能一帧完整接收
|