eddy_em: (Default)
[personal profile] eddy_em
Вот как ни гляну, большинство народу для считывания данных калибровки в BMP/BME280 использует типичный ардуиноподход, как, например, здесь: зачем-то отправляет кучу команд чтения регистров вместо того, чтобы как предлагается в даташите, считать эти данные "за один присест".
Вот, как это делается неправильно:
if (read_register16(dev, 0x88, &dev->dig_T1)
			&& read_register16(dev, 0x8a, (uint16_t *) &dev->dig_T2)
			&& read_register16(dev, 0x8c, (uint16_t *) &dev->dig_T3)
			&& read_register16(dev, 0x8e, &dev->dig_P1)
			&& read_register16(dev, 0x90, (uint16_t *) &dev->dig_P2)
			&& read_register16(dev, 0x92, (uint16_t *) &dev->dig_P3)
			&& read_register16(dev, 0x94, (uint16_t *) &dev->dig_P4)
			&& read_register16(dev, 0x96, (uint16_t *) &dev->dig_P5)
			&& read_register16(dev, 0x98, (uint16_t *) &dev->dig_P6)
			&& read_register16(dev, 0x9a, (uint16_t *) &dev->dig_P7)
			&& read_register16(dev, 0x9c, (uint16_t *) &dev->dig_P8)
			&& read_register16(dev, 0x9e,
					(uint16_t *) &dev->dig_P9)) {

		return true;
	}

А вот — правильно:
if(I2C_OK != i2c_7bit_send_onebyte(BMP280_REG_CALIBA, 0)) return 0;
if(I2C_OK != i2c_7bit_receive((uint8_t*)&CaliData, BMP280_CALIBA_SIZE)) return 0;
return 1;

Вот неужели людям так нравится портянка копипасты, чреватая возможностью не тот регистр где-нибудь нарисовать (или не ту переменную) + насилующая шину I2C лишними операциями?
This account has disabled anonymous posting.
If you don't have an account you can create one now.
HTML doesn't work in the subject.
More info about formatting

If you are unable to use this captcha for any reason, please contact us by email at support@dreamwidth.org

October 2025

S M T W T F S
   1234
567 89 1011
121314 15161718
19202122232425
2627 28293031 

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Feb. 24th, 2026 10:05 pm
Powered by Dreamwidth Studios