完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
我在使用 LilyGo-T-Wristband 板将 Arduino 代码移植到本机 idf-esp 代码时遇到问题。无法通过 SPI 从 ST7735 读取 ID 寄存器。这是我的 SPI init 代码并阅读:
代码: gpio_config_t io_conf; io_conf.intr_type = GPIO_INTR_DISABLE; io_conf.mode = GPIO_MODE_OUTPUT; io_conf.pull_down_en = GPIO_PULLDOWN_DISABLE; io_conf.pull_up_en = GPIO_PULLUP_DISABLE; io_conf.pin_bit_mask = (1ULL< esp_err_t ret; spi_bus_config_t buscfg; memset(&buscfg,0,sizeof(buscfg)); buscfg.miso_io_num= -1; //no MISO line buscfg.mosi_io_num=TFT_MOSI; buscfg.sclk_io_num=TFT_SCLK; buscfg.quadhd_io_num=-1; buscfg.max_transfer_sz=160*80*2; buscfg.quadwp_io_num = -1; buscfg.flags = SPICOMMON_BUSFLAG_MASTER; spi_device_interface_config_t devcfg; memset(&devcfg, 0, sizeof(devcfg)); devcfg.clock_speed_hz=SPI_READ_FREQUENCY; //Clock out at 10 MHz devcfg.mode=0; //SPI mode 0 devcfg.spics_io_num=TFT_CS; //CS pin devcfg.queue_size=1; devcfg.flags = SPI_DEVICE_HALFDUPLEX; //Initialize the SPI bus ret=spi_bus_initialize(SPI2_HOST, &buscfg, SPI_DMA_DISABLED); ESP_ERROR_CHECK(ret); //Attach the LCD to the SPI bus ret=spi_bus_add_device(SPI2_HOST, &devcfg, &my_spi); ESP_ERROR_CHECK(ret); //read the ID register 0x04 gpio_set_level(TFT_DC, 0); //set command mode uint8_t cmd = (0x4); spi_transaction_t t; memset(&t, 0, sizeof(t)); //Zero out the transaction t.length=8; //Command is 8 bits t.rxlength = 0; t.tx_buffer=&cmd; //The data is the cmd itself t.rx_buffer = NULL; t.user=(void*)0; //D/C needs to be set to 0 ESP_ERROR_CHECK(spi_device_polling_transmit(my_spi, &t)); //Transmit! gpio_set_level(TFT_DC, 1); //set DATA mode uint8_t rbuf[4] = {0}; memset(&t, 0, sizeof(spi_transaction_t)); t.tx_buffer=NULL; //send nothing t.length=0; //send nothing t.rx_buffer=rbuf; //receive RGB data to buffer t.rxlength=8*3; //one line size in bits t.flags=0; //undo SPI_TRANS_USE_TXDATA flag t.user=(void*)1; ESP_ERROR_CHECK(spi_device_polling_transmit(my_spi, &t)); //Transmit! 有任何想法吗? |
|
相关推荐
|
|
只有小组成员才能发言,加入小组>>
1030 浏览 1 评论
562浏览 6评论
470浏览 5评论
有没有办法在不使用混杂模式的情况下实现Wifi驱动程序接收缓冲区访问中断呢?
454浏览 5评论
454浏览 4评论
428浏览 4评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-4 01:07 , Processed in 0.581569 second(s), Total 43, Slave 36 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号