[feat][examples/at] add at demo with 602 to get hefeng weather

This commit is contained in:
jzlv 2022-04-26 11:13:31 +08:00
parent 15257f8786
commit e8c2b6a4f9
8 changed files with 1078 additions and 0 deletions

Binary file not shown.

204
examples/at_client/at.c Normal file
View File

@ -0,0 +1,204 @@
#include "bflb_platform.h"
#include "hal_uart.h"
#include "at.h"
#include "ring_buffer.h"
#define UART_SEND_BUF_SZIE 1024
char send_buf[UART_SEND_BUF_SZIE] = { 0 };
#define UART_RX_RINGBUFFER_SIZE (1 * 1024)
uint8_t uart_rx_mem[UART_RX_RINGBUFFER_SIZE];
struct device *uart1;
Ring_Buffer_Type uart1_rx_rb;
static void uart1_irq_callback(struct device *dev, void *args, uint32_t size, uint32_t state)
{
Ring_Buffer_Write(&uart1_rx_rb, (uint8_t *)args, size);
}
uint32_t at_vprintfln(const char *format, va_list args)
{
uint32_t len;
len = vsnprintf(send_buf, sizeof(send_buf) - 2, format, args);
if (len > sizeof(send_buf) - 2)
len = sizeof(send_buf) - 2;
memcpy(send_buf + len, "\r\n", 2);
len = len + 2;
MSG("%s\r\n", send_buf);
device_control(uart1, DEVICE_CTRL_CLR_INT, (void *)(UART_RX_FIFO_IT | UART_RTO_IT));
uart1->oflag &= ~DEVICE_OFLAG_INT_RX;
return device_write(uart1, 0, (uint8_t *)send_buf, len);
}
int at_read_line(struct at_client *client)
{
uint32_t read_len = 0;
uint32_t start_time = 0;
char ch = 0, last_ch = 0;
memset(client->recv_line_buf, 0, client->recv_bufsz);
client->recv_line_len = 0;
start_time = bflb_platform_get_time_ms();
while (1) {
while (device_read(uart1, 0, &ch, 1) == 0) {
if ((bflb_platform_get_time_ms() - start_time) > client->timeout) {
client->resp_status = AT_RESP_TIMEOUT;
return AT_RESP_TIMEOUT;
}
}
if (read_len < client->recv_bufsz) {
client->recv_line_buf[read_len++] = ch;
client->recv_line_len = read_len;
} else {
MSG("buf full\r\n");
client->resp_status = AT_RESP_BUFF_FULL;
return AT_RESP_BUFF_FULL;
}
if (ch == '\n' && last_ch == '\r') {
if (strstr((const char *)client->recv_line_buf, (const char *)client->resp_succ)) {
client->resp_status = AT_RESP_OK;
goto match_out;
} else if (client->resp_err && strstr((const char *)client->recv_line_buf, (const char *)client->resp_err)) {
client->resp_status = AT_RESP_ERROR;
goto match_out;
}
}
last_ch = ch;
}
match_out:
MSG("%s", client->recv_line_buf);
return read_len;
}
int at_exe_cmd(struct at_client *client, char *cmd_expr, ...)
{
va_list ap;
va_start(ap, cmd_expr);
at_vprintfln(cmd_expr, ap);
va_end(ap);
return at_read_line(client);
}
int at_write_recv(uint8_t *send_buffer, uint32_t send_len, uint8_t *recv_buffer, uint32_t *recv_len, uint32_t timeout)
{
int ret = 0;
uint8_t found = 0;
uint32_t read_len = 0;
uint32_t start_time = 0;
uint8_t ch = 0, last_ch = 0;
uint8_t tmp_buf[32] = { 0 };
const char *found_string = "+IPD:0,";
uint8_t found_index = 0;
struct at_client static_client;
static_client.recv_line_buf = tmp_buf;
static_client.recv_bufsz = 32;
static_client.resp_succ = ">";
static_client.resp_err = "FAIL";
static_client.timeout = 1000;
ret = at_exe_cmd(&static_client, "AT+CIPSEND=0,%d", 114);
if (ret < 0) {
return -1;
}
Ring_Buffer_Reset(&uart1_rx_rb);
device_control(uart1, DEVICE_CTRL_SET_INT, (void *)(UART_RX_FIFO_IT | UART_RTO_IT));
device_write(uart1, 0, (uint8_t *)send_buffer, send_len);
if (recv_buffer == NULL) {
return 0;
}
uint8_t *p = recv_buffer;
start_time = bflb_platform_get_time_ms();
while (1) {
while (Ring_Buffer_Read_Byte(&uart1_rx_rb, &ch) == 0) {
if ((bflb_platform_get_time_ms() - start_time) > timeout) {
return AT_RESP_TIMEOUT;
}
}
if (found == 0) {
tmp_buf[found_index++] = ch;
if (strstr((const char *)tmp_buf, found_string)) {
found = 1;
found_index = 0;
}
} else if (found == 1) {
tmp_buf[found_index++] = ch;
if (ch == '\n' && last_ch == '\r') {
if (found_index == 3) {
read_len = (tmp_buf[0] - '0');
} else if (found_index == 4) {
read_len = (tmp_buf[0] - '0') * 10 + (tmp_buf[1] - '0');
} else if (found_index == 5) {
read_len = (tmp_buf[0] - '0') * 100 + (tmp_buf[1] - '0') * 10 + (tmp_buf[2] - '0');
}
*recv_len = read_len;
found = 2;
}
last_ch = ch;
} else {
*p++ = ch;
read_len--;
if (read_len == 0) {
return 0;
}
}
}
return 0;
}
#define __is_print(ch) ((unsigned int)((ch) - ' ') < 127u - ' ')
void at_dump_hex(const void *ptr, uint32_t buflen)
{
unsigned char *buf = (unsigned char *)ptr;
int i, j;
for (i = 0; i < buflen; i += 16) {
MSG("%08X:", i);
for (j = 0; j < 16; j++)
if (i + j < buflen) {
if ((j % 8) == 0) {
MSG(" ");
}
MSG("%02X ", buf[i + j]);
} else
MSG(" ");
MSG(" ");
for (j = 0; j < 16; j++)
if (i + j < buflen)
MSG("%c", __is_print(buf[i + j]) ? buf[i + j] : '.');
MSG("\n");
}
}
void at_client_init()
{
Ring_Buffer_Init(&uart1_rx_rb, uart_rx_mem, UART_RX_RINGBUFFER_SIZE, cpu_global_irq_disable, cpu_global_irq_enable);
uart_register(UART1_INDEX, "uart1");
uart1 = device_find("uart1");
if (uart1) {
UART_DEV(uart1)->baudrate = 115200;
device_open(uart1, DEVICE_OFLAG_STREAM_TX | DEVICE_OFLAG_INT_RX);
device_set_callback(uart1, uart1_irq_callback);
device_control(uart1, DEVICE_CTRL_SET_INT, (void *)(UART_RX_FIFO_IT | UART_RTO_IT));
Ring_Buffer_Reset(&uart1_rx_rb);
}
}

29
examples/at_client/at.h Normal file
View File

@ -0,0 +1,29 @@
#ifndef __AT_H_
#define __AT_H_
enum at_resp_status {
AT_RESP_OK = 0, /* AT response end is OK */
AT_RESP_ERROR = -1, /* AT response end is ERROR */
AT_RESP_TIMEOUT = -2, /* AT response is timeout */
AT_RESP_BUFF_FULL = -3, /* AT response buffer is full */
};
struct at_client {
/* the current received one line data buffer */
uint8_t *recv_line_buf;
/* The length of the currently received one line data */
uint32_t recv_line_len;
/* The maximum supported receive data length */
uint32_t recv_bufsz;
uint32_t timeout;
const char *resp_succ;
const char *resp_err;
enum at_resp_status resp_status;
};
int at_exe_cmd(struct at_client *client, char *cmd_expr, ...);
int at_write_recv(uint8_t *send_buffer, uint32_t send_len, uint8_t *recv_buffer, uint32_t *recv_len, uint32_t timeout);
void at_dump_hex(const void *ptr, uint32_t buflen);
void at_client_init(void);
#endif

View File

@ -0,0 +1,5 @@
set(TARGET_REQUIRED_SRCS ${CMAKE_CURRENT_LIST_DIR}/../at.c)
set(TARGET_REQUIRED_PRIVATE_INCLUDE ${CMAKE_CURRENT_LIST_DIR}/..)
set(mains main.c)
generate_bin()

View File

@ -0,0 +1,744 @@
<?xml version="1.0" encoding="UTF-8"?>
<Project Name="at_client_httpget" Version="1" Language="C">
<Description>CPU: RV32IMAFC
Chip: bl70x
Board: bl70x_iot
</Description>
<Dependencies Name="Debug"/>
<VirtualDirectory Name="app">
<File Name="../main.c">
<FileOption/>
</File>
<File Name="../../at.c">
<FileOption/>
</File>
</VirtualDirectory>
<VirtualDirectory Name="chip">
<VirtualDirectory Name="riscv">
<File Name="../../../../drivers/bl702_driver/startup/interrupt.c">
<FileOption/>
</File>
<File Name="../../../../drivers/bl702_driver/startup/system_bl702.c">
<FileOption/>
</File>
</VirtualDirectory>
<VirtualDirectory Name="startup">
<File Name="../../../../drivers/bl702_driver/startup/GCC/entry.S">
<FileOption/>
</File>
<File Name="../../../../drivers/bl702_driver/startup/GCC/start_load.c">
<FileOption/>
</File>
</VirtualDirectory>
</VirtualDirectory>
<VirtualDirectory Name="hal">
<File Name="../../../../drivers/bl702_driver/hal_drv/src/hal_acomp.c">
<FileOption/>
</File>
<File Name="../../../../drivers/bl702_driver/hal_drv/src/hal_adc.c">
<FileOption/>
</File>
<File Name="../../../../drivers/bl702_driver/hal_drv/src/hal_boot2.c">
<FileOption/>
</File>
<File Name="../../../../drivers/bl702_driver/hal_drv/src/hal_cam.c">
<FileOption/>
</File>
<File Name="../../../../drivers/bl702_driver/hal_drv/src/hal_clock.c">
<FileOption/>
</File>
<File Name="../../../../drivers/bl702_driver/hal_drv/src/hal_common.c">
<FileOption/>
</File>
<File Name="../../../../drivers/bl702_driver/hal_drv/src/hal_dac.c">
<FileOption/>
</File>
<File Name="../../../../drivers/bl702_driver/hal_drv/src/hal_dma.c">
<FileOption/>
</File>
<File Name="../../../../drivers/bl702_driver/hal_drv/src/hal_emac.c">
<FileOption/>
</File>
<File Name="../../../../drivers/bl702_driver/hal_drv/src/hal_flash.c">
<FileOption/>
</File>
<File Name="../../../../drivers/bl702_driver/hal_drv/src/hal_gpio.c">
<FileOption/>
</File>
<File Name="../../../../drivers/bl702_driver/hal_drv/src/hal_i2c.c">
<FileOption/>
</File>
<File Name="../../../../drivers/bl702_driver/hal_drv/src/hal_i2s.c">
<FileOption/>
</File>
<File Name="../../../../drivers/bl702_driver/hal_drv/src/hal_keyscan.c">
<FileOption/>
</File>
<File Name="../../../../drivers/bl702_driver/hal_drv/src/hal_mjpeg.c">
<FileOption/>
</File>
<File Name="../../../../drivers/bl702_driver/hal_drv/src/hal_mtimer.c">
<FileOption/>
</File>
<File Name="../../../../drivers/bl702_driver/hal_drv/src/hal_pm.c">
<FileOption/>
</File>
<File Name="../../../../drivers/bl702_driver/hal_drv/src/hal_pwm.c">
<FileOption/>
</File>
<File Name="../../../../drivers/bl702_driver/hal_drv/src/hal_qdec.c">
<FileOption/>
</File>
<File Name="../../../../drivers/bl702_driver/hal_drv/src/hal_rtc.c">
<FileOption/>
</File>
<File Name="../../../../drivers/bl702_driver/hal_drv/src/hal_sec_aes.c">
<FileOption/>
</File>
<File Name="../../../../drivers/bl702_driver/hal_drv/src/hal_sec_dsa.c">
<FileOption/>
</File>
<File Name="../../../../drivers/bl702_driver/hal_drv/src/hal_sec_ecdsa.c">
<FileOption/>
</File>
<File Name="../../../../drivers/bl702_driver/hal_drv/src/hal_sec_hash.c">
<FileOption/>
</File>
<File Name="../../../../drivers/bl702_driver/hal_drv/src/hal_spi.c">
<FileOption/>
</File>
<File Name="../../../../drivers/bl702_driver/hal_drv/src/hal_timer.c">
<FileOption/>
</File>
<File Name="../../../../drivers/bl702_driver/hal_drv/src/hal_uart.c">
<FileOption/>
</File>
<File Name="../../../../drivers/bl702_driver/hal_drv/src/hal_usb.c">
<FileOption/>
</File>
<File Name="../../../../drivers/bl702_driver/hal_drv/src/hal_wdt.c">
<FileOption/>
</File>
</VirtualDirectory>
<VirtualDirectory Name="std">
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_acomp.c">
<FileOption/>
</File>
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_adc.c">
<FileOption/>
</File>
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_aon.c">
<FileOption/>
</File>
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_cam.c">
<FileOption/>
</File>
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_clock.c">
<FileOption/>
</File>
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_dac.c">
<FileOption/>
</File>
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_dma.c">
<FileOption/>
</File>
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_ef_ctrl.c">
<FileOption/>
</File>
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_emac.c">
<FileOption/>
</File>
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_glb.c">
<FileOption/>
</File>
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_hbn.c">
<FileOption/>
</File>
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_i2c.c">
<FileOption/>
</File>
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_i2c_gpio_sim.c">
<FileOption/>
</File>
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_i2s.c">
<FileOption/>
</File>
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_ir.c">
<FileOption/>
</File>
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_common.c">
<FileOption/>
</File>
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_kys.c">
<FileOption/>
</File>
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_l1c.c">
<FileOption/>
</File>
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_mjpeg.c">
<FileOption/>
</File>
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_pds.c">
<FileOption/>
</File>
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_psram.c">
<FileOption/>
</File>
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_pwm.c">
<FileOption/>
</File>
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_qdec.c">
<FileOption/>
</File>
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_romapi.c">
<FileOption/>
</File>
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_sec_dbg.c">
<FileOption/>
</File>
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_sec_eng.c">
<FileOption/>
</File>
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_sf_cfg.c">
<FileOption/>
</File>
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_sf_cfg_ext.c">
<FileOption/>
</File>
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_sf_ctrl.c">
<FileOption/>
</File>
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_sflash.c">
<FileOption/>
</File>
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_sflash_ext.c" ExcludeProjConfig="">
<FileOption/>
</File>
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_spi.c">
<FileOption/>
</File>
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_timer.c">
<FileOption/>
</File>
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_uart.c">
<FileOption/>
</File>
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_usb.c">
<FileOption/>
</File>
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_xip_sflash.c">
<FileOption/>
</File>
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_xip_sflash_ext.c">
<FileOption/>
</File>
</VirtualDirectory>
<VirtualDirectory Name="bsp">
<VirtualDirectory Name="board">
<File Name="../../../../bsp/board/bl702/board.c">
<FileOption/>
</File>
</VirtualDirectory>
<VirtualDirectory Name="bsp_common">
<File Name="../../../../bsp/bsp_common/platform/bflb_platform.c">
<FileOption/>
</File>
<File Name="../../../../bsp/bsp_common/platform/syscalls.c">
<FileOption/>
</File>
</VirtualDirectory>
</VirtualDirectory>
<VirtualDirectory Name="common">
<File Name="../../../../common/device/drv_device.c">
<FileOption/>
</File>
<File Name="../../../../common/memheap/drv_mmheap.c">
<FileOption/>
</File>
<File Name="../../../../common/ring_buffer/ring_buffer.c">
<FileOption/>
</File>
<File Name="../../../../common/soft_crc/softcrc.c">
<FileOption/>
</File>
<File Name="../../../../common/misc/misc.c">
<FileOption/>
</File>
</VirtualDirectory>
<VirtualDirectory Name="script">
<File Name="../../../../tools/openocd/bl70x_gdb.init">
<FileOption/>
</File>
<File Name="../../../../drivers/bl702_driver/regs/bl70x_reg.svc">
<FileOption/>
</File>
</VirtualDirectory>
<MonitorProgress>
<DebugLaunch>154</DebugLaunch>
<FlashOperate>104</FlashOperate>
</MonitorProgress>
<VirtualDirectory Name="components">
<VirtualDirectory Name="fatfs">
<File Name="../../../../components/fatfs/diskio.c">
<FileOption/>
</File>
<File Name="../../../../components/fatfs/ff.c">
<FileOption/>
</File>
<File Name="../../../../components/fatfs/ffsystem.c">
<FileOption/>
</File>
<File Name="../../../../components/fatfs/ffunicode.c">
<FileOption/>
</File>
</VirtualDirectory>
<VirtualDirectory Name="shell">
<File Name="../../../../components/shell/shell.c">
<FileOption/>
</File>
</VirtualDirectory>
<VirtualDirectory Name="usb_stack">
<VirtualDirectory Name="class">
<VirtualDirectory Name="cdc">
<File Name="../../../../components/usb_stack/class/cdc/usbd_cdc.c">
<FileOption/>
</File>
</VirtualDirectory>
<VirtualDirectory Name="hid">
<File Name="../../../../components/usb_stack/class/hid/usbd_hid.c">
<FileOption/>
</File>
</VirtualDirectory>
<VirtualDirectory Name="msc">
<File Name="../../../../components/usb_stack/class/msc/usbd_msc.c">
<FileOption/>
</File>
</VirtualDirectory>
</VirtualDirectory>
<VirtualDirectory Name="core">
<File Name="../../../../components/usb_stack/core/usbd_core.c">
<FileOption/>
</File>
</VirtualDirectory>
</VirtualDirectory>
</VirtualDirectory>
<Dependencies Name="BuildSet"/>
<DebugSessions>
<watchExpressions/>
<memoryExpressions>;;;</memoryExpressions>
<statistics>;;MHZ;</statistics>
<peripheralTabs>
<Tab disFormat="Hex">glb</Tab>
<Tab disFormat="Hex">uart</Tab>
</peripheralTabs>
<WatchDisplayFormat>1</WatchDisplayFormat>
<LocalDisplayFormat>1</LocalDisplayFormat>
<debugLayout/>
<memoryTabColSizeExpressions>100:8;100:8;100:8;100:8;</memoryTabColSizeExpressions>
</DebugSessions>
<DebugSessions>
<watchExpressions/>
<memoryExpressions>;;;</memoryExpressions>
<statistics>;;MHZ;</statistics>
<peripheralTabs>
<Tab disFormat="Hex">glb</Tab>
<Tab disFormat="Hex">uart</Tab>
</peripheralTabs>
<WatchDisplayFormat>1</WatchDisplayFormat>
<LocalDisplayFormat>1</LocalDisplayFormat>
<debugLayout/>
<memoryTabColSizeExpressions>100:8;100:8;100:8;100:8;</memoryTabColSizeExpressions>
</DebugSessions>
<Dependencies Name="CK_Link_Debug"/>
<Dependencies Name="OpenOCD_Debug"/>
<BuildConfigs>
<BuildConfig Name="CK_Link_Debug">
<Target>
<ROMBank Selected="1">
<ROM1>
<InUse>no</InUse>
<Start>0x23000000</Start>
<Size>0x100000</Size>
</ROM1>
<ROM2>
<InUse>no</InUse>
<Start>0x22014000</Start>
<Size>0x4000</Size>
</ROM2>
<ROM3>
<InUse>no</InUse>
<Start>0x42018000</Start>
<Size>0x8000</Size>
</ROM3>
<ROM4>
<InUse>no</InUse>
<Start/>
<Size/>
</ROM4>
<ROM5>
<InUse>no</InUse>
<Start/>
<Size/>
</ROM5>
</ROMBank>
<RAMBank>
<RAM1>
<InUse>yes</InUse>
<Start>0x42020000</Start>
<Size>0xc000</Size>
<Init>yes</Init>
</RAM1>
<RAM2>
<InUse>no</InUse>
<Start/>
<Size/>
<Init>yes</Init>
</RAM2>
<RAM3>
<InUse>no</InUse>
<Start/>
<Size/>
<Init>yes</Init>
</RAM3>
<RAM4>
<InUse>no</InUse>
<Start/>
<Size/>
<Init>yes</Init>
</RAM4>
<RAM5>
<InUse>no</InUse>
<Start/>
<Size/>
<Init>yes</Init>
</RAM5>
</RAMBank>
<CPU>rv32imafc</CPU>
<UseMiniLib>yes</UseMiniLib>
<Endian>little</Endian>
<UseHardFloat>no</UseHardFloat>
<UseEnhancedLRW>no</UseEnhancedLRW>
<UseContinueBuild>no</UseContinueBuild>
<UseSemiHost>no</UseSemiHost>
</Target>
<Output>
<OutputName>$(ProjectName)</OutputName>
<Type>Executable</Type>
<CreateHexFile>no</CreateHexFile>
<CreateBinFile>yes</CreateBinFile>
<Preprocessor>no</Preprocessor>
<Disassmeble>yes</Disassmeble>
<CallGraph>no</CallGraph>
<Map>yes</Map>
</Output>
<User>
<BeforeCompile>
<RunUserProg>no</RunUserProg>
<UserProgName/>
</BeforeCompile>
<BeforeMake>
<RunUserProg>no</RunUserProg>
<UserProgName/>
</BeforeMake>
<AfterMake>
<RunUserProg>no</RunUserProg>
<UserProgName>$(ProjectPath)../../../../tools/bflb_flash_tool/bflb_mcu_tool.exe --chipname=bl702 --interface=openocd --firmware="$(ProjectPath)/Obj/$(ProjectName).bin" </UserProgName>
</AfterMake>
</User>
<Compiler>
<Define>ARCH_RISCV;BFLB_USE_HAL_DRIVER;BFLB_USE_ROM_DRIVER;bl706_iot</Define>
<Undefine/>
<Optim>Optimize more (-O2)</Optim>
<DebugLevel>Default (-g)</DebugLevel>
<IncludePath>$(ProjectPath);$(ProjectPath)../;$(ProjectPath)../../../../components/fatfs;$(ProjectPath)../../../../components/freertos/Source/include;$(ProjectPath)../../../../components/shell;$(ProjectPath)../../../../components/usb_stack/class/audio;$(ProjectPath)../../../../components/usb_stack/class/cdc;$(ProjectPath)../../../../components/usb_stack/class/hid;$(ProjectPath)../../../../components/usb_stack/class/msc;$(ProjectPath)../../../../components/usb_stack/class/video;$(ProjectPath)../../../../components/usb_stack/class/webusb;$(ProjectPath)../../../../components/usb_stack/class/winusb;$(ProjectPath)../../../../components/usb_stack/common;$(ProjectPath)../../../../components/usb_stack/core;$(ProjectPath)../../../../bsp/board/bl702;$(ProjectPath)../../../../bsp/bsp_common/platform;$(ProjectPath)../../../../common/device;$(ProjectPath)../../../../common/list;$(ProjectPath)../../../../common/memheap;$(ProjectPath)../../../../common/misc;$(ProjectPath)../../../../common/ring_buffer;$(ProjectPath)../../../../common/soft_crc;$(ProjectPath)../../../../components/shell;$(ProjectPath)../../../../drivers/bl702_driver;$(ProjectPath)../../../../drivers/bl702_driver/hal_drv/default_config;$(ProjectPath)../../../../drivers/bl702_driver/hal_drv/inc;$(ProjectPath)../../../../drivers/bl702_driver/regs;$(ProjectPath)../../../../drivers/bl702_driver/startup;$(ProjectPath)../../../../drivers/bl702_driver/std_drv/inc;$(ProjectPath)../../../../drivers/bl602_driver/risc-v/Core/Include;$(ProjectPath)../../../../drivers/bl602_driver/hal_drv/inc;$(ProjectPath)../../../../drivers/bl602_driver/hal_drv/default_config;$(ProjectPath)../../../../drivers/bl602_driver/regs;$(ProjectPath)../../../../drivers/bl602_driver/std_drv/inc;$(ProjectPath)../../../../examples/at_client</IncludePath>
<OtherFlags>-fshort-enums -fno-common -fms-extensions -ffunction-sections -fdata-sections -fstrict-volatile-bitfields -Wall -Wshift-negative-value -Wchar-subscripts -Wformat -Wuninitialized -Winit-self -Wignored-qualifiers -Wunused -Wundef -msmall-data-limit=4 -std=c99</OtherFlags>
<Verbose>no</Verbose>
<Ansi>no</Ansi>
<Syntax>no</Syntax>
<Pedantic>no</Pedantic>
<PedanticErr>no</PedanticErr>
<InhibitWarn>no</InhibitWarn>
<AllWarn>yes</AllWarn>
<WarnErr>no</WarnErr>
<OneElfS>yes</OneElfS>
<OneElfSPerData>no</OneElfSPerData>
<Fstrict>no</Fstrict>
</Compiler>
<Asm>
<Define/>
<Undefine/>
<IncludePath>$(ProjectPath);$(ProjectPath)../;$(ProjectPath)../../../../components/fatfs;$(ProjectPath)../../../../components/freertos/Source/include;$(ProjectPath)../../../../components/shell;$(ProjectPath)../../../../components/usb_stack/class/audio;$(ProjectPath)../../../../components/usb_stack/class/cdc;$(ProjectPath)../../../../components/usb_stack/class/hid;$(ProjectPath)../../../../components/usb_stack/class/msc;$(ProjectPath)../../../../components/usb_stack/class/video;$(ProjectPath)../../../../components/usb_stack/class/webusb;$(ProjectPath)../../../../components/usb_stack/class/winusb;$(ProjectPath)../../../../components/usb_stack/common;$(ProjectPath)../../../../components/usb_stack/core;$(ProjectPath)../../../../bsp/board/bl702;$(ProjectPath)../../../../bsp/bsp_common/platform;$(ProjectPath)../../../../common/device;$(ProjectPath)../../../../common/list;$(ProjectPath)../../../../common/memheap;$(ProjectPath)../../../../common/misc;$(ProjectPath)../../../../common/ring_buffer;$(ProjectPath)../../../../common/soft_crc;$(ProjectPath)../../../../components/shell;$(ProjectPath)../../../../drivers/bl702_driver;$(ProjectPath)../../../../drivers/bl702_driver/hal_drv/default_config;$(ProjectPath)../../../../drivers/bl702_driver/hal_drv/inc;$(ProjectPath)../../../../drivers/bl702_driver/regs;$(ProjectPath)../../../../drivers/bl702_driver/startup;$(ProjectPath)../../../../drivers/bl702_driver/std_drv/inc;$(ProjectPath)../../../../drivers/bl602_driver/risc-v/Core/Include;$(ProjectPath)../../../../drivers/bl602_driver/startup;$(ProjectPath)../../../../drivers/bl602_driver/hal_drv/inc;$(ProjectPath)../../../../drivers/bl602_driver/hal_drv/default_config;$(ProjectPath)../../../../drivers/bl602_driver/regs;$(ProjectPath)../../../../drivers/bl602_driver/std_drv/inc</IncludePath>
<OtherFlags/>
<DebugLevel>gdwarf2</DebugLevel>
</Asm>
<Linker>
<Garbage>yes</Garbage>
<Garbage2>yes</Garbage2>
<LDFile>$(ProjectPath)../../../../drivers/bl702_driver/bl702_flash.ld</LDFile>
<LibName>c</LibName>
<LibPath/>
<OtherFlags>--specs=nano.specs</OtherFlags>
<AutoLDFile>no</AutoLDFile>
<LinkType/>
</Linker>
<Debug>
<LoadApplicationAtStartup>yes</LoadApplicationAtStartup>
<Connector>ICE</Connector>
<StopAt>yes</StopAt>
<StopAtText>main</StopAtText>
<InitFile/>
<AfterLoadFile>$(ProjectPath)/../../../../tools/openocd/bl70x_gdb.init</AfterLoadFile>
<AutoRun>yes</AutoRun>
<ResetType>Hard Reset</ResetType>
<SoftResetVal>23000000</SoftResetVal>
<ResetAfterLoad>no</ResetAfterLoad>
<AfterResetFile/>
<Dumpcore>no</Dumpcore>
<DumpcoreText>$(ProjectPath)/$(ProjectName).cdkcore</DumpcoreText>
<ConfigICE>
<IP>localhost</IP>
<PORT>1025</PORT>
<CPUNumber>0</CPUNumber>
<Clock>2000</Clock>
<Delay>10</Delay>
<WaitReset>50</WaitReset>
<DDC>yes</DDC>
<TRST>no</TRST>
<DebugPrint>no</DebugPrint>
<Connect>Normal</Connect>
<ResetType>Hard Reset</ResetType>
<SoftResetVal>21000000</SoftResetVal>
<RTOSType>Bare Metal</RTOSType>
<DownloadToFlash>yes</DownloadToFlash>
<ResetAfterConnect>yes</ResetAfterConnect>
<GDBName/>
<GDBServerType>Local</GDBServerType>
<OtherFlags>-arch riscv</OtherFlags>
</ConfigICE>
<ConfigSIM>
<SIMTarget/>
<OtherFlags/>
<NoGraphic>yes</NoGraphic>
<Log>no</Log>
<SimTrace>no</SimTrace>
</ConfigSIM>
<ConfigOpenOCD>
<OpenOCDExecutablePath>openocd-hifive</OpenOCDExecutablePath>
<OpenOCDTelnetPortEnable>no</OpenOCDTelnetPortEnable>
<OpenOCDTelnetPort>4444</OpenOCDTelnetPort>
<OpenOCDTclPortEnable>no</OpenOCDTclPortEnable>
<OpenOCDTclPort>6666</OpenOCDTclPort>
<OpenOCDConfigOptions>-f ../../../../tools/openocd/if_rv_dbg_plus.cfg -f ../../../../tools/openocd/tgt_702.cfg</OpenOCDConfigOptions>
<OpenOCDTimeout>5000</OpenOCDTimeout>
</ConfigOpenOCD>
</Debug>
<Flash>
<InitFile/>
<Erase>Erase Sectors</Erase>
<Algorithms Path="">bl702_flasher.elf</Algorithms>
<Program>yes</Program>
<Verify>yes</Verify>
<ResetAndRun>no</ResetAndRun>
<ResetType>Hard Reset</ResetType>
<SoftResetVal/>
<External>no</External>
<Command/>
<Arguments/>
</Flash>
</BuildConfig>
<BuildConfig Name="OpenOCD_Debug">
<Target>
<ROMBank Selected="1">
<ROM1>
<InUse>no</InUse>
<Start>0x23000000</Start>
<Size>0x100000</Size>
</ROM1>
<ROM2>
<InUse>no</InUse>
<Start>0x22014000</Start>
<Size>0x4000</Size>
</ROM2>
<ROM3>
<InUse>no</InUse>
<Start>0x42018000</Start>
<Size>0x8000</Size>
</ROM3>
<ROM4>
<InUse>no</InUse>
<Start/>
<Size/>
</ROM4>
<ROM5>
<InUse>no</InUse>
<Start/>
<Size/>
</ROM5>
</ROMBank>
<RAMBank>
<RAM1>
<InUse>yes</InUse>
<Start>0x42020000</Start>
<Size>0xc000</Size>
<Init>yes</Init>
</RAM1>
<RAM2>
<InUse>no</InUse>
<Start/>
<Size/>
<Init>yes</Init>
</RAM2>
<RAM3>
<InUse>no</InUse>
<Start/>
<Size/>
<Init>yes</Init>
</RAM3>
<RAM4>
<InUse>no</InUse>
<Start/>
<Size/>
<Init>yes</Init>
</RAM4>
<RAM5>
<InUse>no</InUse>
<Start/>
<Size/>
<Init>yes</Init>
</RAM5>
</RAMBank>
<CPU>rv32imafc</CPU>
<UseMiniLib>yes</UseMiniLib>
<Endian>little</Endian>
<UseHardFloat>no</UseHardFloat>
<UseEnhancedLRW>no</UseEnhancedLRW>
<UseContinueBuild>no</UseContinueBuild>
<UseSemiHost>no</UseSemiHost>
</Target>
<Output>
<OutputName>$(ProjectName)</OutputName>
<Type>Executable</Type>
<CreateHexFile>no</CreateHexFile>
<CreateBinFile>yes</CreateBinFile>
<Preprocessor>no</Preprocessor>
<Disassmeble>yes</Disassmeble>
<CallGraph>no</CallGraph>
<Map>yes</Map>
</Output>
<User>
<BeforeCompile>
<RunUserProg>no</RunUserProg>
<UserProgName/>
</BeforeCompile>
<BeforeMake>
<RunUserProg>no</RunUserProg>
<UserProgName/>
</BeforeMake>
<AfterMake>
<RunUserProg>no</RunUserProg>
<UserProgName>$(ProjectPath)../../../../tools/bflb_flash_tool/bflb_mcu_tool.exe --chipname=bl702 --interface=openocd --firmware="$(ProjectPath)/Obj/$(ProjectName).bin" </UserProgName>
</AfterMake>
</User>
<Compiler>
<Define>ARCH_RISCV;BFLB_USE_HAL_DRIVER;BFLB_USE_ROM_DRIVER;bl706_iot</Define>
<Undefine/>
<Optim>Optimize more (-O2)</Optim>
<DebugLevel>Default (-g)</DebugLevel>
<IncludePath>$(ProjectPath);$(ProjectPath)../;$(ProjectPath)../../../../components/fatfs;$(ProjectPath)../../../../components/freertos/Source/include;$(ProjectPath)../../../../components/shell;$(ProjectPath)../../../../components/usb_stack/class/audio;$(ProjectPath)../../../../components/usb_stack/class/cdc;$(ProjectPath)../../../../components/usb_stack/class/hid;$(ProjectPath)../../../../components/usb_stack/class/msc;$(ProjectPath)../../../../components/usb_stack/class/video;$(ProjectPath)../../../../components/usb_stack/class/webusb;$(ProjectPath)../../../../components/usb_stack/class/winusb;$(ProjectPath)../../../../components/usb_stack/common;$(ProjectPath)../../../../components/usb_stack/core;$(ProjectPath)../../../../bsp/board/bl702;$(ProjectPath)../../../../bsp/bsp_common/platform;$(ProjectPath)../../../../common/device;$(ProjectPath)../../../../common/list;$(ProjectPath)../../../../common/memheap;$(ProjectPath)../../../../common/misc;$(ProjectPath)../../../../common/ring_buffer;$(ProjectPath)../../../../common/soft_crc;$(ProjectPath)../../../../components/shell;$(ProjectPath)../../../../drivers/bl702_driver;$(ProjectPath)../../../../drivers/bl702_driver/hal_drv/default_config;$(ProjectPath)../../../../drivers/bl702_driver/hal_drv/inc;$(ProjectPath)../../../../drivers/bl702_driver/regs;$(ProjectPath)../../../../drivers/bl702_driver/startup;$(ProjectPath)../../../../drivers/bl702_driver/std_drv/inc</IncludePath>
<OtherFlags>-fshort-enums -fno-common -fms-extensions -ffunction-sections -fdata-sections -fstrict-volatile-bitfields -Wall -Wshift-negative-value -Wchar-subscripts -Wformat -Wuninitialized -Winit-self -Wignored-qualifiers -Wunused -Wundef -msmall-data-limit=4 -std=c99</OtherFlags>
<Verbose>no</Verbose>
<Ansi>no</Ansi>
<Syntax>no</Syntax>
<Pedantic>no</Pedantic>
<PedanticErr>no</PedanticErr>
<InhibitWarn>no</InhibitWarn>
<AllWarn>yes</AllWarn>
<WarnErr>no</WarnErr>
<OneElfS>yes</OneElfS>
<OneElfSPerData>no</OneElfSPerData>
<Fstrict>no</Fstrict>
</Compiler>
<Asm>
<Define/>
<Undefine/>
<IncludePath>$(ProjectPath);$(ProjectPath)../;$(ProjectPath)../../../../components/fatfs;$(ProjectPath)../../../../components/freertos/Source/include;$(ProjectPath)../../../../components/shell;$(ProjectPath)../../../../components/usb_stack/class/audio;$(ProjectPath)../../../../components/usb_stack/class/cdc;$(ProjectPath)../../../../components/usb_stack/class/hid;$(ProjectPath)../../../../components/usb_stack/class/msc;$(ProjectPath)../../../../components/usb_stack/class/video;$(ProjectPath)../../../../components/usb_stack/class/webusb;$(ProjectPath)../../../../components/usb_stack/class/winusb;$(ProjectPath)../../../../components/usb_stack/common;$(ProjectPath)../../../../components/usb_stack/core;$(ProjectPath)../../../../bsp/board/bl702;$(ProjectPath)../../../../bsp/bsp_common/platform;$(ProjectPath)../../../../common/device;$(ProjectPath)../../../../common/list;$(ProjectPath)../../../../common/memheap;$(ProjectPath)../../../../common/misc;$(ProjectPath)../../../../common/ring_buffer;$(ProjectPath)../../../../common/soft_crc;$(ProjectPath)../../../../components/shell;$(ProjectPath)../../../../drivers/bl702_driver;$(ProjectPath)../../../../drivers/bl702_driver/hal_drv/default_config;$(ProjectPath)../../../../drivers/bl702_driver/hal_drv/inc;$(ProjectPath)../../../../drivers/bl702_driver/regs;$(ProjectPath)../../../../drivers/bl702_driver/startup;$(ProjectPath)../../../../drivers/bl702_driver/std_drv/inc;$(ProjectPath)../../../../drivers/bl602_driver/risc-v/Core/Include;$(ProjectPath)../../../../drivers/bl602_driver/startup;$(ProjectPath)../../../../drivers/bl602_driver/hal_drv/inc;$(ProjectPath)../../../../drivers/bl602_driver/hal_drv/default_config;$(ProjectPath)../../../../drivers/bl602_driver/regs;$(ProjectPath)../../../../drivers/bl602_driver/std_drv/inc</IncludePath>
<OtherFlags/>
<DebugLevel>gdwarf2</DebugLevel>
</Asm>
<Linker>
<Garbage>yes</Garbage>
<Garbage2>yes</Garbage2>
<LDFile>$(ProjectPath)../../../../drivers/bl702_driver/bl702_flash.ld</LDFile>
<LibName>c</LibName>
<LibPath/>
<OtherFlags>--specs=nano.specs</OtherFlags>
<AutoLDFile>no</AutoLDFile>
<LinkType/>
</Linker>
<Debug>
<LoadApplicationAtStartup>yes</LoadApplicationAtStartup>
<Connector>OpenOCD</Connector>
<StopAt>yes</StopAt>
<StopAtText>main</StopAtText>
<InitFile/>
<AfterLoadFile>$(ProjectPath)/../../../../tools/openocd/bl70x_gdb.init</AfterLoadFile>
<AutoRun>yes</AutoRun>
<ResetType>Hard Reset</ResetType>
<SoftResetVal>23000000</SoftResetVal>
<ResetAfterLoad>no</ResetAfterLoad>
<AfterResetFile/>
<Dumpcore>no</Dumpcore>
<DumpcoreText>$(ProjectPath)/$(ProjectName).cdkcore</DumpcoreText>
<ConfigICE>
<IP>localhost</IP>
<PORT>1025</PORT>
<CPUNumber>0</CPUNumber>
<Clock>2000</Clock>
<Delay>10</Delay>
<WaitReset>50</WaitReset>
<DDC>yes</DDC>
<TRST>no</TRST>
<DebugPrint>no</DebugPrint>
<Connect>Normal</Connect>
<ResetType>Hard Reset</ResetType>
<SoftResetVal>21000000</SoftResetVal>
<RTOSType>Bare Metal</RTOSType>
<DownloadToFlash>yes</DownloadToFlash>
<ResetAfterConnect>yes</ResetAfterConnect>
<GDBName/>
<GDBServerType>Local</GDBServerType>
<OtherFlags>-arch riscv</OtherFlags>
</ConfigICE>
<ConfigSIM>
<SIMTarget/>
<OtherFlags/>
<NoGraphic>yes</NoGraphic>
<Log>no</Log>
<SimTrace>no</SimTrace>
</ConfigSIM>
<ConfigOpenOCD>
<OpenOCDExecutablePath>openocd-hifive</OpenOCDExecutablePath>
<OpenOCDTelnetPortEnable>no</OpenOCDTelnetPortEnable>
<OpenOCDTelnetPort>4444</OpenOCDTelnetPort>
<OpenOCDTclPortEnable>no</OpenOCDTclPortEnable>
<OpenOCDTclPort>6666</OpenOCDTclPort>
<OpenOCDConfigOptions>-f ../../../../tools/openocd/if_rv_dbg_plus.cfg -f ../../../../tools/openocd/tgt_702.cfg</OpenOCDConfigOptions>
<OpenOCDTimeout>5000</OpenOCDTimeout>
</ConfigOpenOCD>
</Debug>
<Flash>
<InitFile/>
<Erase>Erase Sectors</Erase>
<Algorithms Path="">bl70x_flasher.elf</Algorithms>
<Program>yes</Program>
<Verify>yes</Verify>
<ResetAndRun>no</ResetAndRun>
<ResetType>Hard Reset</ResetType>
<SoftResetVal/>
<External>no</External>
<Command/>
<Arguments/>
</Flash>
</BuildConfig>
</BuildConfigs>
</Project>

View File

@ -0,0 +1,86 @@
/**
* @file main.c
* @brief
*
* Copyright (c) 2021 Bouffalolab team
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
*/
#include "bflb_platform.h"
#include "at.h"
#define UART_RECV_BUF_SZIE 64
uint8_t recv_buf[UART_RECV_BUF_SZIE];
struct at_client static_client;
static const char *http_get = "GET https://api.seniverse.com/v3/weather/now.json?key=SCeYO8heOo9MPuTxY&location=beijing&language=zh-Hans&unit=c\r\n";
int main(void)
{
int ret = 0;
uint32_t recv_len = 0;
uint8_t recv_buffer[1024] = { 0 };
bflb_platform_init(0);
at_client_init();
memset(&static_client, 0, sizeof(struct at_client));
static_client.recv_line_buf = recv_buf;
static_client.recv_bufsz = UART_RECV_BUF_SZIE;
static_client.resp_succ = "OK";
static_client.resp_err = NULL;
static_client.timeout = 200;
ret = at_exe_cmd(&static_client, "AT");
//static_client.timeout = 1000;
//ret = at_exe_cmd(&static_client, "AT+RST");
ret = at_exe_cmd(&static_client, "AT+CWMODE=1");
ret = at_exe_cmd(&static_client, "AT+CIPRECVCFG=1");
static_client.resp_succ = "wifi connected";
static_client.resp_err = NULL;
static_client.timeout = 5000;
while (at_exe_cmd(&static_client, "AT+CWJAP=\"%s\",\"%s\"", "OPPO Reno4 5G", "12345678") < 0) {
}
MSG("wifi connected success\r\n");
bflb_platform_delay_ms(1000);
static_client.resp_succ = "CONNECTED";
static_client.resp_err = "ERROR: Connect fail";
static_client.timeout = 5000;
while (at_exe_cmd(&static_client, "AT+CIPSTART=0,\"TCP\",\"%s\",%d", "116.62.81.138", 80) < 0) {
}
MSG("tcp connected\r\n");
bflb_platform_delay_ms(1000);
at_write_recv((uint8_t *)http_get, 114, recv_buffer, &recv_len, 5000);
at_dump_hex(recv_buffer, recv_len);
while (1) {
bflb_platform_delay_ms(1000);
}
}

View File

@ -0,0 +1,10 @@
**board/bl706_iot/pinmux_config.h** 中 **CONFIG_GPIO18_FUNC** 选择 **GPIO_FUN_UART1_TX**, **CONFIG_GPIO19_FUNC** 选择 **GPIO_FUN_UART1_RX**
- UART1_TX 连接 BL602 GPIO3 (UART RX)
- UART1_RX 连接 BL602 GPIO4 (UART TX)
```bash
$ make APP=at_client BOARD=bl706_iot
```

Binary file not shown.