/* Write (both set and clear) bits of an 8-bit register on the LIS3DH.  */
static int lis3dh_write_bits(const lis3dh_t *dev, const lis3dh_reg_t reg, const uint8_t mask, const uint8_t values)
/* Write (both set and clear) bits of an 8-bit register on the LIS3DH.  */
static int lis3dh_write_bits(const lis3dh_t *dev, const lis3dh_reg_t reg, const uint8_t mask, const uint8_t values)
{
    uint8_t tmp;
    if (lis3dh_read_regs(dev, reg, 1, &tmp) < 0) {
        return -1;
    }
    tmp &= ~mask;
    tmp |= (values & mask);
    if (lis3dh_write_reg(dev, reg, tmp) < 0) {
        return -1;
    }
    return 0;
}