first and working ethernet

This commit is contained in:
2025-07-26 21:48:13 -04:00
commit 473f9013c0
58 changed files with 3405 additions and 0 deletions

Binary file not shown.

View File

@@ -0,0 +1,41 @@
# Generated Cmake Pico project file
cmake_minimum_required(VERSION 3.13)
set(CMAKE_C_STANDARD 11)
set(CMAKE_CXX_STANDARD 17)
# initalize pico_sdk from installed location
# (note this can come from environment, CMake cache etc)
#set(PICO_SDK_PATH "D:/Raspberry/Pico-Code/pico-sdk")
# Pull in Raspberry Pi Pico SDK (must be before project)
include(pico_sdk_import.cmake)
project(RP2040_WS2812B_Test C CXX ASM)
# Initialise the Raspberry Pi Pico SDK
pico_sdk_init()
# Add executable. Default name is the project name, version 0.1
add_executable(RP2040_WS2812B_Test RP2040_WS2812B_Test.c )
pico_generate_pio_header(RP2040_WS2812B_Test ${CMAKE_CURRENT_LIST_DIR}/ws2812.pio OUTPUT_DIR ${CMAKE_CURRENT_LIST_DIR}/generated)
pico_set_program_name(RP2040_WS2812B_Test "RP2040_WS2812B_Test")
pico_set_program_version(RP2040_WS2812B_Test "0.1")
pico_enable_stdio_uart(RP2040_WS2812B_Test 0)
pico_enable_stdio_usb(RP2040_WS2812B_Test 0)
# Add the standard library to the build
target_link_libraries(RP2040_WS2812B_Test pico_stdlib)
# Add any user requested libraries
target_link_libraries(RP2040_WS2812B_Test
hardware_pio
)
pico_add_extra_outputs(RP2040_WS2812B_Test)

View File

@@ -0,0 +1,51 @@
#include <stdio.h>
#include <stdlib.h>
#include "pico/stdlib.h"
#include "hardware/pio.h"
#include "hardware/clocks.h"
#include "ws2812.pio.h"
void put_pixel(uint32_t pixel_grb)
{
pio_sm_put_blocking(pio0, 0, pixel_grb << 8u);
}
void put_rgb(uint8_t red, uint8_t green, uint8_t blue)
{
uint32_t mask = (green << 16) | (red << 8) | (blue << 0);
put_pixel(mask);
}
int main()
{
//set_sys_clock_48();
stdio_init_all();
PIO pio = pio0;
int sm = 0;
uint offset = pio_add_program(pio, &ws2812_program);
uint8_t cnt = 0;
puts("RP2040-Zero WS2812 Test");
ws2812_program_init(pio, sm, offset, 25, 800000, true);
while (1)
{
for (cnt = 0; cnt < 0xff; cnt++)
{
put_rgb(cnt, 0xff - cnt, 0);
sleep_ms(3);
}
for (cnt = 0; cnt < 0xff; cnt++)
{
put_rgb(0xff - cnt, 0, cnt);
sleep_ms(3);
}
for (cnt = 0; cnt < 0xff; cnt++)
{
put_rgb(0, cnt, 0xff - cnt);
sleep_ms(3);
}
}
}

View File

@@ -0,0 +1,34 @@
/*****************************************************************************
* | File : Readme_CN.txt
* | Author :
* | Function : Help with use
* | Info :
*----------------
* | This version: V1.0
* | Date : 2023-04-23
* | Info : 在这里提供一个中文版本的使用文档,以便你的快速使用
******************************************************************************/
这个文件是帮助您使用本例程。
由于我们的LCD越来越多不便于我们的维护因此把所有的LCD程序做成一个工程。
在这里简略的描述本工程的使用:
1.基本信息:
本例程用于测试或者演示RP2040-ETH上WS2812B;
2.管脚连接:
DIN -> 25
3.基本使用:
你需要执行:
如果目录已经存在,则可以直接进入。 如果没有目录,执行:
mkdir build
进入目录并添加SDK:
cd build
export PICO_SDK_PATH=../../pico-sdk
其中 ../../pico-sdk 是你的SDK的目录。
执行cmake自动生成Makefile文件:
cmake ..
执行make生成可执行文件然后在终端中输入
make
编译好的uf2文件复制到pico中即可

View File

@@ -0,0 +1,35 @@
/*****************************************************************************
* | File : Readme_EN.txt
* | Author :
* | Function : Help with use
* | Info :
*----------------
* | This version: V1.0
* | Date : 2021-02-04
* | Info : Here is an English version of the documentation for your quick use.
******************************************************************************/
This file is to help you use this routine.
Since our ink screens are getting more and more, it is not convenient for our maintenance, so all the ink screen programs are made into one project.
A brief description of the use of this project is here:
1. Basic information:
This routine is used to test or demonstrate WS2812B on RP2040-ETH.
2. Pin connection:
Pin connection You can look at dev_config.c/h in \lib\Config. Again, here:
DIN -> 25
3. Basic use:
You need to execute:
If the directory already exists, you can go directly. If there is no build directory, execute
mkdir build
Enter the build directory and type in the terminal:
cd build
export PICO_SDK_PATH=../../pico-sdk
Where ../../pico-sdk is your installed SDK directory
Execute cmake, automatically generate Makefile file, enter in the terminal:
cmake ..
Execute make to generate an executable file, and enter in the terminal:
make
Copy the compiled uf2 file to pico

View File

@@ -0,0 +1,61 @@
// -------------------------------------------------- //
// This file is autogenerated by pioasm; do not edit! //
// -------------------------------------------------- //
#pragma once
#if !PICO_NO_HARDWARE
#include "hardware/pio.h"
#endif
// ------ //
// ws2812 //
// ------ //
#define ws2812_wrap_target 0
#define ws2812_wrap 3
#define ws2812_T1 2
#define ws2812_T2 5
#define ws2812_T3 3
static const uint16_t ws2812_program_instructions[] = {
// .wrap_target
0x6221, // 0: out x, 1 side 0 [2]
0x1123, // 1: jmp !x, 3 side 1 [1]
0x1400, // 2: jmp 0 side 1 [4]
0xa442, // 3: nop side 0 [4]
// .wrap
};
#if !PICO_NO_HARDWARE
static const struct pio_program ws2812_program = {
.instructions = ws2812_program_instructions,
.length = 4,
.origin = -1,
};
static inline pio_sm_config ws2812_program_get_default_config(uint offset) {
pio_sm_config c = pio_get_default_sm_config();
sm_config_set_wrap(&c, offset + ws2812_wrap_target, offset + ws2812_wrap);
sm_config_set_sideset(&c, 1, false, false);
return c;
}
#include "hardware/clocks.h"
static inline void ws2812_program_init(PIO pio, uint sm, uint offset, uint pin, float freq, bool rgbw) {
pio_gpio_init(pio, pin);
pio_sm_set_consecutive_pindirs(pio, sm, pin, 1, true);
pio_sm_config c = ws2812_program_get_default_config(offset);
sm_config_set_sideset_pins(&c, pin);
sm_config_set_out_shift(&c, false, true, rgbw ? 32 : 24);
sm_config_set_fifo_join(&c, PIO_FIFO_JOIN_TX);
int cycles_per_bit = ws2812_T1 + ws2812_T2 + ws2812_T3;
float div = clock_get_hz(clk_sys) / (freq * cycles_per_bit);
sm_config_set_clkdiv(&c, div);
pio_sm_init(pio, sm, offset, &c);
pio_sm_set_enabled(pio, sm, true);
}
#endif

View File

@@ -0,0 +1,62 @@
# This is a copy of <PICO_SDK_PATH>/external/pico_sdk_import.cmake
# This can be dropped into an external project to help locate this SDK
# It should be include()ed prior to project()
if (DEFINED ENV{PICO_SDK_PATH} AND (NOT PICO_SDK_PATH))
set(PICO_SDK_PATH $ENV{PICO_SDK_PATH})
message("Using PICO_SDK_PATH from environment ('${PICO_SDK_PATH}')")
endif ()
if (DEFINED ENV{PICO_SDK_FETCH_FROM_GIT} AND (NOT PICO_SDK_FETCH_FROM_GIT))
set(PICO_SDK_FETCH_FROM_GIT $ENV{PICO_SDK_FETCH_FROM_GIT})
message("Using PICO_SDK_FETCH_FROM_GIT from environment ('${PICO_SDK_FETCH_FROM_GIT}')")
endif ()
if (DEFINED ENV{PICO_SDK_FETCH_FROM_GIT_PATH} AND (NOT PICO_SDK_FETCH_FROM_GIT_PATH))
set(PICO_SDK_FETCH_FROM_GIT_PATH $ENV{PICO_SDK_FETCH_FROM_GIT_PATH})
message("Using PICO_SDK_FETCH_FROM_GIT_PATH from environment ('${PICO_SDK_FETCH_FROM_GIT_PATH}')")
endif ()
set(PICO_SDK_PATH "${PICO_SDK_PATH}" CACHE PATH "Path to the Raspberry Pi Pico SDK")
set(PICO_SDK_FETCH_FROM_GIT "${PICO_SDK_FETCH_FROM_GIT}" CACHE BOOL "Set to ON to fetch copy of SDK from git if not otherwise locatable")
set(PICO_SDK_FETCH_FROM_GIT_PATH "${PICO_SDK_FETCH_FROM_GIT_PATH}" CACHE FILEPATH "location to download SDK")
if (NOT PICO_SDK_PATH)
if (PICO_SDK_FETCH_FROM_GIT)
include(FetchContent)
set(FETCHCONTENT_BASE_DIR_SAVE ${FETCHCONTENT_BASE_DIR})
if (PICO_SDK_FETCH_FROM_GIT_PATH)
get_filename_component(FETCHCONTENT_BASE_DIR "${PICO_SDK_FETCH_FROM_GIT_PATH}" REALPATH BASE_DIR "${CMAKE_SOURCE_DIR}")
endif ()
FetchContent_Declare(
pico_sdk
GIT_REPOSITORY https://github.com/raspberrypi/pico-sdk
GIT_TAG master
)
if (NOT pico_sdk)
message("Downloading Raspberry Pi Pico SDK")
FetchContent_Populate(pico_sdk)
set(PICO_SDK_PATH ${pico_sdk_SOURCE_DIR})
endif ()
set(FETCHCONTENT_BASE_DIR ${FETCHCONTENT_BASE_DIR_SAVE})
else ()
message(FATAL_ERROR
"SDK location was not specified. Please set PICO_SDK_PATH or set PICO_SDK_FETCH_FROM_GIT to on to fetch from git."
)
endif ()
endif ()
get_filename_component(PICO_SDK_PATH "${PICO_SDK_PATH}" REALPATH BASE_DIR "${CMAKE_BINARY_DIR}")
if (NOT EXISTS ${PICO_SDK_PATH})
message(FATAL_ERROR "Directory '${PICO_SDK_PATH}' not found")
endif ()
set(PICO_SDK_INIT_CMAKE_FILE ${PICO_SDK_PATH}/pico_sdk_init.cmake)
if (NOT EXISTS ${PICO_SDK_INIT_CMAKE_FILE})
message(FATAL_ERROR "Directory '${PICO_SDK_PATH}' does not appear to contain the Raspberry Pi Pico SDK")
endif ()
set(PICO_SDK_PATH ${PICO_SDK_PATH} CACHE PATH "Path to the Raspberry Pi Pico SDK" FORCE)
include(${PICO_SDK_INIT_CMAKE_FILE})

View File

@@ -0,0 +1,48 @@
;
; Copyright (c) 2020 Raspberry Pi (Trading) Ltd.
;
; SPDX-License-Identifier: BSD-3-Clause
;
.program ws2812
.side_set 1
.define public T1 2
.define public T2 5
.define public T3 3
.lang_opt python sideset_init = pico.PIO.OUT_HIGH
.lang_opt python out_init = pico.PIO.OUT_HIGH
.lang_opt python out_shiftdir = 1
.wrap_target
bitloop:
out x, 1 side 0 [T3 - 1] ; Side-set still takes place when instruction stalls
jmp !x do_zero side 1 [T1 - 1] ; Branch on the bit we shifted out. Positive pulse
do_one:
jmp bitloop side 1 [T2 - 1] ; Continue driving high, for a long pulse
do_zero:
nop side 0 [T2 - 1] ; Or drive low, for a short pulse
.wrap
% c-sdk {
#include "hardware/clocks.h"
static inline void ws2812_program_init(PIO pio, uint sm, uint offset, uint pin, float freq, bool rgbw) {
pio_gpio_init(pio, pin);
pio_sm_set_consecutive_pindirs(pio, sm, pin, 1, true);
pio_sm_config c = ws2812_program_get_default_config(offset);
sm_config_set_sideset_pins(&c, pin);
sm_config_set_out_shift(&c, false, true, rgbw ? 32 : 24);
sm_config_set_fifo_join(&c, PIO_FIFO_JOIN_TX);
int cycles_per_bit = ws2812_T1 + ws2812_T2 + ws2812_T3;
float div = clock_get_hz(clk_sys) / (freq * cycles_per_bit);
sm_config_set_clkdiv(&c, div);
pio_sm_init(pio, sm, offset, &c);
pio_sm_set_enabled(pio, sm, true);
}
%}

View File

@@ -0,0 +1,53 @@
import time
from machine import Pin
import rp2
max_lum =100
r=0
g=0
b=0
@rp2.asm_pio(sideset_init=rp2.PIO.OUT_LOW, out_shiftdir=rp2.PIO.SHIFT_LEFT, autopull=True, pull_thresh=24)
def ws2812():
T1 = 2
T2 = 5
T3 = 3
wrap_target()
label("bitloop")
out(x, 1) .side(0) [T3 - 1]
jmp(not_x, "do_zero") .side(1) [T1 - 1]
jmp("bitloop") .side(1) [T2 - 1]
label("do_zero")
nop() .side(0) [T2 - 1]
wrap()
# Create the StateMachine with the ws2812 program, outputting on Pin(4).
sm = rp2.StateMachine(0, ws2812, freq=8_000_000, sideset_base=Pin(25))
# Start the StateMachine, it will wait for data on its FIFO.
sm.active(1)
# Color change
while True:
for i in range(0,max_lum):
r=i
b=max_lum-i
rgb =(g<<24) | (r<<16) | (b<<8)
sm.put(rgb)
time.sleep_ms(10)
time.sleep_ms(300)
for i in range(0,max_lum):
g=i
r=max_lum-i
rgb =(g<<24) | (r<<16) | (b<<8)
sm.put(rgb)
time.sleep_ms(10)
time.sleep_ms(300)
for i in range(0,max_lum):
b=i
g=max_lum-i
rgb =(g<<24) | (r<<16) | (b<<8)
sm.put(rgb)
time.sleep_ms(10)
time.sleep_ms(300)

View File

@@ -0,0 +1,36 @@
/*****************************************************************************
* | File : Readme_CN.txt
* | Author :
* | Function : Help with use
* | Info :
*----------------
* | This version: V1.0
* | Date : 2021-11-22
* | Info : 在这里提供一个中文版本的使用文档,以便你的快速使用
******************************************************************************/
这个文件是帮助您使用本例程。
在这里简略的描述本工程的使用:
1.基本信息:
本例程用于测试或者演示RP2040-Zero上WS2812B;
2.管脚连接:
管脚连接你可以在RP2040-Zero.py查看这里也再重述一次
DIN -> 16
3.基本使用:
1): 按住RP2040-Zero板上的Boot按键将RP2040-Zero通过Type-C USB线接到电脑的USB接口然后松开按键。
接入之后电脑会自动识别到一个可移动盘RPI-RP2
2): 将Python目录下的uf2文件夹中rp2-pico-20210902-v1.17.uf2 文件复制到识别的可移动盘RPI-RP2
3): 更新Thonny IDE
sudo apt upgrade thonny
4): 打开Thonny IDE 点击树莓logo -> Programming -> Thonny Python IDE
选择Tools -> Options... -> Interpreter
选择MicroPython(Raspberry Pi Pico 和ttyACM0端口
5): 在Thonny IDE中打开Python/RP2040-Zero.py文件
然后运行当前脚本(绿色小三角)即可

View File

@@ -0,0 +1,38 @@
/*****************************************************************************
* | File : Readme_EN.txt
* | Author :
* | Function : Help with use
* | Info :
*----------------
* | This version: V1.0
* | Date : 2021-11-22
* | Info : Here is an English version of the documentation for your quick use.
******************************************************************************/
This file is to help you use this routine.
Here is a brief description of the use of this project:
1. Basic information:
This routine is used to test or demonstrate WS2812B on RP2040-Zero.
2. Pin connection:
You can check the pin connection at RP2040-Zero.py, and repeat it here:
DIN -> 16
3. Basic use:
1): Press and hold the Bootsel button on the RP2040-Zero board, connect RP2040-Zero to the USB port of the
computer through the Type-C USB cable, and then release the button.
After connecting, the computer will automatically recognize a removable disk (RPI-RP2)
2): Copy the rp2-Pico-20210902-v1.17.uf2 file from the Uf2 folder in the Python directory to an identified
removable disk (rpi-rp2)
3): Update Thonny IDE
sudo apt upgrade thonny
4): Open Thonny IDE Click raspberry logo -> Programming -> Thonny Python IDE
select Tools -> Options... -> Interpreter
select MicroPython(Raspberry Pi Pico and ttyACM0 port
5): Open the Python/ rp2040-zero.py file in Thonny IDE
Then run the current script (little green triangle)

View File

@@ -0,0 +1 @@
2021-11-22新创建。

View File

@@ -0,0 +1 @@
2021-11-22: newly built.