Example #1
0
bool ms5611Detect(baro_t *baro)
{
    GPIO_InitTypeDef GPIO_InitStructure;
    bool ack = false;
    uint8_t sig,i;
    GPIO_InitStructure.GPIO_Pin = GPIO_Pin_13;                   // PC13 (BMP085's XCLR reset input, which we use to disable it)
    GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
    GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
    GPIO_Init(GPIOC, &GPIO_InitStructure);
    BMP085_OFF;
    delay(50);                                                   // Crashpilot 100ms No idea how long the chip takes to power-up, but let's make it 10ms
    // BMP085 is disabled. If we have a MS5611, it will reply. if no reply, means either we have BMP085 or no baro at all.
    ack = i2cRead(MS5611_ADDR, CMD_PROM_RD, 1, &sig);
    if (!ack) return false;
    delay(50);
    for (i = 0; i < 5; i++) ms5611_reset();                      // Reset the damn thing a few times
    for (i = 0; i < PROM_NB; i++) ms5611_c[i] = ms5611_prom(i);  // read all coefficients // read 8 words word:0 = ID; word:1-6 = C1-C6; word:7 = ChkSum
    if (ms5611_crc(ms5611_c) != 0) return false;                 // check crc, bail out if wrong - we are probably talking to BMP085 w/o XCLR line!
// 	  baro->ut_delay = 10000; //    baro->up_delay = 10000; //    baro->repeat_delay = 4000;
    baro->ut_delay = 9500;
    baro->up_delay = 9500;
    baro->repeat_delay = 1;
    baro->start_ut = ms5611_start_ut;
    baro->get_ut = ms5611_get_ut;
    baro->start_up = ms5611_start_up;
    baro->get_up = ms5611_get_up;
    baro->calculate = ms5611_calculate;
    delay(50);
    for (i = 0; i < 10; i++) ms5611_reset();                     // Reset the damn thing a few times
    delay(50);
    return true;
}
Example #2
0
bool ms5611Detect(baro_t *baro)
{
    bool ack = false;
    uint8_t sig;
    int i;

    delay(10); // No idea how long the chip takes to power-up, but let's make it 10ms

    ack = i2cRead(BARO_I2C_INSTANCE, MS5611_ADDR, CMD_PROM_RD, 1, &sig);
    if (!ack)
        return false;

    ms5611_reset();
    // read all coefficients
    for (i = 0; i < PROM_NB; i++)
        ms5611_c[i] = ms5611_prom(i);
    // check crc, bail out if wrong - we are probably talking to BMP085 w/o XCLR line!
    if (ms5611_crc(ms5611_c) != 0)
        return false;

    // TODO prom + CRC
    baro->ut_delay = 10000;
    baro->up_delay = 10000;
    baro->start_ut = ms5611_start_ut;
    baro->get_ut = ms5611_get_ut;
    baro->start_up = ms5611_start_up;
    baro->get_up = ms5611_get_up;
    baro->calculate = ms5611_calculate;

    return true;
}
bool ms5611Init()
{
	bool ack = false;
	uint8_t sig;
	int i;


	ack = i2cRead(MS5611_ADDR, CMD_PROM_RD, 1, &sig);

	if (!ack)
		return false;

	ms5611_reset();
	// read all coefficients
	for (i = 0; i < PROM_NB; i++)
		ms5611_c[i] = ms5611_prom(i);
	// check crc, bail out if wrong - we are probably talking to BMP085 w/o XCLR line!
	if (ms5611_crc(ms5611_c) != 0)
		return false;

	// TODO prom + CRC
	baro.ut_delay = 10000;
	baro.up_delay = 10000;	//us
	baro.start_ut = ms5611_start_ut;
	baro.get_ut = ms5611_get_ut;
	baro.start_up = ms5611_start_up;
	baro.get_up = ms5611_get_up;
	baro.calculate = ms5611_calculate;

	return true;
}
bool ms5611Detect(baro_t *baro)
{
    GPIO_InitTypeDef GPIO_InitStructure;
    bool ack = false;
    uint8_t sig;
    int i;

    // PC13 (BMP085's XCLR reset input, which we use to disable it)
    GPIO_InitStructure.GPIO_Pin = GPIO_Pin_13;
    GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
    GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
    GPIO_Init(GPIOC, &GPIO_InitStructure);
    BMP085_OFF;

    delay(10); // No idea how long the chip takes to power-up, but let's make it 10ms

    // BMP085 is disabled. If we have a MS5611, it will reply. if no reply, means either
    // we have BMP085 or no baro at all.
    ack = i2cRead(MS5611_ADDR, CMD_PROM_RD, 1, &sig);
    if (!ack)
        return false;

    ms5611_reset();
    // read all coefficients
    for (i = 0; i < PROM_NB; i++)
        ms5611_c[i] = ms5611_prom(i);
    // check crc, bail out if wrong - we are probably talking to BMP085 w/o XCLR line!
    if (ms5611_crc(ms5611_c) != 0)
        return false;

    // TODO prom + CRC
    baro->ut_delay = 10000;
    baro->up_delay = 10000;
    baro->repeat_delay = 4000;
    baro->start_ut = ms5611_start_ut;
    baro->get_ut = ms5611_get_ut;
    baro->start_up = ms5611_start_up;
    baro->get_up = ms5611_get_up;
    baro->calculate = ms5611_calculate;

    return true;
}