-
On Zephyr / {
compatible = "nordic,nrf52840-dongle-nrf52840";
/* External ADC GPIO Pins:
* N_RESET_ADC: P1.09 (GPIO 33)
* N_DRDY_ADC : P0.24 (GPIO 5)
* N_CS_ADC : P0.16 (GPIO_4)
*/
external-adc {
compatible = "gpio-leds"; /* why gpio-leds? */
n_cs_adc: n_cs_adc_0 {
gpios = <&gpio0 16 (GPIO_ACTIVE_LOW)>;
label = "N_CS_ADC";
};
};
};
/* SPI Interface to ADC
* nCS_ADC: P0.16 GPIO_4
* SCLK_ADC: P0.13 GPIO_1
* DIN_ADC: P0.14 GPIO_2
* DOUT_ADC: P0.15 GPIO_3
*/
&spi3 {
compatible= "nordic,nrf-spim";
status = "okay";
sck-pin = <13>;
miso-pin = <15>;
mosi-pin = <14>;
};
/* Pin Mapping from Devicetree */
#define ADC_nSS DT_GPIO_PIN(DT_NODELABEL(n_cs_adc), gpios)
#define ADC_SCK NRF_GPIO_PIN_MAP(0,13) // TODO: Find a way to get pin numbers from devicetree
#define ADC_MISO NRF_GPIO_PIN_MAP(0,15) // TODO: Find a way to get pin numbers from devicetree
#define ADC_MOSI NRF_GPIO_PIN_MAP(0,14) // TODO: Find a way to get pin numbers from devicetree
#define ADC_nDRDY DT_GPIO_PIN(DT_NODELABEL(n_drdy_adc), gpios)
/* Device Handle for SPIM3 */
static const nrfx_spim_t spi3 = NRFX_SPIM_INSTANCE(3);
nrfx_spim_config_t spi_config;
/* Set SPI3 properties */
/* TODO: Find a way to use the DTS definitions for the Pin numbers */
spi_config.ss_pin = ADC_nSS;
spi_config.miso_pin = ADC_MISO;
spi_config.mosi_pin = ADC_MOSI;
spi_config.sck_pin = ADC_SCK;
// [..]
/* Initialize SPI Peripheral */
if(nrfx_spim_init(&spi3, &spi_config, ads131_eventHandler, NULL)
// [..] Now this no longer works on Zephyr The correct way would be to port it to use the new |
Beta Was this translation helpful? Give feedback.
Answered by
caco3
Jun 28, 2022
Replies: 1 comment
-
See discussion in https://devzone.nordicsemi.com/f/nordic-q-a/89272/how-to-use-the-nrfx_spim-on-zephyr-3-1 |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
caco3
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
See discussion in https://devzone.nordicsemi.com/f/nordic-q-a/89272/how-to-use-the-nrfx_spim-on-zephyr-3-1