Add test target, parallelize load and info across two devices
This commit is contained in:
@@ -9,26 +9,29 @@ set(CMAKE_C_STANDARD 11)
|
||||
set(CMAKE_CXX_STANDARD 23)
|
||||
pico_sdk_init()
|
||||
|
||||
add_executable(picomap
|
||||
main.cpp
|
||||
dhcp.cpp
|
||||
net.cpp
|
||||
tusb_config.cpp
|
||||
set(LIB_SOURCES
|
||||
lib/dhcp.cpp
|
||||
lib/net.cpp
|
||||
lib/tusb_config.cpp
|
||||
w6300/w6300.cpp
|
||||
)
|
||||
|
||||
target_include_directories(picomap PRIVATE
|
||||
include
|
||||
w6300
|
||||
)
|
||||
set(LIB_DEPS pico_stdlib pico_rand tinyusb_device tinyusb_board hardware_pio hardware_spi hardware_dma hardware_clocks)
|
||||
|
||||
add_executable(picomap firmware.cpp ${LIB_SOURCES})
|
||||
target_include_directories(picomap PRIVATE include w6300)
|
||||
target_compile_options(picomap PRIVATE -Wall -Wextra -Wno-unused-parameter)
|
||||
|
||||
pico_generate_pio_header(picomap ${CMAKE_CURRENT_LIST_DIR}/w6300/qspi.pio)
|
||||
|
||||
pico_enable_stdio_usb(picomap 0)
|
||||
pico_enable_stdio_uart(picomap 0)
|
||||
|
||||
pico_add_extra_outputs(picomap)
|
||||
target_link_libraries(picomap ${LIB_DEPS})
|
||||
|
||||
target_link_libraries(picomap pico_stdlib pico_rand tinyusb_device tinyusb_board hardware_pio hardware_spi hardware_dma hardware_clocks)
|
||||
add_executable(picomap_test test.cpp ${LIB_SOURCES})
|
||||
target_include_directories(picomap_test PRIVATE include w6300)
|
||||
target_compile_options(picomap_test PRIVATE -Wall -Wextra -Wno-unused-parameter)
|
||||
pico_generate_pio_header(picomap_test ${CMAKE_CURRENT_LIST_DIR}/w6300/qspi.pio)
|
||||
pico_enable_stdio_usb(picomap_test 0)
|
||||
pico_enable_stdio_uart(picomap_test 0)
|
||||
pico_add_extra_outputs(picomap_test)
|
||||
target_link_libraries(picomap_test ${LIB_DEPS})
|
||||
|
||||
58
firmware/test.cpp
Normal file
58
firmware/test.cpp
Normal file
@@ -0,0 +1,58 @@
|
||||
#include "pico/stdlib.h"
|
||||
#include "pico/bootrom.h"
|
||||
#include "pico/unique_id.h"
|
||||
#include "tusb.h"
|
||||
#include "wire.h"
|
||||
#include "usb_cdc.h"
|
||||
#include "net.h"
|
||||
#include "w6300.h"
|
||||
|
||||
static usb_cdc usb;
|
||||
|
||||
int main() {
|
||||
tusb_init();
|
||||
net_init();
|
||||
|
||||
static static_vector<uint8_t, 256> rx_buf;
|
||||
|
||||
while (true) {
|
||||
tud_task();
|
||||
|
||||
usb.drain();
|
||||
|
||||
while (tud_cdc_available()) {
|
||||
uint8_t byte;
|
||||
if (tud_cdc_read(&byte, 1) != 1) break;
|
||||
|
||||
rx_buf.push_back(byte);
|
||||
|
||||
auto msg = try_decode(rx_buf);
|
||||
if (!msg) {
|
||||
if (rx_buf.full()) rx_buf.clear();
|
||||
continue;
|
||||
}
|
||||
|
||||
rx_buf.clear();
|
||||
|
||||
switch (msg->type_id) {
|
||||
case RequestPICOBOOT::ext_id:
|
||||
usb.send(encode_response(msg->message_id, ResponsePICOBOOT{}));
|
||||
sleep_ms(100);
|
||||
reset_usb_boot(0, 1);
|
||||
break;
|
||||
case RequestInfo::ext_id: {
|
||||
ResponseInfo resp;
|
||||
pico_unique_board_id_t uid;
|
||||
pico_get_unique_board_id(&uid);
|
||||
std::copy(uid.id, uid.id + 8, resp.board_id.begin());
|
||||
auto ninfo = w6300::get_net_info();
|
||||
resp.mac = ninfo.mac;
|
||||
usb.send(encode_response(msg->message_id, resp));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
__wfi();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user