isme
isme - 认证专家
冰镇大西瓜

注册于 2 年前

回答
280
文章
17
关注者
23

    u8 auto_reconnect = 0xff; 
    tls_wifi_auto_connect_flag (WIFI_AUTO_CNT_FLAG_GET,  &auto_reconnect) ; 
    if (auto_reconnect ! = WIFI_AUTO_CNT_ON) 
    {
        auto_reconnect = WIFI_AUTO_CNT_ON; 
        tls_wifi_auto_connect_flag (WIFI_AUTO_CNT_FLAG_SET,  &auto_reconnect) ;  
        tls_wifi_connect ( (u8 *) "w600",  strlen ("w600") ,   (u8 *) "12345678",  strlen ("12345678") ) ; 
        printf ("---" WIFI_AUTO_CNT_FLAG_SET ON\n") ; 
    }

image. png
1. 这个函数接口返回的是蓝牙状态.
image. png
2. 目前用的是哪个蓝牙库? 需要对看上面对应的文档资料, SDK 默认用的是 NimBLE 版.
3. 你指的蓝牙参数是什么?

W80X 系列芯片 fls 格式固件只能通过串口 0 烧录, 或者通过 CK-LINK 下载 img 程序.

HSPI 只能做为从机, 最高时钟频率 50MHZ, 跟普通 SPI 用法有些许区别.
LSPI 可以做为主机, 最高时钟频率 20MHZ, 跟普通 SPI 用法完全一致.

我重新弄了一个驱动, 板子自身也有发热的情况, 可能本身硬件精度就不是很好.

/***************************************************************************** 
* 
* File Name :  main. c
* 
* Description:  main 
* 
* Copyright  (c)  2014 Winner Micro Electronic Design Co. ,  Ltd.  
* All rights reserved.  
* 
* Author :  dave
* 
* Date :  2014-6-14
*****************************************************************************/ 
#include "wm_include. h"
#include "wm_i2c. h"
#include "stdio. h"
#include "wm_gpio_afsel. h"

#define I2C_FREQ         (5000) 
#define I2C_ADDR         (0x80) 

u8 buf[4]; 

void cht8305_iic_init (void) 
{
    wm_i2c_scl_config (WM_IO_PA_01) ; 
    wm_i2c_sda_config (WM_IO_PA_04) ; 
    
    tls_i2c_init (I2C_FREQ) ; 
}
 
void cht8305_read_reg (u8 reg_addr, u8 len) 
{
    tls_i2c_write_byte (I2C_ADDR,  1) ;  
    tls_i2c_wait_ack () ;     
    tls_i2c_write_byte (reg_addr,  0) ; 
    tls_i2c_wait_ack () ;     
    if  (reg_addr == 0x00 || reg_addr == 0x01) 
    {
        tls_os_time_delay (5) ;  // 10ms delay
    }
    tls_i2c_write_byte (I2C_ADDR|0x01, 1) ;    

    for  (int i = 0;  i  " len-1;  i++)  {
        buf[i] = tls_i2c_read_byte (1, 0) ; 
    }

    buf[len - 1] = tls_i2c_read_byte (0,  1) ;  //Give NACK
}
void cht8305_get_temp_humi (float *t,  float *h) 
{
    cht8305_read_reg (0x00,  4) ; 
    unsigned int th,  tl,  hh,  hl; 
    th = buf[0]; 
    tl = buf[1]; 
    hh = buf[2]; 
    hl = buf[3]; 
     (*t)  =  (th  " " 8 | tl)  * 165. 0 / 65535. 0 - 40. 0; 
     (*h)  =  (hh  " " 8 | hl)  * 100. 0 / 65535. 0; 
}

void UserMain (void) 
{
    printf ("\n user task \n") ; 
    cht8305_iic_init () ; 
    float  ct8305_temp ; 
    float  ct8305_humi; 
    while (1) 
    {
        cht8305_get_temp_humi (&ct8305_temp, &ct8305_humi) ; 
        printf ("upload_hygrotherm ct8305_temp %f, ct8305_humi %f\r\n", ct8305_temp, ct8305_humi) ; 
        tls_os_time_delay (100) ;  // delay 200ms
    }

#if DEMO_CONSOLE
    CreateDemoTask () ; 
#endif
//用户自己的 task
}

image. png
image. png

问题需要描述清楚哦, 如果是 BT 经典蓝牙的 API 使用可以看.
WM_W800_蓝牙系统架构以及 API 描述_V1. 2. pdf

1. 主动联网切换 WIFI 时可以先调用 tls_wifi_disconnect () ; 接口断开网络.
2. 我看你现在这个流程不是很合理, 正常情况下, 模块最好通过类似按键的触发机制让模块进入配网模式, 配网成功后打开自动重连功能, 模块断开连接或者重新上电是能够自动重新连接上 WIFI, 而当想切换 WIFI 网络时, 重新通过按键或其他触发机制进入配网模式即可.

目前 W806 不支持 OTA 升级, 如果需要升级, 可以通过下拉芯片 bootloader 脚进入烧录模式, 然后通过串口 xmodem 协议向芯片发送固件升级.

W800 默认所有函数都是 xip 运行, xip 相比于 ram 运行速率更低, 如果算法对算力有要求, 可以指定一些函数在 ram 运行, 实现方法如下:
  1. 给函数设置 attribute
__attribute__ ( (section (". sram. text") ) ) 
int TestSram (void) 
{
    return 0; 
}
  1. 修改 gcc_csky. ld, 在. data 中添加如下一行
  * (. sram. text) 
W800 还支持某些文件或者某些库的代码段都在 ram 运行, 实现方法如下:
  1. 修改 gcc_csky. ld, 在. text 把下面三行
  * (. text) 
  * (. text*) 
  * (. text. *) 

替换为

  * (EXCLUDE_FILE  (*libuser. a *wm_diy_demo. o) . text*) 
  1. 修改 gcc_csky. ld, 在. data 中添加如下一行
  * (. text*) 
W800 支持一些只读全局变量加载到 ram, 实现方法如下
  1. 给全局变量设置 attribute
 __attribute__ ( (section (". sram. data") ) ) 
char sram_buf[16] = "hello"; 
  1. 修改 gcc_csky. ld, 在. data 中添加如下一行
  * (. sram. data) 

以上内容来源于大神@Alex

发布
问题