NRF52840 Eval Kit User Manual
Vision: V1.0.1 Date: 2019.01.19
29
/
72
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
=
NRF_DRV_SPI_DEFAULT_CONFIG
;
spi_config
.
ss_pin
=
CS_PIN
;
spi_config
.
miso_pin
=
MISO_PIN
;
spi_config
.
mosi_pin
=
MOSI_PIN
;
spi_config
.
sck_pin
=
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
));
Содержание NRF52840
Страница 1: ...NRF52840 Eval Kit User Manual Vision V1 0 1 Date 2019 01 19 1 72 NRF52840 Eval Kit User Manual...
Страница 46: ...NRF52840 Eval Kit User Manual Vision V1 0 1 Date 2019 01 19 46 72 You can also send data directly on Show log...
Страница 61: ...NRF52840 Eval Kit User Manual Vision V1 0 1 Date 2019 01 19 61 72...