icm20948 icon indicating copy to clipboard operation
icm20948 copied to clipboard

bank selection doesn't work properly

Open adambujak opened this issue 4 years ago • 3 comments
trafficstars

I think you need to shift it to the left by 4 because right now you are setting bits 0 and 1 as far as I can tell

adambujak avatar Jul 18 '21 20:07 adambujak

Hmmm, honestly haven't touched or used this since I wrote it. I thought I had tested accessing other banks but maybe not.. If you find this issue is true, please feel free to submit a PR to fix it. Otherwise, I will fix it once I get around to it 👍

stephendpmurphy avatar Jul 19 '21 17:07 stephendpmurphy

I used this code recently, and can confirm while being very well structured, the bank selection is incorrect. for example:

dev.usr_bank.reg_bank_sel = ICM20948_USER_BANK_0;  // (whichever user bank it is, 0, 1, 2)  
// Write to the reg bank select to select bank 0
ret = _spi_write(ICM20948_ADDR_REG_BANK_SEL,  (uint8_t *)&dev.usr_bank.reg_bank_sel, 0x01);

can / should be replaced with

dev.usr_bank.bank0.bytes.REG_BANK_SEL.bits.USER_BANK = ICM20948_USER_BANK_0;    //(again, X being the bank) //// Write to the reg bank select to select bank 0
ret = _spi_write(ICM20948_ADDR_REG_BANK_SEL,& dev.usr_bank.bank0.bytes.REG_BANK_SEL.byte, 0x01);

zafbangash avatar Apr 18 '24 11:04 zafbangash

@zafbangash thanks for confirming this. Happy to review any PR back into the repo to get this fixed!

stephendpmurphy avatar Apr 29 '24 13:04 stephendpmurphy