Implement SPI API for NRF52x

Implement spi_api.c for NRF52X boards using SDK14.

This driver does not implement SPI slave functions and does not use SPIM.
pull/6547/head
sarahmarshy 2018-02-22 13:35:57 -06:00 committed by Marcus Chang
parent d11f74cb4c
commit c9d16e9e89
4 changed files with 666 additions and 500 deletions

View File

@ -2666,7 +2666,7 @@
#ifndef SPI0_USE_EASY_DMA
#define SPI0_USE_EASY_DMA 1
#define SPI0_USE_EASY_DMA 0
#endif
// <o> SPI0_DEFAULT_FREQUENCY - SPI frequency
@ -2688,13 +2688,13 @@
// <e> SPI1_ENABLED - Enable SPI1 instance
//==========================================================
#ifndef SPI1_ENABLED
#define SPI1_ENABLED 0
#define SPI1_ENABLED 1
#endif
// <q> SPI1_USE_EASY_DMA - Use EasyDMA
#ifndef SPI1_USE_EASY_DMA
#define SPI1_USE_EASY_DMA 1
#define SPI1_USE_EASY_DMA 0
#endif
// <o> SPI1_DEFAULT_FREQUENCY - SPI frequency
@ -2716,13 +2716,13 @@
// <e> SPI2_ENABLED - Enable SPI2 instance
//==========================================================
#ifndef SPI2_ENABLED
#define SPI2_ENABLED 0
#define SPI2_ENABLED 1
#endif
// <q> SPI2_USE_EASY_DMA - Use EasyDMA
#ifndef SPI2_USE_EASY_DMA
#define SPI2_USE_EASY_DMA 1
#define SPI2_USE_EASY_DMA 0
#endif
// <o> SPI2_DEFAULT_FREQUENCY - SPI frequency
@ -2928,7 +2928,7 @@
// <e> TWI_ENABLED - nrf_drv_twi - TWI/TWIM peripheral driver
//==========================================================
#ifndef TWI_ENABLED
#define TWI_ENABLED 0
#define TWI_ENABLED 1
#endif
// <o> TWI_DEFAULT_CONFIG_FREQUENCY - Frequency
@ -2988,7 +2988,7 @@
// <e> TWI1_ENABLED - Enable TWI1 instance
//==========================================================
#ifndef TWI1_ENABLED
#define TWI1_ENABLED 0
#define TWI1_ENABLED 1
#endif
// <q> TWI1_USE_EASY_DMA - Use EasyDMA (if present)

View File

@ -2666,7 +2666,7 @@
#ifndef SPI0_USE_EASY_DMA
#define SPI0_USE_EASY_DMA 1
#define SPI0_USE_EASY_DMA 0
#endif
// <o> SPI0_DEFAULT_FREQUENCY - SPI frequency
@ -2688,13 +2688,13 @@
// <e> SPI1_ENABLED - Enable SPI1 instance
//==========================================================
#ifndef SPI1_ENABLED
#define SPI1_ENABLED 0
#define SPI1_ENABLED 1
#endif
// <q> SPI1_USE_EASY_DMA - Use EasyDMA
#ifndef SPI1_USE_EASY_DMA
#define SPI1_USE_EASY_DMA 1
#define SPI1_USE_EASY_DMA 0
#endif
// <o> SPI1_DEFAULT_FREQUENCY - SPI frequency
@ -2716,13 +2716,13 @@
// <e> SPI2_ENABLED - Enable SPI2 instance
//==========================================================
#ifndef SPI2_ENABLED
#define SPI2_ENABLED 0
#define SPI2_ENABLED 1
#endif
// <q> SPI2_USE_EASY_DMA - Use EasyDMA
#ifndef SPI2_USE_EASY_DMA
#define SPI2_USE_EASY_DMA 1
#define SPI2_USE_EASY_DMA 0
#endif
// <o> SPI2_DEFAULT_FREQUENCY - SPI frequency
@ -2928,7 +2928,7 @@
// <e> TWI_ENABLED - nrf_drv_twi - TWI/TWIM peripheral driver
//==========================================================
#ifndef TWI_ENABLED
#define TWI_ENABLED 0
#define TWI_ENABLED 1
#endif
// <o> TWI_DEFAULT_CONFIG_FREQUENCY - Frequency
@ -2988,7 +2988,7 @@
// <e> TWI1_ENABLED - Enable TWI1 instance
//==========================================================
#ifndef TWI1_ENABLED
#define TWI1_ENABLED 0
#define TWI1_ENABLED 1
#endif
// <q> TWI1_USE_EASY_DMA - Use EasyDMA (if present)

View File

@ -43,6 +43,8 @@
#include "PortNames.h"
#include "PeripheralNames.h"
#include "PinNames.h"
#include "nrf_drv_spi.h"
#include "nrf_twi.h"
#include "nrf_pwm.h"
@ -55,7 +57,16 @@ struct serial_s {
}; // but it must be not empty (required by strict compiler - IAR)
struct spi_s {
uint8_t spi_idx;
int instance;
PinName cs;
nrf_drv_spi_config_t config;
bool update;
#if DEVICE_SPI_ASYNCH
uint32_t handler;
uint32_t mask;
uint32_t event;
#endif
};
struct port_s {
@ -73,7 +84,19 @@ struct pwmout_s {
};
struct i2c_s {
uint8_t twi_idx;
int instance;
PinName sda;
PinName scl;
nrf_twi_frequency_t frequency;
int state;
int mode;
bool update;
#if DEVICE_I2C_ASYNCH
uint32_t handler;
uint32_t mask;
uint32_t event;
#endif
};
struct analogin_s {

File diff suppressed because it is too large Load Diff