WIN 7
Visual Studio 2017
我已经写了一个C程序来打开串口。
我已经编写了一个C程序来在蓝牙芯片(定制)中读写闪存。
但是,我必须进入DFU模式才能从闪存读取和写入。
是否可以在不进入DFU模式的情况下从闪存进行读写?
我必须按下按钮才能进入DFU模式,这对于批量生产是很费时间的。
在哪种蓝牙芯片中,读写闪存需要DFU模式?
int test_read_cmd(void)
{
int ret;
int i;
static const unsigned int addr[] = { 0x00000010, 0x00000020, 0x00000030, };
static const unsigned char rlen[sizeof(addr) / sizeof(addr[0])] = { 1, 4, 16, };
unsigned char b[16];
for (i = 0; i < sizeof(rlen); i++) {
ret = read_cmd(addr[i], rlen[i], b);
if (ret) {
return ret;
}
}
return 0;
}
int read_cmd(unsigned int addr, unsigned int len, unsigned char *data)
{
int ret;
unsigned char b[17];
size_t reply_len;
//TRACE("--- Send READ msg addr=0x%08x len=%d ---", addr, len);
if (len > 16) {
TRACE("READ msg length too long: %d", len);
return 1;
}
comm_state = COMM_READ;
memcpy(&b[0], &addr, 4);
b[4] = len;
ret = send_packet(b, 5, TYPE_READ, send_seq++);
if (ret) {
TRACE("Sending READ %d failed", len);
return ret;
}
//TRACE("--- Recv READ %d reply msg ---", len);
ret = recv_reply(b, 1 + len, &reply_len);
if (ret) {
TRACE("Receiving READ %d reply failed", len);
return ret;
}
if (b[0] != ERR_NONE) {
TRACE("READ %d reply error 0x%x", len, b[0]);
return 1;
}
memcpy(data, &b[1], len);
//dump_buffer(data, len);
return 0;
}