My project has the platformio.init below and I am trying to call from main.c Nordic nrfx functions that are part of the framework-zephyr framework at _pio/modules/hal/nordic/nrfx. I can compile main.c but the linking fails with missing definitions of the nrfx functions. How can I add the nrfx functions to my project?
My original platformio.ini.
[env:nrf52_dk]
platform = nordicnrf52
board = nrf52_dk
framework = zephyr
debug_tool = jlink
monitor_speed = 230400
debug_build_flags = -O0 -g -ggdb
build_flags =
-D NRFX_TIMER2_ENABLED=1
Gives these link errors:
c:/users/user/.platformio/packages/toolchain-gccarmnoneeabi/bin/../lib/gcc/arm-none-eabi/8.2.1/../../../../arm-none-eabi/bin/ld.exe: .pio\build\nrf52_dk\src\main.o: in function `InitTimer':
C:\projects\ble_stepper_monitor\repo\platformio/src/main.c:46: undefined reference to `nrfx_timer_init'
c:/users/user/.platformio/packages/toolchain-gccarmnoneeabi/bin/../lib/gcc/arm-none-eabi/8.2.1/../../../../arm-none-eabi/bin/ld.exe: C:\projects\ble_stepper_monitor\repo\platformio/src/main.c:49: undefined reference to `nrfx_timer_extended_compare'
c:/users/user/.platformio/packages/toolchain-gccarmnoneeabi/bin/../lib/gcc/arm-none-eabi/8.2.1/../../../../arm-none-eabi/bin/ld.exe: C:\projects\ble_stepper_monitor\repo\platformio/src/main.c:52: undefined reference to `nrfx_timer_enable'
This is the main.c I am trying to build. The include files are found but not the definitions from nrfx_timer.c
#include <device.h>
#include <devicetree.h>
#include <drivers/gpio.h>
#include <hal/nrf_timer.h>
#include <nrfx_timer.h>
#include <zephyr.h>
static volatile uint32_t m_us_counter = 0; // System time in microseconds
static const nrfx_timer_t m_timer2 = NRFX_TIMER_INSTANCE(2);
void Timer_2_Interrupt_Handler(
nrf_timer_event_t event_type, void* p_context) {
m_us_counter += 100;
}
void InitTimer(void) {
nrfx_err_t err_code;
nrfx_timer_config_t tmr_config = NRFX_TIMER_DEFAULT_CONFIG;
tmr_config.frequency = (nrf_timer_frequency_t)NRF_TIMER_FREQ_1MHz;
tmr_config.mode = (nrf_timer_mode_t)NRF_TIMER_MODE_TIMER;
tmr_config.bit_width = (nrf_timer_bit_width_t)NRF_TIMER_BIT_WIDTH_8;
err_code = nrfx_timer_init(&m_timer2, &tmr_config, Timer_2_Interrupt_Handler);
// APP_ERROR_CHECK(err_code);
nrfx_timer_extended_compare(&m_timer2, NRF_TIMER_CC_CHANNEL0, 100,
NRF_TIMER_SHORT_COMPARE0_CLEAR_MASK, true);
nrfx_timer_enable(&m_timer2);
}
void main(void) {
InitTimer();
}