Extract picoboot and info handlers into lib/handlers
This commit is contained in:
@@ -1,12 +1,10 @@
|
||||
#include "pico/stdlib.h"
|
||||
#include "pico/bootrom.h"
|
||||
#include "pico/unique_id.h"
|
||||
#include "tusb.h"
|
||||
#include "wire.h"
|
||||
#include "usb_cdc.h"
|
||||
#include "timer_queue.h"
|
||||
#include "handlers.h"
|
||||
#include "net.h"
|
||||
#include "w6300.h"
|
||||
|
||||
static usb_cdc usb;
|
||||
static timer_queue timers;
|
||||
@@ -40,22 +38,12 @@ int main() {
|
||||
|
||||
switch (msg->type_id) {
|
||||
case RequestPICOBOOT::ext_id:
|
||||
usb.send(encode_response(msg->message_id, ResponsePICOBOOT{}));
|
||||
sleep_ms(100);
|
||||
reset_usb_boot(0, 1);
|
||||
handle_picoboot(usb, msg->message_id);
|
||||
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;
|
||||
resp.link_local = ninfo.lla;
|
||||
usb.send(encode_response(msg->message_id, resp));
|
||||
case RequestInfo::ext_id:
|
||||
handle_info(usb, msg->message_id);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
__wfi();
|
||||
|
||||
Reference in New Issue
Block a user