Skip to content

Commit

Permalink
Merge pull request Seeed-Studio#1128 from Timo614/timo614-use-shield-…
Browse files Browse the repository at this point in the history
…for-zephyr-examples

Zephyr: Use Expansion shield for examples
  • Loading branch information
MatthewJeffson authored Apr 18, 2024
2 parents 2eaa27a + 6ee88c4 commit 8532451
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 43 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,6 @@ Num | SSID (len) | Chan (Band) | RSSI | Security
```

Let's dive into this example a bit to see why it works:
(Note: the Xiao ESP32S3 is supported specifically by this example so we don't need a custom overlay or conf to load up the file.)
```
&wifi {
status = "okay";
Expand Down Expand Up @@ -265,7 +264,7 @@ Additional information about TFLite is outside of the scope of this guide but th
To test this setup we can use an existing sample with Zephyr:

```
west build -p always -b xiao_esp32s3 samples/drivers/display -- -DDTC_OVERLAY_FILE=$(dirname $(pwd))/applications/xiao-zephyr-examples/xiao-expansion.overlay DEXTRA_CONF_FILE=$(dirname $(pwd))/applications/xiao-zephyr-examples/samples.conf
west build -p always -b xiao_esp32s3 samples/drivers/display -- -DSHIELD=seeed_xiao_expansion_board
west flash
```

Expand All @@ -279,7 +278,7 @@ Let's dive into this example a bit to see why it works:
};
};
&i2c0 {
&xiao_i2c {
status = "okay";
ssd1306: ssd1306@3c {
Expand All @@ -299,22 +298,15 @@ Let's dive into this example a bit to see why it works:
```

The app overlay file in this example sets up a SSD1306 OLED screen at the 0x3C register. It is selected as the zephyr display in the chosen section.
The shield sets up a SSD1306 OLED screen at the 0x3C register. It is selected as the zephyr display in the chosen section.

```
CONFIG_LV_Z_VDB_SIZE=64
CONFIG_LV_COLOR_DEPTH_1=y
CONFIG_I2C=y
```

The associated configuration file enables the OLED screen to properly render by setting its depth to 1 and enabling I2C for the project.

#### Grove - Expansion Board - Button

To test this setup we can use an existing sample with Zephyr:

```
west build -p always -b xiao_esp32s3 samples/basic/button -- -DDTC_OVERLAY_FILE=$(dirname $(pwd))/applications/xiao-zephyr-examples/xiao-expansion.overlay
west build -p always -b xiao_esp32s3 samples/basic/button -- -DSHIELD=seeed_xiao_expansion_board
west flash
west espressif monitor
```
Expand All @@ -341,22 +333,23 @@ Let's dive into this example a bit to see why it works:
```
/ {
aliases {
sw0 = &button0;
sw0 = &xiao_button0;
};
buttons {
compatible = "gpio-keys";
button0: button_0 {
gpios = <&gpio0 2 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>;
label = "Expansion Board Button";
};
compatible = "gpio-keys";
xiao_button0: button_0 {
gpios = <&xiao_d 1 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>;
label = "SW0";
zephyr,code = <INPUT_KEY_0>;
};
};
};
```

The app overlay file is used to setup various board components. Using this file the button example can be utilized as the overlay allows the Zephyr to configure the button and make it available for the associated code.
The shield / overlay file is used to setup various board components. Using this file the button example can be utilized as the overlay allows the Zephyr to configure the button and make it available for the associated code.

In this case GPIO 2 corresponds with Pin A1/D1 on the Xiao ESP32S3. It is setup in this overlay to act as a button and is aliased to the sw0 name to allow it to be used for the sample which has code expecting this.
In this case D1 on the Xiao ESP32S3. It is setup in this overlay to act as a button and is aliased to the sw0 name to allow it to be used for the sample which has code expecting this.


#### Grove - Temperature and Humidity Sensor (SHT31)
Expand Down Expand Up @@ -390,7 +383,7 @@ SHT3XD: 25.84 Cel ; 53.16 %RH

Let's dive into this example a bit to see why it works:
```
&i2c0 {
&xiao_i2c {
sht3xd@44 {
compatible = "sensirion,sht3xd";
reg = <0x44>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ In this case the PWM is using the configured devicetree pwm LED which is associa
For this we'll use an existing sample and our console overlay:
```
cd ~/zephyrproject/zephyr
west build -p always -b xiao_rp2040 samples/drivers/counter/alarm -- -DDTC_OVERLAY_FILE=$(dirname $(pwd))/applications/xiao-zephyr-examples/xiao-rp2040/console.overlay -DEXTRA_CONF_FILE=$(dirname $(pwd))/applications/xiao-zephyr-examples/xiao-rp2040/console.conf
west build -p always -b xiao_rp2040 samples/drivers/counter/alarm -- -DDTC_OVERLAY_FILE=$(dirname $(pwd))/applications/xiao-zephyr-examples/console.overlay -DEXTRA_CONF_FILE=$(dirname $(pwd))/applications/xiao-zephyr-examples/console.conf
```

You can find the uf2 file at `~/zephyrproject/zephyr/build/zephyr/zephyr.uf2`
Expand Down Expand Up @@ -273,7 +273,7 @@ For this example we're going to use the sample tflite "Hello World" along with o

```
cd ~/zephyrproject/zephyr
west build -p always -b xiao_rp2040 samples/modules/tflite-micro/hello_world -- -DDTC_OVERLAY_FILE=$(dirname $(pwd))/applications/xiao-zephyr-examples/xiao-rp2040/console.overlay -DEXTRA_CONF_FILE=$(dirname $(pwd))/applications/xiao-zephyr-examples/xiao-rp2040/console.conf
west build -p always -b xiao_rp2040 samples/modules/tflite-micro/hello_world -- -DDTC_OVERLAY_FILE=$(dirname $(pwd))/applications/xiao-zephyr-examples/console.overlay -DEXTRA_CONF_FILE=$(dirname $(pwd))/applications/xiao-zephyr-examples/console.conf
```

You can find the uf2 file at `~/zephyrproject/zephyr/build/zephyr/zephyr.uf2`
Expand Down Expand Up @@ -324,7 +324,7 @@ To test this setup we can use an existing sample with Zephyr:

```
cd ~/zephyrproject/zephyr
west build -p always -b xiao_rp2040 samples/drivers/display -- -DDTC_OVERLAY_FILE=$(dirname $(pwd))/applications/xiao-zephyr-examples/xiao-rp2040/xiao-expansion.overlay -DEXTRA_CONF_FILE=$(dirname $(pwd))/applications/xiao-zephyr-examples/xiao-rp2040/samples.conf
west build -p always -b xiao_rp2040 samples/drivers/display -- -DSHIELD=seeed_xiao_expansion_board
```

You'll see a display showing multiple black boxes and a blinking box in the corner given this display only supports two colors.
Expand All @@ -337,7 +337,7 @@ Let's dive into this example a bit to see why it works:
};
};
&i2c1 {
&xiao_i2c {
status = "okay";
ssd1306: ssd1306@3c {
Expand All @@ -357,23 +357,15 @@ Let's dive into this example a bit to see why it works:
```

The app overlay file in this example sets up a SSD1306 OLED screen at the 0x3C register. It is selected as the zephyr display in the chosen section.

```
CONFIG_LV_Z_VDB_SIZE=64
CONFIG_LV_COLOR_DEPTH_1=y
CONFIG_I2C=y
```

The associated configuration file enables the OLED screen to properly render by setting its depth to 1 and enabling I2C for the project.
The shield overlay file in this example sets up a SSD1306 OLED screen at the 0x3C register. It is selected as the zephyr display in the chosen section.

#### Grove - Expansion Board - Button

To test this setup we can use an existing sample with Zephyr which we will use along with the USB console overlay and conf.

```
cd ~/zephyrproject/zephyr
west build -p always -b xiao_rp2040 samples/basic/button -- -DDTC_OVERLAY_FILE="$(dirname $(pwd))/applications/xiao-zephyr-examples/xiao-rp2040/xiao-expansion.overlay $(dirname $(pwd))/applications/xiao-zephyr-examples/xiao-rp2040/console.overlay" -DEXTRA_CONF_FILE=$(dirname $(pwd))/applications/xiao-zephyr-examples/xiao-rp2040/console.conf
west build -p always -b xiao_rp2040 samples/basic/button -- -DDTC_OVERLAY_FILE="$(dirname $(pwd))/applications/xiao-zephyr-examples/console.overlay" -DEXTRA_CONF_FILE=$(dirname $(pwd))/applications/xiao-zephyr-examples/console.conf -DSHIELD=seeed_xiao_expansion_board
```

After uploading the uf2 file connect to monitor:
Expand All @@ -400,15 +392,16 @@ Let's dive into this example a bit to see why it works:
```
/ {
aliases {
sw0 = &button0;
sw0 = &xiao_button0;
};
buttons {
compatible = "gpio-keys";
button0: button_0 {
gpios = <&gpio0 27 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>;
label = "Expansion Board Button";
};
compatible = "gpio-keys";
xiao_button0: button_0 {
gpios = <&xiao_d 1 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>;
label = "SW0";
zephyr,code = <INPUT_KEY_0>;
};
};
};
```
Expand All @@ -428,7 +421,7 @@ To test this setup we can use an existing sample with Zephyr which we will enabl

```
cd ~/zephyrproject/zephyr
west build -p always -b xiao_rp2040 samples/sensor/sht3xd -- -DDTC_OVERLAY_FILE="$(dirname $(pwd))/applications/xiao-zephyr-examples/xiao-rp2040/sht31.overlay $(dirname $(pwd))/applications/xiao-zephyr-examples/xiao-rp2040/console.overlay" -DEXTRA_CONF_FILE=$(dirname $(pwd))/applications/xiao-zephyr-examples/xiao-rp2040/console.conf
west build -p always -b xiao_rp2040 samples/sensor/sht3xd -- -DDTC_OVERLAY_FILE="$(dirname $(pwd))/applications/xiao-zephyr-examples/sht31.overlay $(dirname $(pwd))/applications/xiao-zephyr-examples/console.overlay" -DEXTRA_CONF_FILE=$(dirname $(pwd))/applications/xiao-zephyr-examples/console.conf
```

After uploading the uf2 file connect to monitor:
Expand All @@ -451,7 +444,7 @@ SHT3XD: 26.24 Cel ; 52.30 %RH

Let's dive into this example a bit to see why it works:
```
&i2c1 {
&xiao_i2c {
sht3xd@44 {
compatible = "sensirion,sht3xd";
reg = <0x44>;
Expand Down

0 comments on commit 8532451

Please sign in to comment.