Skip to content

Commit 880082b

Browse files
authored
Merge pull request adafruit#11321 from TheFilipcom4607/challenger-rp2040-nfc
Add Challenger RP2040 NFC board
2 parents dea8844 + 83031be commit 880082b

7 files changed

Lines changed: 165 additions & 1 deletion

File tree

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// This file is part of the CircuitPython project: https://circuitpython.org
2+
//
3+
// SPDX-FileCopyrightText: Copyright (c) 2022 Pontus Oldberg, Invector Labs
4+
// SPDX-FileCopyrightText: Copyright (c) 2026 TheFilipcom4607
5+
//
6+
// SPDX-License-Identifier: MIT
7+
8+
#include "supervisor/board.h"
9+
10+
// Use the MP_WEAK supervisor/shared/board.c versions of routines not defined here.
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// This file is part of the CircuitPython project: https://circuitpython.org
2+
//
3+
// SPDX-FileCopyrightText: Copyright (c) 2022 Pontus Oldberg, Invector Labs
4+
//
5+
// SPDX-License-Identifier: MIT
6+
7+
#pragma once
8+
9+
#define MICROPY_HW_BOARD_NAME "Challenger RP2040 NFC"
10+
#define MICROPY_HW_MCU_NAME "rp2040"
11+
12+
// The on-board PN7150 sits on GPIO10/11 with no external pull-up
13+
// resistors: iLabs' Arduino core relies on the RP2040's internal
14+
// pull-ups instead (TwoWire::begin() calls gpio_pull_up() on both pins).
15+
#define CIRCUITPY_I2C_ALLOW_INTERNAL_PULL_UP (1)
16+
17+
#define MICROPY_HW_LED_STATUS (&pin_GPIO24)
18+
#define MICROPY_HW_NEOPIXEL (&pin_GPIO14)
19+
20+
#define DEFAULT_UART_BUS_TX (&pin_GPIO16)
21+
#define DEFAULT_UART_BUS_RX (&pin_GPIO17)
22+
#define DEFAULT_I2C_BUS_SDA (&pin_GPIO0)
23+
#define DEFAULT_I2C_BUS_SCL (&pin_GPIO1)
24+
#define DEFAULT_SPI_BUS_SCK (&pin_GPIO22)
25+
#define DEFAULT_SPI_BUS_MOSI (&pin_GPIO23)
26+
#define DEFAULT_SPI_BUS_MISO (&pin_GPIO20)
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
USB_VID = 0x2e8a
2+
USB_PID = 0x1036
3+
USB_PRODUCT = "Challenger RP2040 NFC"
4+
USB_MANUFACTURER = "Invector Labs"
5+
6+
CHIP_VARIANT = RP2040
7+
CHIP_FAMILY = rp2
8+
9+
EXTERNAL_FLASH_DEVICES = "W25Q64JVxQ"
10+
11+
CIRCUITPY__EVE = 1
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// This file is part of the CircuitPython project: https://circuitpython.org
2+
//
3+
// SPDX-FileCopyrightText: Copyright (c) 2022 Pontus Oldberg, Invector Labs
4+
// SPDX-FileCopyrightText: Copyright (c) 2026 TheFilipcom4607
5+
//
6+
// SPDX-License-Identifier: MIT
7+
8+
#pragma once
9+
10+
// Put board-specific pico-sdk definitions here. This file must exist.
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
// This file is part of the CircuitPython project: https://circuitpython.org
2+
//
3+
// SPDX-FileCopyrightText: Copyright (c) 2022 Pontus Oldberg, Invector Labs
4+
// SPDX-FileCopyrightText: Copyright (c) 2026 TheFilipcom4607
5+
//
6+
// SPDX-License-Identifier: MIT
7+
8+
#include "shared-bindings/board/__init__.h"
9+
10+
static const mp_rom_map_elem_t board_module_globals_table[] = {
11+
CIRCUITPYTHON_BOARD_DICT_STANDARD_ITEMS
12+
13+
{ MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_GPIO0) },
14+
{ MP_ROM_QSTR(MP_QSTR_GP0), MP_ROM_PTR(&pin_GPIO0) },
15+
{ MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_GPIO1) },
16+
{ MP_ROM_QSTR(MP_QSTR_GP1), MP_ROM_PTR(&pin_GPIO1) },
17+
18+
{ MP_ROM_QSTR(MP_QSTR_D5), MP_ROM_PTR(&pin_GPIO2) },
19+
{ MP_ROM_QSTR(MP_QSTR_GP2), MP_ROM_PTR(&pin_GPIO2) },
20+
{ MP_ROM_QSTR(MP_QSTR_D6), MP_ROM_PTR(&pin_GPIO3) },
21+
{ MP_ROM_QSTR(MP_QSTR_GP3), MP_ROM_PTR(&pin_GPIO3) },
22+
{ MP_ROM_QSTR(MP_QSTR_D9), MP_ROM_PTR(&pin_GPIO4) },
23+
{ MP_ROM_QSTR(MP_QSTR_GP4), MP_ROM_PTR(&pin_GPIO4) },
24+
{ MP_ROM_QSTR(MP_QSTR_D10), MP_ROM_PTR(&pin_GPIO5) },
25+
{ MP_ROM_QSTR(MP_QSTR_GP5), MP_ROM_PTR(&pin_GPIO5) },
26+
{ MP_ROM_QSTR(MP_QSTR_D11), MP_ROM_PTR(&pin_GPIO6) },
27+
{ MP_ROM_QSTR(MP_QSTR_GP6), MP_ROM_PTR(&pin_GPIO6) },
28+
{ MP_ROM_QSTR(MP_QSTR_D12), MP_ROM_PTR(&pin_GPIO7) },
29+
{ MP_ROM_QSTR(MP_QSTR_GP7), MP_ROM_PTR(&pin_GPIO7) },
30+
{ MP_ROM_QSTR(MP_QSTR_D13), MP_ROM_PTR(&pin_GPIO8) },
31+
{ MP_ROM_QSTR(MP_QSTR_GP8), MP_ROM_PTR(&pin_GPIO8) },
32+
33+
// On board PN7150 NFC controller. Not available on the pin headers.
34+
{ MP_ROM_QSTR(MP_QSTR_NFC_IRQ), MP_ROM_PTR(&pin_GPIO9) },
35+
{ MP_ROM_QSTR(MP_QSTR_GP9), MP_ROM_PTR(&pin_GPIO9) },
36+
{ MP_ROM_QSTR(MP_QSTR_NFC_SDA), MP_ROM_PTR(&pin_GPIO10) },
37+
{ MP_ROM_QSTR(MP_QSTR_GP10), MP_ROM_PTR(&pin_GPIO10) },
38+
{ MP_ROM_QSTR(MP_QSTR_NFC_SCL), MP_ROM_PTR(&pin_GPIO11) },
39+
{ MP_ROM_QSTR(MP_QSTR_GP11), MP_ROM_PTR(&pin_GPIO11) },
40+
{ MP_ROM_QSTR(MP_QSTR_NFC_RESET), MP_ROM_PTR(&pin_GPIO12) },
41+
{ MP_ROM_QSTR(MP_QSTR_GP12), MP_ROM_PTR(&pin_GPIO12) },
42+
43+
{ MP_ROM_QSTR(MP_QSTR_GP13), MP_ROM_PTR(&pin_GPIO13) },
44+
45+
{ MP_ROM_QSTR(MP_QSTR_NEOPIXEL), MP_ROM_PTR(&pin_GPIO14) },
46+
{ MP_ROM_QSTR(MP_QSTR_GP14), MP_ROM_PTR(&pin_GPIO14) },
47+
48+
{ MP_ROM_QSTR(MP_QSTR_D0), MP_ROM_PTR(&pin_GPIO16) },
49+
{ MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_GPIO16) },
50+
{ MP_ROM_QSTR(MP_QSTR_GP16), MP_ROM_PTR(&pin_GPIO16) },
51+
{ MP_ROM_QSTR(MP_QSTR_D1), MP_ROM_PTR(&pin_GPIO17) },
52+
{ MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_GPIO17) },
53+
{ MP_ROM_QSTR(MP_QSTR_GP17), MP_ROM_PTR(&pin_GPIO17) },
54+
55+
{ MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_GPIO20) },
56+
{ MP_ROM_QSTR(MP_QSTR_SDI), MP_ROM_PTR(&pin_GPIO20) },
57+
{ MP_ROM_QSTR(MP_QSTR_GP20), MP_ROM_PTR(&pin_GPIO20) },
58+
{ MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_GPIO22) },
59+
{ MP_ROM_QSTR(MP_QSTR_GP22), MP_ROM_PTR(&pin_GPIO22) },
60+
{ MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_GPIO23) },
61+
{ MP_ROM_QSTR(MP_QSTR_SDO), MP_ROM_PTR(&pin_GPIO23) },
62+
{ MP_ROM_QSTR(MP_QSTR_GP23), MP_ROM_PTR(&pin_GPIO23) },
63+
64+
{ MP_ROM_QSTR(MP_QSTR_LED), MP_ROM_PTR(&pin_GPIO24) },
65+
{ MP_ROM_QSTR(MP_QSTR_GP24), MP_ROM_PTR(&pin_GPIO24) },
66+
67+
// A4 and A5 are digital only on this board.
68+
{ MP_ROM_QSTR(MP_QSTR_A4), MP_ROM_PTR(&pin_GPIO19) },
69+
{ MP_ROM_QSTR(MP_QSTR_GP19), MP_ROM_PTR(&pin_GPIO19) },
70+
{ MP_ROM_QSTR(MP_QSTR_A5), MP_ROM_PTR(&pin_GPIO21) },
71+
{ MP_ROM_QSTR(MP_QSTR_GP21), MP_ROM_PTR(&pin_GPIO21) },
72+
73+
{ MP_ROM_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_GPIO26) },
74+
{ MP_ROM_QSTR(MP_QSTR_GP26), MP_ROM_PTR(&pin_GPIO26) },
75+
{ MP_ROM_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_GPIO27) },
76+
{ MP_ROM_QSTR(MP_QSTR_GP27), MP_ROM_PTR(&pin_GPIO27) },
77+
{ MP_ROM_QSTR(MP_QSTR_A2), MP_ROM_PTR(&pin_GPIO28) },
78+
{ MP_ROM_QSTR(MP_QSTR_GP28), MP_ROM_PTR(&pin_GPIO28) },
79+
{ MP_ROM_QSTR(MP_QSTR_A3), MP_ROM_PTR(&pin_GPIO29) },
80+
{ MP_ROM_QSTR(MP_QSTR_GP29), MP_ROM_PTR(&pin_GPIO29) },
81+
82+
{ MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) },
83+
{ MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) },
84+
{ MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) },
85+
};
86+
MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table);

ports/raspberrypi/common-hal/busio/I2C.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,12 @@ void common_hal_busio_i2c_construct(busio_i2c_obj_t *self,
4848
mp_arg_validate_int_max(frequency, 1000000, MP_QSTR_frequency);
4949

5050

51-
#if CIRCUITPY_REQUIRE_I2C_PULLUPS
51+
// Don't bother to check for pull-ups when the internal pull-ups are used.
52+
#if CIRCUITPY_REQUIRE_I2C_PULLUPS && !CIRCUITPY_I2C_ALLOW_INTERNAL_PULL_UP
53+
54+
// TODO: maybe check the pull-up efficacy with timing scaled by frequency
55+
// as is done in espressif, instead of using a fixed 3us.
56+
5257
// Test that the pins are in a high state. (Hopefully indicating they are pulled up.)
5358
gpio_set_function(sda->number, GPIO_FUNC_SIO);
5459
gpio_set_function(scl->number, GPIO_FUNC_SIO);
@@ -98,6 +103,12 @@ void common_hal_busio_i2c_construct(busio_i2c_obj_t *self,
98103

99104
gpio_set_function(self->scl_pin, GPIO_FUNC_I2C);
100105
gpio_set_function(self->sda_pin, GPIO_FUNC_I2C);
106+
107+
#if CIRCUITPY_I2C_ALLOW_INTERNAL_PULL_UP
108+
// Enable the internal pull-ups only once the pins belong to the I2C peripheral.
109+
gpio_pull_up(self->scl_pin);
110+
gpio_pull_up(self->sda_pin);
111+
#endif
101112
}
102113

103114
bool common_hal_busio_i2c_deinited(busio_i2c_obj_t *self) {

ports/raspberrypi/mpconfigport.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,16 @@
4646
// This also includes mpconfigboard.h.
4747
#include "py/circuitpy_mpconfig.h"
4848

49+
// Turn on this option to allow the use of the internal pull-up resistors on
50+
// the I2C pins, for boards whose on-board I2C peripherals lack external pull
51+
// up resistors. The internal pull-ups are weak, and using them is only to
52+
// compensate for design decisions that are out of the control of the authors
53+
// of CircuitPython. It is not an endorsement of running without appropriate
54+
// external pull up resistors.
55+
#ifndef CIRCUITPY_I2C_ALLOW_INTERNAL_PULL_UP
56+
#define CIRCUITPY_I2C_ALLOW_INTERNAL_PULL_UP (0)
57+
#endif
58+
4959
#if CIRCUITPY_CYW43
5060
#define MICROPY_PY_LWIP_ENTER cyw43_arch_lwip_begin();
5161
#define MICROPY_PY_LWIP_REENTER MICROPY_PY_LWIP_ENTER

0 commit comments

Comments
 (0)