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

發布
問題