|
3 | 3 | Copyright 2026 Moddable Tech, Inc.<BR> |
4 | 4 | Updated: January 13, 2026 |
5 | 5 |
|
6 | | -This document is a guide to building apps with the Zephyr SDK. |
| 6 | +This document is a guide to building Moddable apps with the Zephyr SDK. |
7 | 7 |
|
8 | 8 | ## Table of Contents |
9 | 9 |
|
10 | 10 | * [Overview](#overview) |
| 11 | +* [Platforms](#platforms) |
| 12 | + * [zephyr](#platforms-zephyr) |
11 | 13 | * [Build Types](#builds) |
12 | 14 | * [Debug](#build-debug) |
13 | 15 | * [Instrumented](#build-instrumented) |
14 | 16 | * [Release](#build-release) |
15 | 17 | * Setup instructions |
| 18 | + |
16 | 19 | | [](#mac) | [](#win) | [](#lin) | |
17 | 20 | | :--- | :--- | :--- | |
18 | 21 | | • [Installing](#mac-instructions)<BR>• [Troubleshooting](#mac-troubleshooting) | • [Installing](#win-instructions)<BR>• [Troubleshooting](#win-troubleshooting) | • [Installing](#lin-instructions)<BR>• [Troubleshooting](#lin-troubleshooting) |
19 | 22 | * [Using Zephyr Device Tree in JavaScript](#devicetree) |
20 | 23 | * [Debugging Native Code](#debugging-native-code) |
21 | 24 | * [Adding a new board](#new-board) |
| 25 | +* [IO Connfiguration](#io-config) |
22 | 26 |
|
23 | 27 | <a id="overview"></a> |
24 | 28 | ## Overview |
@@ -70,7 +74,7 @@ Omitting both the `-d` and `-i` options on the `mcconfig` command line selects a |
70 | 74 | <a id="mac"></a> |
71 | 75 | ## macOS |
72 | 76 |
|
73 | | -The Moddable SDK build uses Zephyr SDK v4.2.0-rc1 (commit `ffb28eed`). |
| 77 | +The Moddable SDK build uses Zephyr SDK v4.3 or later. |
74 | 78 |
|
75 | 79 | <a id="mac-instructions"></a> |
76 | 80 | ### Installing |
@@ -421,3 +425,55 @@ To add new board to Moddable: |
421 | 425 | cd $MODDABLE/examples/helloworld |
422 | 426 | mcconfig -d -m -p zephyr/new_board |
423 | 427 | ``` |
| 428 | + |
| 429 | +<a id="io-config"></a> |
| 430 | +## IO Configuration |
| 431 | + |
| 432 | +Zephyr uses .dts files files to define hardware IO configuration. |
| 433 | +Moddable uses .overlay files specified in the `zephyrOverlay` section of `manifest.json`. |
| 434 | + |
| 435 | +The Nordic [`nrf52840dk` device]( ../../build/devices/zephyr/targets/nrf52840dk/manifest.json) device manifest demonstrates: |
| 436 | + |
| 437 | + "zephyrOverlay": [ |
| 438 | + "./analog.overlay", |
| 439 | + "./pwm.overlay" |
| 440 | + ], |
| 441 | + |
| 442 | +### `analog` |
| 443 | + |
| 444 | +Use `port` and `channel` to choose which analog channel to sample from. Different devices may use a different port naming schemes. |
| 445 | + |
| 446 | + const analogInput = new device.io.Analog({ |
| 447 | + port: "adc", |
| 448 | + channel: 0 |
| 449 | + }); |
| 450 | + |
| 451 | +### `digital` |
| 452 | + |
| 453 | +Use an object with `port` and `pin` to describe the pin of a Digital object. |
| 454 | + |
| 455 | + const led = new device.io.Digital({ |
| 456 | + ...options, |
| 457 | + pin: {port: "gpioe", pin: 1}, |
| 458 | + mode: Digital.Output, |
| 459 | + }); |
| 460 | + |
| 461 | +### `pwm` |
| 462 | + |
| 463 | +Use `port` and `channel` to specify what zephyr configuration to use. You can also specify the frequncy by the `hz` property, and resolution (in number of bits) with the `resolution` property. |
| 464 | + |
| 465 | + const led1 = new device.io.PWM({ |
| 466 | + port: "pwm0", |
| 467 | + hz: "100", |
| 468 | + resolution: "10", |
| 469 | + channel: "0" |
| 470 | + }); |
| 471 | + |
| 472 | +### `display` |
| 473 | + |
| 474 | +Zephyr display configuration are found in shield definition files. For example, the `stm32u5a9j_dk` target's [`manifest.json`]( ../../build/devices/zephyr/targets/stm32u5a9j_dk/manifest.json) contains: |
| 475 | + |
| 476 | + "zephyrShields": [ |
| 477 | + "st_lcd_dsi_mb1835" |
| 478 | + ], |
| 479 | + |
0 commit comments