Try adding w5500-test, though it doesn't fit

This commit is contained in:
Artemis Tosini 2023-11-13 06:52:43 +00:00
parent 3b63f9d5e5
commit bd27ddf9ec
Signed by: artemist
GPG key ID: EE5227935FE3FF18
7 changed files with 77 additions and 10 deletions

View file

@ -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"
},

View file

@ -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;
});

1
zephyr/.gitignore vendored
View file

@ -1 +1,2 @@
build/
.cache/

View file

@ -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)

View file

@ -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>;
};
};

View file

@ -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

View file

@ -0,0 +1,44 @@
/*
* Copyright (c) 2016 Intel Corporation
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <zephyr/kernel.h>
#include <zephyr/drivers/gpio.h>
/* 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;
}