From cec9015e198c7cb688862858e3dc1f3b750bc3ca Mon Sep 17 00:00:00 2001 From: ladyada Date: Mon, 17 May 2021 13:05:08 -0400 Subject: [PATCH 1/5] iz makropad with oled --- .../boards/adafruit_macropad_rp2040/board.c | 40 +++++++++++++++++++ .../adafruit_macropad_rp2040/mpconfigboard.h | 7 ++++ .../adafruit_macropad_rp2040/mpconfigboard.mk | 9 +++++ .../boards/adafruit_macropad_rp2040/pins.c | 35 ++++++++++++++++ 4 files changed, 91 insertions(+) create mode 100644 ports/raspberrypi/boards/adafruit_macropad_rp2040/board.c create mode 100644 ports/raspberrypi/boards/adafruit_macropad_rp2040/mpconfigboard.h create mode 100644 ports/raspberrypi/boards/adafruit_macropad_rp2040/mpconfigboard.mk create mode 100644 ports/raspberrypi/boards/adafruit_macropad_rp2040/pins.c diff --git a/ports/raspberrypi/boards/adafruit_macropad_rp2040/board.c b/ports/raspberrypi/boards/adafruit_macropad_rp2040/board.c new file mode 100644 index 0000000000..c4021a83e9 --- /dev/null +++ b/ports/raspberrypi/boards/adafruit_macropad_rp2040/board.c @@ -0,0 +1,40 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2021 Scott Shawcroft for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "supervisor/board.h" + +#include "shared-bindings/microcontroller/Pin.h" +#include "src/rp2_common/hardware_gpio/include/hardware/gpio.h" + +void board_init(void) { +} + +bool board_requests_safe_mode(void) { + return false; +} + +void reset_board(void) { +} diff --git a/ports/raspberrypi/boards/adafruit_macropad_rp2040/mpconfigboard.h b/ports/raspberrypi/boards/adafruit_macropad_rp2040/mpconfigboard.h new file mode 100644 index 0000000000..5900003713 --- /dev/null +++ b/ports/raspberrypi/boards/adafruit_macropad_rp2040/mpconfigboard.h @@ -0,0 +1,7 @@ +#define MICROPY_HW_BOARD_NAME "Adafruit Macropad RP2040" +#define MICROPY_HW_MCU_NAME "rp2040" + +#define MICROPY_HW_NEOPIXEL (&pin_GPIO16) + +#define DEFAULT_I2C_BUS_SCL (&pin_GPIO25) +#define DEFAULT_I2C_BUS_SDA (&pin_GPIO24) diff --git a/ports/raspberrypi/boards/adafruit_macropad_rp2040/mpconfigboard.mk b/ports/raspberrypi/boards/adafruit_macropad_rp2040/mpconfigboard.mk new file mode 100644 index 0000000000..4d708bcf79 --- /dev/null +++ b/ports/raspberrypi/boards/adafruit_macropad_rp2040/mpconfigboard.mk @@ -0,0 +1,9 @@ +USB_VID = 0x239A +USB_PID = 0x8108 +USB_PRODUCT = "Macropad RP2040" +USB_MANUFACTURER = "Adafruit" + +CHIP_VARIANT = RP2040 +CHIP_FAMILY = rp2 + +EXTERNAL_FLASH_DEVICES = "W25Q64JVxQ" diff --git a/ports/raspberrypi/boards/adafruit_macropad_rp2040/pins.c b/ports/raspberrypi/boards/adafruit_macropad_rp2040/pins.c new file mode 100644 index 0000000000..51f2a2ad33 --- /dev/null +++ b/ports/raspberrypi/boards/adafruit_macropad_rp2040/pins.c @@ -0,0 +1,35 @@ +#include "shared-bindings/board/__init__.h" + +STATIC const mp_rom_map_elem_t board_global_dict_table[] = { + { MP_ROM_QSTR(MP_QSTR_KEY1), MP_ROM_PTR(&pin_GPIO1) }, + { MP_ROM_QSTR(MP_QSTR_KEY2), MP_ROM_PTR(&pin_GPIO2) }, + { MP_ROM_QSTR(MP_QSTR_KEY3), MP_ROM_PTR(&pin_GPIO3) }, + { MP_ROM_QSTR(MP_QSTR_KEY4), MP_ROM_PTR(&pin_GPIO4) }, + { MP_ROM_QSTR(MP_QSTR_KEY5), MP_ROM_PTR(&pin_GPIO5) }, + { MP_ROM_QSTR(MP_QSTR_KEY6), MP_ROM_PTR(&pin_GPIO6) }, + { MP_ROM_QSTR(MP_QSTR_KEY7), MP_ROM_PTR(&pin_GPIO7) }, + { MP_ROM_QSTR(MP_QSTR_KEY8), MP_ROM_PTR(&pin_GPIO8) }, + { MP_ROM_QSTR(MP_QSTR_KEY9), MP_ROM_PTR(&pin_GPIO9) }, + { MP_ROM_QSTR(MP_QSTR_KEY10), MP_ROM_PTR(&pin_GPIO10) }, + { MP_ROM_QSTR(MP_QSTR_KEY11), MP_ROM_PTR(&pin_GPIO11) }, + { MP_ROM_QSTR(MP_QSTR_KEY12), MP_ROM_PTR(&pin_GPIO12) }, + + { MP_ROM_QSTR(MP_QSTR_ENCODER_SWITCH), MP_ROM_PTR(&pin_GPIO0) }, + + { MP_ROM_QSTR(MP_QSTR_NEOPIXEL), MP_ROM_PTR(&pin_GPIO16) }, + { MP_ROM_QSTR(MP_QSTR_ENCODER_A), MP_ROM_PTR(&pin_GPIO17) }, + { MP_ROM_QSTR(MP_QSTR_ENCODER_B), MP_ROM_PTR(&pin_GPIO18) }, + + { MP_ROM_QSTR(MP_QSTR_OLED_RESET), MP_ROM_PTR(&pin_GPIO23) }, + + { MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_GPIO24) }, + { MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_GPIO25) }, + + { MP_ROM_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_GPIO26) }, + { MP_ROM_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_GPIO27) }, + { MP_ROM_QSTR(MP_QSTR_A2), MP_ROM_PTR(&pin_GPIO28) }, + { MP_ROM_QSTR(MP_QSTR_A3), MP_ROM_PTR(&pin_GPIO29) }, + + { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, +}; +MP_DEFINE_CONST_DICT(board_module_globals, board_global_dict_table); From 38ffc4352d18c59a10d490a75bdb521ac4e8c8fc Mon Sep 17 00:00:00 2001 From: ladyada Date: Mon, 17 May 2021 13:05:54 -0400 Subject: [PATCH 2/5] add workflow for makropad --- .github/workflows/build.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 9df017ce3a..194c8a7261 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -176,6 +176,7 @@ jobs: - "TG-Watch" - "adafruit_feather_rp2040" - "adafruit_itsybitsy_rp2040" + - "adafruit_macropad_rp2040" - "adafruit_neokey_trinkey_m0" - "adafruit_proxlight_trinkey_m0" - "adafruit_qt2040_trinkey" From fdbd3bc8c2fb9dd46708c7ee237b72bfb621d272 Mon Sep 17 00:00:00 2001 From: lady ada Date: Tue, 18 May 2021 11:09:31 -0400 Subject: [PATCH 3/5] add missing AREF pin --- ports/atmel-samd/boards/feather_m0_express/pins.c | 1 + 1 file changed, 1 insertion(+) diff --git a/ports/atmel-samd/boards/feather_m0_express/pins.c b/ports/atmel-samd/boards/feather_m0_express/pins.c index 19320ca794..aea705a493 100644 --- a/ports/atmel-samd/boards/feather_m0_express/pins.c +++ b/ports/atmel-samd/boards/feather_m0_express/pins.c @@ -1,6 +1,7 @@ #include "shared-bindings/board/__init__.h" STATIC const mp_rom_map_elem_t board_global_dict_table[] = { + { MP_ROM_QSTR(MP_QSTR_AREF), MP_ROM_PTR(&pin_PA03) }, { MP_ROM_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_PA02) }, { MP_ROM_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_PB08) }, { MP_ROM_QSTR(MP_QSTR_A2), MP_ROM_PTR(&pin_PB09) }, From d8b895f1d7a5b1e3d75034cb682cfaaf305fd76d Mon Sep 17 00:00:00 2001 From: lady ada Date: Tue, 18 May 2021 20:53:13 -0400 Subject: [PATCH 4/5] add LED and speaker - natch! --- ports/raspberrypi/boards/adafruit_macropad_rp2040/pins.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ports/raspberrypi/boards/adafruit_macropad_rp2040/pins.c b/ports/raspberrypi/boards/adafruit_macropad_rp2040/pins.c index 51f2a2ad33..8ce16c0e9c 100644 --- a/ports/raspberrypi/boards/adafruit_macropad_rp2040/pins.c +++ b/ports/raspberrypi/boards/adafruit_macropad_rp2040/pins.c @@ -14,6 +14,9 @@ STATIC const mp_rom_map_elem_t board_global_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_KEY11), MP_ROM_PTR(&pin_GPIO11) }, { MP_ROM_QSTR(MP_QSTR_KEY12), MP_ROM_PTR(&pin_GPIO12) }, + { MP_ROM_QSTR(MP_QSTR_LED), MP_ROM_PTR(&pin_GPIO13) }, + { MP_ROM_QSTR(MP_QSTR_SPEAKER), MP_ROM_PTR(&pin_GPIO14) }, + { MP_ROM_QSTR(MP_QSTR_ENCODER_SWITCH), MP_ROM_PTR(&pin_GPIO0) }, { MP_ROM_QSTR(MP_QSTR_NEOPIXEL), MP_ROM_PTR(&pin_GPIO16) }, From 9a70aa1e8de62baf65d932355b20676002c66ccc Mon Sep 17 00:00:00 2001 From: lady ada Date: Tue, 18 May 2021 22:20:38 -0400 Subject: [PATCH 5/5] figure out the AREF thing later --- ports/atmel-samd/boards/feather_m0_express/pins.c | 1 - 1 file changed, 1 deletion(-) diff --git a/ports/atmel-samd/boards/feather_m0_express/pins.c b/ports/atmel-samd/boards/feather_m0_express/pins.c index aea705a493..19320ca794 100644 --- a/ports/atmel-samd/boards/feather_m0_express/pins.c +++ b/ports/atmel-samd/boards/feather_m0_express/pins.c @@ -1,7 +1,6 @@ #include "shared-bindings/board/__init__.h" STATIC const mp_rom_map_elem_t board_global_dict_table[] = { - { MP_ROM_QSTR(MP_QSTR_AREF), MP_ROM_PTR(&pin_PA03) }, { MP_ROM_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_PA02) }, { MP_ROM_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_PB08) }, { MP_ROM_QSTR(MP_QSTR_A2), MP_ROM_PTR(&pin_PB09) },