Hi,
I am developing an audio application on nRF54L15. I have successfully used the Zephyr API to read sequences from the ADC with extra samplings (the "extra samplings" part would've been nice to see in the DevAcademy exercise). To get higher sampling rates and access to Noise Shaping and Limits event monitoring I instead turned to the nrfx driver, starting with DevAcademy Lesson 6, Exercise 3.
I'm surprised by the configurations that are written in code (some duplicates of configurations outside the code), rather than in configuration files such as Kconfig or Device Tree. Configurations such as the Timer number, pin assignments and SAADC advanced config options.
// boards/nrf54l15dk_nrf54l15_cpuapp.conf CONFIG_NRFX_TIMER22=y
A snippet from the mentioned exercise:
/* STEP 2 - Include header for nrfx drivers */ #include <nrfx_saadc.h> #include <nrfx_timer.h> #include <helpers/nrfx_gppi.h> #if defined(DPPI_PRESENT) #include <nrfx_dppi.h> #else #include <nrfx_ppi.h> #endif /* STEP 3.1 - Define the SAADC sample interval in microseconds */ #define SAADC_SAMPLE_INTERVAL_US 50 /* STEP 4.1 - Define the buffer size for the SAADC */ #define SAADC_BUFFER_SIZE 8000 /* STEP 4.6 - Declare the struct to hold the configuration for the SAADC channel used to sample the battery voltage */ #if NRF_SAADC_HAS_AIN_AS_PIN #if defined(CONFIG_SOC_NRF54L15) #define NRF_SAADC_INPUT_AIN4 NRF_PIN_PORT_TO_PIN_NUMBER(11U, 1) #define SAADC_INPUT_PIN NRF_SAADC_INPUT_AIN4 #else BUILD_ASSERT(0, "Unsupported device family"); #endif #else #define SAADC_INPUT_PIN NRF_SAADC_INPUT_AIN0 #endif static nrfx_saadc_channel_t channel = NRFX_SAADC_DEFAULT_CHANNEL_SE(SAADC_INPUT_PIN, 0); /* STEP 3.2 - Declaring an instance of nrfx_timer for TIMER2. */ #if defined(CONFIG_SOC_NRF54L15) #define TIMER_INSTANCE_NUMBER 22 #else #define TIMER_INSTANCE_NUMBER 2 #endif const nrfx_timer_t timer_instance = NRFX_TIMER_INSTANCE(TIMER_INSTANCE_NUMBER);
Surely these configurations belong in Kconfig or Device Tree and not in code? Is the exercise out of date, a "quick and dirty" example or is it simply not feasible to sort out upstream in Zephyr since it's specific to the Nordic devices and drivers? If it's possible to neatly bring the configurations from code scope to configuration scope an example would be much appreciated!
I'm on SDK 3.1.1 and nRF54L15DK.
Best regards,
Charlie