Skip to content

Commit

Permalink
fix: 解决netdrv-ch390h在780epm下死机的问题
Browse files Browse the repository at this point in the history
原因是txtmp需要动态分配
  • Loading branch information
wendal committed Jan 23, 2025
1 parent bc5804f commit 300dc6c
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions components/network/netdrv/src/ch390h_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,12 @@ int luat_ch390h_read(ch390h_t* ch, uint8_t addr, uint16_t count, uint8_t* buff)
return 0;
}

static char *txtmp;
int luat_ch390h_write(ch390h_t* ch, uint8_t addr, uint16_t count, uint8_t* buff) {
static char txtmp[2048] = {0};
if (txtmp == NULL) {
LLOGI("分配txtmp缓冲区 4k");
txtmp = luat_heap_malloc(4096);
}
luat_gpio_set(ch->cspin, 0);
if (count > 1600) {
return 0; // 直接不发送
Expand All @@ -65,7 +69,6 @@ int luat_ch390h_write(ch390h_t* ch, uint8_t addr, uint16_t count, uint8_t* buff)
txtmp[0] = (addr + i) | 0x80;
txtmp[1] = buff[i];
luat_spi_send(ch->spiid, (const char* )txtmp, 2);
// LLOGD("寄存器写 addr %02X value %02X", addr, tmp[1]);
}
}

Expand Down

0 comments on commit 300dc6c

Please sign in to comment.