Skip to content

Commit 6fe4dc9

Browse files
sarahmarshy0xc0170
authored andcommitted
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.
1 parent dfcbb4c commit 6fe4dc9

File tree

4 files changed

+639
-473
lines changed

4 files changed

+639
-473
lines changed

targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_NRF52/TARGET_MCU_NRF52832/config/sdk_config.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2666,7 +2666,7 @@
26662666

26672667

26682668
#ifndef SPI0_USE_EASY_DMA
2669-
#define SPI0_USE_EASY_DMA 1
2669+
#define SPI0_USE_EASY_DMA 0
26702670
#endif
26712671

26722672
// <o> SPI0_DEFAULT_FREQUENCY - SPI frequency
@@ -2688,13 +2688,13 @@
26882688
// <e> SPI1_ENABLED - Enable SPI1 instance
26892689
//==========================================================
26902690
#ifndef SPI1_ENABLED
2691-
#define SPI1_ENABLED 0
2691+
#define SPI1_ENABLED 1
26922692
#endif
26932693
// <q> SPI1_USE_EASY_DMA - Use EasyDMA
26942694

26952695

26962696
#ifndef SPI1_USE_EASY_DMA
2697-
#define SPI1_USE_EASY_DMA 1
2697+
#define SPI1_USE_EASY_DMA 0
26982698
#endif
26992699

27002700
// <o> SPI1_DEFAULT_FREQUENCY - SPI frequency
@@ -2716,13 +2716,13 @@
27162716
// <e> SPI2_ENABLED - Enable SPI2 instance
27172717
//==========================================================
27182718
#ifndef SPI2_ENABLED
2719-
#define SPI2_ENABLED 0
2719+
#define SPI2_ENABLED 1
27202720
#endif
27212721
// <q> SPI2_USE_EASY_DMA - Use EasyDMA
27222722

27232723

27242724
#ifndef SPI2_USE_EASY_DMA
2725-
#define SPI2_USE_EASY_DMA 1
2725+
#define SPI2_USE_EASY_DMA 0
27262726
#endif
27272727

27282728
// <o> SPI2_DEFAULT_FREQUENCY - SPI frequency
@@ -2928,7 +2928,7 @@
29282928
// <e> TWI_ENABLED - nrf_drv_twi - TWI/TWIM peripheral driver
29292929
//==========================================================
29302930
#ifndef TWI_ENABLED
2931-
#define TWI_ENABLED 0
2931+
#define TWI_ENABLED 1
29322932
#endif
29332933
// <o> TWI_DEFAULT_CONFIG_FREQUENCY - Frequency
29342934

@@ -2988,7 +2988,7 @@
29882988
// <e> TWI1_ENABLED - Enable TWI1 instance
29892989
//==========================================================
29902990
#ifndef TWI1_ENABLED
2991-
#define TWI1_ENABLED 0
2991+
#define TWI1_ENABLED 1
29922992
#endif
29932993
// <q> TWI1_USE_EASY_DMA - Use EasyDMA (if present)
29942994

targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_NRF52/TARGET_MCU_NRF52840/config/sdk_config.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2666,7 +2666,7 @@
26662666

26672667

26682668
#ifndef SPI0_USE_EASY_DMA
2669-
#define SPI0_USE_EASY_DMA 1
2669+
#define SPI0_USE_EASY_DMA 0
26702670
#endif
26712671

26722672
// <o> SPI0_DEFAULT_FREQUENCY - SPI frequency
@@ -2688,13 +2688,13 @@
26882688
// <e> SPI1_ENABLED - Enable SPI1 instance
26892689
//==========================================================
26902690
#ifndef SPI1_ENABLED
2691-
#define SPI1_ENABLED 0
2691+
#define SPI1_ENABLED 1
26922692
#endif
26932693
// <q> SPI1_USE_EASY_DMA - Use EasyDMA
26942694

26952695

26962696
#ifndef SPI1_USE_EASY_DMA
2697-
#define SPI1_USE_EASY_DMA 1
2697+
#define SPI1_USE_EASY_DMA 0
26982698
#endif
26992699

27002700
// <o> SPI1_DEFAULT_FREQUENCY - SPI frequency
@@ -2716,13 +2716,13 @@
27162716
// <e> SPI2_ENABLED - Enable SPI2 instance
27172717
//==========================================================
27182718
#ifndef SPI2_ENABLED
2719-
#define SPI2_ENABLED 0
2719+
#define SPI2_ENABLED 1
27202720
#endif
27212721
// <q> SPI2_USE_EASY_DMA - Use EasyDMA
27222722

27232723

27242724
#ifndef SPI2_USE_EASY_DMA
2725-
#define SPI2_USE_EASY_DMA 1
2725+
#define SPI2_USE_EASY_DMA 0
27262726
#endif
27272727

27282728
// <o> SPI2_DEFAULT_FREQUENCY - SPI frequency
@@ -2928,7 +2928,7 @@
29282928
// <e> TWI_ENABLED - nrf_drv_twi - TWI/TWIM peripheral driver
29292929
//==========================================================
29302930
#ifndef TWI_ENABLED
2931-
#define TWI_ENABLED 0
2931+
#define TWI_ENABLED 1
29322932
#endif
29332933
// <o> TWI_DEFAULT_CONFIG_FREQUENCY - Frequency
29342934

@@ -2988,7 +2988,7 @@
29882988
// <e> TWI1_ENABLED - Enable TWI1 instance
29892989
//==========================================================
29902990
#ifndef TWI1_ENABLED
2991-
#define TWI1_ENABLED 0
2991+
#define TWI1_ENABLED 1
29922992
#endif
29932993
// <q> TWI1_USE_EASY_DMA - Use EasyDMA (if present)
29942994

targets/TARGET_NORDIC/TARGET_NRF5x/objects.h

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@
4343
#include "PortNames.h"
4444
#include "PeripheralNames.h"
4545
#include "PinNames.h"
46+
#include "nrf_drv_spi.h"
47+
#include "nrf_twi.h"
4648

4749
#include "nrf_pwm.h"
4850

@@ -55,7 +57,16 @@ struct serial_s {
5557
}; // but it must be not empty (required by strict compiler - IAR)
5658

5759
struct spi_s {
58-
uint8_t spi_idx;
60+
int instance;
61+
PinName cs;
62+
nrf_drv_spi_config_t config;
63+
bool update;
64+
65+
#if DEVICE_SPI_ASYNCH
66+
uint32_t handler;
67+
uint32_t mask;
68+
uint32_t event;
69+
#endif
5970
};
6071

6172
struct port_s {
@@ -73,7 +84,19 @@ struct pwmout_s {
7384
};
7485

7586
struct i2c_s {
76-
uint8_t twi_idx;
87+
int instance;
88+
PinName sda;
89+
PinName scl;
90+
nrf_twi_frequency_t frequency;
91+
int state;
92+
int mode;
93+
bool update;
94+
95+
#if DEVICE_I2C_ASYNCH
96+
uint32_t handler;
97+
uint32_t mask;
98+
uint32_t event;
99+
#endif
77100
};
78101

79102
struct analogin_s {

0 commit comments

Comments
 (0)