zephyr
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| zephyr [2025/04/20 14:42] – [KConfig] utedass | zephyr [2025/12/03 21:35] (current) – [Länkar] utedass | ||
|---|---|---|---|
| Line 4: | Line 4: | ||
| ===== Länkar ===== | ===== Länkar ===== | ||
| + | * [[https:// | ||
| * [[https:// | * [[https:// | ||
| * [[https:// | * [[https:// | ||
| + | |||
| + | * [[https:// | ||
| + | |||
| + | * [[https:// | ||
| + | |||
| + | == Real world examples == | ||
| + | * [[https:// | ||
| + | * [[https:// | ||
| + | * [[https:// | ||
| + | * [[https:// | ||
| + | |||
| == Shawn Hymel / Digikey == | == Shawn Hymel / Digikey == | ||
| Line 43: | Line 55: | ||
| </ | </ | ||
| + | ===== Platser ===== | ||
| + | | '' | ||
| + | | '' | ||
| + | | '' | ||
| + | | '' | ||
| + | | '' | ||
| ===== CMake ===== | ===== CMake ===== | ||
| === CMakeList.txt in project === | === CMakeList.txt in project === | ||
| Line 86: | Line 104: | ||
| </ | </ | ||
| - | Sparas till ./ | + | Sparas till '' |
| + | |||
| + | Generates an include file in '' | ||
| För att göra persistent, kolla diff mellan ./ | För att göra persistent, kolla diff mellan ./ | ||
| Line 150: | Line 170: | ||
| The final devicetree will end up under '' | The final devicetree will end up under '' | ||
| + | |||
| + | There is an include file generated from this in '' | ||
| === Words === | === Words === | ||
| Line 325: | Line 347: | ||
| </ | </ | ||
| + | ==== Overlay files ==== | ||
| + | |||
| + | == Example == | ||
| + | '' | ||
| + | < | ||
| + | / { | ||
| + | aliases { | ||
| + | my-led = &led0; | ||
| + | }; | ||
| + | |||
| + | leds { | ||
| + | compatible = " | ||
| + | led0: d5 { | ||
| + | gpios = <& | ||
| + | }; | ||
| + | }; | ||
| + | }; | ||
| + | </ | ||
| + | ===== C-kod ===== | ||
| + | == Exempel blink == | ||
| + | <code c> | ||
| + | #include < | ||
| + | #include < | ||
| + | #include < | ||
| + | |||
| + | // Settings | ||
| + | static const int32_t sleep_time_ms = 1000; | ||
| + | static const struct gpio_dt_spec led = GPIO_DT_SPEC_GET(DT_ALIAS(my_led), | ||
| + | |||
| + | int main(void) | ||
| + | { | ||
| + | int ret; | ||
| + | int state = 0; | ||
| + | |||
| + | // Make sure that the GPIO was initialized | ||
| + | if (!gpio_is_ready_dt(& | ||
| + | { | ||
| + | return 0; | ||
| + | } | ||
| + | |||
| + | // Set the GPIO as output | ||
| + | ret = gpio_pin_configure_dt(& | ||
| + | if (ret < 0) | ||
| + | { | ||
| + | return 0; | ||
| + | } | ||
| + | |||
| + | // Do forever | ||
| + | while (1) | ||
| + | { | ||
| + | |||
| + | // Change the state of the pin and print | ||
| + | state = !state; | ||
| + | printk(" | ||
| + | |||
| + | // Set pin state | ||
| + | ret = gpio_pin_set_dt(& | ||
| + | if (ret < 0) | ||
| + | { | ||
| + | return 0; | ||
| + | } | ||
| + | |||
| + | // Sleep | ||
| + | k_msleep(sleep_time_ms); | ||
| + | } | ||
| + | |||
| + | return 0; | ||
| + | } | ||
| + | </ | ||
zephyr.1745160138.txt.gz · Last modified: 2025/04/20 14:42 by utedass
