From d7173967087e022d20d1f9c812b1b668e9d3f71b Mon Sep 17 00:00:00 2001 From: Stefan Kerkmann Date: Thu, 30 Jun 2022 13:19:27 +0200 Subject: [Core] Add Raspberry Pi RP2040 support (#14877) * Disable RESET keycode because of naming conflicts * Add Pico SDK as submodule * Add RP2040 build support to QMK * Adjust USB endpoint structs for RP2040 * Add RP2040 bootloader and double-tap reset routine * Add generic and pro micro RP2040 boards * Add RP2040 onekey keyboard * Add WS2812 PIO DMA enabled driver and documentation Supports regular and open-drain output configuration. RP2040 GPIOs are sadly not 5V tolerant, so this is a bit use-less or needs extra hardware or you take the risk to fry your hardware. * Adjust SIO Driver for RP2040 * Adjust I2C Driver for RP2040 * Adjust SPI Driver for RP2040 * Add PIO serial driver and documentation * Add general RP2040 documentation * Apply suggestions from code review Co-authored-by: Nick Brassel Co-authored-by: Nick Brassel --- platforms/chibios/chibios_config.h | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'platforms/chibios/chibios_config.h') diff --git a/platforms/chibios/chibios_config.h b/platforms/chibios/chibios_config.h index a7098f2713..1571bd5cd3 100644 --- a/platforms/chibios/chibios_config.h +++ b/platforms/chibios/chibios_config.h @@ -19,6 +19,27 @@ # define SPLIT_USB_DETECT // Force this on when dedicated pin is not used #endif +#if defined(MCU_RP) +# define CPU_CLOCK RP_CORE_CLK + +# define USE_GPIOV1 +# define PAL_OUTPUT_TYPE_OPENDRAIN _Static_assert(0, "RP2040 has no Open Drain GPIO configuration, setting this is not possible"); + +# define usb_lld_endpoint_fields + +# define I2C1_SCL_PAL_MODE (PAL_MODE_ALTERNATE_I2C | PAL_RP_PAD_SLEWFAST | PAL_RP_PAD_PUE | PAL_RP_PAD_DRIVE4) +# define I2C1_SDA_PAL_MODE I2C1_SCL_PAL_MODE + +# define USE_I2CV1_CONTRIB +# if !defined(I2C1_CLOCK_SPEED) +# define I2C1_CLOCK_SPEED 400000 +# endif + +# define SPI_SCK_PAL_MODE (PAL_MODE_ALTERNATE_SPI | PAL_RP_PAD_SLEWFAST | PAL_RP_PAD_DRIVE4) +# define SPI_MOSI_PAL_MODE SPI_SCK_PAL_MODE +# define SPI_MISO_PAL_MODE SPI_SCK_PAL_MODE +#endif + // STM32 compatibility #if defined(MCU_STM32) # define CPU_CLOCK STM32_SYSCLK -- cgit v1.2.3 From ac5e6b6a3bfad12ab7d9786a18fcc90f8bf4caf7 Mon Sep 17 00:00:00 2001 From: Ryan Date: Sun, 3 Jul 2022 00:12:45 +1000 Subject: Tentative Teensy 3.5 support (#14420) * Tentative Teensy 3.5 support * Set firmware format to .hex for ARM Teensys * Got to "device descriptor failed" by comparing with Teensy 3.6 code * Drop down to 96MHz... * Bump back up to 120MHz --- platforms/chibios/chibios_config.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'platforms/chibios/chibios_config.h') diff --git a/platforms/chibios/chibios_config.h b/platforms/chibios/chibios_config.h index 1571bd5cd3..e5aa8e3d05 100644 --- a/platforms/chibios/chibios_config.h +++ b/platforms/chibios/chibios_config.h @@ -95,7 +95,7 @@ #if defined(MCU_KINETIS) # define CPU_CLOCK KINETIS_SYSCLK_FREQUENCY -# if defined(K20x) || defined(KL2x) +# if defined(K20x) || defined(K60x) || defined(KL2x) # define USE_I2CV1 # define USE_I2CV1_CONTRIB // for some reason a bunch of ChibiOS-Contrib boards only have clock_speed # define USE_GPIOV1 -- cgit v1.2.3 From 3f5dc472965e6a5b8efe60e33c7b6c2d18d92008 Mon Sep 17 00:00:00 2001 From: Stefan Kerkmann Date: Mon, 11 Jul 2022 15:17:05 +0200 Subject: [Core] Use polled waiting on ChibiOS platforms that support it (#17607) * Use polled waiting on platforms that support it Due to context switching overhead waiting a very short amount of time on a sleeping thread is often not accurate and in fact not usable for timing critical usage i.e. in a driver. Thus we use polled waiting for ranges in the us range on platforms that support it instead. The fallback is the thread sleeping mechanism. This includes: * ARM platforms with CYCCNT register (ARMv7, ARMv8) this is incremented at CPU clock frequency * GD32VF103 RISC-V port with CSR_MCYCLE register this is incremented at CPU clock frequency * RP2040 ARMv6 port which uses the integrated timer peripheral which is incremented with a fixed 1MHz frequency * Use wait_us() instead of chSysPolledDelayX ...as it is powered by busy waiting now. * Add chibios waiting methods test bench --- platforms/chibios/chibios_config.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'platforms/chibios/chibios_config.h') diff --git a/platforms/chibios/chibios_config.h b/platforms/chibios/chibios_config.h index e5aa8e3d05..c7a3a98fb0 100644 --- a/platforms/chibios/chibios_config.h +++ b/platforms/chibios/chibios_config.h @@ -21,6 +21,9 @@ #if defined(MCU_RP) # define CPU_CLOCK RP_CORE_CLK +// ChibiOS uses the RP2040 timer peripheral as its real time counter, this timer +// is monotonic and running at 1MHz. +# define REALTIME_COUNTER_CLOCK 1000000 # define USE_GPIOV1 # define PAL_OUTPUT_TYPE_OPENDRAIN _Static_assert(0, "RP2040 has no Open Drain GPIO configuration, setting this is not possible"); @@ -102,6 +105,11 @@ # endif #endif +#if defined(MCU_MIMXRT1062) +# include "clock_config.h" +# define CPU_CLOCK BOARD_BOOTCLOCKRUN_CORE_CLOCK +#endif + #if defined(HT32) # define CPU_CLOCK HT32_CK_SYS_FREQUENCY # define PAL_MODE_ALTERNATE PAL_HT32_MODE_AF @@ -109,3 +117,7 @@ # define PAL_OUTPUT_TYPE_PUSHPULL PAL_HT32_MODE_DIR # define PAL_OUTPUT_SPEED_HIGHEST 0 #endif + +#if !defined(REALTIME_COUNTER_CLOCK) +# define REALTIME_COUNTER_CLOCK CPU_CLOCK +#endif -- cgit v1.2.3 From dfff040433a2cabd4a1047bbeb9eb72b736bba2e Mon Sep 17 00:00:00 2001 From: Nick Brassel Date: Wed, 13 Jul 2022 14:42:24 +1000 Subject: Allow MCU-specific overrides for SPI flags. (#17650) --- platforms/chibios/chibios_config.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'platforms/chibios/chibios_config.h') diff --git a/platforms/chibios/chibios_config.h b/platforms/chibios/chibios_config.h index c7a3a98fb0..8dcc23727f 100644 --- a/platforms/chibios/chibios_config.h +++ b/platforms/chibios/chibios_config.h @@ -84,6 +84,8 @@ # define PAL_OUTPUT_TYPE_PUSHPULL PAL_WB32_OTYPE_PUSHPULL # define PAL_OUTPUT_SPEED_HIGHEST PAL_WB32_OSPEED_HIGH # define PAL_PUPDR_FLOATING PAL_WB32_PUPDR_FLOATING + +# define SPI_SCK_FLAGS PAL_MODE_ALTERNATE(SPI_SCK_PAL_MODE) | PAL_OUTPUT_TYPE_PUSHPULL | PAL_OUTPUT_SPEED_HIGHEST | PAL_WB32_CURRENT_LEVEL3 # endif #endif @@ -121,3 +123,16 @@ #if !defined(REALTIME_COUNTER_CLOCK) # define REALTIME_COUNTER_CLOCK CPU_CLOCK #endif + +// SPI Fallbacks +#ifndef SPI_SCK_FLAGS +# define SPI_SCK_FLAGS PAL_MODE_ALTERNATE(SPI_SCK_PAL_MODE) | PAL_OUTPUT_TYPE_PUSHPULL | PAL_OUTPUT_SPEED_HIGHEST +#endif + +#ifndef SPI_MOSI_FLAGS +# define SPI_MOSI_FLAGS PAL_MODE_ALTERNATE(SPI_MOSI_PAL_MODE) | PAL_OUTPUT_TYPE_PUSHPULL | PAL_OUTPUT_SPEED_HIGHEST +#endif + +#ifndef SPI_MISO_FLAGS +# define SPI_MISO_FLAGS PAL_MODE_ALTERNATE(SPI_MISO_PAL_MODE) | PAL_OUTPUT_TYPE_PUSHPULL | PAL_OUTPUT_SPEED_HIGHEST +#endif -- cgit v1.2.3