Skip to content
Permalink
Browse files

drivers: counter: Add helper macros for logging

Added macros to simplify logging in the counter driver.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
  • Loading branch information...
nordic-krch authored and carlescufi committed May 20, 2019
1 parent 10074fc commit 591b0e1c7af2df9f1f192336073962ea0f83b9d1
Showing with 10 additions and 8 deletions.
  1. +10 −8 drivers/counter/counter_nrfx_rtc.c
@@ -18,6 +18,11 @@
#include <logging/log.h>
LOG_MODULE_REGISTER(LOG_MODULE_NAME, LOG_LEVEL);

#define ERR(...) LOG_INST_ERR(get_nrfx_config(dev)->log, __VA_ARGS__)
#define WRN(...) LOG_INST_WRN(get_nrfx_config(dev)->log, __VA_ARGS__)
#define INF(...) LOG_INST_INF(get_nrfx_config(dev)->log, __VA_ARGS__)
#define DBG(...) LOG_INST_DBG(get_nrfx_config(dev)->log, __VA_ARGS__)

#define COUNTER_MAX_TOP_VALUE RTC_COUNTER_COUNTER_Msk

#define CC_TO_ID(cc) ((cc) - 1)
@@ -113,8 +118,7 @@ static int counter_nrfx_set_alarm(struct device *dev, u8_t chan_id,
/* From Product Specification: If a CC register value is 0 when
* a CLEAR task is set, this will not trigger a COMPARE event.
*/
LOG_INST_INF(nrfx_config->log,
"Attempt to set CC to 0, delayed to 1.");
INF("Attempt to set CC to 0, delayed to 1.");
cc_val++;
}
nrfx_rtc_cc_set(rtc, ID_TO_CC(chan_id), cc_val, true);
@@ -228,8 +232,7 @@ static int ppi_setup(struct device *dev)
#ifdef DPPI_PRESENT
result = nrfx_dppi_channel_alloc(&data->ppi_ch);
if (result != NRFX_SUCCESS) {
LOG_INST_ERR(nrfx_config->log,
"Failed to allocate PPI channel.");
ERR("Failed to allocate PPI channel.");
return -ENODEV;
}

@@ -245,8 +248,7 @@ static int ppi_setup(struct device *dev)

result = nrfx_ppi_channel_alloc(&data->ppi_ch);
if (result != NRFX_SUCCESS) {
LOG_INST_ERR(nrfx_config->log,
"Failed to allocate PPI channel.");
ERR("Failed to allocate PPI channel.");
return -ENODEV;
}

@@ -277,7 +279,7 @@ static int init_rtc(struct device *dev,
nrfx_err_t result = nrfx_rtc_init(rtc, config, handler);

if (result != NRFX_SUCCESS) {
LOG_INST_ERR(nrfx_config->log, "Failed to initialize device.");
ERR("Failed to initialize device.");
return -EBUSY;
}

@@ -288,7 +290,7 @@ static int init_rtc(struct device *dev,

data->top = COUNTER_MAX_TOP_VALUE;

LOG_INST_DBG(nrfx_config->log, "Initialized");
DBG("Initialized");
return 0;
}

0 comments on commit 591b0e1

Please sign in to comment.
You can’t perform that action at this time.