完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
ESP32s3 I2c0 SCL一直高电平,没有时钟输出,SDA也是一直高电平
日志显示初始化成功 I (4197) driver-codec: i2s driver init success I (9197) driver-codec: I2C_MASTER_NUM=0,mode=1,speed=100000 I (9197) driver-codec: I2C initialized successfully I (9207) driver-codec: i2c_read cnt = 0, error = -1 代码如下: #define I2C0_MASTER_SCL_IO 18 /*!< GPIO number used for I2C master clock */ #define I2C0_MASTER_SDA_IO 17 /*!< GPIO number used for I2C master data */ static esp_err_t i2c_master_init(void) { int i2c_master_port = I2C_MASTER_NUM; i2c_config_t conf = { .mode = I2C_MODE_MASTER, .sda_io_num = I2C0_MASTER_SDA_IO, .scl_io_num = I2C0_MASTER_SCL_IO, .sda_pullup_en = GPIO_PULLUP_ENABLE, .scl_pullup_en = GPIO_PULLUP_ENABLE, .master.clk_speed = I2C_MASTER_FREQ_HZ, .clk_flags = 0, }; esp_err_t err = i2c_param_config(i2c_master_port, &conf); if (err != ESP_OK) { return err; } ESP_LOGI(TAG, "I2C_MASTER_NUM=%d,mode=%d,speed=%d",i2c_master_port,conf.mode,conf.master.clk_speed); return i2c_driver_install(i2c_master_port, conf.mode, I2C_MASTER_RX_BUF_DISABLE, I2C_MASTER_TX_BUF_DISABLE, 0); } uint16_t AW88266A_i2c_read(unsigned char reg_addr) { int ret; uint8_t cnt = 0; uint8_t data_buff[2] = {0}; uint16_t data = 0; while (cnt < I2C_RETRY_TIMES) { ret = i2c_master_write_read_device(I2C_MASTER_NUM, AW88266A_CODEC_ADDR, ®_addr, 1, data_buff, 2, I2C_MASTER_TIMEOUT_MS / portTICK_PERIOD_MS); if (ret != 0) ESP_LOGI(TAG, "i2c_read cnt = %d, error = %dn", cnt, ret); else break; cnt++; } data = (((data_buff[0] << 8) & 0xff00) | (data_buff[1] & 0x00ff)); ESP_LOGI(TAG, "i2c_read data = %dn", data); return data; } |
|
相关推荐
|
|
只有小组成员才能发言,加入小组>>
350 浏览 0 评论
1196 浏览 1 评论
588浏览 6评论
484浏览 5评论
有没有办法在不使用混杂模式的情况下实现Wifi驱动程序接收缓冲区访问中断呢?
468浏览 5评论
467浏览 4评论
445浏览 4评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-29 15:32 , Processed in 0.910876 second(s), Total 73, Slave 57 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号