-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Add support for the Sillicon Labs Thunderboard Sense (updated) #7929
Conversation
To address some of the previous comments:
The emlib files are now a package, the other vendor files are in the
The emlib files are now a package.
Turns out that this is still needed until selective compilation of peripherals is included (cannot find PR number this quick).
Done.
Done, but using my own mirror, since Silicon Labs is not updating their repository anymore. |
So, this PR is the start of fixing #1123. If this PR gets merged, I will open additional PR's to add support for the following boards (I own most of them):
Optionally (will replace existing one):
In total, I can add support for 715 additional MCUs (34 families). That is excluding devices with less than 4kb of flash and 8kb of memory. |
Would you mind rebaseing this to #7241? I hope to be able to merge it today... |
@kaspar030 Yeah sure, I'll adapt this PR after #7241 gets merged. |
Awesome, and thanks for sticking with this, despite the trouble I might have caused you :-) Will review the PR now. Already tested it (with #7921 being merged) and it works like a charm... |
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.
Looking good! Some remarks (of which some are probably subjective and debatable..).
{ | ||
.name = "Button 1", | ||
.pin = PB0_PIN, | ||
.mode = GPIO_IN_PU |
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.
you could add .flags = SAUL_GPIO_INVERTED
here to reflect active low circuit of the buttons...
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.
Done, thanks for de addition.
boards/sltb001a/Makefile.features
Outdated
@@ -0,0 +1,19 @@ | |||
# Put defined MCU peripherals here (in alphabetical order) | |||
FEATURES_PROVIDED += periph_adc | |||
FEATURES_PROVIDED += periph_cpuid |
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.
could you adapt the list of features to the changes introduced in #7880?
So move all features that don't depend on any board specific configuration (e.g. cpuid) to the (possibly shared) CPU's makefile.features, which then needs to be included from this file.
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.
I only moved periph_cpuid
.
boards/sltb001a/board.c
Outdated
#include "periph/gpio.h" | ||
#include "periph/i2c.h" | ||
|
||
#if BMP280_ENABLED || CCS811_ENABLED || ICM_20648_ENABLED || SI1133_ENABLED || SI7021_ENABLED || SI7210A_ENABLED || RGB_LED1_ENABLED || RGB_LED2_ENABLED || RGB_LED3_ENABLED || RGB_LED4_ENABLED |
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.
this line seems to slightly exceed the 80 char line length... :-)
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.
Fixed :-)
boards/sltb001a/board.c
Outdated
#if BMP280_ENABLED || CCS811_ENABLED || ICM_20648_ENABLED || SI1133_ENABLED || SI7021_ENABLED || SI7210A_ENABLED || RGB_LED1_ENABLED || RGB_LED2_ENABLED || RGB_LED3_ENABLED || RGB_LED4_ENABLED | ||
static inline void board_usleep(uint32_t delay) | ||
{ | ||
delay = (delay * 1000) / (1000 / (SystemCoreClock / 1000 / 1000)); |
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.
delay = (delay * (SystemCoreClock / 1000000))
?
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.
Also, divide this value by 2, as the loop takes two instructions (nop
and inc and 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.
I think I have it now:
MHz / 1000 / 1000 -> instructions per usec -> multiply by delay to get number of instructions to skip, divided by two (compare and inc).
boards/sltb001a/include/board.h
Outdated
#ifndef BMP280_ENABLED | ||
#define BMP280_ENABLED (1) | ||
#endif | ||
#define BMP280_I2C (0) |
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.
here and below: this should better be I2C_DEV(0)
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.
Done.
cpu/efr32mg1p/Makefile.include
Outdated
|
||
# enable memory protection unit | ||
USEMODULE += mpu_stack_guard | ||
USEMODULE += pm_layered |
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.
shouldn't pm_layered
be included from efm32_common
?
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.
For the STM32F1/F2/F4 it is also on per-CPU base. Any preference?
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.
The STMs do this on a per-CPU base, as we simply didn't touch all of the CPUs, yet. In the end this will be done in stm32_common
. So as I also see all EFM32 CPUs use that module, I would put the usemodule define there.
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.
Done.
cpu/efr32mg1p/Makefile.include
Outdated
export CPU_ARCH = cortex-m4 | ||
export CPU_FAM = efr32mg1p | ||
|
||
# enable memory protection unit |
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.
any reason for enabling memory protection as default for this CPU? Shouldn't this be something that is enabled by the user?
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.
I'll remove it from here (I think I found it a good idea to enable it by default back then).
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.
I think it makes sense to remove it. This again a matter of expectation: CPUs should only include what their implementation really needs. Everything else should be up to external modules/applications to define.
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.
Done.
cpu/efr32mg1p/periph/Makefile
Outdated
@@ -0,0 +1,3 @@ | |||
MODULE = periph | |||
|
|||
include $(RIOTBASE)/Makefile.base |
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.
probably best to wait for #7241 and adapt before merging.
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.
Not yet included, but will do once merged.
WEAK_DEFAULT void isr_fpueh(void); | ||
|
||
/* interrupt vector table */ | ||
ISR_VECTOR(1) const isr_t vector_cpu[CPU_IRQ_NUMOF] = { |
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.
I would prefer to use the indexed notation here, e.g.
[ 0] = isr_em, ...
[ 2] = isr_wdog0, ...
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.
Fixed.
pkg/emlib/Makefile
Outdated
@@ -0,0 +1,11 @@ | |||
PKG_NAME=emlib | |||
PKG_URL=https://github.com/basilfx/emlib |
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.
just wondering: as we use your fork of the emlib, couldn't we simply apply the patches directly to your fork and skip them in RIOT?
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.
That's fine. I'll rename it, remove the patches and fix the URL.
Thanks @haukepetersen for the review. I have fixed almost all feedback, and improved a few other things:
I think #7241 is the only thing remaining, if you agree :-) |
boards/sltb001a/Makefile.dep
Outdated
ifneq (,$(filter saul_default,$(USEMODULE))) | ||
USEMODULE += saul_gpio | ||
USEMODULE += bmp280 | ||
USEMODULE += si70xx |
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.
once #7296 is merged, here you can use the exact reference of the sensor (si7021 I think)
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.
And included :-)
e2496c9
to
e9f1b3e
Compare
Nice. #7241 is on its way, I expect it to be merged today. |
e9f1b3e
to
e837fbd
Compare
Support for #7241 added and some other fixes have been pushed. There is one problem remaining: due to #7241, What is the best way to fix this? (cc @kaspar030)? (I see a similar case for Other than that, it should be ready. |
One way would be to have a different file for each rtc implementation, and then make "periph_rtc" depend on the right one (e.g., "periph_rtc_gemstone").
hwrng_rngb is currently unused... |
boards/sltb001a/Makefile.include
Outdated
# setup serial terminal | ||
include $(RIOTMAKE)/tools/serial.inc.mk | ||
|
||
# include board dependencies |
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.
remove this here, the file is included by the main Makefile.dep
endif | ||
|
||
# i2c is required for environmental sensors | ||
USEMODULE += periph_i2c |
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.
The sensors should specify their dependencies themselves, in drivers/Makefile.dep.
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.
The board itself needs i2c for enabling the sensors (there is an additional chip on that board that is used as a GPIO expander).
I'll change the comment to reflect that situation.
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.
just this one thing and @kaspar030's last comment, then I think we should be ready to go!
cpu/efm32_common/periph/rtc.c
Outdated
#include "em_cmu.h" | ||
#include "em_rtc.h" | ||
|
||
#if defined(RTC_COUNT) && RTC_COUNT > 0 |
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.
I think these guards should be dropped now, as the RTC is only build if the feature is provided by the board/cpu, which again should only be the case if a valud RTC configuration is present...
cpu/efm32_common/periph/pwm.c
Outdated
#include "em_timer_utils.h" | ||
|
||
/* guard file in case no PWM device was specified */ | ||
#ifdef PWM_NUMOF |
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.
no need anymore, as this file is only build if a pwm feature is defined.
--> please check also all other periph implementation files for this.
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.
Done.
e837fbd
to
0e3bd43
Compare
I've updated + rebased this PR. All comments should be fixed. I also implemented a flashpage driver. New benchmarks/compile results here. |
a847d4b
to
d60204c
Compare
It's finally green 😎 Last few commits include whitespace removal and Doxygen fixes. If permitted, I'll squash it down into the first four commits. |
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 now! -> ACK
please squash
d60204c
to
da40837
Compare
Squashed! And it's green! I'll add the Wiki page after this is merged. |
Changes have been incorporated and @haukepetersen already approved.
da40837
to
a45d626
Compare
Reworded 102d85b because it's the No other changes besides a rebase. |
Excellent! Well done and thanks for all the work you put in! |
So here is my fourth attempt of adding EFM32 to RIOT-OS. I choose to open a new PR, since a lot has changed since my last attempt (#5652). It is a similar PR to #5652 and #4824 and the comments of PR #4722 still apply.
This PR adds support for the Thunderboard Sense (SLTB001A) by Silicon Labs. It's still a vendor-library supported version, but this time this vendor library is added as an external package. It's split up in four commits, and this is as small as I can get it.
Most drivers have been implemented. The best example to check out is one with SAUL enabled, since drivers for the Si7021 and BMP280 are available (it does depend on #7921 for the time being).