Add test target, parallelize load and info across two devices
This commit is contained in:
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