-
Notifications
You must be signed in to change notification settings - Fork 6.8k
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
boards: arm: add adc node and fixes for Nucleo L412RB-P #34187
Conversation
One problem I need to fix... Arduino header uses SPI2 and not SPI1. The L4 device tree does not support SPI2 so I will need to add it myself. |
Added a SPI2 node to L412 device tree (to use Arduino pins) and fixed trailing white spaces. |
Added a quick change: |
Added |
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.
Don't add arbitrary devices to the board configuration.
Board configuration should stick to available "out-of-the-box" hardware.
Is |
@erwango please take a look again. I created overlay files in the sample which works. |
* i2c interface for the Nucleo F401RE and APDS9960 | ||
*/ | ||
|
||
&i2c1 { |
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 wonder if there would be ways to set this much more generic using arduino_i2c port reference, and avoid introducing board specific files.
Could you have a check to samples/sensor/amg88xx/app.overlay
and see if same approach could be used here ?
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 would be nice. I will take a look.
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.
app.overlay is not right way here because we have a board in the tree equipped with this sensor. It is better to add a generic shield support for APDS9960 breakout-boards.
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.
Something like shield support for SSD1306 displays
* i2c interface for the Nucleo F401RE and APDS9960 | ||
*/ | ||
|
||
&i2c1 { |
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.
app.overlay is not right way here because we have a board in the tree equipped with this sensor. It is better to add a generic shield support for APDS9960 breakout-boards.
So it means that each time a sensor is available on a supported board, we can't use this generic approach ? |
I'm now facing a problem with the Shield approach. When I create a shield for the sensor like this (by following https://docs.zephyrproject.org/latest/guides/porting/shields.html): And then add the shield to the sensor sample's cmake_minimum_required(VERSION 3.13.1)
set(SHIELD adafruit_apds9960) # <-- add SHIELD to preprocessor
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
project(apds9960)
FILE(GLOB app_sources src/*.c)
target_sources(app PRIVATE ${app_sources}) The sample will work for all boards that support the arduino header. Now the problem I see is how do we determine when to set
Two cases I see where we don't want this:
Any ideas on how to check these conditions in CMake? What are your thoughts on this? Edit: For reference, this is how my generic overlay looks like for the shield at the moment: &arduino_i2c {
status = "okay";
apds9960: apds9960@39 {
/* Device Address is 0x39 */
compatible = "avago,apds9960";
reg = <0x39>;
label = "APDS9960";
int-gpios = <&arduino_header 19 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>; /* D13 */
};
}; |
Please have a look to
|
Node definition in app.overlay would win and overwrite the one in |
@GunZi200 |
In the long run we need to enable a generic way to run add-on sensors on boards w/o too much code addition (such as having a board.overlay for each board in each sensor with obviously doesn't scale). |
@GunZi200 can you please drop the last commit related to APDS9960 sensor so that this PR can be unblocked? You can then open a new PR for APDS9960 shield. |
Sure I’ll do it later this evening and also fix the SPI issue @FRASTM found. :) |
I've removed the sensor node changes. Regarding the SPI CS pin, there is no chip select (NSS) assigned to PA11 in the pinmux or in the datasheet. See: /* SPI_NSS */
spi1_nss_pa4: spi1_nss_pa4 {
pinmux = <STM32_PINMUX('A', 4, AF5)>;
bias-pull-up;
};
spi1_nss_pa15: spi1_nss_pa15 {
pinmux = <STM32_PINMUX('A', 15, AF5)>;
bias-pull-up;
};
spi1_nss_pb0: spi1_nss_pb0 {
pinmux = <STM32_PINMUX('B', 0, AF5)>;
bias-pull-up;
};
spi2_nss_pb9: spi2_nss_pb9 {
pinmux = <STM32_PINMUX('B', 9, AF5)>;
bias-pull-up;
};
spi2_nss_pb12: spi2_nss_pb12 {
pinmux = <STM32_PINMUX('B', 12, AF5)>;
bias-pull-up;
}; None of SPI2 NSS are on the arduino connector. I think this is a fault with the board design. But can we not assign any GPIO pin as CS in the device tree? The I/O pin choice should not matter. I'm not sure how to select PA11 specifically. For now I did not change the pin assignment. |
@erwango I've added two notes to the documentation. One about the revision number and one about the SPI2 CS pin not being located on the arduino connector. I'm assuming this is what you meant by:
|
Hi, just a friendly reminder :) |
@erwango please revisit |
I don’t see how the build failures are related to my changes. Is it possible to re-run it? |
@GunZi200 Indeed. This should be fixed by rebasing on latest master. |
This commit adds a SPI2 node for STM32L412 which will be used for the board Nucleo L412RB-P. Signed-off-by: Guðni Már Gilbert <gudni.m.g@gmail.com>
When I added this board recently I mistakenly placed the Arduino SCL pin (Default Zephyr pin) as PB6 when it should be PB8. The SPI node is now properly set to SPI2 peripheral instead of SPI1. SPI2 is the most suitable to follow the silkscreen on the printed circuit board. Added arduino_gpio to yaml. Signed-off-by: Guðni Már Gilbert <gudni.m.g@gmail.com>
The board has 16 input channels on ADC1. Signed-off-by: Guðni Már Gilbert <gudni.m.g@gmail.com>
add board revision number to board description (MB1319C) Signed-off-by: Guðni Már Gilbert <gudni.m.g@gmail.com>
Add sensor apds9960 node to two boards (both tested):Nucleo L412RB-PNucleo F401RE