39 unsigned char currbank = 0xff;
41 LINFO(
"Loading ICM20948 DMP firmware...");
44 for (
size_t i = 0; i <
sizeof(dmp3_image); i += chunksiz)
48 if (bank != currbank) { writeRegister(ICM20948_REG_MEM_BANK_SEL, bank); currbank = bank; }
51 writeRegister(ICM20948_REG_MEM_START_ADDR, addr & 0xff);
53 LDEBUG(
" Writing " << chunksiz <<
" bytes to MEMS addr 0x" << std::hex << addr);
56 if (addr + chunksiz >
sizeof(dmp3_image)) chunksiz =
sizeof(dmp3_image) - addr;
57 writeRegisterArray(ICM20948_REG_MEM_R_W, &dmp3_image[i], chunksiz);
62 bool verify_error =
false;
66 LINFO(
"Verifying ICM20948 DMP firmware...");
71 for (
size_t i = 0; i <
sizeof(dmp3_image); i += chunksiz)
75 if (bank != currbank) { writeRegister(ICM20948_REG_MEM_BANK_SEL, bank); currbank = bank; }
78 writeRegister(ICM20948_REG_MEM_START_ADDR, addr & 0xff);
80 LDEBUG(
" Reading " << chunksiz <<
" bytes from MEMS addr 0x" << std::hex << addr);
83 if (addr + chunksiz >
sizeof(dmp3_image)) chunksiz =
sizeof(dmp3_image) - addr;
84 readRegisterArray(ICM20948_REG_MEM_R_W, buf, chunksiz);
85 for (
size_t j = 0; j < chunksiz; ++j)
86 if (buf[j] != dmp3_image[i + j])
88 LDEBUG(
"DMP code verify error addr=" << std::hex << std::showbase << addr + j <<
", read=" << buf[j] <<
89 ", orig=" << dmp3_image[i + j]);
97 writeRegister(ICM20948_REG_MEM_BANK_SEL, 0);
101 writeRegisterArray(ICM20948_REG_PRGM_START_ADDRH, &dmp_addr[0], 2);
103 LINFO(
"Loaded " <<
sizeof(dmp3_image) <<
" bytes of DMP firmware.");
108 if (errthrow)
LFATAL(
"Error during DMP firmware verify -- DMP NOT OPERATIONAL");
109 else LERROR(
"Error during DMP firmware verify -- DMP NOT OPERATIONAL");