drivers counter_nrfx_rtc: Fix for simulation
For simulation, let's convert the hardcoded DT/real HW address to the valid addr for simulation on the fly. Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
This commit is contained in:
parent
5b8b9c9f6a
commit
62e9a38590
|
@ -44,6 +44,12 @@ LOG_MODULE_REGISTER(LOG_MODULE_NAME, CONFIG_COUNTER_LOG_LEVEL);
|
|||
#define CC_ADJUSTED_OFFSET 16
|
||||
#define CC_ADJ_MASK(chan) (BIT(chan + CC_ADJUSTED_OFFSET))
|
||||
|
||||
#if defined(CONFIG_SOC_SERIES_BSIM_NRFXX)
|
||||
#define MAYBE_CONST_CONFIG
|
||||
#else
|
||||
#define MAYBE_CONST_CONFIG const
|
||||
#endif
|
||||
|
||||
struct counter_nrfx_data {
|
||||
counter_top_callback_t top_cb;
|
||||
void *top_user_data;
|
||||
|
@ -534,11 +540,20 @@ static uint32_t get_pending_int(const struct device *dev)
|
|||
|
||||
static int init_rtc(const struct device *dev, uint32_t prescaler)
|
||||
{
|
||||
const struct counter_nrfx_config *nrfx_config = dev->config;
|
||||
MAYBE_CONST_CONFIG struct counter_nrfx_config *nrfx_config =
|
||||
(MAYBE_CONST_CONFIG struct counter_nrfx_config *) dev->config;
|
||||
struct counter_nrfx_data *data = dev->data;
|
||||
struct counter_top_cfg top_cfg = {
|
||||
.ticks = NRF_RTC_COUNTER_MAX
|
||||
};
|
||||
|
||||
#if defined(CONFIG_SOC_SERIES_BSIM_NRFXX)
|
||||
/* For simulated devices we need to convert the hardcoded DT address from the real
|
||||
* peripheral into the correct one for simulation
|
||||
*/
|
||||
nrfx_config->rtc = nhw_convert_periph_base_addr(nrfx_config->rtc);
|
||||
#endif
|
||||
|
||||
NRF_RTC_Type *rtc = nrfx_config->rtc;
|
||||
int err;
|
||||
|
||||
|
@ -705,7 +720,8 @@ static const struct counter_driver_api counter_nrfx_driver_api = {
|
|||
static struct counter_nrfx_ch_data \
|
||||
counter##idx##_ch_data[DT_INST_PROP(idx, cc_num)]; \
|
||||
LOG_INSTANCE_REGISTER(LOG_MODULE_NAME, idx, CONFIG_COUNTER_LOG_LEVEL); \
|
||||
static const struct counter_nrfx_config nrfx_counter_##idx##_config = {\
|
||||
static MAYBE_CONST_CONFIG \
|
||||
struct counter_nrfx_config nrfx_counter_##idx##_config = { \
|
||||
.info = { \
|
||||
.max_top_value = NRF_RTC_COUNTER_MAX, \
|
||||
.freq = DT_INST_PROP(idx, clock_frequency) / \
|
||||
|
|
Loading…
Reference in a new issue