Skip to content

initial soft reset may be required #6

Description

@tdjastrzebski

Not sure why, but my BMP581 does not seem to properly initialize during POR.
I think in any case, to be on the safe side performing soft reset during init may be a good idea - in my case it fixed the issue.
Improved bmp5_init() code below.

int8_t bmp5_init(struct bmp5_dev *dev) {
    int8_t rslt;
    uint8_t reg_data;
    uint8_t chip_id;

    /* Check for null pointer in the device structure */
    rslt = null_ptr_check(dev);

    if (rslt != BMP5_OK) return rslt;

    dev->chip_id = 0;

    if (dev->intf == BMP5_SPI_INTF) {
        /* Performing a single read via SPI of registers,
            * e.g. registers CHIP_ID, before the actual
            * SPI communication with the device.
            */
        rslt = bmp5_get_regs(BMP5_REG_CHIP_ID, &reg_data, 1, dev);
        if (rslt != BMP5_OK) return rslt;
    }

    /* perform soft reset */
    reg_data = BMP5_SOFT_RESET_CMD;
    rslt = bmp5_set_regs(BMP5_REG_CMD, &reg_data, 1, dev);
    dev->delay_us(BMP5_DELAY_US_SOFT_RESET, dev->intf_ptr);

    if (rslt != BMP5_OK) return rslt;

    rslt = bmp5_get_interrupt_status(&reg_data, dev);

    if (rslt != BMP5_OK) return rslt;
        
    if ((reg_data & BMP5_INT_ASSERTED_POR_SOFTRESET_COMPLETE) != BMP5_INT_ASSERTED_POR_SOFTRESET_COMPLETE) {
        return BMP5_E_POR_SOFTRESET;
    }
    
    /* Read chip_id */
    rslt = bmp5_get_regs(BMP5_REG_CHIP_ID, &chip_id, 1, dev);

    if (rslt != BMP5_OK) return rslt;

    if (chip_id != 0) {
        /* Validate post power-up procedure */
        rslt = power_up_check(dev);
    } else {
        return BMP5_E_INVALID_CHIP_ID;
    }

    rslt = validate_chip_id(chip_id, dev);

    return rslt;
}```

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions