Skip to content

Commit 9282bc6

Browse files
committed
Nano 33 BLE - enable the SPI1 sensors
Resolves: #51 There is an IO pin on the NANO that that when turned on, enables most of the sensors on the BLE sense which are on SPI1. The MBED version, enables this pin as part of the main(). Which I am trying to emulate. There is code already in, that if you use at least one of the zephyr device drivers, will eanble this pin. However that does not help when you are using external libraries or the like. So I added details about this pin in our overlay file, in the zephyr,user section. I then added code to main.cpp, that is only included if your are building using an NRFX board. Currently the nano and one of the nicla boards. Could also specically only do this on the NANO, but probably does not matter as, the code tries to find that property and only if it is found, does it turn on the pin. Note: The MBED version turn on this pin with high drive. Which I emulated using the information, mentioned in the zephyr discussion. zephyrproject-rtos/zephyr#78710 In one of my sketches I verified that the pin pads configuration looks the same as mbed setup. With these changes I am able to access most of the sensors. Most of the testing has been done by @mjs513, with some by myself as well.
1 parent c0b7ef0 commit 9282bc6

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

cores/arduino/main.cpp

+18
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@
1313
void start_static_threads();
1414
#endif
1515

16+
#ifdef CONFIG_GPIO_NRFX
17+
#include <zephyr/dt-bindings/gpio/nordic-nrf-gpio.h>
18+
#endif
19+
1620
int main(void) {
1721
#if (DT_NODE_HAS_PROP(DT_PATH(zephyr_user), cdc_acm) && CONFIG_USB_CDC_ACM)
1822
Serial.begin(115200);
@@ -22,6 +26,20 @@ int main(void) {
2226
start_static_threads();
2327
#endif
2428

29+
#ifdef CONFIG_GPIO_NRFX
30+
static const struct gpio_dt_spec enable_sensors =
31+
GPIO_DT_SPEC_GET(DT_PATH(zephyr_user), pin_enable_gpios);
32+
if (gpio_is_ready_dt(&enable_sensors)) {
33+
gpio_flags_t flags = enable_sensors.dt_flags | GPIO_OUTPUT_HIGH | GPIO_ACTIVE_HIGH | NRF_GPIO_DRIVE_H0H1;
34+
Serial.println((uint32_t)flags, HEX);
35+
36+
gpio_pin_configure(enable_sensors.port, enable_sensors.pin, flags);
37+
gpio_pin_set(enable_sensors.port, enable_sensors.pin, HIGH);
38+
//Serial.println("### Sensor pin enabled ###");
39+
40+
delay(500);
41+
}
42+
#endif
2543
setup();
2644

2745
for (;;) {

loader/boards/arduino_nano_33_ble_sense.overlay

+2
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@
4545

4646
/ {
4747
zephyr,user {
48+
pin-enable-gpios = <&gpio0 22 GPIO_ACTIVE_HIGH>;
49+
4850
digital-pin-gpios = <&arduino_nano_header 0 0>,
4951
<&arduino_nano_header 1 0>,
5052
<&arduino_nano_header 2 0>,

0 commit comments

Comments
 (0)