This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

using nrf5340 and Zephyr OS , Is device binding and device tree the only way to use nrf5340's peripheral?

In a .c file  ,code like below  (build a image using nrf5340dk_cpuappns) :

#include "nrf_gpio.h"

#define SPIM2_CS NRF_GPIO_    PIN_MAP(0,15)
#define SPIM2_SDO NRF_GPIO_ PIN_MAP(0,18)
#define SPIM2_CLK NRF_GPIO     PIN_MAP(0,12)
#define SPIM2_SDI NRF_GPIO_   PIN_MAP(0,14)

static void ADS129x_GPIO_Init(void){

  nrf_gpio_cfg_output(SPIM2_CS);

  nrf_gpio_pin_set(SPIM2_CS);

}

static void ADS129x_SPIInit(void){

   nrf_spim_pins_set(NRF_SPIM2_NS,  SPIM2_CLK,  SPIM2_SDO,  SPIM2_SDI);
    nrf_spim_frequency_set(NRF_SPIM2_NS,  NRF_SPIM_FREQ_1M);
   nrf_spim_configure(NRF_SPIM2_NS,  NRF_SPIM_MODE_1,  NRF_SPIM_BIT_ORDER_MSB_FIRST);
   nrf_spim_enable(NRF_SPIM2_NS);

}

Can use nrf5340's peripheral SPIM2  like this way?

Related