-
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
Expanding "shield" functionality (example uses WNC-M14A2A and SARA modem) #14057
Changes from all commits
4cb1a63
28d7f4e
e53f58b
9f2c8db
d685032
f1576d5
93ed6b0
0560624
7b1638a
d12922b
dfaa250
c5cbebf
74ddf2f
4c3ae4b
1f199b3
ffbeaee
b606d35
a56e073
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
zephyr_library() | ||
zephyr_library_sources(board.c) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/* | ||
* Copyright (c) 2019 Foundries.io | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
#include <init.h> | ||
#include "board.h" | ||
#include <gpio.h> | ||
|
||
static int particle_boron_init(struct device *dev) | ||
{ | ||
|
||
ARG_UNUSED(dev); | ||
|
||
#if defined(CONFIG_MODEM_UBLOX_SARA_R4) | ||
struct device *gpio_dev; | ||
|
||
/* Enable the serial buffer for SARA-R4 modem */ | ||
gpio_dev = device_get_binding(SERIAL_BUFFER_ENABLE_GPIO_NAME); | ||
if (!gpio_dev) { | ||
return -ENODEV; | ||
} | ||
|
||
gpio_pin_configure(gpio_dev, V_INT_DETECT_GPIO_PIN, GPIO_DIR_IN); | ||
|
||
gpio_pin_configure(gpio_dev, SERIAL_BUFFER_ENABLE_GPIO_PIN, | ||
GPIO_DIR_OUT); | ||
#endif | ||
|
||
return 0; | ||
} | ||
|
||
/* needs to be done after GPIO driver init */ | ||
SYS_INIT(particle_boron_init, POST_KERNEL, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/* | ||
* Copyright (c) 2019 Foundries.io | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
#ifndef __INC_BOARD_H | ||
#define __INC_BOARD_H | ||
|
||
/* pin used to enable the buffer power */ | ||
#define SERIAL_BUFFER_ENABLE_GPIO_NAME DT_NORDIC_NRF_GPIO_0_LABEL | ||
#define SERIAL_BUFFER_ENABLE_GPIO_PIN 25 | ||
|
||
/* pin used to detect V_INT (buffer power) */ | ||
#define V_INT_DETECT_GPIO_PIN 2 | ||
|
||
#endif /* __INC_BOARD_H */ |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
CONFIG_UART_4=y | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
CONFIG_UART_MCUX_3=y |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
CONFIG_GPIO_NRF_P1=y | ||
CONFIG_UART_1_NRF_UARTE=y |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/* | ||
* Copyright (c) 2019 Foundries.io | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
&arduino_serial { | ||
tx-pin = <34>; | ||
rx-pin = <33>; | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# Enable u-blox SARA-R4 modem | ||
CONFIG_MODEM=y | ||
CONFIG_MODEM_SHELL=y | ||
CONFIG_MODEM_UBLOX_SARA_R4=y | ||
CONFIG_UART_INTERRUPT_DRIVEN=y | ||
|
||
# extend retry timing to 20 seconds for LTE/LTE-M | ||
CONFIG_COAP_INIT_ACK_TIMEOUT_MS=20000 | ||
|
||
# Hack: disable IPv6 for now | ||
# CONFIG_NET_IPV6 is not set | ||
# CONFIG_NET_CONFIG_NEED_IPV6 is not set |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/* | ||
* Copyright (c) 2019 Foundries.io | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
&arduino_serial { | ||
current-speed = <115200>; | ||
status = "ok"; | ||
|
||
sara_r4 { | ||
compatible = "ublox,sara-r4"; | ||
label = "ublox-sara-r4"; | ||
mdm-power-gpios = <&arduino_header 11 0>; /* D5 */ | ||
mdm-reset-gpios = <&arduino_header 12 0>; /* D6 */ | ||
status = "ok"; | ||
}; | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
CONFIG_UART_MCUX_2=y | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What if instead we add a CONFIG_ARDUINO_SERIAL to
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @MaureenHelm I like this idea. I was struggling with the abstraction between a shield's UART (arduino_serial) and a HW specific UART (Like if the driver needed to be used directly). A great example of this is the Particle.io Boron board which has a U-blox SARA-R41xx modem connected to the nRF52840 directly via UART1 vs. a SparkFun LTE Cat M1 shield which has the U-blox SARA-R41xx connected to Arduino R3-compatible headers. The shield configuration should only reference the arduino_serial and stay away from anything too specific to the device. However, this approach won't work for the WNC-M14A2A modem. The UART pins are on non-standard Arduino pins. The traditional Arduino UART is actually C16/C17 pins (UART_3) for K64F. Technically, ARDUINO_SERIAL should enable UART_3 (where BT_UART is identified). And, the BT_UART setting could go away if we migrate that to a shield setup. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/* | ||
* Copyright (c) 2019 Foundries.io | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
/* | ||
* WNC-M14A2A shield uses an odd UART available on *some* Arduino-R3-compatible | ||
* headers. It needs to be defined individually. | ||
*/ | ||
&uart2 { | ||
current-speed = <115200>; | ||
hw-flow-control; | ||
status = "ok"; | ||
|
||
wnc_m14a2a: wncm14a2a { | ||
status = "ok"; | ||
compatible = "wnc,m14a2a"; | ||
label = "wnc-m14a2a"; | ||
mdm-boot-mode-sel-gpios = <&arduino_header 7 0>; /* D1 */ | ||
mdm-power-gpios = <&arduino_header 8 0>; /* D2 */ | ||
mdm-keep-awake-gpios = <&arduino_header 12 0>; /* D6 */ | ||
mdm-reset-gpios = <&arduino_header 14 0>; /* D8 */ | ||
mdm-shld-trans-ena-gpios = <&arduino_header 15 0>; /* D9 */ | ||
}; | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
CONFIG_GPIO_NRF_P1=y | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Rather do it as Kconfig.defconfig than .conf direct setting style There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Like I said above, this particular setting can be abstracted under
The standard Arduino serial pins are different. |
||
CONFIG_UART_1_NRF_UARTE=y | ||
CONFIG_UART_1_NRF_FLOW_CONTROL=y |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* | ||
* Copyright (c) 2019 Foundries.io | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
/* | ||
* WNC-M14A2A shield uses an odd UART available on *some* Arduino-R3-compatible | ||
* headers. It needs to be defined individually. | ||
*/ | ||
&uart1 { | ||
current-speed = <115200>; | ||
hw-flow-control; | ||
status = "ok"; | ||
|
||
tx-pin = <46>; | ||
rx-pin = <45>; | ||
rts-pin = <44>; | ||
cts-pin = <47>; | ||
|
||
wnc_m14a2a: wncm14a2a { | ||
status = "ok"; | ||
compatible = "wnc,m14a2a"; | ||
label = "wnc-m14a2a"; | ||
mdm-boot-mode-sel-gpios = <&arduino_header 7 0>; /* D1 */ | ||
mdm-power-gpios = <&arduino_header 8 0>; /* D2 */ | ||
mdm-keep-awake-gpios = <&arduino_header 12 0>; /* D6 */ | ||
mdm-reset-gpios = <&arduino_header 14 0>; /* D8 */ | ||
mdm-shld-trans-ena-gpios = <&arduino_header 15 0>; /* D9 */ | ||
}; | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
/* | ||
* Copyright (c) 2019 Foundries.io | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
/* File meant to be empty */ |
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.
@mike-scott , why not applying @MaureenHelm's proposal (in d5eda49#r263920854) here?
This is close to what we should get in future, if get read of Kconfig symbols per device instance. Then, the following would do the same:
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.
@erwango This PR is now suffering from "scope creep". There are several more additions I want to do, but felt like it would be best to land it as is and then make those changes.
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, this approach doesn't work for WNC-M14A2A (the original modem driver in this PR) -- it uses non-standard pins for UART on the Arduino headers.
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'd rather say this is an ambitious PR that could have been split in small pieces.
Please not that I retained myself to request again for splitting board connector dts definitions into dedicated .dtsi files :-).
Anyway, agreed to let this as a further enhancement.