You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

152 lines
12 KiB

  1. # Raspberry Pi RP2040
  2. The following table shows the current driver status for peripherals on RP2040 MCUs:
  3. | System | Support |
  4. | ---------------------------------------------------------------- | ---------------------------------------------- |
  5. | [ADC driver](adc_driver.md) | :heavy_check_mark: |
  6. | [Audio](audio_driver.md#pwm-hardware) | :heavy_check_mark: |
  7. | [Backlight](feature_backlight.md) | :heavy_check_mark: |
  8. | [I2C driver](i2c_driver.md) | :heavy_check_mark: |
  9. | [SPI driver](spi_driver.md) | :heavy_check_mark: |
  10. | [WS2812 driver](ws2812_driver.md) | :heavy_check_mark: using `PIO` driver |
  11. | [External EEPROMs](eeprom_driver.md) | :heavy_check_mark: using `I2C` or `SPI` driver |
  12. | [EEPROM emulation](eeprom_driver.md#wear_leveling-configuration) | :heavy_check_mark: |
  13. | [serial driver](serial_driver.md) | :heavy_check_mark: using `SIO` or `PIO` driver |
  14. | [UART driver](uart_driver.md) | :heavy_check_mark: using `SIO` driver |
  15. ## GPIO
  16. <img alt="Raspberry Pi Pico pinout" src="https://i.imgur.com/nLaiYDE.jpg" width="48%"/>
  17. <img alt="Sparkfun RP2040 Pro Micro pinout" src="https://i.imgur.com/1TPAhrs.jpg" width="48%"/>
  18. !> The GPIO pins of the RP2040 are not 5V tolerant!
  19. ### Pin nomenclature
  20. To address individual pins on the RP2040, QMK uses the `GPx` abbreviation -- where the `x` stands for the GPIO number of the pin. This number can likely be found on the official pinout diagram of your board. Note that these GPIO numbers match the RP2040 MCU datasheet, and don't necessarily match the number you see printed on the board. For instance the Raspberry Pi Pico uses numbers from 1 to 40 for their pins, but these are not identical to the RP2040's GPIO numbers. So if you want to use the pin 11 of the Pico for your keyboard, you would refer to it as `GP8` in the config files.
  21. ### Alternate functions
  22. The RP2040 features flexible GPIO function multiplexing, this means that every pin can be connected to nearly all the internal peripherals like I2C, SPI, UART or PWM. This allows for flexible PCB designs that are much less restricted in the selection of GPIO pins. To find out which pin can use which peripheral refer to the official [Raspberry PI RP2040 datasheet](https://datasheets.raspberrypi.com/rp2040/rp2040-datasheet.pdf#page=14) section 1.4.3 GPIO functions.
  23. ## Selecting hardware peripherals and drivers
  24. QMK RP2040 support builds upon ChibiOS and thus follows their convention for activating drivers and associated hardware peripherals. These tables only give a quick overview which values have to be used, please refer to the ChibiOS specific sections on the driver pages.
  25. ### I2C Driver
  26. | RP2040 Peripheral | `mcuconf.h` values | `I2C_DRIVER` |
  27. | ----------------- | ------------------ | ------------ |
  28. | `I2C0` | `RP_I2C_USE_I2C0` | `I2CD0` |
  29. | `I2C1` | `RP_I2C_USE_I2C1` | `I2CD1` |
  30. To configure the I2C driver please read the [ChibiOS/ARM](i2c_driver.md#arm-configuration) section.
  31. ### SPI Driver
  32. | RP2040 Peripheral | `mcuconf.h` values | `SPI_DRIVER` |
  33. | ----------------- | ------------------ | ------------ |
  34. | `SPI0` | `RP_SPI_USE_SPI0` | `SPID0` |
  35. | `SPI1` | `RP_SPI_USE_SPI1` | `SPID1` |
  36. To configure the SPI driver please read the [ChibiOS/ARM](spi_driver.md#chibiosarm-configuration) section.
  37. ### UART Driver
  38. | RP2040 Peripheral | `mcuconf.h` values | `UART_DRIVER` |
  39. | ----------------- | ------------------ | ------------- |
  40. | `UART0` | `RP_SIO_USE_UART0` | `SIOD0` |
  41. | `UART1` | `RP_SIO_USE_UART1` | `SIOD1` |
  42. ## Double-tap reset boot-loader entry :id=double-tap
  43. The double-tap reset mechanism is an alternate way in QMK to enter the embedded mass storage UF2 boot-loader of the RP2040. It enables bootloader entry by a fast double-tap of the reset pin on start up, which is similar to the behavior of AVR Pro Micros. This feature activated by default for the Pro Micro RP2040 board, but has to be configured for other boards. To activate it, add the following options to your keyboards `config.h` file:
  44. ```c
  45. #define RP2040_BOOTLOADER_DOUBLE_TAP_RESET // Activates the double-tap behavior
  46. #define RP2040_BOOTLOADER_DOUBLE_TAP_RESET_TIMEOUT 200U // Timeout window in ms in which the double tap can occur.
  47. #define RP2040_BOOTLOADER_DOUBLE_TAP_RESET_LED GP17 // Specify a optional status led by GPIO number which blinks when entering the bootloader
  48. ```
  49. ## Pre-defined RP2040 boards
  50. QMK defines two boards that you can choose from to base your RP2040 powered keyboard upon. These boards provide pre-configured default pins and drivers.
  51. ### Generic Pro Micro RP2040
  52. This is the default board that is chosen, unless any other RP2040 board is selected in your keyboards `rules.mk` file. It assumes a pin layout for the I2C, SPI and Serial drivers which is identical to the Sparkfun Pro Micro RP2040, however all values can be overwritten by defining them in your keyboards `config.h` file. The [double-tap](#double-tap) reset to enter boot-loader behavior is activated by default.
  53. | Driver configuration define | Value |
  54. | -------------------------------------------------------------------------- | ------------------------------------ |
  55. | **I2C driver** | |
  56. | `I2C_DRIVER` | `I2CD1` |
  57. | `I2C1_SDA_PIN` | `GP2` |
  58. | `I2C1_SCL_PIN` | `GP3` |
  59. | **SPI driver** | |
  60. | `SPI_DRIVER` | `SPID0` |
  61. | `SPI_SCK_PIN` | `GP18` |
  62. | `SPI_MISO_PIN` | `GP20` |
  63. | `SPI_MOSI_PIN` | `GP19` |
  64. | **Serial driver** | |
  65. | `SERIAL_USART_DRIVER` ([SIO Driver](serial_driver.md#the-sio-driver) only) | `SIOD0` |
  66. | `SOFT_SERIAL_PIN` | undefined, use `SERIAL_USART_TX_PIN` |
  67. | `SERIAL_USART_TX_PIN` | `GP0` |
  68. | `SERIAL_USART_RX_PIN` | `GP1` |
  69. | **UART driver** | |
  70. | `UART_DRIVER` | `SIOD0` |
  71. | `UART_TX_PIN` | `GP0` |
  72. | `UART_RX_PIN` | `GP1` |
  73. ?> The pin-outs of Adafruit's KB2040 and Boardsource's Blok both deviate from the Sparkfun Pro Micro RP2040. Lookup the pin-out of these boards and adjust your keyboards pin definition accordingly if you want to use these boards.
  74. ### Generic RP2040 board
  75. This board can be chosen as a base for RP2040 keyboards which configure all necessary pins and drivers themselves and do not wish to leverage the configuration matching the Generic Pro Micro RP2040 board. Thus it doesn't provide any pre-configured pins or drivers. To select this board add the following line to your keyboards `rules.mk` file.
  76. ```make
  77. BOARD = GENERIC_RP_RP2040
  78. ```
  79. ## Split keyboard support
  80. Split keyboards are fully supported using the [serial driver](serial_driver.md) in both full-duplex and half-duplex configurations. Two driver subsystems are supported by the RP2040, the hardware UART based `SIO` and the Programmable IO based `PIO` driver.
  81. | Feature | [SIO Driver](serial_driver.md#the-sio-driver) | [PIO Driver](serial_driver.md#the-pio-driver) |
  82. | ----------------------------- | --------------------------------------------- | --------------------------------------------- |
  83. | Half-Duplex operation | | :heavy_check_mark: |
  84. | Full-Duplex operation | :heavy_check_mark: | :heavy_check_mark: |
  85. | `TX` and `RX` pin swapping | | :heavy_check_mark: |
  86. | Any GPIO as `TX` and `RX` pin | Only UART capable pins | :heavy_check_mark: |
  87. | Simple configuration | | :heavy_check_mark: |
  88. The `PIO` driver is much more flexible then the `SIO` driver, the only "downside" is the usage of `PIO` resources which in turn are not available for advanced user programs. Under normal circumstances, this resource allocation will be a non-issue.
  89. ## RP2040 second stage bootloader selection
  90. As the RP2040 does not have any internal flash memory it depends on an external SPI flash memory chip to store and execute instructions from. To successfully interact with a wide variety of these chips a second stage bootloader that is compatible with the chosen external flash memory has to be supplied with each firmware image. By default an `W25Q080` compatible bootloader is assumed, but others can be chosen by adding one of the defines listed in the table below to your keyboards `config.h` file.
  91. | Compatible with flash chip | Selection |
  92. | :------------------------- | ---------------------------------- |
  93. | W25Q080 | Selected by default |
  94. | AT25SF128A | `#define RP2040_FLASH_AT25SF128A` |
  95. | GD25Q64CS | `#define RP2040_FLASH_GD25Q64CS` |
  96. | W25X10CL | `#define RP2040_FLASH_W25X10CL` |
  97. | IS25LP080 | `#define RP2040_FLASH_IS25LP080` |
  98. | Generic 03H flash | `#define RP2040_FLASH_GENERIC_03H` |
  99. ## RP2040 Community Edition :id=rp2040_ce
  100. The "RP2040 Community Edition" standard is a pinout that was defined by a committee of designers on the BastardKB Discord server.
  101. These boards are designed to be a drop-in replacement for keyboards wanting an upgrade from ATmega32u4 based pro micros (eg. Elite-C).
  102. | Pinout Compatible Controllers |
  103. | -------------------------------------------------------------------------------- |
  104. | [0xB2 Splinky](https://github.com/plut0nium/0xB2/) |
  105. | [Elite-Pi](https://keeb.io/products/elite-pi-usb-c-pro-micro-replacement-rp2040) |
  106. | [Sea-Picro EXT](https://github.com/joshajohnson/sea-picro) |
  107. | [0xCB Helios](https://keeb.supply/products/0xcb-helios) |
  108. | [Frood](https://github.com/piit79/Frood) |
  109. | [Liatris](https://splitkb.com/products/liatris) |