Skip to content

Commit 5509f39

Browse files
committed
nrf: Add a nrfx submodule and prepare for using the new drivers
1 parent 7cd34f2 commit 5509f39

File tree

20 files changed

+63
-142
lines changed

20 files changed

+63
-142
lines changed

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,3 +70,6 @@
7070
[submodule "ports/atmel-samd/peripherals"]
7171
path = ports/atmel-samd/peripherals
7272
url = https://github.com/adafruit/samd-peripherals.git
73+
[submodule "ports/nrf/nrfx"]
74+
path = ports/nrf/nrfx
75+
url = https://github.com/NordicSemiconductor/nrfx.git

ports/nrf/Makefile

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,6 @@ FATFS_DIR = lib/oofatfs
4242

4343
CROSS_COMPILE = arm-none-eabi-
4444

45-
MCU_VARIANT_UPPER = $(shell echo $(MCU_VARIANT) | tr '[:lower:]' '[:upper:]')
46-
4745
INC += -I.
4846
INC += -I../..
4947
INC += -I$(BUILD)
@@ -63,7 +61,6 @@ INC += -I../../lib/mp-readline
6361
INC += -I./drivers/bluetooth
6462
INC += -I./drivers
6563

66-
NRF_DEFINES += -D$(MCU_VARIANT_UPPER)
6764
NRF_DEFINES += -DCONFIG_GPIO_AS_PINRESET
6865

6966
CFLAGS += -mthumb -mabi=aapcs -fsingle-precision-constant -Wdouble-promotion
@@ -73,6 +70,7 @@ CFLAGS += -fno-strict-aliasing
7370
CFLAGS += -fstack-usage
7471
CFLAGS += -fdata-sections -ffunction-sections
7572
CFLAGS += -DNRF5_HAL_H='<$(MCU_VARIANT)_hal.h>'
73+
CFLAGS += -D__START=main
7674

7775
LDFLAGS = $(CFLAGS)
7876
LDFLAGS += -Xlinker -Map=$(@:.elf=.map)
@@ -125,7 +123,7 @@ SRC_C += \
125123
drivers/bluetooth/ble_drv.c \
126124
drivers/bluetooth/ble_uart.c \
127125
boards/$(BOARD)/board.c \
128-
device/$(MCU_VARIANT)/system_$(MCU_SUB_VARIANT).c \
126+
nrfx/mdk/system_$(MCU_SUB_VARIANT).c \
129127
device/$(MCU_VARIANT)/startup_$(MCU_SUB_VARIANT).c \
130128
lib/oofatfs/ff.c \
131129
lib/oofatfs/option/ccsbcs.c \

ports/nrf/boards/feather52832/mpconfigboard.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MCU_SERIES = m4
22
MCU_VARIANT = nrf52
3-
MCU_SUB_VARIANT = nrf52832
3+
MCU_SUB_VARIANT = nrf52
44
SOFTDEV_VERSION ?= 2.0.1
55

66
LD_FILE = boards/feather52832/custom_nrf52832_dfu_app_$(SOFTDEV_VERSION).ld
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MCU_SERIES = m4
22
MCU_VARIANT = nrf52
3-
MCU_SUB_VARIANT = nrf52832
3+
MCU_SUB_VARIANT = nrf52
44
LD_FILE = boards/nrf52832_512k_64k.ld
55

66
NRF_DEFINES += -DNRF52832_XXAA

ports/nrf/boards/pca10040/mpconfigboard_s132.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MCU_SERIES = m4
22
MCU_VARIANT = nrf52
3-
MCU_SUB_VARIANT = nrf52832
3+
MCU_SUB_VARIANT = nrf52
44
SOFTDEV_VERSION = 5.0.0
55

66
LD_FILE = boards/nrf52832_512k_64k_s132_$(SOFTDEV_VERSION).ld

ports/nrf/drivers/bluetooth/ble_drv.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@
3030
#include <string.h>
3131
#include <stdbool.h>
3232

33+
#define NRF52 // Needed for SD132 v2
34+
3335
#include "py/runtime.h"
3436
#include "ble_drv.h"
3537
#include "mpconfigport.h"

ports/nrf/hal/hal_gpio.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ void GPIOTE_IRQHandler(void) {
9494
GPIOTE_BASE->EVENTS_IN[3] = 0;
9595
m_callback(HAL_GPIO_EVENT_CHANNEL_3);
9696
}
97-
#if NRF52
97+
9898
if (GPIOTE_BASE->EVENTS_IN[4]) {
9999
GPIOTE_BASE->EVENTS_IN[4] = 0;
100100
m_callback(HAL_GPIO_EVENT_CHANNEL_4);
@@ -111,7 +111,6 @@ void GPIOTE_IRQHandler(void) {
111111
GPIOTE_BASE->EVENTS_IN[7] = 0;
112112
m_callback(HAL_GPIO_EVENT_CHANNEL_7);
113113
}
114-
#endif
115114
}
116115

117116
#endif // if 0

ports/nrf/hal/hal_gpio.h

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -29,18 +29,12 @@
2929

3030
#include "nrf.h"
3131

32-
#if NRF51
33-
#define POINTERS (const uint32_t[]){NRF_GPIO_BASE}
32+
#ifdef NRF52832_XXAA
33+
#define POINTERS (const uint32_t[]){NRF_P0_BASE}
3434
#endif
3535

36-
#if NRF52
37-
#ifdef NRF52832_XXAA
38-
#define POINTERS (const uint32_t[]){NRF_P0_BASE}
39-
#endif
40-
41-
#ifdef NRF52840_XXAA
42-
#define POINTERS (const uint32_t[]){NRF_P0_BASE, NRF_P1_BASE}
43-
#endif
36+
#ifdef NRF52840_XXAA
37+
#define POINTERS (const uint32_t[]){NRF_P0_BASE, NRF_P1_BASE}
4438
#endif
4539

4640
#define GPIO_BASE(x) ((NRF_GPIO_Type *)POINTERS[x])
@@ -133,12 +127,10 @@ typedef enum {
133127
HAL_GPIO_EVENT_CHANNEL_1,
134128
HAL_GPIO_EVENT_CHANNEL_2,
135129
HAL_GPIO_EVENT_CHANNEL_3,
136-
#if NRF52
137130
HAL_GPIO_EVENT_CHANNEL_4,
138131
HAL_GPIO_EVENT_CHANNEL_5,
139132
HAL_GPIO_EVENT_CHANNEL_6,
140133
HAL_GPIO_EVENT_CHANNEL_7
141-
#endif
142134
} hal_gpio_event_channel_t;
143135

144136
typedef struct {

ports/nrf/hal/hal_irq.h

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,8 @@
3737

3838
#define BLUETOOTH_STACK_ENABLED() (ble_drv_stack_enabled())
3939

40-
#ifdef NRF51
41-
#include "nrf_soc.h"
42-
#elif defined(NRF52)
43-
#include "nrf_nvic.h"
44-
#endif
40+
#define NRF52
41+
#include "nrf_nvic.h"
4542
#endif // BLUETOOTH_SD
4643

4744
static inline void hal_irq_clear(uint32_t irq_num) {

0 commit comments

Comments
 (0)