File tree Expand file tree Collapse file tree
variants/arduino_nano_rp2040_connect_rp2040 Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ /*
2+ * Copyright (c) Arduino s.r.l. and/or its affiliated companies
3+ *
4+ * SPDX-License-Identifier: Apache-2.0
5+ */
6+
7+ #include " Arduino.h"
8+
9+ #define NANO_RP2040_LED_PIN 6
10+
11+ void _on_1200_bps () {
12+ /*
13+ * Call reset_usb_boot() directly via the RP2040 ROM lookup table.
14+ * This avoids depending on rom_reset_usb_boot from libpico (not
15+ * exported to LLEXT sketches). The ROM is always at 0x00000000:
16+ * 0x14: 16-bit offset of the function table
17+ * 0x18: 16-bit offset of the table lookup function
18+ * 'UB' is the 2-byte code for reset_usb_boot (ROM_FUNC_RESET_USB_BOOT).
19+ */
20+ typedef void *(*rom_lookup_fn)(uint16_t *table, uint32_t code);
21+ typedef void __attribute__ ((noreturn)) (*reset_usb_boot_fn)(uint32_t , uint32_t );
22+
23+ rom_lookup_fn lookup = (rom_lookup_fn)(uintptr_t )(*(volatile uint16_t *)0x18u );
24+ uint16_t *table = (uint16_t *)(uintptr_t )(*(volatile uint16_t *)0x14u );
25+
26+ reset_usb_boot_fn fn = (reset_usb_boot_fn) lookup (table, (' U' | (' B' << 8 )));
27+ fn (1u << NANO_RP2040_LED_PIN, 0u );
28+ }
You can’t perform that action at this time.
0 commit comments