Compare commits

...
Sign in to create a new pull request.

6 commits
main ... 2.7

Author SHA1 Message Date
rbaron
b9c5c0dc45 clang-format 2024-10-15 22:28:17 +02:00
rbaron
89f7d72e51 Update
It looks like ZBOSS's macro fiesta introduced a new argument in `ZB_ZCL_SET_ATTR_DESC_*` --  see [git blame](11a7add841/zboss/production/include/zcl/zb_zcl_illuminance_measurement.h (L129))
2024-10-15 22:21:30 +02:00
rbaron
3db3f90097 Update nrf-sdk and toolchain to 2.7 2024-10-15 20:14:32 +02:00
rbaron
2a61058866 Fix double promotion warning in soil-read-loop sample 2024-10-15 19:31:17 +02:00
rbaron
b8eb8473ea Remove historical nrf52840dk_nrf52840.overlay
This relic of the past was briefly used when I first wrote the
nrf-connect firmware and tested it against the nrf52840dk_nrf52840 dev
board.
2024-10-15 19:08:47 +02:00
rbaron
3ef4464b65 SDK 2.7.0 -- implicit double promotion warnings fix
In [018dbcfd6679c273842084ce34c167295bc6f354](018dbcfd66),
Zephyr introduced the -Wdouble-promotion compiler flag.

We have some debugging logs that implicitly promote floats to double,
and it generates a lot of warnings. This commit fixes it.
2024-10-15 19:06:20 +02:00
9 changed files with 17 additions and 99 deletions

View file

@ -1,6 +1,6 @@
{ {
"name": "nrf-connect:v2.4", "name": "nrf-connect:v2.7",
"image": "nordicplayground/nrfconnect-sdk:v2.5-branch", "image": "nordicplayground/nrfconnect-sdk:v2.7-branch",
"features": { "features": {
}, },
"customizations": { "customizations": {

View file

@ -18,7 +18,7 @@ runs:
steps: steps:
- run: | - run: |
docker run --rm -v ${GITHUB_WORKSPACE}:/repo \ docker run --rm -v ${GITHUB_WORKSPACE}:/repo \
nordicplayground/nrfconnect-sdk:v2.5-branch \ nordicplayground/nrfconnect-sdk:v2.7-branch \
west build \ west build \
--build-dir /repo/${{ inputs.sample-dir }}/build \ --build-dir /repo/${{ inputs.sample-dir }}/build \
--pristine \ --pristine \

View file

@ -21,4 +21,6 @@
#define UNUSED_OK(expr) (void)expr; #define UNUSED_OK(expr) (void)expr;
#define DOUBLE_PROMO_OK(expr) (double)(expr)
#endif // _PRST_MACROS_H_ #endif // _PRST_MACROS_H_

View file

@ -97,7 +97,8 @@ static inline float get_soil_moisture_percent(float battery_voltage,
const float wet = eval_poly(wet_coeffs, x); const float wet = eval_poly(wet_coeffs, x);
const float percent = (raw_adc_output - dry) / (wet - dry); const float percent = (raw_adc_output - dry) / (wet - dry);
LOG_DBG("Read soil moisture 2: %.2f | Raw %u | Batt: %.2f | Dry: %.2f | Wet: %.2f", LOG_DBG("Read soil moisture 2: %.2f | Raw %u | Batt: %.2f | Dry: %.2f | Wet: %.2f",
100.0f * percent, raw_adc_output, x, dry, wet); DOUBLE_PROMO_OK(100 * percent),
raw_adc_output, DOUBLE_PROMO_OK(x), DOUBLE_PROMO_OK(dry), DOUBLE_PROMO_OK(wet));
return percent; return percent;
} }
@ -177,7 +178,7 @@ int prst_adc_photo_read(float battery_voltage, prst_adc_photo_sensor_t* out) {
const float current_sun = 3.59e-3f; const float current_sun = 3.59e-3f;
const float current = out->adc_read.voltage / phototransistor_resistor; const float current = out->adc_read.voltage / phototransistor_resistor;
out->brightness = MAX(0, MIN(lux_sun * current / current_sun, UINT16_MAX)); out->brightness = MAX(0, MIN(lux_sun * current / current_sun, UINT16_MAX));
LOG_DBG("Read phototransistor: %u lx | %.2f V", out->brightness, out->adc_read.voltage); LOG_DBG("Read phototransistor: %u lx | %.2f V", out->brightness, DOUBLE_PROMO_OK(out->adc_read.voltage));
#elif DT_NODE_EXISTS(DT_NODELABEL(ldr)) #elif DT_NODE_EXISTS(DT_NODELABEL(ldr))
RET_IF_ERR(gpio_pin_set_dt(&ldr_enable_dt, 1)); RET_IF_ERR(gpio_pin_set_dt(&ldr_enable_dt, 1));
@ -201,7 +202,7 @@ int prst_adc_photo_read(float battery_voltage, prst_adc_photo_sensor_t* out) {
const float pow_value = 1.5832f; const float pow_value = 1.5832f;
out->brightness = out->brightness =
MAX(0, MIN(mult_value / powf(photo_resistance, pow_value), UINT16_MAX)); MAX(0, MIN(mult_value / powf(photo_resistance, pow_value), UINT16_MAX));
LOG_DBG("Read LDR: %u lx | %.2f V", out->brightness, out->adc_read.voltage); LOG_DBG("Read LDR: %u lx | %.2f V", out->brightness, DOUBLE_PROMO_OK(out->adc_read.voltage));
#endif #endif

View file

@ -15,12 +15,12 @@ int prst_sensors_read_all(prst_sensors_t *sensors) {
RET_IF_ERR(prst_shtc3_read(&sensors->shtc3)) RET_IF_ERR(prst_shtc3_read(&sensors->shtc3))
LOG_DBG("Batt: %d mV (%.2f%%)", sensors->batt.adc_read.millivolts, LOG_DBG("Batt: %d mV (%.2f%%)", sensors->batt.adc_read.millivolts,
100 * sensors->batt.percentage); DOUBLE_PROMO_OK(100 * sensors->batt.percentage));
LOG_DBG("Soil: %.0f %%", 100 * sensors->soil.percentage); LOG_DBG("Soil: %.0f %%", DOUBLE_PROMO_OK(100 * sensors->soil.percentage));
LOG_DBG("Photo: %u lx (%d mV)", sensors->photo.brightness, LOG_DBG("Photo: %u lx (%d mV)", sensors->photo.brightness,
sensors->photo.adc_read.millivolts); sensors->photo.adc_read.millivolts);
LOG_DBG("Temp: %f oC", sensors->shtc3.temp_c); LOG_DBG("Temp: %f oC", DOUBLE_PROMO_OK(sensors->shtc3.temp_c));
LOG_DBG("Humi: %.0f %%", 100 * sensors->shtc3.rel_humi); LOG_DBG("Humi: %.0f %%", DOUBLE_PROMO_OK(100 * sensors->shtc3.rel_humi));
LOG_DBG("--------------------------------------------------"); LOG_DBG("--------------------------------------------------");
return 0; return 0;

View file

@ -46,7 +46,7 @@ int prst_shtc3_read(prst_shtc3_read_t *out) {
out->temp_c = -45 + 175 * ((float)((buff[0] << 8) | buff[1])) / (1 << 16); out->temp_c = -45 + 175 * ((float)((buff[0] << 8) | buff[1])) / (1 << 16);
out->rel_humi = ((float)((buff[3] << 8) | buff[4])) / UINT16_MAX; out->rel_humi = ((float)((buff[3] << 8) | buff[4])) / UINT16_MAX;
LOG_DBG("Read temp: %f oC (%d)", out->temp_c, (int)out->temp_c); LOG_DBG("Read temp: %f oC (%d)", DOUBLE_PROMO_OK(out->temp_c), (int)out->temp_c);
LOG_DBG("Read humi: %.0f %%", 100.0 * out->rel_humi); LOG_DBG("Read humi: %.0f %%", DOUBLE_PROMO_OK(100.0f * out->rel_humi));
return 0; return 0;
} }

View file

@ -1,86 +0,0 @@
&pinctrl {
/* Configure pwm0 instance to use pin 5. */
pwm0_default: pwm0_default {
group1 {
psels = <NRF_PSEL(PWM_OUT0, 0, 5)>;
nordic,invert;
};
};
pwm0_sleep: pwm0_sleep {
group1 {
psels = <NRF_PSEL(PWM_OUT0, 0, 5)>;
low-power-enable;
};
};
/* Configure i2c0 instance to use pins 24 (SDA) & 13 (SCL). */
i2c0_default: i2c0_default {
group1 {
psels = <NRF_PSEL(TWIM_SDA, 0, 24)>,
<NRF_PSEL(TWIM_SCL, 0, 13)>;
};
};
i2c0_sleep: i2c0_sleep {
group1 {
psels = <NRF_PSEL(TWIM_SDA, 0, 24)>,
<NRF_PSEL(TWIM_SCL, 0, 13)>;
low-power-enable;
};
};
};
&i2c0 {
shtc3: shtc3@70 {
compatible = "i2c-device";
reg = <0x70>;
label = "SHTC3";
};
};
&adc {
#address-cells = <1>;
#size-cells = <0>;
channel@0 {
reg = <0>;
zephyr,gain = "ADC_GAIN_1_6";
zephyr,reference = "ADC_REF_INTERNAL";
zephyr,acquisition-time = <ADC_ACQ_TIME_DEFAULT>;
// P0.03.
zephyr,input-positive = <NRF_SAADC_AIN1>;
zephyr,resolution = <10>;
};
channel@1 {
reg = <1>;
zephyr,gain = "ADC_GAIN_1_6";
zephyr,reference = "ADC_REF_INTERNAL";
zephyr,acquisition-time = <ADC_ACQ_TIME_DEFAULT>;
// P0.02.
zephyr,input-positive = <NRF_SAADC_AIN0>;
zephyr,resolution = <10>;
};
channel@2 {
reg = <2>;
zephyr,gain = "ADC_GAIN_1_6";
zephyr,reference = "ADC_REF_INTERNAL";
zephyr,acquisition-time = <ADC_ACQ_TIME_DEFAULT>;
zephyr,input-positive = <NRF_SAADC_VDD>;
zephyr,resolution = <10>;
};
};
/ {
zephyr,user {
io-channels = <&adc 0>, <&adc 1>, <&adc 2>;
};
soil_pwm: soil_pwm {
compatible = "pwm-fixed";
pwms = <&pwm0 0 PWM_MSEC(100) PWM_POLARITY_INVERTED>;
pulse = <PWM_MSEC(50)>;
};
};

View file

@ -64,6 +64,6 @@ int main(void) {
int32_t soil_val_mv = soil_buf; int32_t soil_val_mv = soil_buf;
RET_IF_ERR(adc_raw_to_millivolts_dt(&adc_soil_spec, &soil_val_mv)); RET_IF_ERR(adc_raw_to_millivolts_dt(&adc_soil_spec, &soil_val_mv));
LOG_INF("%.2f;%u", batt_val_mv / 1000.0f, soil_buf); LOG_INF("%.2f;%u", DOUBLE_PROMO_OK(batt_val_mv / 1000.0f), soil_buf);
} }
} }

View file

@ -29,6 +29,7 @@ void prst_zcl_soil_moisture_init_client(void);
PRST_ZB_ZCL_ATTR_SOIL_MOISTURE_VALUE_ID, \ PRST_ZB_ZCL_ATTR_SOIL_MOISTURE_VALUE_ID, \
ZB_ZCL_ATTR_TYPE_U16, \ ZB_ZCL_ATTR_TYPE_U16, \
ZB_ZCL_ATTR_ACCESS_READ_ONLY | ZB_ZCL_ATTR_ACCESS_REPORTING, \ ZB_ZCL_ATTR_ACCESS_READ_ONLY | ZB_ZCL_ATTR_ACCESS_REPORTING, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*)data_ptr \ (void*)data_ptr \
} }