Hello,
I'm going to use nrf52-ble-image-transfer-demo-master for my application. But demo used other way with cpp code for configuring nrf52832 interfaces(spi, twi, gpio...) I hope to use ordinary library and function, but for example if I configure spi like below
sdk_config.h
// <e> SPI_ENABLED - nrf_drv_spi - SPI/SPIM peripheral driver
//==========================================================
#ifndef SPI_ENABLED
#define SPI_ENABLED 1
#endif
#if SPI_ENABLED
// <o> SPI_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority
// <i> Priorities 0,2 (nRF51) and 0,1,4,5 (nRF52) are reserved for SoftDevice
// <0=> 0 (highest)
// <1=> 1
// <2=> 2
// <3=> 3
// <4=> 4
// <5=> 5
// <6=> 6
// <7=> 7
#ifndef SPI_DEFAULT_CONFIG_IRQ_PRIORITY
#define SPI_DEFAULT_CONFIG_IRQ_PRIORITY 7
#endif
// <e> SPI0_ENABLED - Enable SPI0 instance
//==========================================================
#ifndef SPI0_ENABLED
#define SPI0_ENABLED 1
#endif
#if SPI0_ENABLED
// <q> SPI0_USE_EASY_DMA - Use EasyDMA
#ifndef SPI0_USE_EASY_DMA
#define SPI0_USE_EASY_DMA 1
#endif
// <o> SPI0_DEFAULT_FREQUENCY - SPI frequency
// <33554432=> 125 kHz
// <67108864=> 250 kHz
// <134217728=> 500 kHz
// <268435456=> 1 MHz
// <536870912=> 2 MHz
// <1073741824=> 4 MHz
// <2147483648=> 8 MHz
#ifndef SPI0_DEFAULT_FREQUENCY
#define SPI0_DEFAULT_FREQUENCY 1073741824
#endif
#endif //SPI0_ENABLED
// </e>
main.c
#include "nrf_drv_spi.h"
// SPI //
#define SPI_INSTANCE 0 /**< SPI instance index. */
static const nrf_drv_spi_t spi = NRF_DRV_SPI_INSTANCE(SPI_INSTANCE); /**< SPI instance. */
static volatile bool spi_xfer_done; /**< Flag used to indicate that SPI instance completed the transfer. */
static uint8_t m_tx_buf[256]; /**< TX buffer. */
static uint8_t m_rx_buf[256]; /**< RX buffer. */
/**
* @brief SPI user event handler.
* @param event
*/
void spi_event_handler(nrf_drv_spi_evt_t const* p_event, void* p_context){
spi_xfer_done = true;
}
void spi_init(){
nrf_drv_spi_config_t spi_config = NRF_DRV_SPI_DEFAULT_CONFIG;
spi_config.ss_pin = 1;
spi_config.miso_pin = 2;
spi_config.mosi_pin = 3;
spi_config.sck_pin = 4;
APP_ERROR_CHECK(nrf_drv_spi_init(&spi, &spi_config, spi_event_handler, NULL));
}
I get errors like
*** Using Compiler 'V5.06 (build 20)', folder: 'C:\Keil_v5\ARM\ARMCC\Bin'
Build target 'nrf52832_xxaa'
compiling main.c...
..\..\..\main.c(82): error: #29: expected an expression
static const nrf_drv_spi_t spi =
RF_DRV_SPI_INSTANCE(SPI_INSTANCE); /**< SPI instance. */
..\..\..\main.c(82): error: #29: expected an expression
static const nrf_drv_spi_t spi =
RF_DRV_SPI_INSTANCE(SPI_INSTANCE); /**< SPI instance. */
..\..\..\main.c(82): error: #29: expected an expression
static const nrf_drv_spi_t spi =
RF_DRV_SPI_INSTANCE(SPI_INSTANCE); /**< SPI instance. */
..\..\..\main.c(82): error: #29: expected an expression
static const nrf_drv_spi_t spi =
RF_DRV_SPI_INSTANCE(SPI_INSTANCE); /**< SPI instance. */
..\..\..\main.c(96): error: #29: expected an expression
nrf_drv_spi_config_t spi_config =
RF_DRV_SPI_DEFAULT_CONFIG;
..\..\..\main.c(96): error: #29: expected an expression
nrf_drv_spi_config_t spi_config =
RF_DRV_SPI_DEFAULT_CONFIG;
..\..\..\main.c(96): error: #29: expected an expression
nrf_drv_spi_config_t spi_config =
RF_DRV_SPI_DEFAULT_CONFIG;
..\..\..\main.c(96): error: #29: expected an expression
nrf_drv_spi_config_t spi_config =
RF_DRV_SPI_DEFAULT_CONFIG;
..\..\..\main.c(96): error: #29: expected an expression
nrf_drv_spi_config_t spi_config =
RF_DRV_SPI_DEFAULT_CONFIG;
..\..\..\main.c(96): error: #29: expected an expression
nrf_drv_spi_config_t spi_config =
RF_DRV_SPI_DEFAULT_CONFIG;
..\..\..\main.c(96): error: #29: expected an expression
nrf_drv_spi_config_t spi_config =
RF_DRV_SPI_DEFAULT_CONFIG;
..\..\..\main.c(96): error: #29: expected an expression
nrf_drv_spi_config_t spi_config =
RF_DRV_SPI_DEFAULT_CONFIG;
..\..\..\main.c(96): error: #29: expected an expression
nrf_drv_spi_config_t spi_config =
RF_DRV_SPI_DEFAULT_CONFIG;
..\..\..\main.c(84): warning: #177-D: variable "m_tx_buf" was declared but never referenced
static uint8_t m_tx_buf[256]; /**< TX buffer. */
..\..\..\main.c(85): warning: #177-D: variable "m_rx_buf" was declared but never referenced
static uint8_t m_rx_buf[256]; /**< RX buffer. */
..\..\..\main.c: 2 warnings, 13 errors
".\_build\nrf52832_xxaa.axf" - 13 Error(s), 2 Warning(s).
Target not created.
Build Time Elapsed: 00:00:02
How can I use nrf52 interface through ordinary method? I'm using nrf52832 DK.