From d2f854f89b2d4030d327d29cf8aa8df7ca6fc0ed Mon Sep 17 00:00:00 2001
From: sekigon-gonnoc <43873124+sekigon-gonnoc@users.noreply.github.com>
Date: Sun, 27 Jun 2021 18:46:12 +0900
Subject: [PATCH 01/24] PICOSDK Support
Build pico-example/cdc_msc sample on qmk build system
Add usb descriptors
Use usb config in config.h
tentative implementation
Enable debug print by cdc
Process queued transfer before new report
Fix dprint hang on Windows
resolve warnings
Add pico uart/i2c/spi sources
Trim mouse report ID before send
implement atomic_util
Add eeprom emulation
Save emulated eeprom by CLI comamnd
Delete unused file
Implement RGBLIGHT
Add pio_manager
Implement split
Chang default serial speed
Print elf size
Fix make command
Add eeprom save command to keymaps
Reset when CDC baudrate is 1200bps
Replace pro micro pin config to RP2040 pro micro
Add i2c functions
Disable LTO automatically
Add CTPIM, CONVERT_TO_PICO_MICRO option
Add MIDI functions
Call usb_task() in midi send function
Convert pico-sdk results to i2c_status
Add build target uf2 to rp2040
Remove unused parts
Fix warnings
rp2040 samples: Update readme.md
Check pico-sdk setup
Implement lazy write back from eepemu to ROM
Add PiPi Gherkin
Change DDYNAMIC_KEYMAP_EEPROM_MAX_ADDR to 4095
PiPi Gherkin: Increase DYNAMIC_KEYMAP_LAYER_COUNT to 6
Change interface number of RAW to 1 due to VIA restriction
Generate bs2_default_padded_checksummed.S at build time
Calculate eeprom emulation region
Fix warning
Add pico/usb_util.c to SRC
Fix pico's split
Add keyboard_quantizer/rp
Add pwm driver
Remove unused file
Add analog.c
Change default FLASH clock div to 4
Fix merge mistakes and issues.
rejig files
remove ugfx
more rejigging
remove qmk_main
add watchdog back
---
.gitmodules | 3 +
Makefile | 1 +
builddefs/build_keyboard.mk | 18 +
builddefs/common_features.mk | 2 +
builddefs/common_rules.mk | 10 +-
data/schemas/definitions.jsonschema | 4 +
keyboards/rp2040_example/config.h | 155 +++++++
keyboards/rp2040_example/info.json | 19 +
keyboards/rp2040_example/keymaps/adc/keymap.c | 85 ++++
.../rp2040_example/keymaps/adc/readme.md | 1 +
keyboards/rp2040_example/keymaps/adc/rules.mk | 2 +
.../rp2040_example/keymaps/default/keymap.c | 75 ++++
.../rp2040_example/keymaps/default/readme.md | 1 +
.../rp2040_example/keymaps/rgblight/config.h | 6 +
.../rp2040_example/keymaps/rgblight/keymap.c | 83 ++++
.../rp2040_example/keymaps/rgblight/readme.md | 1 +
.../rp2040_example/keymaps/rgblight/rules.mk | 2 +
keyboards/rp2040_example/readme.md | 24 +
keyboards/rp2040_example/rp2040_example.c | 24 +
keyboards/rp2040_example/rp2040_example.h | 35 ++
keyboards/rp2040_example/rules.mk | 23 +
keyboards/rp2040_split/config.h | 157 +++++++
keyboards/rp2040_split/info.json | 19 +
.../rp2040_split/keymaps/default/keymap.c | 80 ++++
.../rp2040_split/keymaps/default/readme.md | 1 +
keyboards/rp2040_split/readme.md | 26 ++
keyboards/rp2040_split/rp2040_split.c | 23 +
keyboards/rp2040_split/rp2040_split.h | 39 ++
keyboards/rp2040_split/rules.mk | 24 +
lib/pico-sdk | 1 +
platforms/pico/_print.h | 36 ++
platforms/pico/_wait.c | 89 ++++
platforms/pico/_wait.h | 24 +
platforms/pico/atomic_util.h | 35 ++
platforms/pico/boards/pico_boards.h | 7 +
platforms/pico/boards/pico_pro_micro.h | 21 +
platforms/pico/bootloader.c | 13 +
platforms/pico/convert_to_pico_micro.mk | 7 +
platforms/pico/drivers/analog.c | 23 +
platforms/pico/drivers/analog.h | 19 +
platforms/pico/drivers/i2c_master.c | 100 +++++
platforms/pico/drivers/i2c_master.h | 53 +++
platforms/pico/drivers/serial.c | 425 ++++++++++++++++++
platforms/pico/drivers/serial_usart.c | 237 ++++++++++
platforms/pico/drivers/uart.h | 15 +
platforms/pico/drivers/uart_rx.pio.h | 120 +++++
platforms/pico/drivers/uart_tx.pio.h | 73 +++
platforms/pico/drivers/ws2812.c | 51 +++
platforms/pico/drivers/ws2812.pio.h | 114 +++++
platforms/pico/eeprom.c | 272 +++++++++++
platforms/pico/gpio.h | 34 ++
platforms/pico/pin_defs.h | 17 +
platforms/pico/platform.c | 14 +
platforms/pico/platform.mk | 405 +++++++++++++++++
platforms/pico/platform_deps.h | 18 +
platforms/pico/print.c | 6 +
platforms/pico/suspend.c | 145 ++++++
platforms/pico/timer.c | 67 +++
quantum/audio/driver_pico_pwm.h | 2 +
quantum/audio/driver_pico_pwm_hardware.c | 108 +++++
quantum/dynamic_keymap.c | 2 +
quantum/split_common/split_util.c | 41 +-
tmk_core/protocol.mk | 10 +-
.../midi/bytequeue/interrupt_setting.c | 12 +
tmk_core/protocol/pico.mk | 19 +
.../pico/bs2_default_padded_checksummed.S | 23 +
tmk_core/protocol/pico/iusb.c | 91 ++++
tmk_core/protocol/pico/iusb.h | 12 +
.../pico/lufa_utils/LUFA/Drivers/USB/USB.h | 42 ++
tmk_core/protocol/pico/msc_disk.c | 259 +++++++++++
tmk_core/protocol/pico/pico.c | 282 ++++++++++++
tmk_core/protocol/pico/pico/config_autogen.h | 11 +
tmk_core/protocol/pico/pico/version.h | 19 +
tmk_core/protocol/pico/pico_cdc.h | 9 +
tmk_core/protocol/pico/pico_eeprom.h | 7 +
tmk_core/protocol/pico/pio_manager.c | 32 ++
tmk_core/protocol/pico/pio_manager.h | 8 +
tmk_core/protocol/pico/tusb_config.h | 122 +++++
tmk_core/protocol/pico/usb_descriptors.c | 227 ++++++++++
tmk_core/protocol/pico/usb_descriptors.h | 58 +++
tmk_core/protocol/pico/usb_util.c | 12 +
tmk_core/protocol/usb_descriptor.h | 2 +
82 files changed, 4785 insertions(+), 9 deletions(-)
create mode 100644 keyboards/rp2040_example/config.h
create mode 100644 keyboards/rp2040_example/info.json
create mode 100644 keyboards/rp2040_example/keymaps/adc/keymap.c
create mode 100644 keyboards/rp2040_example/keymaps/adc/readme.md
create mode 100644 keyboards/rp2040_example/keymaps/adc/rules.mk
create mode 100644 keyboards/rp2040_example/keymaps/default/keymap.c
create mode 100644 keyboards/rp2040_example/keymaps/default/readme.md
create mode 100644 keyboards/rp2040_example/keymaps/rgblight/config.h
create mode 100644 keyboards/rp2040_example/keymaps/rgblight/keymap.c
create mode 100644 keyboards/rp2040_example/keymaps/rgblight/readme.md
create mode 100644 keyboards/rp2040_example/keymaps/rgblight/rules.mk
create mode 100644 keyboards/rp2040_example/readme.md
create mode 100644 keyboards/rp2040_example/rp2040_example.c
create mode 100644 keyboards/rp2040_example/rp2040_example.h
create mode 100644 keyboards/rp2040_example/rules.mk
create mode 100644 keyboards/rp2040_split/config.h
create mode 100644 keyboards/rp2040_split/info.json
create mode 100644 keyboards/rp2040_split/keymaps/default/keymap.c
create mode 100644 keyboards/rp2040_split/keymaps/default/readme.md
create mode 100644 keyboards/rp2040_split/readme.md
create mode 100644 keyboards/rp2040_split/rp2040_split.c
create mode 100644 keyboards/rp2040_split/rp2040_split.h
create mode 100644 keyboards/rp2040_split/rules.mk
create mode 160000 lib/pico-sdk
create mode 100644 platforms/pico/_print.h
create mode 100644 platforms/pico/_wait.c
create mode 100644 platforms/pico/_wait.h
create mode 100644 platforms/pico/atomic_util.h
create mode 100644 platforms/pico/boards/pico_boards.h
create mode 100644 platforms/pico/boards/pico_pro_micro.h
create mode 100644 platforms/pico/bootloader.c
create mode 100644 platforms/pico/convert_to_pico_micro.mk
create mode 100644 platforms/pico/drivers/analog.c
create mode 100644 platforms/pico/drivers/analog.h
create mode 100644 platforms/pico/drivers/i2c_master.c
create mode 100644 platforms/pico/drivers/i2c_master.h
create mode 100644 platforms/pico/drivers/serial.c
create mode 100644 platforms/pico/drivers/serial_usart.c
create mode 100644 platforms/pico/drivers/uart.h
create mode 100644 platforms/pico/drivers/uart_rx.pio.h
create mode 100644 platforms/pico/drivers/uart_tx.pio.h
create mode 100644 platforms/pico/drivers/ws2812.c
create mode 100644 platforms/pico/drivers/ws2812.pio.h
create mode 100644 platforms/pico/eeprom.c
create mode 100644 platforms/pico/gpio.h
create mode 100644 platforms/pico/pin_defs.h
create mode 100644 platforms/pico/platform.c
create mode 100644 platforms/pico/platform.mk
create mode 100644 platforms/pico/platform_deps.h
create mode 100644 platforms/pico/print.c
create mode 100644 platforms/pico/suspend.c
create mode 100644 platforms/pico/timer.c
create mode 100644 quantum/audio/driver_pico_pwm.h
create mode 100644 quantum/audio/driver_pico_pwm_hardware.c
create mode 100644 tmk_core/protocol/pico.mk
create mode 100644 tmk_core/protocol/pico/bs2_default_padded_checksummed.S
create mode 100644 tmk_core/protocol/pico/iusb.c
create mode 100644 tmk_core/protocol/pico/iusb.h
create mode 100644 tmk_core/protocol/pico/lufa_utils/LUFA/Drivers/USB/USB.h
create mode 100644 tmk_core/protocol/pico/msc_disk.c
create mode 100644 tmk_core/protocol/pico/pico.c
create mode 100644 tmk_core/protocol/pico/pico/config_autogen.h
create mode 100644 tmk_core/protocol/pico/pico/version.h
create mode 100644 tmk_core/protocol/pico/pico_cdc.h
create mode 100644 tmk_core/protocol/pico/pico_eeprom.h
create mode 100644 tmk_core/protocol/pico/pio_manager.c
create mode 100644 tmk_core/protocol/pico/pio_manager.h
create mode 100644 tmk_core/protocol/pico/tusb_config.h
create mode 100644 tmk_core/protocol/pico/usb_descriptors.c
create mode 100644 tmk_core/protocol/pico/usb_descriptors.h
create mode 100644 tmk_core/protocol/pico/usb_util.c
diff --git a/.gitmodules b/.gitmodules
index 681693a5a4..7bbb7910a1 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -18,3 +18,6 @@
[submodule "lib/printf"]
path = lib/printf
url = https://github.com/qmk/printf
+[submodule "lib/pico-sdk"]
+ path = lib/pico-sdk
+ url = https://github.com/raspberrypi/pico-sdk
diff --git a/Makefile b/Makefile
index 4c2e6a04dc..fc6d016448 100644
--- a/Makefile
+++ b/Makefile
@@ -401,6 +401,7 @@ ifndef SKIP_GIT
if [ ! -e lib/lufa ]; then git submodule sync lib/lufa && git submodule update --depth 50 --init lib/lufa; fi
if [ ! -e lib/vusb ]; then git submodule sync lib/vusb && git submodule update --depth 50 --init lib/vusb; fi
if [ ! -e lib/printf ]; then git submodule sync lib/printf && git submodule update --depth 50 --init lib/printf; fi
+ if [ ! -e lib/pico-sdk ]; then git submodule sync lib/pico-sdk && git submodule update --depth 50 --init lib/pico-sdk; fi
git submodule status --recursive 2>/dev/null | \
while IFS= read -r x; do \
case "$$x" in \
diff --git a/builddefs/build_keyboard.mk b/builddefs/build_keyboard.mk
index 50956c9780..588c070a08 100644
--- a/builddefs/build_keyboard.mk
+++ b/builddefs/build_keyboard.mk
@@ -177,6 +177,18 @@ ifeq ($(strip $(CONVERT_TO_PROTON_C)), yes)
include platforms/chibios/boards/QMK_PROTON_C/convert_to_proton_c.mk
endif
+ifeq ($(strip $(CTPIM)), yes)
+ CONVERT_TO_PICO_MICRO=yes
+endif
+
+ifeq ($(strip $(CONVERT_TO_PICO_MICRO)), yes)
+ include platforms/pico/convert_to_pico_micro.mk
+endif
+
+ifneq ($(FORCE_LAYOUT),)
+ TARGET := $(TARGET)_$(FORCE_LAYOUT)
+endif
+
include $(BUILDDEFS_PATH)/mcu_selection.mk
# Find all the C source files to be compiled in subfolders.
@@ -261,6 +273,12 @@ ifdef MCU_FAMILY
PLATFORM_KEY=chibios
FIRMWARE_FORMAT?=bin
OPT_DEFS += -DMCU_$(MCU_FAMILY)
+ ifeq ($(MCU_FAMILY),PICO)
+ $(info "PLATFORM RP2040")
+ PLATFORM=PICO_SDK
+ PLATFORM_KEY=pico
+ FIRMWARE_FORMAT=elf
+ endif
else ifdef ARM_ATSAM
PLATFORM=ARM_ATSAM
PLATFORM_KEY=arm_atsam
diff --git a/builddefs/common_features.mk b/builddefs/common_features.mk
index 4819f66787..661ec2c8b4 100644
--- a/builddefs/common_features.mk
+++ b/builddefs/common_features.mk
@@ -207,6 +207,8 @@ else
COMMON_VPATH += $(DRIVER_PATH)/eeprom
SRC += eeprom_driver.c eeprom_transient.c
endif
+ else ifeq ($(PLATFORM),PICO_SDK)
+ SRC += $(PLATFORM_COMMON_DIR)/eeprom.c
else ifeq ($(PLATFORM),ARM_ATSAM)
# arm_atsam EEPROM
OPT_DEFS += -DEEPROM_SAMD
diff --git a/builddefs/common_rules.mk b/builddefs/common_rules.mk
index 6dfcf2b7f7..858adc5ae9 100644
--- a/builddefs/common_rules.mk
+++ b/builddefs/common_rules.mk
@@ -53,7 +53,7 @@ OPT ?= s
# gnu89 = c89 plus GCC extensions
# c99 = ISO C99 standard (not yet fully implemented)
# gnu99 = c99 plus GCC extensions
-CSTANDARD = -std=gnu99
+CSTANDARD = -std=gnu11
# Place -D or -U options here for C sources
@@ -86,8 +86,12 @@ ifeq ($(strip $(LTO_ENABLE)), yes)
$(info Enabling LTO on ChibiOS-targeting boards is known to have a high likelihood of failure.)
$(info If unsure, set LTO_ENABLE = no.)
endif
- CDEFS += -flto
- CDEFS += -DLTO_ENABLE
+ ifeq ($(PLATFORM),PICO_SDK)
+ $(info LTO is not available for this platform. Disabled automatically.)
+ else
+ CDEFS += -flto
+ CDEFS += -DLTO_ENABLE
+ endif
endif
DEBUG_ENABLE ?= yes
diff --git a/data/schemas/definitions.jsonschema b/data/schemas/definitions.jsonschema
index 46aba52cbd..83cf64f344 100644
--- a/data/schemas/definitions.jsonschema
+++ b/data/schemas/definitions.jsonschema
@@ -89,6 +89,10 @@
"type": "string",
"pattern": "^LINE_PIN\\d{1,2}$"
},
+ {
+ "type": "string",
+ "pattern": "^\\d{1,2}$"
+ },
{
"type": "number",
"multipleOf": 1
diff --git a/keyboards/rp2040_example/config.h b/keyboards/rp2040_example/config.h
new file mode 100644
index 0000000000..d6141803c2
--- /dev/null
+++ b/keyboards/rp2040_example/config.h
@@ -0,0 +1,155 @@
+/*
+Copyright 2021 sekigon-gonnoc
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program. If not, see .
+*/
+
+#pragma once
+
+#include "config_common.h"
+
+/* USB Device descriptor parameter */
+#define VENDOR_ID 0xFEED
+#define PRODUCT_ID 0x0000
+#define DEVICE_VER 0x0001
+#define MANUFACTURER sekigon-gonnoc
+#define PRODUCT rp2040_example
+
+/* key matrix size */
+#define MATRIX_ROWS 2
+#define MATRIX_COLS 3
+
+#define DEBUG_MATRIX_SCAN_RATE
+#define DEBUG_ACTION
+
+/*
+ * Keyboard Matrix Assignments
+ *
+ * Change this to how you wired your keyboard
+ * COLS: AVR pins used for columns, left to right
+ * ROWS: AVR pins used for rows, top to bottom
+ * DIODE_DIRECTION: COL2ROW = COL = Anode (+), ROW = Cathode (-, marked on diode)
+ * ROW2COL = ROW = Anode (+), COL = Cathode (-, marked on diode)
+ *
+ */
+#define MATRIX_ROW_PINS { 0, 1 }
+#define MATRIX_COL_PINS { 2, 3, 4 }
+#define UNUSED_PINS
+
+/* COL2ROW, ROW2COL */
+#define DIODE_DIRECTION COL2ROW
+
+/*
+ * Split Keyboard specific options, make sure you have 'SPLIT_KEYBOARD = yes' in your rules.mk, and define SOFT_SERIAL_PIN.
+ */
+#define SOFT_SERIAL_PIN D0 // or D1, D2, D3, E6
+
+//#define LED_NUM_LOCK_PIN B0
+//#define LED_CAPS_LOCK_PIN B1
+//#define LED_SCROLL_LOCK_PIN B2
+//#define LED_COMPOSE_PIN B3
+//#define LED_KANA_PIN B4
+
+//#define BACKLIGHT_PIN B7
+//#define BACKLIGHT_LEVELS 3
+//#define BACKLIGHT_BREATHING
+
+//#define RGB_DI_PIN E2
+//#ifdef RGB_DI_PIN
+//# define RGBLED_NUM 16
+//# define RGBLIGHT_HUE_STEP 8
+//# define RGBLIGHT_SAT_STEP 8
+//# define RGBLIGHT_VAL_STEP 8
+//# define RGBLIGHT_LIMIT_VAL 255 /* The maximum brightness level */
+//# define RGBLIGHT_SLEEP /* If defined, the RGB lighting will be switched off when the host goes to sleep */
+/*== all animations enable ==*/
+//# define RGBLIGHT_ANIMATIONS
+/*== or choose animations ==*/
+//# define RGBLIGHT_EFFECT_BREATHING
+//# define RGBLIGHT_EFFECT_RAINBOW_MOOD
+//# define RGBLIGHT_EFFECT_RAINBOW_SWIRL
+//# define RGBLIGHT_EFFECT_SNAKE
+//# define RGBLIGHT_EFFECT_KNIGHT
+//# define RGBLIGHT_EFFECT_CHRISTMAS
+//# define RGBLIGHT_EFFECT_STATIC_GRADIENT
+//# define RGBLIGHT_EFFECT_RGB_TEST
+//# define RGBLIGHT_EFFECT_ALTERNATING
+/*== customize breathing effect ==*/
+/*==== (DEFAULT) use fixed table instead of exp() and sin() ====*/
+//# define RGBLIGHT_BREATHE_TABLE_SIZE 256 // 256(default) or 128 or 64
+/*==== use exp() and sin() ====*/
+//# define RGBLIGHT_EFFECT_BREATHE_CENTER 1.85 // 1 to 2.7
+//# define RGBLIGHT_EFFECT_BREATHE_MAX 255 // 0 to 255
+//#endif
+
+/* Debounce reduces chatter (unintended double-presses) - set 0 if debouncing is not needed */
+#define DEBOUNCE 5
+
+/* define if matrix has ghost (lacks anti-ghosting diodes) */
+//#define MATRIX_HAS_GHOST
+
+/* Mechanical locking support. Use KC_LCAP, KC_LNUM or KC_LSCR instead in keymap */
+#define LOCKING_SUPPORT_ENABLE
+/* Locking resynchronize hack */
+#define LOCKING_RESYNC_ENABLE
+
+/* If defined, GRAVE_ESC will always act as ESC when CTRL is held.
+ * This is useful for the Windows task manager shortcut (ctrl+shift+esc).
+ */
+//#define GRAVE_ESC_CTRL_OVERRIDE
+
+/*
+ * Force NKRO
+ *
+ * Force NKRO (nKey Rollover) to be enabled by default, regardless of the saved
+ * state in the bootmagic EEPROM settings. (Note that NKRO must be enabled in the
+ * makefile for this to work.)
+ *
+ * If forced on, NKRO can be disabled via magic key (default = LShift+RShift+N)
+ * until the next keyboard reset.
+ *
+ * NKRO may prevent your keystrokes from being detected in the BIOS, but it is
+ * fully operational during normal computer usage.
+ *
+ * For a less heavy-handed approach, enable NKRO via magic key (LShift+RShift+N)
+ * or via bootmagic (hold SPACE+N while plugging in the keyboard). Once set by
+ * bootmagic, NKRO mode will always be enabled until it is toggled again during a
+ * power-up.
+ *
+ */
+//#define FORCE_NKRO
+
+/*
+ * Feature disable options
+ * These options are also useful to firmware size reduction.
+ */
+
+/* disable debug print */
+//#define NO_DEBUG
+
+/* disable print */
+//#define NO_PRINT
+
+/* disable action features */
+//#define NO_ACTION_LAYER
+//#define NO_ACTION_TAPPING
+//#define NO_ACTION_ONESHOT
+
+/* disable these deprecated features by default */
+#define NO_ACTION_MACRO
+#define NO_ACTION_FUNCTION
+
+/* Bootmagic Lite key configuration */
+//#define BOOTMAGIC_LITE_ROW 0
+//#define BOOTMAGIC_LITE_COLUMN 0
diff --git a/keyboards/rp2040_example/info.json b/keyboards/rp2040_example/info.json
new file mode 100644
index 0000000000..681b326dfc
--- /dev/null
+++ b/keyboards/rp2040_example/info.json
@@ -0,0 +1,19 @@
+{
+ "keyboard_name": "rp2040_example",
+ "url": "",
+ "maintainer": "sekigon-gonnoc",
+ "width": 3,
+ "height": 2,
+ "layouts": {
+ "LAYOUT": {
+ "layout": [
+ {"label": "k00", "x": 0, "y": 0},
+ {"label": "k01", "x": 1, "y": 0},
+ {"label": "k02", "x": 2, "y": 0},
+
+ {"label": "k10", "x": 0, "y": 1, "w": 1.5},
+ {"label": "k12", "x": 1.5, "y": 1, "w": 1.5}
+ ]
+ }
+ }
+}
diff --git a/keyboards/rp2040_example/keymaps/adc/keymap.c b/keyboards/rp2040_example/keymaps/adc/keymap.c
new file mode 100644
index 0000000000..2ef00700fd
--- /dev/null
+++ b/keyboards/rp2040_example/keymaps/adc/keymap.c
@@ -0,0 +1,85 @@
+/* Copyright 2021 sekigon-gonnoc
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+#include QMK_KEYBOARD_H
+#include "pico_eeprom.h"
+#include "analog.h"
+
+// Defines names for use in layer keycodes and the keymap
+enum layer_names {
+ _BASE,
+ _FN
+};
+
+// Defines the keycodes used by our macros in process_record_user
+enum custom_keycodes {
+ QMKBEST = SAFE_RANGE,
+ QMKURL
+};
+
+const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
+ /* Base */
+ [_BASE] = LAYOUT(
+ KC_A, KC_1, MO(_FN),
+ KC_TAB, KC_SPC
+ ),
+ [_FN] = LAYOUT(
+ QMKBEST, QMKURL, _______,
+ RESET, XXXXXXX
+ )
+};
+
+bool process_record_user(uint16_t keycode, keyrecord_t *record) {
+ switch (keycode) {
+ case QMKBEST:
+ if (record->event.pressed) {
+ // when keycode QMKBEST is pressed
+ SEND_STRING("QMK is the best thing ever!");
+ } else {
+ // when keycode QMKBEST is released
+ }
+ break;
+ case QMKURL:
+ if (record->event.pressed) {
+ // when keycode QMKURL is pressed
+ SEND_STRING("https://qmk.fm/\n");
+ } else {
+ // when keycode QMKURL is released
+ }
+ break;
+
+ case KC_FN0:
+ if (record->event.pressed) {
+ printf("save keymap to eeprom\n");
+ pico_eepemu_flash_dynamic_keymap();
+ printf("complete\n");
+ printf("save eeconfig to eeprom\n");
+ pico_eepemu_flash_eeconfig();
+ printf("complete\n");
+ }
+ return false;
+ break;
+ }
+ return true;
+}
+
+void matrix_scan_user(void) {
+ static int cnt = 0;
+ if (++cnt == 1000) {
+ cnt = 0;
+ int16_t ad = analogReadPin(26);
+ printf("ADC:%d\n", ad);
+ }
+}
diff --git a/keyboards/rp2040_example/keymaps/adc/readme.md b/keyboards/rp2040_example/keymaps/adc/readme.md
new file mode 100644
index 0000000000..7f32c76f01
--- /dev/null
+++ b/keyboards/rp2040_example/keymaps/adc/readme.md
@@ -0,0 +1 @@
+# The default keymap for rp2040_example
diff --git a/keyboards/rp2040_example/keymaps/adc/rules.mk b/keyboards/rp2040_example/keymaps/adc/rules.mk
new file mode 100644
index 0000000000..9ab0f66996
--- /dev/null
+++ b/keyboards/rp2040_example/keymaps/adc/rules.mk
@@ -0,0 +1,2 @@
+
+SRC += analog.c
diff --git a/keyboards/rp2040_example/keymaps/default/keymap.c b/keyboards/rp2040_example/keymaps/default/keymap.c
new file mode 100644
index 0000000000..3cd7c597f6
--- /dev/null
+++ b/keyboards/rp2040_example/keymaps/default/keymap.c
@@ -0,0 +1,75 @@
+/* Copyright 2021 sekigon-gonnoc
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+#include QMK_KEYBOARD_H
+#include "pico_eeprom.h"
+
+// Defines names for use in layer keycodes and the keymap
+enum layer_names {
+ _BASE,
+ _FN
+};
+
+// Defines the keycodes used by our macros in process_record_user
+enum custom_keycodes {
+ QMKBEST = SAFE_RANGE,
+ QMKURL
+};
+
+const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
+ /* Base */
+ [_BASE] = LAYOUT(
+ KC_A, KC_1, MO(_FN),
+ KC_TAB, KC_SPC
+ ),
+ [_FN] = LAYOUT(
+ QMKBEST, QMKURL, _______,
+ RESET, XXXXXXX
+ )
+};
+
+bool process_record_user(uint16_t keycode, keyrecord_t *record) {
+ switch (keycode) {
+ case QMKBEST:
+ if (record->event.pressed) {
+ // when keycode QMKBEST is pressed
+ SEND_STRING("QMK is the best thing ever!");
+ } else {
+ // when keycode QMKBEST is released
+ }
+ break;
+ case QMKURL:
+ if (record->event.pressed) {
+ // when keycode QMKURL is pressed
+ SEND_STRING("https://qmk.fm/\n");
+ } else {
+ // when keycode QMKURL is released
+ }
+ break;
+
+ case KC_FN0:
+ if (record->event.pressed) {
+ printf("save keymap to eeprom\n");
+ pico_eepemu_flash_dynamic_keymap();
+ printf("complete\n");
+ printf("save eeconfig to eeprom\n");
+ pico_eepemu_flash_eeconfig();
+ printf("complete\n");
+ }
+ return false;
+ break;
+ }
+ return true;
+}
diff --git a/keyboards/rp2040_example/keymaps/default/readme.md b/keyboards/rp2040_example/keymaps/default/readme.md
new file mode 100644
index 0000000000..7f32c76f01
--- /dev/null
+++ b/keyboards/rp2040_example/keymaps/default/readme.md
@@ -0,0 +1 @@
+# The default keymap for rp2040_example
diff --git a/keyboards/rp2040_example/keymaps/rgblight/config.h b/keyboards/rp2040_example/keymaps/rgblight/config.h
new file mode 100644
index 0000000000..af26ccf9a3
--- /dev/null
+++ b/keyboards/rp2040_example/keymaps/rgblight/config.h
@@ -0,0 +1,6 @@
+
+#pragma once
+
+#define RGB_DI_PIN 5
+#define RGBLED_NUM 1
+#define RGBLIGHT_ANIMATIONS
diff --git a/keyboards/rp2040_example/keymaps/rgblight/keymap.c b/keyboards/rp2040_example/keymaps/rgblight/keymap.c
new file mode 100644
index 0000000000..a4479f7a38
--- /dev/null
+++ b/keyboards/rp2040_example/keymaps/rgblight/keymap.c
@@ -0,0 +1,83 @@
+/* Copyright 2021 sekigon-gonnoc
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+#include QMK_KEYBOARD_H
+#include "pico_eeprom.h"
+
+// Defines names for use in layer keycodes and the keymap
+enum layer_names {
+ _BASE,
+ _FN
+};
+
+// Defines the keycodes used by our macros in process_record_user
+enum custom_keycodes {
+ QMKBEST = SAFE_RANGE,
+ QMKURL
+};
+
+const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
+ /* Base */
+ [_BASE] = LAYOUT(
+ KC_A, KC_1, MO(_FN),
+ KC_TAB, KC_SPC
+ ),
+ [_FN] = LAYOUT(
+ QMKBEST, QMKURL, _______,
+ RESET, XXXXXXX
+ )
+};
+
+bool process_record_user(uint16_t keycode, keyrecord_t *record) {
+ switch (keycode) {
+ case QMKBEST:
+ if (record->event.pressed) {
+ // when keycode QMKBEST is pressed
+ SEND_STRING("QMK is the best thing ever!");
+ } else {
+ // when keycode QMKBEST is released
+ }
+ break;
+ case QMKURL:
+ if (record->event.pressed) {
+ // when keycode QMKURL is pressed
+ SEND_STRING("https://qmk.fm/\n");
+ } else {
+ // when keycode QMKURL is released
+ }
+ break;
+
+ case KC_FN0:
+ if (record->event.pressed) {
+ printf("save keymap to eeprom\n");
+ pico_eepemu_flash_dynamic_keymap();
+ printf("complete\n");
+ printf("save eeconfig to eeprom\n");
+ pico_eepemu_flash_eeconfig();
+ printf("complete\n");
+ }
+ return false;
+ break;
+ }
+ return true;
+}
+
+#include "rgblight.h"
+
+void keyboard_post_init_user(void) {
+ rgblight_enable();
+ rgblight_mode_noeeprom(35);
+}
+
diff --git a/keyboards/rp2040_example/keymaps/rgblight/readme.md b/keyboards/rp2040_example/keymaps/rgblight/readme.md
new file mode 100644
index 0000000000..7f32c76f01
--- /dev/null
+++ b/keyboards/rp2040_example/keymaps/rgblight/readme.md
@@ -0,0 +1 @@
+# The default keymap for rp2040_example
diff --git a/keyboards/rp2040_example/keymaps/rgblight/rules.mk b/keyboards/rp2040_example/keymaps/rgblight/rules.mk
new file mode 100644
index 0000000000..74dc0328d5
--- /dev/null
+++ b/keyboards/rp2040_example/keymaps/rgblight/rules.mk
@@ -0,0 +1,2 @@
+
+RGBLIGHT_ENABLE = yes
diff --git a/keyboards/rp2040_example/readme.md b/keyboards/rp2040_example/readme.md
new file mode 100644
index 0000000000..3b26c5235d
--- /dev/null
+++ b/keyboards/rp2040_example/readme.md
@@ -0,0 +1,24 @@
+# rp2040_example
+
+* Sample implementation for RP2040.
+
+* Keyboard Maintainer: [sekigon-gonnoc](https://github.com/sekigon-gonnoc)
+
+Make example for this keyboard (after setting up your build environment):
+
+ make rp2040_example:default
+
+Flashing example for this keyboard by `picotool`:
+
+ make rp2040_example:default:flash
+
+Convert firmware into uf2 format:
+
+ make rp2040_example:default:uf2
+
+To replace Pro Micro to Pico Micro, use `CTPIM=yes` (`CONVERT_TO_PICO_MICRO=yes`):
+
+ make ::