Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RIOT POC Milestone 2 #15464

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 3 additions & 10 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,9 @@ quantum/version.h
*.uf2

# Old-style QMK Makefiles
/keyboards/*/Makefile
/keyboards/*/*/Makefile
/keyboards/*/*/*/Makefile
/keyboards/*/*/*/*/Makefile
/keyboards/*/*/*/*/*/Makefile
/keyboards/*/keymaps/Makefile
/keyboards/*/*/keymaps/Makefile
/keyboards/*/*/*/keymaps/Makefile
/keyboards/*/*/*/*/keymaps/Makefile
/keyboards/*/*/*/*/*/keymaps/Makefile
/keyboards/**/Makefile
# ...But allow RIOT board files
!/keyboards/**/boards/*/Makefile

# Eclipse/PyCharm/Other IDE Settings
*.iml
Expand Down
4 changes: 4 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,7 @@
[submodule "lib/printf"]
path = lib/printf
url = https://github.com/qmk/printf
[submodule "lib/riot"]
path = lib/riot
url = https://github.com/qmk/RIOT
branch = extra_usb
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,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/riot ]; then git submodule sync lib/riot && git submodule update --depth 50 --init lib/riot; fi
git submodule status --recursive 2>/dev/null | \
while IFS= read -r x; do \
case "$$x" in \
Expand Down
7 changes: 6 additions & 1 deletion build_keyboard.mk
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,12 @@ endif
# Determine and set parameters based on the keyboard's processor family.
# We can assume a ChibiOS target When MCU_FAMILY is defined since it's
# not used for LUFA
ifdef MCU_FAMILY
ifdef PROTOCOL_RIOT
PLATFORM=RIOT
PLATFORM_KEY=riot
FIRMWARE_FORMAT?=bin
OPT_DEFS += -DMCU_$(MCU_ORIG)
else ifdef MCU_FAMILY
PLATFORM=CHIBIOS
PLATFORM_KEY=chibios
FIRMWARE_FORMAT?=bin
Expand Down
12 changes: 12 additions & 0 deletions builddefs/bootloader.mk
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,18 @@
# BOOTLOADER_SIZE can still be defined manually, but it's recommended
# you add any possible configuration to this list

ifeq ($(strip $(BOOTLOADER)), sam-ba)
OPT_DEFS += -DBOOTLOADER_SAM_BA
endif

ifeq ($(strip $(BOOTLOADER)), md-boot)
OPT_DEFS += -DBOOTLOADER_MD_BOOT
endif

ifeq ($(strip $(BOOTLOADER)), adafruit-nrfutil)
OPT_DEFS += -DBOOTLOADER_ADA_NRF
endif

ifeq ($(strip $(BOOTLOADER)), atmel-dfu)
OPT_DEFS += -DBOOTLOADER_ATMEL_DFU
OPT_DEFS += -DBOOTLOADER_DFU
Expand Down
56 changes: 56 additions & 0 deletions builddefs/mcu_selection.mk
Original file line number Diff line number Diff line change
@@ -1,5 +1,61 @@
MCU_ORIG := $(MCU)

ifneq ($(findstring SAMD21, $(MCU)),)
PROTOCOL_RIOT = yes

# Cortex version
MCU = cortex-m0plus

# ARM version, CORTEX-M0/M1 are 6, CORTEX-M3/M4/M7 are 7
ARMV = 6

# Mapped to riots BOARD arguement
BOARD ?= feather-m0

# TODO: better way to detect PA enum value existance
OPT_DEFS += -DHAS_PORT_PA -DHAS_PORT_PB

USE_FPU ?= no

ROM_OFFSET=0x2000

# force off for now
EEPROM_DRIVER = transient
endif

ifneq ($(findstring SAMD51, $(MCU)),)
PROTOCOL_RIOT = yes

# Cortex version
MCU = cortex-m4

# ARM version, CORTEX-M0/M1 are 6, CORTEX-M3/M4/M7 are 7
ARMV = 7

# Mapped to riots BOARD arguement
BOARD ?= feather-m4

# TODO: better way to detect PA enum value existance
OPT_DEFS += -DHAS_PORT_PA -DHAS_PORT_PB

USE_FPU ?= yes

ROM_OFFSET=0x4000

# force off for now
EEPROM_DRIVER = transient
endif

ifneq ($(findstring nRF52840, $(MCU)),)
PROTOCOL_RIOT = yes

# Mapped to riots BOARD arguement
BOARD ?= adafruit-itsybitsy-nrf52

# force off for now
EEPROM_DRIVER = transient
endif

ifneq ($(findstring MKL26Z64, $(MCU)),)
# Cortex version
MCU = cortex-m0plus
Expand Down
5 changes: 5 additions & 0 deletions common_features.mk
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,11 @@ else
# This will effectively work the same as "transient" if not supported by the chip
SRC += $(PLATFORM_COMMON_DIR)/eeprom_teensy.c
endif
else ifeq ($(PLATFORM),RIOT)
OPT_DEFS += -DEEPROM_DRIVER
COMMON_VPATH += $(DRIVER_PATH)/eeprom
SRC += eeprom_driver.c
SRC += $(PLATFORM_COMMON_DIR)/eeprom.c
else ifeq ($(PLATFORM),ARM_ATSAM)
SRC += $(PLATFORM_COMMON_DIR)/eeprom.c
else ifeq ($(PLATFORM),TEST)
Expand Down
4 changes: 2 additions & 2 deletions data/schemas/keyboard.jsonschema
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
},
"processor": {
"type": "string",
"enum": ["cortex-m0", "cortex-m0plus", "cortex-m3", "cortex-m4", "MKL26Z64", "MK20DX128", "MK20DX256", "MK66FX1M0", "STM32F042", "STM32F072", "STM32F103", "STM32F303", "STM32F401", "STM32F405", "STM32F407", "STM32F411", "STM32F446", "STM32G431", "STM32G474", "STM32L412", "STM32L422", "STM32L433", "STM32L443", "GD32VF103", "WB32F3G71", "atmega16u2", "atmega32u2", "atmega16u4", "atmega32u4", "at90usb162", "at90usb646", "at90usb647", "at90usb1286", "at90usb1287", "atmega32a", "atmega328p", "atmega328", "attiny85", "unknown"]
"enum": ["cortex-m0", "cortex-m0plus", "cortex-m3", "cortex-m4", "SAMD21", "SAMD51", "nRF52840", "MKL26Z64", "MK20DX128", "MK20DX256", "MK66FX1M0", "STM32F042", "STM32F072", "STM32F103", "STM32F303", "STM32F401", "STM32F405", "STM32F407", "STM32F411", "STM32F446", "STM32G431", "STM32G474", "STM32L412", "STM32L422", "STM32L433", "STM32L443", "GD32VF103", "WB32F3G71", "atmega16u2", "atmega32u2", "atmega16u4", "atmega32u4", "at90usb162", "at90usb646", "at90usb647", "at90usb1286", "at90usb1287", "atmega32a", "atmega328p", "atmega328", "attiny85", "unknown"]
},
"audio": {
"type": "object",
Expand Down Expand Up @@ -57,7 +57,7 @@
},
"bootloader": {
"type": "string",
"enum": ["atmel-dfu", "bootloadhid", "bootloadHID", "caterina", "halfkay", "kiibohd", "lufa-dfu", "lufa-ms", "micronucleus", "qmk-dfu", "qmk-hid", "stm32-dfu", "stm32duino", "gd32v-dfu", "wb32-dfu", "unknown", "usbasploader", "USBasp", "tinyuf2"],
"enum": ["sam-ba", "md-boot", "adafruit-nrfutil", "atmel-dfu", "bootloadhid", "bootloadHID", "caterina", "halfkay", "kiibohd", "lufa-dfu", "lufa-ms", "micronucleus", "qmk-dfu", "qmk-hid", "stm32-dfu", "stm32duino", "gd32v-dfu", "wb32-dfu", "unknown", "usbasploader", "USBasp", "tinyuf2"],
},
"bootloader_instructions": {
"type": "string",
Expand Down
32 changes: 32 additions & 0 deletions keyboards/handwired/onekey/adafruit_itsybitsy_m0/config.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/* Copyright 2019
*
* 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 <http://www.gnu.org/licenses/>.
*/

#pragma once

#include "config_common.h"

#define DIRECT_PINS {{ A16 }}
// #define MATRIX_COL_PINS { B0 }
// #define MATRIX_ROW_PINS { A7 }
#define UNUSED_PINS

#define BACKLIGHT_PIN A0
#define BACKLIGHT_PWM_DRIVER PWMD2
#define BACKLIGHT_PWM_CHANNEL 1

#define RGB_DI_PIN A1

#define ADC_PIN A0
5 changes: 5 additions & 0 deletions keyboards/handwired/onekey/adafruit_itsybitsy_m0/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Feather M0 onekey

Supported Hardware: [Adafruit Feather M0 Express](https://www.adafruit.com/product/3403).

To trigger keypress, short together pins ** and **.
10 changes: 10 additions & 0 deletions keyboards/handwired/onekey/adafruit_itsybitsy_m0/rules.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
MCU = SAMD21
BOOTLOADER = sam-ba

MOUSEKEY_ENABLE = no # Mouse keys(+4700)
EXTRAKEY_ENABLE = no # Audio control and System control(+450)
CONSOLE_ENABLE = no # Console for debug(+400)
COMMAND_ENABLE = no # Commands for debug and configuration
# Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE
SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend
NKRO_ENABLE = no
32 changes: 32 additions & 0 deletions keyboards/handwired/onekey/adafruit_itsybitsy_m4/config.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/* Copyright 2019
*
* 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 <http://www.gnu.org/licenses/>.
*/

#pragma once

#include "config_common.h"

#define DIRECT_PINS {{ A16 }}
// #define MATRIX_COL_PINS { B0 }
// #define MATRIX_ROW_PINS { A7 }
#define UNUSED_PINS

// #define BACKLIGHT_PIN A0
// #define BACKLIGHT_PWM_DRIVER PWMD2
// #define BACKLIGHT_PWM_CHANNEL 1

// #define RGB_DI_PIN A1

// #define ADC_PIN A0
5 changes: 5 additions & 0 deletions keyboards/handwired/onekey/adafruit_itsybitsy_m4/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Feather M4 onekey

Supported Hardware: [Adafruit Feather M4 Express](https://www.adafruit.com/product/3857).

To trigger keypress, short together pins ** and **.
10 changes: 10 additions & 0 deletions keyboards/handwired/onekey/adafruit_itsybitsy_m4/rules.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
MCU = SAMD51
BOOTLOADER = sam-ba

MOUSEKEY_ENABLE = no # Mouse keys(+4700)
EXTRAKEY_ENABLE = no # Audio control and System control(+450)
CONSOLE_ENABLE = no # Console for debug(+400)
COMMAND_ENABLE = no # Commands for debug and configuration
# Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE
SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend
NKRO_ENABLE = no
32 changes: 32 additions & 0 deletions keyboards/handwired/onekey/adafruit_itsybitsy_nrf52/config.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/* Copyright 2019
*
* 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 <http://www.gnu.org/licenses/>.
*/

#pragma once

#include "config_common.h"

#define DIRECT_PINS {{ LINE_PIN5 }}
// #define MATRIX_COL_PINS { B0 }
// #define MATRIX_ROW_PINS { A7 }
#define UNUSED_PINS

#define BACKLIGHT_PIN A0
#define BACKLIGHT_PWM_DRIVER PWMD2
#define BACKLIGHT_PWM_CHANNEL 1

#define RGB_DI_PIN A1

#define ADC_PIN A0
5 changes: 5 additions & 0 deletions keyboards/handwired/onekey/adafruit_itsybitsy_nrf52/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# ItsyBitsy nRF52840 onekey

Supported Hardware: [Adafruit ItsyBitsy nRF52840 Express](https://www.adafruit.com/product/4481).

To trigger keypress, short together pins ** and **.
12 changes: 12 additions & 0 deletions keyboards/handwired/onekey/adafruit_itsybitsy_nrf52/rules.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
MCU = nRF52840
BOOTLOADER = adafruit-nrfutil

MOUSEKEY_ENABLE = no # Mouse keys(+4700)
EXTRAKEY_ENABLE = no # Audio control and System control(+450)
CONSOLE_ENABLE = no # Console for debug(+400)
COMMAND_ENABLE = no # Commands for debug and configuration
# Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE
SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend
NKRO_ENABLE = no

PROGRAM_CMD = adafruit-nrfutil dfu genpkg --dev-type 0x0052 --sd-req 0x00B6 --application .build/handwired_onekey_adafruit_itsybitsy_nrf52_default.hex $(BUILD_DIR)/$(TARGET).zip && adafruit-nrfutil --verbose dfu serial -p /dev/ttyACM1 -b 115200 --singlebank --package=$(BUILD_DIR)/$(TARGET).zip
1 change: 1 addition & 0 deletions lib/python/qmk/cli/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
'qmk.cli.generate.keyboard_h',
'qmk.cli.generate.layouts',
'qmk.cli.generate.rgb_breathe_table',
'qmk.cli.generate.riot_header',
'qmk.cli.generate.rules_mk',
'qmk.cli.generate.version_h',
'qmk.cli.hello',
Expand Down
56 changes: 56 additions & 0 deletions lib/python/qmk/cli/generate/riot_header.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
"""Used by the make system to generate stuff from info.json
"""
from dotty_dict import dotty
from milc import cli

from qmk.decorators import automagic_keyboard
from qmk.info import info_json
from qmk.path import is_keyboard, normpath
from qmk.keyboard import keyboard_completer


@cli.argument('-o', '--output', arg_only=True, type=normpath, help='File to write to')
@cli.argument('-q', '--quiet', arg_only=True, action='store_true', help="Quiet mode, only output error messages")
@cli.argument('-kb', '--keyboard', completer=keyboard_completer, help='Keyboard to generate stuff for.')
@cli.subcommand('Used by the make system to generate riot stuff', hidden=True)
@automagic_keyboard
def generate_riot_header(cli):
"""Generates some riot stuff.
"""
# Determine our keyboard(s)
if not cli.config.generate_riot_header.keyboard:
cli.log.error('Missing parameter: --keyboard')
cli.subcommands['info'].print_help()
return False

if not is_keyboard(cli.config.generate_riot_header.keyboard):
cli.log.error('Invalid keyboard: "%s"', cli.config.generate_riot_header.keyboard)
return False

# Build the Keyboard.h file.
kb_info_json = dotty(info_json(cli.config.generate_riot_header.keyboard))

keyboard_h_lines = ['/* This file was generated by `qmk generate-riot-header`. Do not edit or copy.', ' */', '', '#pragma once']
keyboard_h_lines.append(f'#define CONFIG_USB_MANUF_STR "{kb_info_json["manufacturer"]}"')
keyboard_h_lines.append(f'#define CONFIG_USB_PRODUCT_STR "{kb_info_json["keyboard_name"]}"')
keyboard_h_lines.append(f'#define CONFIG_USB_VID {kb_info_json["usb.vid"]}')
keyboard_h_lines.append(f'#define CONFIG_USB_PID {kb_info_json["usb.pid"]}')
keyboard_h_lines.append(f'#define CONFIG_USB_BCD {kb_info_json["usb.device_ver"]}')
keyboard_h_lines.append(f'#define CONFIG_USB_MAX_POWER 500')
keyboard_h_lines.append(f'//#CONFIG_USB_SPEC_BCDVERSION_1_1')
keyboard_h_lines.append(f'//#CONFIG_USBUS_EP0_SIZE_8')

# # Show the results
keyboard_h = '\n'.join(keyboard_h_lines)

if cli.args.output:
cli.args.output.parent.mkdir(parents=True, exist_ok=True)
if cli.args.output.exists():
cli.args.output.replace(cli.args.output.parent / (cli.args.output.name + '.bak'))
cli.args.output.write_text(keyboard_h)

if not cli.args.quiet:
cli.log.info('Wrote Keyboard.h to %s.', cli.args.output)

else:
print(keyboard_h)
1 change: 1 addition & 0 deletions lib/python/qmk/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
CHIBIOS_PROCESSORS = 'cortex-m0', 'cortex-m0plus', 'cortex-m3', 'cortex-m4', 'MKL26Z64', 'MK20DX128', 'MK20DX256', 'MK66FX1M0', 'STM32F042', 'STM32F072', 'STM32F103', 'STM32F303', 'STM32F401', 'STM32F407', 'STM32F411', 'STM32F446', 'STM32G431', 'STM32G474', 'STM32L412', 'STM32L422', 'STM32L433', 'STM32L443', 'GD32VF103', 'WB32F3G71'
LUFA_PROCESSORS = 'at90usb162', 'atmega16u2', 'atmega32u2', 'atmega16u4', 'atmega32u4', 'at90usb646', 'at90usb647', 'at90usb1286', 'at90usb1287', None
VUSB_PROCESSORS = 'atmega32a', 'atmega328p', 'atmega328', 'attiny85'
RIOT_PROCESSORS = 'SAMD21', 'SAMD51', 'nRF52840'

# Common format strings
DATE_FORMAT = '%Y-%m-%d'
Expand Down
Loading