-
Notifications
You must be signed in to change notification settings - Fork 2.1k
cpu/nrf9160: add twi and spi support #16814
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cpu/nrf9160: add twi and spi support #16814
Conversation
393fcdf
to
87c732d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, please squash!
I think it would make sense to merge |
Not really. nRF9160 is a cortex-m33 but they share the same peripherals with a few difference. |
I would like someone to check if this PR didn't not break something in nRF52 SPI and I2C before merging if possible. |
Sure, let me run
I attached a AT24C EEPROM to the I2C bus
still works! |
e52b537
to
0c60a2a
Compare
Squashed, thanks for testing on nRF52 platform ! |
hm looks like you need something like --- a/pkg/nimble/Makefile.dep
+++ b/pkg/nimble/Makefile.dep
@@ -42,7 +42,7 @@ endif
# nimble controller dependencies
ifneq (,$(filter nimble_controller,$(USEMODULE)))
USEMODULE += nimble_transport_ram
- ifneq (,$(filter nrf5%,$(CPU_FAM)))
+ ifneq (,$(filter nrf9160 nrf5%,$(CPU_FAM)))
USEMODULE += nimble_drivers_nrf5x
endif
endif |
Hmm no you would need more than that, this is based on the fact that diff --git a/pkg/nimble/Makefile.dep b/pkg/nimble/Makefile.dep
index 07d4caf282..45e8d47ec8 100644
--- a/pkg/nimble/Makefile.dep
+++ b/pkg/nimble/Makefile.dep
@@ -18,7 +18,9 @@ USEMODULE += nimble_porting_nimble
ifneq (,$(filter mynewt-core,$(USEPKG)))
USEMODULE += mynewt-core_os
USEMODULE += mynewt-core_util
- USEMODULE += mynewt-core_nrf5x_hal
+ ifneq (,$(filter nrf5%,$(CPU)))
+ USEMODULE += mynewt-core_nrf5x_hal
+ endif
else
# uwb-% requires mynewt-core so is incompatible with nimble_npl_riot
ifeq (,$(filter uwb%,$(USEPKG)))
diff --git a/pkg/uwb-core/Makefile.dep b/pkg/uwb-core/Makefile.dep
index b4f0c0355a..fd59855a7a 100644
--- a/pkg/uwb-core/Makefile.dep
+++ b/pkg/uwb-core/Makefile.dep
@@ -25,7 +25,7 @@ endif
ifneq (,$(filter uwb-core_dpl,$(USEMODULE)))
USEPKG += mynewt-core
USEMODULE += mynewt-core_os
- ifneq (,$(filter nrf%,$(CPU)))
+ ifneq (,$(filter nrf5%,$(CPU)))
USEMODULE += mynewt-core_nrf5x_hal
endif
endif |
Wait wait wait, why should nimble even tries to compile on nRF9160 ? It doesn't have a bluetooth radio ! |
Then its unrelated, it just appplies to |
Sadly, this is not enough. I've got new errors then. |
I'll find the fix, this is a bad assumption on my side with the pkg. This should do: diff --git a/pkg/mynewt-core/contrib/Makefile b/pkg/mynewt-core/contrib/Makefile
index 0bb65a903f..c16f097dad 100644
--- a/pkg/mynewt-core/contrib/Makefile
+++ b/pkg/mynewt-core/contrib/Makefile
@@ -3,7 +3,7 @@ MODULE = mynewt-core
# exclude submodule sources from *.c wildcard source selection
SRC := $(filter-out nrf5x_isr.c cputime.c,$(wildcard *.c))
-ifneq (,$(filter nrf%,$(CPU)))
+ifneq (,$(filter nrf5%,$(CPU)))
SRC += nrf5x_isr.c
else
SRC += cputime.c
diff --git a/pkg/mynewt-core/mynewt-core_os.mk b/pkg/mynewt-core/mynewt-core_os.mk
index 8077bdeabe..6bfbccbb1b 100644
--- a/pkg/mynewt-core/mynewt-core_os.mk
+++ b/pkg/mynewt-core/mynewt-core_os.mk
@@ -8,7 +8,7 @@ SRC := \
os_cputime_pwr2.c \
#
-ifneq (,$(filter nrf%,$(CPU)))
+ifneq (,$(filter nrf5%,$(CPU)))
SRC += os_cputime.c
endif
diff --git a/pkg/uwb-core/Makefile.dep b/pkg/uwb-core/Makefile.dep
index b4f0c0355a..fd59855a7a 100644
--- a/pkg/uwb-core/Makefile.dep
+++ b/pkg/uwb-core/Makefile.dep
@@ -25,7 +25,7 @@ endif
ifneq (,$(filter uwb-core_dpl,$(USEMODULE)))
USEPKG += mynewt-core
USEMODULE += mynewt-core_os
- ifneq (,$(filter nrf%,$(CPU)))
+ ifneq (,$(filter nrf5%,$(CPU)))
USEMODULE += mynewt-core_nrf5x_hal
endif
endif |
@fjmolinas Your last patch did the trick ! Thanks for your help :) |
Separete commit is fine IMO |
As nRF9160 doesn't have a bluetooth radio, we should not pull the same dependencies as nRF52, thus ensure these dependencies are only added for nrf5x families
As nRF9160 doesn't have a bluetooth radio, we should not pull the same dependencies as nRF52, thus ensure these dependencies are only added for nrf5x families
any last words for this one ? |
tests/periph_spi: printing and testing SPI clock rates drivers/periph_spi: change API of spi_acquire (from RIOT-OS#15904) drivers/periph_spi: add the `bus` parameter to spi_get_*() This was necessary for implementations where multiple devices can have different clock sources. This broke the macros SPI_CLK_* that were reverted to an enum. periph/spi: adapted to the new API Arbitrary speed support was added to all implementations where it was missing except kinetis. nrf52/periph/spi: moved in nfr5x_common (RIOT-OS#16814)
tests/periph_spi: printing and testing SPI clock rates drivers/periph_spi: change API of spi_acquire (from RIOT-OS#15904) drivers/periph_spi: add the `bus` parameter to spi_get_*() This was necessary for implementations where multiple devices can have different clock sources. This broke the macros SPI_CLK_* that were reverted to an enum. periph/spi: adapted to the new API Arbitrary speed support was added to all implementations where it was missing. nrf52/periph/spi: moved in nfr5x_common (RIOT-OS#16814)
tests/periph_spi: printing and testing SPI clock rates drivers/periph_spi: change API of spi_acquire (from RIOT-OS#15904) drivers/periph_spi: add the `bus` parameter to spi_get_*() This was necessary for implementations where multiple devices can have different clock sources. This broke the macros SPI_CLK_* that were reverted to an enum. periph/spi: adapted to the new API Arbitrary speed support was added to all implementations where it was missing. nrf52/periph/spi: moved in nfr5x_common (RIOT-OS#16814)
tests/periph_spi: printing and testing SPI clock rates drivers/periph_spi: change API of spi_acquire (from RIOT-OS#15904) drivers/periph_spi: add the `bus` parameter to spi_get_*() This was necessary for implementations where multiple devices can have different clock sources. This broke the macros SPI_CLK_* that were reverted to an enum. periph/spi: adapted to the new API Arbitrary speed support was added to all implementations where it was missing. nrf52/periph/spi: moved in nfr5x_common (RIOT-OS#16814)
Contribution description
This PR adds support for I2C and SPI for nRF9160 MCUs.
Since these IPs are the same as nRF52. I moved SPI and I2C code to nrf5x_common (I did not touch nRF51 drivers). And I also recreate a SPI/I2C irq handler to match the behaviour of nrf52 platform.
It would be good to ensure nothing is broken on nRF52 platform with this PR but I don't have the hardware with me for now.
Testing procedure
on nRF52 based board and nRF9160dk, use
tests/periph_i2c
andtests/periph_spi
to test.I provide some output from my custom nRF9160 based board:
tests/driver_hts221:
tests/mtd_raw:
Issues/PRs references
None.