ports: On cold boot, enable USB after boot.py completes.
For mimxrt, nrf, renesas-ra, rp2 and samd ports, this commit implements similar behaviour to the stm32 port, where USB is only brought up after boot.py completes execution. Currently this doesn't add any useful functionality (and may break workflows that depend on USB-CDC being live in boot.py), however it's a precondition for more usable workflows with USB devices defined in Python (allows setting up USB interfaces in boot.py before the device enumerates for the first time). This work was funded through GitHub Sponsors. Signed-off-by: Angus Gratton <angus@redyak.com.au>
This commit is contained in:
committed by
Damien George
parent
5d83bbca60
commit
00ba6aaae4
@@ -33,6 +33,7 @@
|
||||
#include "shared/runtime/gchelper.h"
|
||||
#include "shared/runtime/pyexec.h"
|
||||
#include "shared/runtime/softtimer.h"
|
||||
#include "shared/tinyusb/mp_usbd.h"
|
||||
|
||||
extern uint8_t _sstack, _estack, _sheap, _eheap;
|
||||
extern void adc_deinit_all(void);
|
||||
@@ -56,6 +57,9 @@ void samd_main(void) {
|
||||
|
||||
// Execute user scripts.
|
||||
int ret = pyexec_file_if_exists("boot.py");
|
||||
|
||||
mp_usbd_init();
|
||||
|
||||
if (ret & PYEXEC_FORCED_EXIT) {
|
||||
goto soft_reset_exit;
|
||||
}
|
||||
|
||||
@@ -62,8 +62,6 @@ static void usb_init(void) {
|
||||
PORT->Group[0].PMUX[12].reg = alt << 4 | alt;
|
||||
PORT->Group[0].PINCFG[24].reg = PORT_PINCFG_PMUXEN;
|
||||
PORT->Group[0].PINCFG[25].reg = PORT_PINCFG_PMUXEN;
|
||||
|
||||
tusb_init();
|
||||
}
|
||||
|
||||
// Initialize the µs counter on TC 0/1 or TC4/5
|
||||
|
||||
Reference in New Issue
Block a user