Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit48c1cd6

Browse files
committed
merge: Merge branch 'mr-i2c-issue-fix' into develop.
Signed-off-by: lbuque <1102390310@qq.com>
2 parents3769f0b +5e432be commit48c1cd6

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

‎m5stack/machine_i2c.c‎

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,10 +210,33 @@ void free_bus(uint8_t pos) {
210210
intmachine_hw_i2c_transfer(mp_obj_base_t*self_in,uint16_taddr,size_tn,mp_machine_i2c_buf_t*bufs,unsignedintflags) {
211211
machine_hw_i2c_obj_t*self=MP_OBJ_TO_PTR(self_in);
212212
i2c_cmd_handle_tcmd=i2c_cmd_link_create();
213+
214+
intdata_len=0;
215+
216+
if (flags&MP_MACHINE_I2C_FLAG_WRITE1) {
217+
i2c_master_start(cmd);
218+
i2c_master_write_byte(cmd,addr <<1, true);
219+
i2c_master_write(cmd,bufs->buf,bufs->len, true);
220+
data_len+=bufs->len;
221+
--n;
222+
++bufs;
223+
}
224+
213225
i2c_master_start(cmd);
214226
i2c_master_write_byte(cmd,addr <<1 | (flags&MP_MACHINE_I2C_FLAG_READ), true);
215227

216-
intdata_len=0;
228+
// printf("I2C transfer: addr=%02X, n=%u", addr, n);
229+
// if (flags & MP_MACHINE_I2C_FLAG_READ) {
230+
// printf(", read");
231+
// }
232+
// else if (flags & MP_MACHINE_I2C_FLAG_STOP) {
233+
// printf(", stop");
234+
// }
235+
// else {
236+
// printf(", write");
237+
// }
238+
// printf("\n");
239+
217240
for (;n--;++bufs) {
218241
if (flags&MP_MACHINE_I2C_FLAG_READ) {
219242
i2c_master_read(cmd,bufs->buf,bufs->len,n==0 ?I2C_MASTER_LAST_NACK :I2C_MASTER_ACK);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp