Skip to content

Commit a6de4dc

Browse files
committed
variants: nano_connect: 1200 touch support
Signed-off-by: Gilberto Conti <g.conti@arduino.cc>
1 parent 704030f commit a6de4dc

1 file changed

Lines changed: 28 additions & 0 deletions

File tree

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
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+
}

0 commit comments

Comments
 (0)