}, #endif #if SPI2_ENABLED { SPIS2_IRQ, (uint32_t) SPIM2_SPIS2_SPI2_IRQHandler }, #endif }; static sdk_driver_instances_t m_instances[SPI_COUNT] = { #if SPI0_ENABLED { NRF_DRV_SPI_INSTANCE(0), NRF_DRV_SPIS_INSTANCE(0) }, #endif #if SPI1_ENABLED { NRF_DRV_SPI_INSTANCE(1), NRF_DRV_SPIS_INSTANCE(1) }, #endif #if SPI2_ENABLED { NRF_DRV_SPI_INSTANCE(2), NRF_DRV_SPIS_INSTANCE(2) }, #endif };
#include "nrf_log.h" #include "nrf_gpio.h" #include "boards.h" #include "app_error.h" #include <string.h> #if defined(BOARD_PCA10036) || defined(BOARD_PCA10040) #define SPIS_CS_PIN 29 /**< SPIS CS Pin. Should be shortened with @ref SPI_CS_PIN */ #elif defined(BOARD_PCA10028) #define SPIS_CS_PIN 4 /**< SPIS CS Pin. Should be shortened with @ref SPI_CS_PIN */ #else #error "Example is not supported on that board." #endif #define SPIS_INSTANCE 1 /**< SPIS instance index. */ static const nrf_drv_spis_t spis = NRF_DRV_SPIS_INSTANCE(SPIS_INSTANCE);/**< SPIS instance. */ #define TEST_STRING "Nordic" static uint8_t m_tx_buf[] = TEST_STRING; /**< TX buffer. */ static uint8_t m_rx_buf[sizeof(TEST_STRING)+1]; /**< RX buffer. */ static const uint8_t m_length = sizeof(m_tx_buf); /**< Transfer length. */ static volatile bool spis_xfer_done; /**< Flag used to indicate that SPIS instance completed the transfer. */ /** * @brief SPIS user event handler. * * @param event */ void spis_event_handler(nrf_drv_spis_event_t event) {
#include "nrf_gpiote.h" #include "nrf_soc.h" #include "app_error.h" #include "app_util.h" #include "ser_phy_config_conn_nrf51.h" #include "ser_phy_debug_conn.h" #include "app_error.h" #define _static static #define SER_PHY_SPI_5W_MTU_SIZE SER_PHY_SPI_MTU_SIZE #define SER_PHY_SPI_DEF_CHARACTER 0xFF //SPI default character. Character clocked out in case of an ignored transaction #define SER_PHY_SPI_ORC_CHARACTER 0xFF //SPI over-read character. Character clocked out after an over-read of the transmit buffer static nrf_drv_spis_t m_spis = NRF_DRV_SPIS_INSTANCE(SER_PHY_SPI_SLAVE_INSTANCE); #define _SPI_5W_ //SPI raw peripheral device configuration data typedef struct { int32_t pin_req; //SPI /REQ pin. -1 for not using int32_t pin_rdy; //SPI /RDY pin. -1 for not using int32_t ppi_rdy_ch; //SPI /RDY ppi ready channel int32_t gpiote_rdy_ch; //SPI /RDY pin ready channel } spi_slave_raw_trasp_cfg_t; /**@brief States of the SPI transaction state machine. */ typedef enum {
* */ #include "spi_slave_example.h" #include "nrf_drv_spis.h" #include "app_error.h" #include "bsp.h" #define SPIS_INSTANCE_NUMBER 1 #define TX_BUF_SIZE 16u /**< SPI TX buffer size. */ #define RX_BUF_SIZE TX_BUF_SIZE /**< SPI RX buffer size. */ #define DEF_CHARACTER 0xAAu /**< SPI default character. Character clocked out in case of an ignored transaction. */ #define ORC_CHARACTER 0x55u /**< SPI over-read character. Character clocked out after an over-read of the transmit buffer. */ static nrf_drv_spis_t const m_spis = NRF_DRV_SPIS_INSTANCE(SPIS_INSTANCE_NUMBER); static uint8_t m_tx_buf[TX_BUF_SIZE]; /**< SPI TX buffer. */ static uint8_t m_rx_buf[RX_BUF_SIZE]; /**< SPI RX buffer. */ /**@brief Function for initializing buffers. * * @param[in] p_tx_buf Pointer to a transmit buffer. * @param[in] p_rx_buf Pointer to a receive buffer. * @param[in] len Buffers length. */ static __INLINE void spi_slave_buffers_init(uint8_t * const p_tx_buf, uint8_t * const p_rx_buf, const uint16_t len) { uint16_t i; for (i = 0; i < len; i++) {