F1C200s使用去掉Flash的ESP12F做无线网卡?
-
F1C200s作为主机,8266作为SPI从机,注册SPI从设备的时候,进入probe函数,如下,调用了如下函数:
err = sif_spi_protocol_init(spi); //发送一堆指令
probe函数:
static int esp_spi_probe(struct spi_device *spi) { int err; struct esp_pub *epub; struct esp_spi_ctrl *sctrl; static int dt_get_n=1; if(dt_get_n > 0 ) { esp8089_get_dt_data(spi); // 获取设备树信息 dt_get_n--; } printk("esp8089_spi: %s ENTER\n", __func__); //esp_dbg(ESP_DBG_ERROR, "esp8089_spi: %s enter\n", __func__); /* -------------------------------------------------------------------------- */\ printk(KERN_ERR "esp8089_spi: %s Set CS LOW\n", __func__); gpio_request(esp_cs0_pin, "esp_cs0_pin");// #include "spi_stub.c" gpio_direction_output(esp_cs0_pin,0); gpio_free(esp_cs0_pin); err = esp_setup_spi(spi); //分配一些内存,设置参数 if (err) { esp_dbg(ESP_DBG_ERROR, "esp8089_spi: %s setup_spi error[%d]\n", __func__, err); if(sif_sdio_state == ESP_SDIO_STATE_FIRST_INIT) goto _err_spi; else goto _err_second_init; } //esp_dbg(ESP_DBG_ERROR, "esp8089_spi: %s init_protocol\n", __func__); /* -------------------------------------------------------------------------- */ err = sif_spi_protocol_init(spi); //发送一堆指令 ......
但是这个sif_spi_protocol_init函数,是通过spi向8266发送指令,而且的确有收到8266的返回指令。这里我有几个疑问:
1.发送的这个是什么指令?
2.代码运行到此处,还没有下载固件,为什么8266可以响应spi指令?
3.8266手册上讲,8266作为spi从机,协议是Command(8Bits)+address(8Bits)+read/write data(32Bytes),也就是34个字节,为什么这里只有6个字节?
恳请大佬不吝赐教!感谢!int sif_spi_protocol_init(struct spi_device *spi) { unsigned char spi_proto_ini_status = 0; unsigned char rx_buf1[10]; unsigned char tx_buf1[10]; unsigned char dummy_tx_buf[10]; memset(dummy_tx_buf,0xff,sizeof(dummy_tx_buf)); printk("esp8089_spi: %s\n", __func__); do { //会依次执行下面的命令, if( spi_proto_ini_status == 0 ) { int fail_count = 0; do { //第二层循环 tx_buf1[0]=0x40; tx_buf1[1]=0x00; tx_buf1[2]=0x00; tx_buf1[3]=0x00; tx_buf1[4]=0x00; tx_buf1[5]=0x95; //printf("CMD0 \n"); printk("esp8089_spi: %s, %d\n", __FILE__, __LINE__); printk("esp8089_spi: fail_count = %d\n", fail_count); sif_spi_write_raw_proto(spi, tx_buf1, 6); mdelay(100); sif_spi_write_async_read_proto(spi, dummy_tx_buf, rx_buf1, 10); esp_dbg(ESP_DBG_ERROR, "rx:[0x%02x],[0x%02x],[0x%02x],[0x%02x],[0x%02x],[0x%02x],[0x%02x],[0x%02x],[0x%02x],[0x%02x]\n", rx_buf1[0],rx_buf1[1],rx_buf1[2],rx_buf1[3],rx_buf1[4],rx_buf1[5],rx_buf1[6],rx_buf1[7],rx_buf1[8],rx_buf1[9]); mdelay(100); if(++fail_count > 10) return -ETIMEDOUT; } while( rx_buf1[2] != 0x01 ); } else if( spi_proto_ini_status == 1 ) { tx_buf1[0]=0x45; tx_buf1[1]=0x00; tx_buf1[2]=0x20; //0x04; tx_buf1[3]=0x00; tx_buf1[4]=0x00; tx_buf1[5]=0x01; //spi_err("CMD 5 1st\n"); printk("esp8089_spi: %s, %d\n", __FILE__, __LINE__); sif_spi_write_raw(spi, tx_buf1, 6); sif_spi_write_async_read(spi,dummy_tx_buf, rx_buf1,10); esp_dbg(ESP_DBG_ERROR, "rx:[0x%02x],[0x%02x],[0x%02x],[0x%02x],[0x%02x],[0x%02x],[0x%02x],[0x%02x],[0x%02x],[0x%02x]\n", rx_buf1[0],rx_buf1[1],rx_buf1[2],rx_buf1[3],rx_buf1[4],rx_buf1[5],rx_buf1[6],rx_buf1[7],rx_buf1[8],rx_buf1[9]); } else if( spi_proto_ini_status == 2 ) { tx_buf1[0]=0x45; tx_buf1[1]=0x00; tx_buf1[2]=0x20; tx_buf1[3]=0x00; tx_buf1[4]=0x00; tx_buf1[5]=0x01; //spi_err("CMD5 2nd\n"); printk("esp8089_spi: %s, %d\n", __FILE__, __LINE__); sif_spi_write_raw(spi, tx_buf1, 6); sif_spi_write_async_read(spi,dummy_tx_buf, rx_buf1,10); esp_dbg(ESP_DBG_ERROR, "rx:[0x%02x],[0x%02x],[0x%02x],[0x%02x],[0x%02x],[0x%02x],[0x%02x],[0x%02x],[0x%02x],[0x%02x]\n", rx_buf1[0],rx_buf1[1] ,rx_buf1[2],rx_buf1[3],rx_buf1[4],rx_buf1[5],rx_buf1[6],rx_buf1[7],rx_buf1[8],rx_buf1[9]); } ...
Copyright © 2024 深圳全志在线有限公司 粤ICP备2021084185号 粤公网安备44030502007680号