Skip to content

Commit

Permalink
Initial comm to W5500 working
Browse files Browse the repository at this point in the history
  • Loading branch information
vkottler committed Oct 30, 2023
1 parent 11deab2 commit 5a9030a
Show file tree
Hide file tree
Showing 11 changed files with 100 additions and 2 deletions.
9 changes: 9 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,12 @@
[submodule "pico-sdk"]
path = pico-sdk
url = https://github.com/raspberrypi/pico-sdk.git
[submodule "pico-extras"]
path = pico-extras
url = https://github.com/raspberrypi/pico-extras.git
[submodule "ioLibrary_Driver"]
path = ioLibrary_Driver
url = https://github.com/Wiznet/ioLibrary_Driver.git
[submodule "RP2040-HAT-C"]
path = RP2040-HAT-C
url = https://github.com/Wiznet/RP2040-HAT-C.git
1 change: 1 addition & 0 deletions RP2040-HAT-C
Submodule RP2040-HAT-C added at a23950
2 changes: 1 addition & 1 deletion config
1 change: 1 addition & 0 deletions ioLibrary_Driver
Submodule ioLibrary_Driver added at 3847fb
10 changes: 9 additions & 1 deletion local/yambs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
includes:
- ../config/python/yambs/cflag_groups.yaml
- ../config/python/yambs/pico-sdk.yaml
- ../config/python/yambs/ioLibrary_Driver.yaml
- ../config/python/yambs/RP2040-HAT-C.yaml

default_target: pico

Expand All @@ -16,7 +18,13 @@ ldflag_groups:
variants:
pico:
prefix: "arm-picolibc-eabi-"
cflag_groups: [picolib, m0plus, armv6m, pico-sdk]
cflag_groups:
- picolib
- m0plus
- armv6m
- pico-sdk
- ioLibrary_Driver
- RP2040-HAT-C
ldflag_groups: [semihost]
targets: [uf2s]

Expand Down
1 change: 1 addition & 0 deletions pico-extras
Submodule pico-extras added at 09c64d
23 changes: 23 additions & 0 deletions src/apps/test_file.cc
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
/* internal */
#include "cli.h"
#include "uart_stdio.h"
#include "wizchip.h"

void core1_app(void)
{
pico_wizchip_init();

while (true)
{
// some kind of state machine thing?
Expand All @@ -14,8 +17,28 @@ void core1_app(void)
}
}

/* Clock */
#define PLL_SYS_KHZ (133 * 1000)

static void set_clock_khz(void)
{
// set a system clock frequency in khz
set_sys_clock_khz(PLL_SYS_KHZ, true);

// configure the specified clock
clock_configure(
clk_peri,
0, // No glitchless mux
CLOCKS_CLK_PERI_CTRL_AUXSRC_VALUE_CLKSRC_PLL_SYS, // System PLL on AUX
// mux
PLL_SYS_KHZ * 1000, // Input frequency
PLL_SYS_KHZ * 1000 // Output (must be same as no divider)
);
}

void init(void)
{
set_clock_khz();
stdio_usb_init();

gpio_init(led_pin);
Expand Down
6 changes: 6 additions & 0 deletions src/cli.cc
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,15 @@ void do_clocks(CommandLine &cli)
frequency_count_khz(CLOCKS_FC0_SRC_VALUE_CLK_RTC));
}

void do_net(CommandLine &cli)
{
(void)cli;
}

void register_commands(CommandLineApp &app)
{
app.add_handler("led", do_led, "toggle the LED on or off");
app.add_handler("exit", do_exit, "exit the application");
app.add_handler("clocks", do_clocks);
app.add_handler("net", do_net);
}
1 change: 1 addition & 0 deletions src/pico_headers.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "pico/critical_section.h"
#include "pico/multicore.h"
#include "pico/stdio_usb.h"
#include "pico/stdlib.h"
#include "pico/time.h"

#pragma GCC diagnostic pop
45 changes: 45 additions & 0 deletions src/wizchip.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#include "wizchip.h"

extern "C"
{
#include "wizchip_conf.h"

#include "w5x00_spi.h"

#include "dhcp.h"
#include "dns.h"
#include "timer.h"
}

/* Timer */
static volatile uint16_t g_msec_cnt = 0;

/* Timer */
static void repeating_timer_callback(void)
{
auto val = g_msec_cnt;
val++;

if (val >= 1000 - 1)
{
val = 0;

DHCP_time_handler();
DNS_time_handler();
}

g_msec_cnt = val;
}

extern "C" void pico_wizchip_init(void)
{
wizchip_spi_initialize();
wizchip_cris_initialize();

wizchip_reset();

wizchip_initialize();
wizchip_check();

wizchip_1ms_timer_initialize(repeating_timer_callback);
}
3 changes: 3 additions & 0 deletions src/wizchip.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#pragma once

extern "C" void pico_wizchip_init(void);

0 comments on commit 5a9030a

Please sign in to comment.