Reuse macros.h in nrf-connect/samples/soil_read_loop/src/main.c

This commit is contained in:
rbaron 2022-11-27 23:21:50 +01:00
parent 89d2999bd8
commit 46a8285f59

View file

@ -2,25 +2,11 @@
#include <drivers/gpio.h> #include <drivers/gpio.h>
#include <drivers/pwm.h> #include <drivers/pwm.h>
#include <logging/log.h> #include <logging/log.h>
#include <prstlib/macros.h>
#include <zephyr/zephyr.h> #include <zephyr/zephyr.h>
LOG_MODULE_REGISTER(main, LOG_LEVEL_DBG); LOG_MODULE_REGISTER(main, LOG_LEVEL_DBG);
#define PRST_STRINGIFY(x) #x
#define PRST_TO_STRING(x) PRST_STRINGIFY(x)
#define PRST_LOCATION __FILE__ ":" PRST_TO_STRING(__LINE__)
#define RET_IF_ERR_MSG(expr, msg) \
{ \
int err = (expr); \
if (err) { \
LOG_ERR("Error: " msg " in " PRST_LOCATION); \
return err; \
} \
}
#define RET_IF_ERR(expr) RET_IF_ERR_MSG(expr, "")
static const struct pwm_dt_spec soil_pwm_dt = static const struct pwm_dt_spec soil_pwm_dt =
PWM_DT_SPEC_GET(DT_NODELABEL(soil_pwm)); PWM_DT_SPEC_GET(DT_NODELABEL(soil_pwm));
static const uint32_t pulse = DT_PROP(DT_NODELABEL(soil_pwm), pulse); static const uint32_t pulse = DT_PROP(DT_NODELABEL(soil_pwm), pulse);