User Tools

Site Tools


zephyr

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
zephyr [2025/04/20 14:42] – [KConfig] utedasszephyr [2025/12/03 21:35] (current) – [Länkar] utedass
Line 4: Line 4:
 ===== Länkar ===== ===== Länkar =====
  
 +  * [[https://github.com/Utedass/zephyr-workspace]] -- My own devcontainer setup for Zephyr development
   * [[https://embedded.fm/episodes/475?rq=zephyr]] -- Nämner bland annat att det finns några tänkta sätt att strukturera sina projekt för att inte blanda in sin projekt-kod i zephyr-repot   * [[https://embedded.fm/episodes/475?rq=zephyr]] -- Nämner bland annat att det finns några tänkta sätt att strukturera sina projekt för att inte blanda in sin projekt-kod i zephyr-repot
   * [[https://www.youtube.com/watch?v=tAH5fy0rSo4|Youtube Linux Foundation]] -- Zephyr Project: RTOS Start-up and Initialization Flow   * [[https://www.youtube.com/watch?v=tAH5fy0rSo4|Youtube Linux Foundation]] -- Zephyr Project: RTOS Start-up and Initialization Flow
 +
 +  * [[https://interrupt.memfault.com/blog/building-drivers-on-zephyr]]
 +
 +  * [[https://community.circuitdojo.com/d/146-zephyr-driver-development-use-of-i2c-and-spi-apis]]
 +
 +== Real world examples == 
 +  * [[https://github.com/zephyrproject-rtos/awesome-zephyr-rtos/tree/main]] -- Awezome Zephyr related list
 +  * [[https://github.com/xycloo/zephyr-examples/tree/master]] -- Rust examples
 +  * [[https://github.com/zmkfirmware/zmk/tree/main]] -- Zephyr Mechanical Keyboard
 +  * [[https://github.com/jakkra/ZSWatch/tree/main]] -- Open Source Smart Watch
 +
  
 == Shawn Hymel / Digikey == == Shawn Hymel / Digikey ==
Line 43: Line 55:
 </code> </code>
  
 +===== Platser =====
 +| ''zephyr/dts/<arch>/<mfr>/<soc>/'' | .dtsi filer för olika chip |
 +| ''zephyr/dts/bindings/<feature>/<compatible>.yaml'' | .yaml binding-filer för olika chips drivrutiner |
 +| ''zephyr/boards/<mfr>/<board>/'' | .dts, Kconfig och default configs för boards |
 +| ''zephyr/soc/<mfr>/<soc>/soc.h'' | Startup-kod, HAL-includes etc för specifikt chip |
 +| ''zephyr/arch/<arch>/core/'' | Assembler-startup etc för specifik arkitektur |
 ===== CMake ===== ===== CMake =====
 === CMakeList.txt in project === === CMakeList.txt in project ===
Line 86: Line 104:
 </code> </code>
  
-Sparas till ./build/zephyr/.config som kommer tas bort vid nästa bygge.+Sparas till ''./build/zephyr/.config'' som kommer tas bort vid nästa bygge. 
 + 
 +Generates an include file in ''build/zephyr/include/generated/zephyr/autoconf.h''
  
 För att göra persistent, kolla diff mellan ./build/zephyr/.config.old För att göra persistent, kolla diff mellan ./build/zephyr/.config.old
Line 150: Line 170:
  
 The final devicetree will end up under ''build/zephyr/zephyr.dts''. The final devicetree will end up under ''build/zephyr/zephyr.dts''.
 +
 +There is an include file generated from this in ''build/zephyr/include/generated/zephyr/devicetree_generated.h''
  
 === Words === === Words ===
Line 325: Line 347:
 </code> </code>
  
 +==== Overlay files ====
 +
 +== Example ==
 +''boards/esp32s3_devkitc.overlay''
 +<code>
 +/ {
 +    aliases {
 +        my-led = &led0;
 +    };
 +
 +    leds {
 +        compatible = "gpio-leds";
 +        led0: d5 {
 +            gpios = <&gpio0 5 GPIO_ACTIVE_HIGH>;
 +        };
 +    };
 +};
 +</code>
 +===== C-kod =====
 +== Exempel blink ==
 +<code c>
 +#include <stdio.h>
 +#include <zephyr/kernel.h>
 +#include <zephyr/drivers/gpio.h>
 +
 +// Settings
 +static const int32_t sleep_time_ms = 1000;
 +static const struct gpio_dt_spec led = GPIO_DT_SPEC_GET(DT_ALIAS(my_led), gpios);
 +
 +int main(void)
 +{
 + int ret;
 + int state = 0;
 +
 + // Make sure that the GPIO was initialized
 + if (!gpio_is_ready_dt(&led))
 + {
 + return 0;
 + }
 +
 + // Set the GPIO as output
 + ret = gpio_pin_configure_dt(&led, GPIO_OUTPUT);
 + if (ret < 0)
 + {
 + return 0;
 + }
 +
 + // Do forever
 + while (1)
 + {
 +
 + // Change the state of the pin and print
 + state = !state;
 + printk("LED state: %d\r\n", state);
 +
 + // Set pin state
 + ret = gpio_pin_set_dt(&led, state);
 + if (ret < 0)
 + {
 + return 0;
 + }
 +
 + // Sleep
 + k_msleep(sleep_time_ms);
 + }
 +
 + return 0;
 +}
 +</code>
zephyr.1745160138.txt.gz · Last modified: 2025/04/20 14:42 by utedass

Except where otherwise noted, content on this wiki is licensed under the following license: CC0 1.0 Universal
CC0 1.0 Universal Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki