Chapter 6. Spi; Loopback Testing - Waveshare NRF52840 User Manual

Eval kit
Table of Contents

Advertisement

NRF52840 Eval Kit User Manual

CHAPTER 6. SPI

Examples used in this chapter: 004_SPI(Example), 005_SPI(OLED)
In this chapter, we will describe about how to use SPI interface of NRF52840, do
loopback testing and try to drive a 0.96inch OLED module.

LOOPBACK TESTING

main.c
#include "nrf_drv_spi.h"
#include "nrf_gpio.h"
#include "app_util_platform.h"
#include "nrf_delay.h"
#include "app_error.h"
#include <string.h>
#include "nrf_log.h"
#include "nrf_log_ctrl.h"
#include "nrf_log_default_backends.h"
#include "spi.h"
int
main(void)
{
APP_ERROR_CHECK(NRF_LOG_INIT(NULL));
NRF_LOG_DEFAULT_BACKENDS_INIT();
nrf_drv_spi_config_t spi_config
spi_config.ss_pin
spi_config.miso_pin
spi_config.mosi_pin
spi_config.sck_pin
/*
Doesn't print what to send or what received in SPI
*/
//APP_ERROR_CHECK(nrf_drv_spi_init(&spi, &spi_config, NULL,
NULL));
/*
Print what to send or what received in SPI
*/
APP_ERROR_CHECK(nrf_drv_spi_init(&spi, &spi_config,
spi_event_handler, NULL));
Vision: V1.0.1 Date: 2019.01.19
= NRF_DRV_SPI_DEFAULT_CONFIG;
= CS_PIN;
= MISO_PIN;
= MOSI_PIN;
= SCK_PIN;
29 / 72

Advertisement

Table of Contents
loading

Table of Contents