mirror of
https://github.com/Ralim/IronOS.git
synced 2025-02-26 07:53:55 +00:00
Cleanup make includes and formatting rules (#1860)
* Draft cleanup of the folder definition mess * Move old startup * Fixup! broken hacky includes * Update Makefile * Update Makefile * Update Makefile * Bulk format * Who knew, header guards are a wise idea * Squash some sizing warnings * Drop broken usb stack * Fix BLE headers to be sensible * Cleaning up proper c styling * We have newer clang, it does bracketing now * Run clang-format brackets * We can drop the old messy bracket-checker with newer clang format * WiP formatter * Align grids of scripts by right side Massively easier to read in nearly all cases * Excempt the table for compression from formatter
This commit is contained in:
@@ -31,27 +31,33 @@ bool Si7210::init() {
|
||||
}
|
||||
|
||||
/* Disable periodic auto-wakeup by device, and tamper detect. */
|
||||
if ((!write_reg(SI7210_CTRL3, (uint8_t)~SL_TIMEENA_MASK, 0)))
|
||||
if ((!write_reg(SI7210_CTRL3, (uint8_t)~SL_TIMEENA_MASK, 0))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Disable tamper detection by setting sw_tamper to 63 */
|
||||
if (!write_reg(SI7210_CTRL3, SL_FAST_MASK | SL_TIMEENA_MASK, 63 << 2))
|
||||
if (!write_reg(SI7210_CTRL3, SL_FAST_MASK | SL_TIMEENA_MASK, 63 << 2)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!set_high_range())
|
||||
if (!set_high_range()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Stop the control loop by setting stop bit */
|
||||
if (!write_reg(SI7210_POWER_CTRL, MEAS_MASK | USESTORE_MASK, STOP_MASK)) /* WARNING: Removed USE_STORE MASK */
|
||||
if (!write_reg(SI7210_POWER_CTRL, MEAS_MASK | USESTORE_MASK, STOP_MASK)) { /* WARNING: Removed USE_STORE MASK */
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Use a burst size of 128/4096 samples in FIR and IIR modes */
|
||||
if (!write_reg(SI7210_CTRL4, 0, DF_BURSTSIZE_128 | DF_BW_4096))
|
||||
if (!write_reg(SI7210_CTRL4, 0, DF_BURSTSIZE_128 | DF_BW_4096)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Select field strength measurement */
|
||||
if (!write_reg(SI7210_DSPSIGSEL, 0, DSP_SIGSEL_FIELD_MASK))
|
||||
if (!write_reg(SI7210_DSPSIGSEL, 0, DSP_SIGSEL_FIELD_MASK)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true; // start_periodic_measurement();
|
||||
}
|
||||
@@ -84,8 +90,9 @@ bool Si7210::read_reg(const uint8_t reg, uint8_t *val) { return ACCEL_I2C_CLASS:
|
||||
|
||||
bool Si7210::start_periodic_measurement() {
|
||||
/* Enable periodic wakeup */
|
||||
if (!write_reg(SI7210_CTRL3, (uint8_t)~SL_TIMEENA_MASK, SL_TIMEENA_MASK))
|
||||
if (!write_reg(SI7210_CTRL3, (uint8_t)~SL_TIMEENA_MASK, SL_TIMEENA_MASK)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Start measurement */
|
||||
/* Change to ~STOP_MASK with STOP_MASK */
|
||||
@@ -97,17 +104,20 @@ bool Si7210::get_field_strength(int16_t *field) {
|
||||
uint8_t val = 0;
|
||||
ACCEL_I2C_CLASS::wakePart(SI7210_ADDRESS);
|
||||
|
||||
if (!write_reg(SI7210_POWER_CTRL, MEAS_MASK | USESTORE_MASK, STOP_MASK))
|
||||
if (!write_reg(SI7210_POWER_CTRL, MEAS_MASK | USESTORE_MASK, STOP_MASK)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Read most-significant byte */
|
||||
if (!read_reg(SI7210_DSPSIGM, &val))
|
||||
if (!read_reg(SI7210_DSPSIGM, &val)) {
|
||||
return false;
|
||||
}
|
||||
*field = (val & DSP_SIGM_DATA_MASK) << 8;
|
||||
|
||||
/* Read least-significant byte of data */
|
||||
if (!read_reg(SI7210_DSPSIGL, &val))
|
||||
if (!read_reg(SI7210_DSPSIGL, &val)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
*field += val;
|
||||
*field -= 16384U;
|
||||
|
||||
Reference in New Issue
Block a user