Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lps2x series sensors lps2xx_pressure_raw_get() API return wrong raw pressure data #170

Open
zackermei opened this issue Nov 1, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@zackermei
Copy link

According to lps22hb datasheet, the pressure data are stored in 3 registers, so the last line *buff *= 256; of below API should be removed. I had confirmed this issue in lps22hb, and checked other lps2x series sensors, looks like they had the same issue.

int32_t lps22hb_pressure_raw_get(const stmdev_ctx_t *ctx, uint32_t *buff)
{
  uint8_t reg[3];
  int32_t ret;

  ret =  lps22hb_read_reg(ctx, LPS22HB_PRESS_OUT_XL, reg, 3);
  *buff = reg[2];
  *buff = (*buff * 256) + reg[1];
  *buff = (*buff * 256) + reg[0];
  *buff *= 256; /* this line should be removed */

  return ret;
}
@zackermei zackermei added the bug Something isn't working label Nov 1, 2024
@zackermei
Copy link
Author

this issue had been mention by others as well.
STMicroelectronics/lps22hb-pid#1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant