diff --git a/flake.lock b/flake.lock index 1f03a90..ff309f5 100644 --- a/flake.lock +++ b/flake.lock @@ -10,11 +10,11 @@ ] }, "locked": { - "lastModified": 1699827895, - "narHash": "sha256-Fzjd9h3TDPXORNl6pek+e79eFjbmSaU4Hi/MUpjSRz4=", + "lastModified": 1699858083, + "narHash": "sha256-EXmVoYDYszdWlaxRzedQ3Q7ehbqIGfbe9EaHSBD4cgQ=", "ref": "refs/heads/canon", - "rev": "763d83f15705ab6c6b033e445f96d40bc4f10eb4", - "revCount": 9, + "rev": "453af715eebd7102131d2cc6846dd23d49f853ac", + "revCount": 12, "type": "git", "url": "https://git.mildlyfunctional.gay/artemist/packages.git" }, diff --git a/flake.nix b/flake.nix index d77e7b9..c4b03ab 100644 --- a/flake.nix +++ b/flake.nix @@ -19,12 +19,8 @@ arm-zephyr-eabi riscv64-zephyr-elf ]; - zephyrSrc = pkgs.fetchFromGitHub { - owner = "zephyrproject-rtos"; - repo = "zephyr"; - rev = "v3.5.0"; - hash = "sha256-72QFsKOWkF6BiP4XgZAXXSBcN4t6yvhAeXCpgCYrhe8="; - }; + modules = with artemist-packages.packages.${system}.zephyr.modules; + [ mbedtls ]; }; formatter = pkgs.nixfmt; }); diff --git a/zephyr/.gitignore b/zephyr/.gitignore index 567609b..a4fb4fb 100644 --- a/zephyr/.gitignore +++ b/zephyr/.gitignore @@ -1 +1,2 @@ build/ +.cache/ diff --git a/zephyr/w5500-test/CMakeLists.txt b/zephyr/w5500-test/CMakeLists.txt new file mode 100644 index 0000000..09f7fd4 --- /dev/null +++ b/zephyr/w5500-test/CMakeLists.txt @@ -0,0 +1,5 @@ +cmake_minimum_required(VERSION 3.20.0) +find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) + +project(w5500-test) +target_sources(app PRIVATE src/main.c) diff --git a/zephyr/w5500-test/boards/sparkfun_red_v_things_plus.overlay b/zephyr/w5500-test/boards/sparkfun_red_v_things_plus.overlay new file mode 100644 index 0000000..216dae7 --- /dev/null +++ b/zephyr/w5500-test/boards/sparkfun_red_v_things_plus.overlay @@ -0,0 +1,10 @@ +&spi1 { + cs-gpios = <&gpio0 9 GPIO_ACTIVE_LOW>; + + w5500@0 { + compatible = "wiznet,w5500"; + reg = <0>; + int-gpios = <&gpio0 10 GPIO_ACTIVE_LOW>; + spi-max-frequency = <10000000>; + }; +}; diff --git a/zephyr/w5500-test/prj.conf b/zephyr/w5500-test/prj.conf new file mode 100644 index 0000000..db5ef19 --- /dev/null +++ b/zephyr/w5500-test/prj.conf @@ -0,0 +1,11 @@ +CONFIG_NET_L2_ETHERNET=y +CONFIG_ETH_DRIVER=y +CONFIG_ETH_W5500=y + +CONFIG_NETWORKING=y +CONFIG_NET_IPV6=y +CONFIG_NET_TCP=y + +CONFIG_NET_SOCKETS=y +CONFIG_NET_SOCKETS_POSIX_NAMES=y +CONFIG_NET_SOCKETS_POLL_MAX=4 diff --git a/zephyr/w5500-test/src/main.c b/zephyr/w5500-test/src/main.c new file mode 100644 index 0000000..a6d0954 --- /dev/null +++ b/zephyr/w5500-test/src/main.c @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2016 Intel Corporation + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include +#include + +/* 1000 msec = 1 sec */ +#define SLEEP_TIME_MS 1000 + +/* The devicetree node identifier for the "led0" alias. */ +#define LED0_NODE DT_ALIAS(led0) + +/* + * A build error on this line means your board is unsupported. + * See the sample documentation for information on how to fix this. + */ +static const struct gpio_dt_spec led = GPIO_DT_SPEC_GET(LED0_NODE, gpios); + +int main(void) +{ + int ret; + + if (!gpio_is_ready_dt(&led)) { + return 0; + } + + ret = gpio_pin_configure_dt(&led, GPIO_OUTPUT_ACTIVE); + if (ret < 0) { + return 0; + } + + while (1) { + ret = gpio_pin_toggle_dt(&led); + if (ret < 0) { + return 0; + } + k_msleep(SLEEP_TIME_MS); + } + return 0; +} +