@geastack/targets 0.1.77

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (348) hide show
  1. package/LICENSE +674 -0
  2. package/README.md +83 -0
  3. package/package.json +50 -0
  4. package/targets/cmake/geatsc-generated-archive-build.mjs +614 -0
  5. package/targets/cmake/geatsc_generated_archive.cmake +116 -0
  6. package/targets/cmake/geatsc_generated_archive_build.cmake +50 -0
  7. package/targets/esp32/app_project.cmake +33 -0
  8. package/targets/esp32/apps/app_manager.cpp +188 -0
  9. package/targets/esp32/apps/app_manager.h +10 -0
  10. package/targets/esp32/chip_bindings/README.md +58 -0
  11. package/targets/esp32/chip_bindings/audio/es8311.cpp +556 -0
  12. package/targets/esp32/chip_bindings/displays/co5300.cpp +510 -0
  13. package/targets/esp32/chip_bindings/displays/co5300.h +47 -0
  14. package/targets/esp32/chip_bindings/displays/co5300_async_stream.inc +79 -0
  15. package/targets/esp32/chip_bindings/displays/qspi_panel.h +65 -0
  16. package/targets/esp32/chip_bindings/displays/sh8601.cpp +583 -0
  17. package/targets/esp32/chip_bindings/displays/sh8601.h +36 -0
  18. package/targets/esp32/chip_bindings/gps/lc76g.cpp +296 -0
  19. package/targets/esp32/chip_bindings/gps/lc76g.h +7 -0
  20. package/targets/esp32/chip_bindings/imu/bmi270.cpp +299 -0
  21. package/targets/esp32/chip_bindings/imu/bmi270_config.inl +439 -0
  22. package/targets/esp32/chip_bindings/imu/qmi8658.cpp +213 -0
  23. package/targets/esp32/chip_bindings/power/axp2101.cpp +185 -0
  24. package/targets/esp32/chip_bindings/touch/cst9217.cpp +229 -0
  25. package/targets/esp32/chip_bindings/touch/cst9217_controller.h +78 -0
  26. package/targets/esp32/chip_bindings/touch/ft3168.cpp +340 -0
  27. package/targets/esp32/chip_bindings/touch/ft3168_controller.h +103 -0
  28. package/targets/esp32/chip_bindings/touch/ft6336.cpp +310 -0
  29. package/targets/esp32/chip_bindings/touch/ft6336_controller.h +90 -0
  30. package/targets/esp32/components/gea_framework/CMakeLists.txt +62 -0
  31. package/targets/esp32/connectivity/ble_hid.cpp +2916 -0
  32. package/targets/esp32/connectivity/ble_hid.h +8 -0
  33. package/targets/esp32/connectivity/diagnostics_transport.cpp +523 -0
  34. package/targets/esp32/connectivity/diagnostics_transport_offline.cpp +108 -0
  35. package/targets/esp32/connectivity/wifi.cpp +615 -0
  36. package/targets/esp32/connectivity/wifi_debug_offline.cpp +37 -0
  37. package/targets/esp32/connectivity/wifi_task_stack.h +119 -0
  38. package/targets/esp32/display.cpp +6010 -0
  39. package/targets/esp32/display_headless.cpp +468 -0
  40. package/targets/esp32/gea/platform_random.h +11 -0
  41. package/targets/esp32/gea_framework.cmake +382 -0
  42. package/targets/esp32/gpio.cpp +229 -0
  43. package/targets/esp32/host_sources.cmake +35 -0
  44. package/targets/esp32/imu_absent.cpp +36 -0
  45. package/targets/esp32/ldfragments/gea_ui_state_external.lf +35 -0
  46. package/targets/esp32/memory_config.h +64 -0
  47. package/targets/esp32/power_absent.cpp +22 -0
  48. package/targets/esp32/sdk-patches/0001-esp_ptr_dma_capable-accept-PSRAM.patch +70 -0
  49. package/targets/esp32/sdk-patches/0002-gdma-access_ext_mem-spi_master.patch +59 -0
  50. package/targets/esp32/sdk-patches/README.md +127 -0
  51. package/targets/esp32/services/app_runner.cpp +248 -0
  52. package/targets/esp32/services/app_state.cpp +56 -0
  53. package/targets/esp32/services/audio_runtime_stub.cpp +86 -0
  54. package/targets/esp32/services/battery_service.cpp +31 -0
  55. package/targets/esp32/services/device_control.cpp +1896 -0
  56. package/targets/esp32/services/device_control.h +31 -0
  57. package/targets/esp32/services/frame_scheduler.cpp +1571 -0
  58. package/targets/esp32/services/heap.cpp +129 -0
  59. package/targets/esp32/services/memory.cpp +103 -0
  60. package/targets/esp32/services/ota.cpp +840 -0
  61. package/targets/esp32/services/ota_image.cpp +162 -0
  62. package/targets/esp32/services/ota_image.h +16 -0
  63. package/targets/esp32/services/storage_service.cpp +159 -0
  64. package/targets/esp32/touch_absent.cpp +44 -0
  65. package/targets/esp32-m5stack-m5paper/CMakeLists.txt +10 -0
  66. package/targets/esp32-m5stack-m5paper/README.md +55 -0
  67. package/targets/esp32-m5stack-m5paper/dependencies.lock +76 -0
  68. package/targets/esp32-m5stack-m5paper/main/CMakeLists.txt +46 -0
  69. package/targets/esp32-m5stack-m5paper/main/Kconfig.projbuild +10 -0
  70. package/targets/esp32-m5stack-m5paper/main/app_main.cpp +114 -0
  71. package/targets/esp32-m5stack-m5paper/main/audio_stub.cpp +27 -0
  72. package/targets/esp32-m5stack-m5paper/main/buttons.cpp +111 -0
  73. package/targets/esp32-m5stack-m5paper/main/display.cpp +1074 -0
  74. package/targets/esp32-m5stack-m5paper/main/i2c.cpp +36 -0
  75. package/targets/esp32-m5stack-m5paper/main/idf_component.yml +7 -0
  76. package/targets/esp32-m5stack-m5paper/main/imu_stub.cpp +20 -0
  77. package/targets/esp32-m5stack-m5paper/main/include/board.h +100 -0
  78. package/targets/esp32-m5stack-m5paper/main/include/buttons.h +8 -0
  79. package/targets/esp32-m5stack-m5paper/main/launcher_button.cpp +82 -0
  80. package/targets/esp32-m5stack-m5paper/main/m5paper_psram.lf +20 -0
  81. package/targets/esp32-m5stack-m5paper/main/power.cpp +73 -0
  82. package/targets/esp32-m5stack-m5paper/main/sdcard_mount.cpp +82 -0
  83. package/targets/esp32-m5stack-m5paper/main/touch.cpp +279 -0
  84. package/targets/esp32-m5stack-m5paper/partitions.csv +9 -0
  85. package/targets/esp32-m5stack-m5paper/sdkconfig.defaults +84 -0
  86. package/targets/esp32-p4-m5stack-tab5/CMakeLists.txt +10 -0
  87. package/targets/esp32-p4-m5stack-tab5/dependencies.lock +276 -0
  88. package/targets/esp32-p4-m5stack-tab5/main/CMakeLists.txt +586 -0
  89. package/targets/esp32-p4-m5stack-tab5/main/Kconfig.projbuild +12 -0
  90. package/targets/esp32-p4-m5stack-tab5/main/app_main.cpp +177 -0
  91. package/targets/esp32-p4-m5stack-tab5/main/camera.cpp +2025 -0
  92. package/targets/esp32-p4-m5stack-tab5/main/display.cpp +4033 -0
  93. package/targets/esp32-p4-m5stack-tab5/main/fatfs_ffconf.h +383 -0
  94. package/targets/esp32-p4-m5stack-tab5/main/i2c.cpp +39 -0
  95. package/targets/esp32-p4-m5stack-tab5/main/idf_component.yml +21 -0
  96. package/targets/esp32-p4-m5stack-tab5/main/include/board.h +130 -0
  97. package/targets/esp32-p4-m5stack-tab5/main/include/tab5_drivers.h +68 -0
  98. package/targets/esp32-p4-m5stack-tab5/main/include/wifi_config.h.example +5 -0
  99. package/targets/esp32-p4-m5stack-tab5/main/launcher_button.cpp +188 -0
  100. package/targets/esp32-p4-m5stack-tab5/main/power.cpp +22 -0
  101. package/targets/esp32-p4-m5stack-tab5/main/sdcard_mount.cpp +125 -0
  102. package/targets/esp32-p4-m5stack-tab5/main/tab5_audio.cpp +345 -0
  103. package/targets/esp32-p4-m5stack-tab5/main/tab5_drivers.cpp +871 -0
  104. package/targets/esp32-p4-m5stack-tab5/main/tab5_imu.cpp +246 -0
  105. package/targets/esp32-p4-m5stack-tab5/main/touch.cpp +206 -0
  106. package/targets/esp32-p4-m5stack-tab5/partitions.csv +12 -0
  107. package/targets/esp32-p4-m5stack-tab5/sdkconfig.defaults +128 -0
  108. package/targets/esp32-p4-waveshare-touch-lcd-3.5/CMakeLists.txt +19 -0
  109. package/targets/esp32-p4-waveshare-touch-lcd-3.5/component-patches/0001-esp_video-csi-raw-passthrough-p4-rev-lt-v3.patch +28 -0
  110. package/targets/esp32-p4-waveshare-touch-lcd-3.5/component-patches/README.md +45 -0
  111. package/targets/esp32-p4-waveshare-touch-lcd-3.5/component-patches/apply.sh +37 -0
  112. package/targets/esp32-p4-waveshare-touch-lcd-3.5/dependencies.lock +196 -0
  113. package/targets/esp32-p4-waveshare-touch-lcd-3.5/main/CMakeLists.txt +562 -0
  114. package/targets/esp32-p4-waveshare-touch-lcd-3.5/main/Kconfig.projbuild +12 -0
  115. package/targets/esp32-p4-waveshare-touch-lcd-3.5/main/app_main.cpp +166 -0
  116. package/targets/esp32-p4-waveshare-touch-lcd-3.5/main/camera.cpp +2105 -0
  117. package/targets/esp32-p4-waveshare-touch-lcd-3.5/main/display.cpp +1730 -0
  118. package/targets/esp32-p4-waveshare-touch-lcd-3.5/main/fatfs_ffconf.h +383 -0
  119. package/targets/esp32-p4-waveshare-touch-lcd-3.5/main/i2c.cpp +39 -0
  120. package/targets/esp32-p4-waveshare-touch-lcd-3.5/main/idf_component.yml +11 -0
  121. package/targets/esp32-p4-waveshare-touch-lcd-3.5/main/include/board.h +87 -0
  122. package/targets/esp32-p4-waveshare-touch-lcd-3.5/main/include/panel_native.h +59 -0
  123. package/targets/esp32-p4-waveshare-touch-lcd-3.5/main/include/wifi_config.h.example +5 -0
  124. package/targets/esp32-p4-waveshare-touch-lcd-3.5/main/launcher_button.cpp +191 -0
  125. package/targets/esp32-p4-waveshare-touch-lcd-3.5/main/power.cpp +15 -0
  126. package/targets/esp32-p4-waveshare-touch-lcd-3.5/main/touch.cpp +306 -0
  127. package/targets/esp32-p4-waveshare-touch-lcd-3.5/partitions.csv +13 -0
  128. package/targets/esp32-p4-waveshare-touch-lcd-3.5/patches/README.md +22 -0
  129. package/targets/esp32-p4-waveshare-touch-lcd-3.5/patches/espressif__esp_video-csi-bypass.patch +28 -0
  130. package/targets/esp32-p4-waveshare-touch-lcd-3.5/sdkconfig.defaults +109 -0
  131. package/targets/esp32-p4-waveshare-touch-lcd-3.5/tools/README-camera-capture.md +84 -0
  132. package/targets/esp32-p4-waveshare-touch-lcd-3.5/tools/capture-camera.py +369 -0
  133. package/targets/esp32-p4-waveshare-touch-lcd-7/CMakeLists.txt +10 -0
  134. package/targets/esp32-p4-waveshare-touch-lcd-7/dependencies.lock +258 -0
  135. package/targets/esp32-p4-waveshare-touch-lcd-7/main/CMakeLists.txt +577 -0
  136. package/targets/esp32-p4-waveshare-touch-lcd-7/main/Kconfig.projbuild +12 -0
  137. package/targets/esp32-p4-waveshare-touch-lcd-7/main/app_main.cpp +177 -0
  138. package/targets/esp32-p4-waveshare-touch-lcd-7/main/camera.cpp +1935 -0
  139. package/targets/esp32-p4-waveshare-touch-lcd-7/main/display.cpp +2832 -0
  140. package/targets/esp32-p4-waveshare-touch-lcd-7/main/fatfs_ffconf.h +383 -0
  141. package/targets/esp32-p4-waveshare-touch-lcd-7/main/i2c.cpp +39 -0
  142. package/targets/esp32-p4-waveshare-touch-lcd-7/main/idf_component.yml +23 -0
  143. package/targets/esp32-p4-waveshare-touch-lcd-7/main/include/board.h +68 -0
  144. package/targets/esp32-p4-waveshare-touch-lcd-7/main/include/wifi_config.h.example +5 -0
  145. package/targets/esp32-p4-waveshare-touch-lcd-7/main/launcher_button.cpp +191 -0
  146. package/targets/esp32-p4-waveshare-touch-lcd-7/main/power.cpp +15 -0
  147. package/targets/esp32-p4-waveshare-touch-lcd-7/main/sdcard_mount.cpp +125 -0
  148. package/targets/esp32-p4-waveshare-touch-lcd-7/main/touch.cpp +332 -0
  149. package/targets/esp32-p4-waveshare-touch-lcd-7/partitions.csv +12 -0
  150. package/targets/esp32-p4-waveshare-touch-lcd-7/sdkconfig.defaults +122 -0
  151. package/targets/esp32-p4-waveshare-touch-lcd-7/tools/README-camera-capture.md +84 -0
  152. package/targets/esp32-p4-waveshare-touch-lcd-7/tools/capture-camera.py +369 -0
  153. package/targets/esp32-s3-devkit-n16r8.json +31 -0
  154. package/targets/esp32-s3-elecrow-rotary-2.1/CMakeLists.txt +10 -0
  155. package/targets/esp32-s3-elecrow-rotary-2.1/dependencies.lock +40 -0
  156. package/targets/esp32-s3-elecrow-rotary-2.1/main/CMakeLists.txt +549 -0
  157. package/targets/esp32-s3-elecrow-rotary-2.1/main/Kconfig.projbuild +12 -0
  158. package/targets/esp32-s3-elecrow-rotary-2.1/main/app_main.cpp +187 -0
  159. package/targets/esp32-s3-elecrow-rotary-2.1/main/display_rgb.cpp +1338 -0
  160. package/targets/esp32-s3-elecrow-rotary-2.1/main/i2c.cpp +39 -0
  161. package/targets/esp32-s3-elecrow-rotary-2.1/main/idf_component.yml +5 -0
  162. package/targets/esp32-s3-elecrow-rotary-2.1/main/include/board.h +142 -0
  163. package/targets/esp32-s3-elecrow-rotary-2.1/main/include/pcf8574.h +16 -0
  164. package/targets/esp32-s3-elecrow-rotary-2.1/main/include/rotary_encoder.h +7 -0
  165. package/targets/esp32-s3-elecrow-rotary-2.1/main/launcher_button.cpp +191 -0
  166. package/targets/esp32-s3-elecrow-rotary-2.1/main/pcf8574.cpp +86 -0
  167. package/targets/esp32-s3-elecrow-rotary-2.1/main/platform_stubs.cpp +47 -0
  168. package/targets/esp32-s3-elecrow-rotary-2.1/main/rotary_encoder.cpp +135 -0
  169. package/targets/esp32-s3-elecrow-rotary-2.1/main/touch.cpp +250 -0
  170. package/targets/esp32-s3-elecrow-rotary-2.1/partitions.csv +8 -0
  171. package/targets/esp32-s3-elecrow-rotary-2.1/sdkconfig.defaults +116 -0
  172. package/targets/esp32-s3-epaper-1.54/CMakeLists.txt +10 -0
  173. package/targets/esp32-s3-epaper-1.54/dependencies.lock +76 -0
  174. package/targets/esp32-s3-epaper-1.54/main/CMakeLists.txt +691 -0
  175. package/targets/esp32-s3-epaper-1.54/main/Kconfig.projbuild +12 -0
  176. package/targets/esp32-s3-epaper-1.54/main/app_main.cpp +181 -0
  177. package/targets/esp32-s3-epaper-1.54/main/buttons.cpp +144 -0
  178. package/targets/esp32-s3-epaper-1.54/main/display.cpp +1281 -0
  179. package/targets/esp32-s3-epaper-1.54/main/fatfs_ffconf.h +377 -0
  180. package/targets/esp32-s3-epaper-1.54/main/i2c.cpp +39 -0
  181. package/targets/esp32-s3-epaper-1.54/main/idf_component.yml +7 -0
  182. package/targets/esp32-s3-epaper-1.54/main/imu_stub.cpp +21 -0
  183. package/targets/esp32-s3-epaper-1.54/main/include/board.h +119 -0
  184. package/targets/esp32-s3-epaper-1.54/main/include/buttons.h +9 -0
  185. package/targets/esp32-s3-epaper-1.54/main/include/wifi_config.h.example +5 -0
  186. package/targets/esp32-s3-epaper-1.54/main/launcher_button.cpp +191 -0
  187. package/targets/esp32-s3-epaper-1.54/main/power.cpp +15 -0
  188. package/targets/esp32-s3-epaper-1.54/main/sdcard_mount.cpp +89 -0
  189. package/targets/esp32-s3-epaper-1.54/main/touch.cpp +299 -0
  190. package/targets/esp32-s3-epaper-1.54/partitions.csv +8 -0
  191. package/targets/esp32-s3-epaper-1.54/sdkconfig.defaults +217 -0
  192. package/targets/esp32-s3-lilygo-t-display-s3-long/CMakeLists.txt +10 -0
  193. package/targets/esp32-s3-lilygo-t-display-s3-long/README.md +29 -0
  194. package/targets/esp32-s3-lilygo-t-display-s3-long/dependencies.lock +116 -0
  195. package/targets/esp32-s3-lilygo-t-display-s3-long/main/CMakeLists.txt +90 -0
  196. package/targets/esp32-s3-lilygo-t-display-s3-long/main/idf_component.yml +7 -0
  197. package/targets/esp32-s3-lilygo-t-display-s3-long/main/include/board.h +61 -0
  198. package/targets/esp32-s3-lilygo-t-display-s3-long/main/touch.cpp +299 -0
  199. package/targets/esp32-s3-lilygo-t-display-s3-long/partitions.csv +7 -0
  200. package/targets/esp32-s3-lilygo-t-display-s3-long/sdkconfig.defaults +50 -0
  201. package/targets/esp32-s3-lilygo-t5-epaper-4.7/CMakeLists.txt +12 -0
  202. package/targets/esp32-s3-lilygo-t5-epaper-4.7/components/epd_driver/CMakeLists.txt +17 -0
  203. package/targets/esp32-s3-lilygo-t5-epaper-4.7/components/epd_driver/ed047tc1.c +269 -0
  204. package/targets/esp32-s3-lilygo-t5-epaper-4.7/components/epd_driver/ed047tc1.h +142 -0
  205. package/targets/esp32-s3-lilygo-t5-epaper-4.7/components/epd_driver/epd_driver.c +1114 -0
  206. package/targets/esp32-s3-lilygo-t5-epaper-4.7/components/epd_driver/epd_driver.h +410 -0
  207. package/targets/esp32-s3-lilygo-t5-epaper-4.7/components/epd_driver/gea_epd.c +989 -0
  208. package/targets/esp32-s3-lilygo-t5-epaper-4.7/components/epd_driver/i2s_data_bus.c +489 -0
  209. package/targets/esp32-s3-lilygo-t5-epaper-4.7/components/epd_driver/i2s_data_bus.h +104 -0
  210. package/targets/esp32-s3-lilygo-t5-epaper-4.7/components/epd_driver/rmt_pulse.c +136 -0
  211. package/targets/esp32-s3-lilygo-t5-epaper-4.7/components/epd_driver/rmt_pulse.h +78 -0
  212. package/targets/esp32-s3-lilygo-t5-epaper-4.7/components/epd_driver/utilities.h +49 -0
  213. package/targets/esp32-s3-lilygo-t5-epaper-4.7/dependencies.lock +35 -0
  214. package/targets/esp32-s3-lilygo-t5-epaper-4.7/main/CMakeLists.txt +30 -0
  215. package/targets/esp32-s3-lilygo-t5-epaper-4.7/main/Kconfig.projbuild +10 -0
  216. package/targets/esp32-s3-lilygo-t5-epaper-4.7/main/app_main.cpp +95 -0
  217. package/targets/esp32-s3-lilygo-t5-epaper-4.7/main/audio_stub.cpp +27 -0
  218. package/targets/esp32-s3-lilygo-t5-epaper-4.7/main/buttons.cpp +40 -0
  219. package/targets/esp32-s3-lilygo-t5-epaper-4.7/main/display.cpp +627 -0
  220. package/targets/esp32-s3-lilygo-t5-epaper-4.7/main/i2c.cpp +36 -0
  221. package/targets/esp32-s3-lilygo-t5-epaper-4.7/main/idf_component.yml +4 -0
  222. package/targets/esp32-s3-lilygo-t5-epaper-4.7/main/imu_stub.cpp +20 -0
  223. package/targets/esp32-s3-lilygo-t5-epaper-4.7/main/include/board.h +85 -0
  224. package/targets/esp32-s3-lilygo-t5-epaper-4.7/main/include/buttons.h +8 -0
  225. package/targets/esp32-s3-lilygo-t5-epaper-4.7/main/launcher_button.cpp +82 -0
  226. package/targets/esp32-s3-lilygo-t5-epaper-4.7/main/power.cpp +36 -0
  227. package/targets/esp32-s3-lilygo-t5-epaper-4.7/main/sdcard_mount.cpp +90 -0
  228. package/targets/esp32-s3-lilygo-t5-epaper-4.7/main/touch.cpp +293 -0
  229. package/targets/esp32-s3-lilygo-t5-epaper-4.7/partitions.csv +9 -0
  230. package/targets/esp32-s3-lilygo-t5-epaper-4.7/sdkconfig.defaults +217 -0
  231. package/targets/esp32-s3-m5stack-papers3/CMakeLists.txt +13 -0
  232. package/targets/esp32-s3-m5stack-papers3/components/papers3_epd/CMakeLists.txt +5 -0
  233. package/targets/esp32-s3-m5stack-papers3/components/papers3_epd/include/papers3_epd.h +74 -0
  234. package/targets/esp32-s3-m5stack-papers3/components/papers3_epd/papers3_epd.c +671 -0
  235. package/targets/esp32-s3-m5stack-papers3/dependencies.lock +76 -0
  236. package/targets/esp32-s3-m5stack-papers3/main/CMakeLists.txt +64 -0
  237. package/targets/esp32-s3-m5stack-papers3/main/Kconfig.projbuild +10 -0
  238. package/targets/esp32-s3-m5stack-papers3/main/app_main.cpp +96 -0
  239. package/targets/esp32-s3-m5stack-papers3/main/audio_stub.cpp +27 -0
  240. package/targets/esp32-s3-m5stack-papers3/main/buttons.cpp +49 -0
  241. package/targets/esp32-s3-m5stack-papers3/main/display.cpp +706 -0
  242. package/targets/esp32-s3-m5stack-papers3/main/i2c.cpp +36 -0
  243. package/targets/esp32-s3-m5stack-papers3/main/idf_component.yml +14 -0
  244. package/targets/esp32-s3-m5stack-papers3/main/imu.cpp +351 -0
  245. package/targets/esp32-s3-m5stack-papers3/main/include/board.h +101 -0
  246. package/targets/esp32-s3-m5stack-papers3/main/include/buttons.h +8 -0
  247. package/targets/esp32-s3-m5stack-papers3/main/launcher_button.cpp +96 -0
  248. package/targets/esp32-s3-m5stack-papers3/main/power.cpp +102 -0
  249. package/targets/esp32-s3-m5stack-papers3/main/sdcard_mount.cpp +88 -0
  250. package/targets/esp32-s3-m5stack-papers3/main/touch.cpp +287 -0
  251. package/targets/esp32-s3-m5stack-papers3/partitions.csv +9 -0
  252. package/targets/esp32-s3-m5stack-papers3/sdkconfig.defaults +232 -0
  253. package/targets/esp32-s3-m5stack-sticks3/CMakeLists.txt +10 -0
  254. package/targets/esp32-s3-m5stack-sticks3/dependencies.lock +51 -0
  255. package/targets/esp32-s3-m5stack-sticks3/main/CMakeLists.txt +51 -0
  256. package/targets/esp32-s3-m5stack-sticks3/main/Kconfig.projbuild +12 -0
  257. package/targets/esp32-s3-m5stack-sticks3/main/app_main.cpp +130 -0
  258. package/targets/esp32-s3-m5stack-sticks3/main/buttons.cpp +101 -0
  259. package/targets/esp32-s3-m5stack-sticks3/main/display.cpp +1391 -0
  260. package/targets/esp32-s3-m5stack-sticks3/main/i2c.cpp +39 -0
  261. package/targets/esp32-s3-m5stack-sticks3/main/idf_component.yml +8 -0
  262. package/targets/esp32-s3-m5stack-sticks3/main/imu_stub.cpp +9 -0
  263. package/targets/esp32-s3-m5stack-sticks3/main/include/board.h +89 -0
  264. package/targets/esp32-s3-m5stack-sticks3/main/include/buttons.h +9 -0
  265. package/targets/esp32-s3-m5stack-sticks3/main/launcher_button.cpp +191 -0
  266. package/targets/esp32-s3-m5stack-sticks3/main/power.cpp +15 -0
  267. package/targets/esp32-s3-m5stack-sticks3/main/sdcard_mount.cpp +8 -0
  268. package/targets/esp32-s3-m5stack-sticks3/main/touch.cpp +65 -0
  269. package/targets/esp32-s3-m5stack-sticks3/partitions.csv +8 -0
  270. package/targets/esp32-s3-m5stack-sticks3/sdkconfig.defaults +130 -0
  271. package/targets/esp32-s3-touch-amoled-1.75/CMakeLists.txt +10 -0
  272. package/targets/esp32-s3-touch-amoled-1.75/dependencies.lock +130 -0
  273. package/targets/esp32-s3-touch-amoled-1.75/main/CMakeLists.txt +589 -0
  274. package/targets/esp32-s3-touch-amoled-1.75/main/Kconfig.projbuild +12 -0
  275. package/targets/esp32-s3-touch-amoled-1.75/main/app_main.cpp +153 -0
  276. package/targets/esp32-s3-touch-amoled-1.75/main/i2c.cpp +39 -0
  277. package/targets/esp32-s3-touch-amoled-1.75/main/idf_component.yml +9 -0
  278. package/targets/esp32-s3-touch-amoled-1.75/main/include/board.h +110 -0
  279. package/targets/esp32-s3-touch-amoled-1.75/main/include/wifi_config.h.example +5 -0
  280. package/targets/esp32-s3-touch-amoled-1.75/main/launcher_button.cpp +191 -0
  281. package/targets/esp32-s3-touch-amoled-1.75/main/touch.cpp +45 -0
  282. package/targets/esp32-s3-touch-amoled-1.75/partitions.csv +8 -0
  283. package/targets/esp32-s3-touch-amoled-1.75/sdkconfig.defaults +179 -0
  284. package/targets/esp32-s3-touch-amoled-1.8/CMakeLists.txt +10 -0
  285. package/targets/esp32-s3-touch-amoled-1.8/dependencies.lock +105 -0
  286. package/targets/esp32-s3-touch-amoled-1.8/main/CMakeLists.txt +768 -0
  287. package/targets/esp32-s3-touch-amoled-1.8/main/Kconfig.projbuild +12 -0
  288. package/targets/esp32-s3-touch-amoled-1.8/main/app_main.cpp +172 -0
  289. package/targets/esp32-s3-touch-amoled-1.8/main/i2c.cpp +39 -0
  290. package/targets/esp32-s3-touch-amoled-1.8/main/idf_component.yml +8 -0
  291. package/targets/esp32-s3-touch-amoled-1.8/main/include/board.h +83 -0
  292. package/targets/esp32-s3-touch-amoled-1.8/main/include/wifi_config.h.example +5 -0
  293. package/targets/esp32-s3-touch-amoled-1.8/main/launcher_button.cpp +191 -0
  294. package/targets/esp32-s3-touch-amoled-1.8/main/touch.cpp +41 -0
  295. package/targets/esp32-s3-touch-amoled-1.8/partitions.csv +8 -0
  296. package/targets/esp32-s3-touch-amoled-1.8/sdkconfig.defaults +179 -0
  297. package/targets/esp32-s3-touch-amoled-2.06/CMakeLists.txt +10 -0
  298. package/targets/esp32-s3-touch-amoled-2.06/dependencies.lock +64 -0
  299. package/targets/esp32-s3-touch-amoled-2.06/main/CMakeLists.txt +1121 -0
  300. package/targets/esp32-s3-touch-amoled-2.06/main/Kconfig.projbuild +12 -0
  301. package/targets/esp32-s3-touch-amoled-2.06/main/app_main.cpp +333 -0
  302. package/targets/esp32-s3-touch-amoled-2.06/main/i2c.cpp +39 -0
  303. package/targets/esp32-s3-touch-amoled-2.06/main/idf_component.yml +27 -0
  304. package/targets/esp32-s3-touch-amoled-2.06/main/include/board.h +114 -0
  305. package/targets/esp32-s3-touch-amoled-2.06/main/include/wifi_config.h.example +5 -0
  306. package/targets/esp32-s3-touch-amoled-2.06/main/launcher_button.cpp +199 -0
  307. package/targets/esp32-s3-touch-amoled-2.06/main/sdcard_mount.cpp +105 -0
  308. package/targets/esp32-s3-touch-amoled-2.06/main/touch.cpp +49 -0
  309. package/targets/esp32-s3-touch-amoled-2.06/partitions.csv +14 -0
  310. package/targets/esp32-s3-touch-amoled-2.06/sdkconfig.defaults +273 -0
  311. package/targets/esp32-s3-touch-amoled-2.41/CMakeLists.txt +10 -0
  312. package/targets/esp32-s3-touch-amoled-2.41/main/CMakeLists.txt +71 -0
  313. package/targets/esp32-s3-touch-amoled-2.41/main/Kconfig.projbuild +12 -0
  314. package/targets/esp32-s3-touch-amoled-2.41/main/idf_component.yml +27 -0
  315. package/targets/esp32-s3-touch-amoled-2.41/main/include/board.h +108 -0
  316. package/targets/esp32-s3-touch-amoled-2.41/main/include/wifi_config.h.example +5 -0
  317. package/targets/esp32-s3-touch-amoled-2.41/main/panel_reset.cpp +82 -0
  318. package/targets/esp32-s3-touch-amoled-2.41/main/touch.cpp +49 -0
  319. package/targets/esp32-s3-touch-amoled-2.41/partitions.csv +8 -0
  320. package/targets/esp32-s3-touch-amoled-2.41/sdkconfig.defaults +273 -0
  321. package/targets/rp2350-tufty-2350/CMakeLists.txt +348 -0
  322. package/targets/rp2350-tufty-2350/README.md +53 -0
  323. package/targets/rp2350-tufty-2350/boards/pimoroni_tufty2350.h +87 -0
  324. package/targets/rp2350-tufty-2350/main/bringup.cpp +187 -0
  325. package/targets/rp2350-tufty-2350/main/include/board.h +124 -0
  326. package/targets/rp2350-tufty-2350/main/rp2350_panel.cpp +428 -0
  327. package/targets/rp2350-tufty-2350/main/rp2350_panel.h +46 -0
  328. package/targets/rp2350-tufty-2350/main/st7789_parallel.pio +7 -0
  329. package/targets/rp2350-waveshare-touch-amoled-2.41/CMakeLists.txt +345 -0
  330. package/targets/rp2350-waveshare-touch-amoled-2.41/README.md +153 -0
  331. package/targets/rp2350-waveshare-touch-amoled-2.41/boards/waveshare_rp2350_touch_amoled_2_41.h +59 -0
  332. package/targets/rp2350-waveshare-touch-amoled-2.41/main/app.cpp +984 -0
  333. package/targets/rp2350-waveshare-touch-amoled-2.41/main/bringup.cpp +222 -0
  334. package/targets/rp2350-waveshare-touch-amoled-2.41/main/include/board.h +138 -0
  335. package/targets/rp2350-waveshare-touch-amoled-2.41/main/rp2350_gea_platform.cpp +2553 -0
  336. package/targets/rp2350-waveshare-touch-amoled-2.41/main/rp2350_gea_platform.h +18 -0
  337. package/targets/rp2350-waveshare-touch-amoled-2.41/main/rp2350_host_fetch_stub.cpp +64 -0
  338. package/targets/rp2350-waveshare-touch-amoled-2.41/main/rp2350_panel.cpp +677 -0
  339. package/targets/rp2350-waveshare-touch-amoled-2.41/main/rp2350_panel.h +48 -0
  340. package/targets/rp2350-waveshare-touch-amoled-2.41/main/vendor/waveshare_psram/rp_pico_alloc.c +354 -0
  341. package/targets/rp2350-waveshare-touch-amoled-2.41/main/vendor/waveshare_psram/rp_pico_alloc.h +56 -0
  342. package/targets/rp2350-waveshare-touch-amoled-2.41/main/vendor/waveshare_psram/tlsf/tlsf.c +1284 -0
  343. package/targets/rp2350-waveshare-touch-amoled-2.41/main/vendor/waveshare_psram/tlsf/tlsf.h +95 -0
  344. package/targets/rp2350-waveshare-touch-amoled-2.41/main/vendor/waveshare_psram/tlsf/tlsf_block_functions.h +123 -0
  345. package/targets/rp2350-waveshare-touch-amoled-2.41/main/vendor/waveshare_psram/tlsf/tlsf_common.h +127 -0
  346. package/targets/rp2350-waveshare-touch-amoled-2.41/tools/rp2350-scroll-bench.py +162 -0
  347. package/targets/rp2350-waveshare-touch-amoled-2.41/tools/rp2350-scroll-parity.py +198 -0
  348. package/targets.json +154 -0
@@ -0,0 +1,677 @@
1
+ #include "rp2350_panel.h"
2
+
3
+ #include "hardware/clocks.h"
4
+ #include "hardware/dma.h"
5
+ #include "hardware/gpio.h"
6
+ #include "hardware/pio.h"
7
+ #include "hardware/xip_cache.h"
8
+ #include "pico/stdlib.h"
9
+
10
+ #include <algorithm>
11
+ #include <cstddef>
12
+ #include <cstdint>
13
+ #include <cstdio>
14
+
15
+ namespace gea::rp2350 {
16
+ namespace {
17
+
18
+ constexpr int kPinCs = 9;
19
+ constexpr int kPinSclk = 10;
20
+ constexpr int kPinDio0 = 11;
21
+ constexpr int kPinReset = 15;
22
+ constexpr int kXGap = 16;
23
+ constexpr int kDrawRounding = 2;
24
+ constexpr float kQspiClockDiv = 1.0f;
25
+ // PIO clock the panel bus was tuned at (sys_clk=200MHz, div=1.0 => 200MHz PIO,
26
+ // ~100MHz SCLK). The divider is recomputed at init from the live clk_sys so the
27
+ // wire speed stays pinned here even when the system is overclocked past 200MHz.
28
+ constexpr float kQspiPioTargetHz = 200000000.0f;
29
+ constexpr int kMaxDmaChunkRows = 64;
30
+ constexpr int kMaxDmaDepth = 2;
31
+
32
+ struct QspiState {
33
+ PIO pio = pio0;
34
+ uint sm = 0;
35
+ int dma = -1;
36
+ dma_channel_config dmaConfig{};
37
+ bool ready = false;
38
+ int brightness = 100;
39
+ int flushRows = 64;
40
+ int flushDepth = 2;
41
+ };
42
+
43
+ // Async span-flush state. While a flush is in flight the DMA (re-armed for
44
+ // span B from its completion IRQ) feeds the PIO, the SM runs with a 32-bit
45
+ // autopull threshold, and CS stays asserted; panelSpanFlushComplete() settles
46
+ // all of it before any other panel traffic. `spanBWords` is consumed by the
47
+ // IRQ handler; `spanActive` covers the whole kick-to-settle window.
48
+ volatile bool gSpanActive = false;
49
+ volatile std::uint32_t gSpanBWords = 0;
50
+ const std::uint8_t *volatile gSpanBSrc = nullptr;
51
+ dma_channel_config gSpanWordConfig{};
52
+ int gSpanStallCount = 0;
53
+
54
+ QspiState gQspi;
55
+ std::uint16_t gDmaChunk[kMaxDmaDepth][kPanelWidth * kMaxDmaChunkRows];
56
+ PanelFlushStats gFlushStats;
57
+
58
+ #define qspi_4wire_data_wrap_target 0
59
+ #define qspi_4wire_data_wrap 1
60
+ static const std::uint16_t qspi_4wire_data_program_instructions[] = {
61
+ 0x7004, // out pins, 4 side 0
62
+ 0xb842, // nop side 1
63
+ };
64
+
65
+ static const pio_program qspi_4wire_data_program = {
66
+ .instructions = qspi_4wire_data_program_instructions,
67
+ .length = 2,
68
+ .origin = -1,
69
+ };
70
+
71
+ pio_sm_config qspiProgramDefaultConfig(uint offset)
72
+ {
73
+ pio_sm_config config = pio_get_default_sm_config();
74
+ sm_config_set_wrap(&config, offset + qspi_4wire_data_wrap_target, offset + qspi_4wire_data_wrap);
75
+ sm_config_set_sideset(&config, 2, true, false);
76
+ return config;
77
+ }
78
+
79
+ void qspiProgramInit(PIO pio, uint sm, uint offset)
80
+ {
81
+ pio_sm_config config = qspiProgramDefaultConfig(offset);
82
+ pio_gpio_init(pio, kPinSclk);
83
+ pio_sm_set_consecutive_pindirs(pio, sm, kPinSclk, 1, true);
84
+ sm_config_set_sideset_pins(&config, kPinSclk);
85
+ sm_config_set_out_pins(&config, kPinDio0, 4);
86
+ sm_config_set_out_shift(&config, false, true, 8);
87
+ for (uint pin = 0; pin < 4; ++pin) {
88
+ pio_gpio_init(pio, kPinDio0 + pin);
89
+ }
90
+ pio_sm_set_consecutive_pindirs(pio, sm, kPinDio0, 4, true);
91
+ // Keep the panel bus at its tuned speed independent of the system overclock.
92
+ const float clkDiv = static_cast<float>(clock_get_hz(clk_sys)) / kQspiPioTargetHz;
93
+ sm_config_set_clkdiv(&config, clkDiv < 1.0f ? 1.0f : clkDiv);
94
+ pio_sm_init(pio, sm, offset, &config);
95
+ pio_sm_clear_fifos(pio, sm);
96
+ pio_sm_set_enabled(pio, sm, true);
97
+ }
98
+
99
+ void select()
100
+ {
101
+ gpio_put(kPinCs, 0);
102
+ }
103
+
104
+ void waitQspiIdle()
105
+ {
106
+ const std::uint32_t txStallMask = 1u << (PIO_FDEBUG_TXSTALL_LSB + gQspi.sm);
107
+ gQspi.pio->fdebug = txStallMask;
108
+ while (!(gQspi.pio->fdebug & txStallMask)) {
109
+ tight_loop_contents();
110
+ }
111
+ sleep_us(2);
112
+ }
113
+
114
+ void deselect()
115
+ {
116
+ waitQspiIdle();
117
+ gpio_put(kPinCs, 1);
118
+ }
119
+
120
+ void writePacked(std::uint32_t value)
121
+ {
122
+ pio_sm_put_blocking(gQspi.pio, gQspi.sm, value << 24);
123
+ }
124
+
125
+ void writeQspiByte(std::uint8_t value)
126
+ {
127
+ std::uint8_t packed[4]{};
128
+ for (int i = 0; i < 4; ++i) {
129
+ const std::uint8_t bit0 = (value & (1u << (2 * i))) ? 1u : 0u;
130
+ const std::uint8_t bit1 = (value & (1u << (2 * i + 1))) ? 1u : 0u;
131
+ packed[3 - i] = static_cast<std::uint8_t>(bit0 | (bit1 << 4));
132
+ }
133
+ for (std::uint8_t byte : packed) writePacked(byte);
134
+ }
135
+
136
+ void writeRegister(std::uint8_t address)
137
+ {
138
+ writeQspiByte(0x02);
139
+ writeQspiByte(0x00);
140
+ writeQspiByte(address);
141
+ writeQspiByte(0x00);
142
+ }
143
+
144
+ void writePixelRegister(std::uint8_t address)
145
+ {
146
+ writeQspiByte(0x32);
147
+ writeQspiByte(0x00);
148
+ writeQspiByte(address);
149
+ writeQspiByte(0x00);
150
+ }
151
+
152
+ void writeCommand(std::uint8_t command)
153
+ {
154
+ select();
155
+ writeRegister(command);
156
+ deselect();
157
+ }
158
+
159
+ void writeCommandData(std::uint8_t command, std::uint8_t data)
160
+ {
161
+ select();
162
+ writeRegister(command);
163
+ writeQspiByte(data);
164
+ deselect();
165
+ }
166
+
167
+ void setWindow(int x0, int y0, int x1Exclusive, int y1Exclusive)
168
+ {
169
+ x0 += kXGap;
170
+ x1Exclusive += kXGap;
171
+
172
+ select();
173
+ writeRegister(0x2a);
174
+ writeQspiByte(static_cast<std::uint8_t>(x0 >> 8));
175
+ writeQspiByte(static_cast<std::uint8_t>(x0 & 0xff));
176
+ writeQspiByte(static_cast<std::uint8_t>((x1Exclusive - 1) >> 8));
177
+ writeQspiByte(static_cast<std::uint8_t>((x1Exclusive - 1) & 0xff));
178
+ deselect();
179
+
180
+ select();
181
+ writeRegister(0x2b);
182
+ writeQspiByte(static_cast<std::uint8_t>(y0 >> 8));
183
+ writeQspiByte(static_cast<std::uint8_t>(y0 & 0xff));
184
+ writeQspiByte(static_cast<std::uint8_t>((y1Exclusive - 1) >> 8));
185
+ writeQspiByte(static_cast<std::uint8_t>((y1Exclusive - 1) & 0xff));
186
+ deselect();
187
+ }
188
+
189
+ int roundDownWindowCoord(int value)
190
+ {
191
+ return value & ~(kDrawRounding - 1);
192
+ }
193
+
194
+ int roundUpWindowCoord(int value)
195
+ {
196
+ return (value + kDrawRounding - 1) & ~(kDrawRounding - 1);
197
+ }
198
+
199
+ void roundMemoryWindow(int *x0, int *y0, int *x1, int *y1)
200
+ {
201
+ static_assert((kDrawRounding & (kDrawRounding - 1)) == 0, "kDrawRounding must be a power of two");
202
+ if (!x0 || !y0 || !x1 || !y1) return;
203
+ *x0 = std::max(0, roundDownWindowCoord(*x0));
204
+ *y0 = std::max(0, roundDownWindowCoord(*y0));
205
+ const int xEnd = std::min(kPanelWidth, roundUpWindowCoord(*x1 + 1));
206
+ const int yEnd = std::min(kPanelHeight, roundUpWindowCoord(*y1 + 1));
207
+ *x1 = xEnd - 1;
208
+ *y1 = yEnd - 1;
209
+ }
210
+
211
+ void resetPanel()
212
+ {
213
+ gpio_put(kPinReset, 1);
214
+ sleep_ms(50);
215
+ gpio_put(kPinReset, 0);
216
+ sleep_ms(50);
217
+ gpio_put(kPinReset, 1);
218
+ sleep_ms(300);
219
+ }
220
+
221
+ void initRegisters()
222
+ {
223
+ writeCommand(0x11);
224
+ sleep_ms(120);
225
+
226
+ select();
227
+ writeRegister(0x44);
228
+ writeQspiByte(0x01);
229
+ writeQspiByte(0xd1);
230
+ deselect();
231
+
232
+ writeCommandData(0xfe, 0x20);
233
+ writeCommandData(0x63, 0xff);
234
+ writeCommandData(0x26, 0x0a);
235
+ writeCommandData(0x24, 0x80);
236
+ writeCommandData(0xfe, 0x00);
237
+ writeCommandData(0x3a, 0x55);
238
+ writeCommandData(0xc4, 0x80);
239
+ writeCommandData(0xc2, 0x00);
240
+ sleep_ms(10);
241
+ writeCommandData(0x35, 0x00);
242
+ writeCommandData(0x51, 0x00);
243
+ writeCommand(0x29);
244
+ sleep_ms(10);
245
+ writeCommandData(0x51, 0xff);
246
+ sleep_ms(10);
247
+ }
248
+
249
+ void startDma(const std::uint16_t *buffer, int pixelCount)
250
+ {
251
+ gFlushStats.chunkCount++;
252
+ gFlushStats.pixelCount += pixelCount;
253
+ dma_channel_configure(gQspi.dma,
254
+ &gQspi.dmaConfig,
255
+ &gQspi.pio->txf[gQspi.sm],
256
+ reinterpret_cast<const std::uint8_t *>(buffer),
257
+ static_cast<std::uint32_t>(pixelCount * 2),
258
+ true);
259
+ }
260
+
261
+ void waitDma()
262
+ {
263
+ const std::uint64_t startUs = time_us_64();
264
+ while (dma_channel_is_busy(gQspi.dma)) {
265
+ tight_loop_contents();
266
+ }
267
+ gFlushStats.txWaitUs += static_cast<std::int64_t>(time_us_64() - startUs);
268
+ }
269
+
270
+ int prepareChunk(std::uint16_t *dst, const std::uint16_t *pixels, int stridePixels, int x0, int y, int y1, int width)
271
+ {
272
+ const std::uint64_t startUs = time_us_64();
273
+ const int rows = std::min(gQspi.flushRows, y1 - y + 1);
274
+ for (int row = 0; row < rows; ++row) {
275
+ std::copy_n(pixels + static_cast<std::size_t>(y + row) * stridePixels + x0,
276
+ width,
277
+ dst + static_cast<std::size_t>(row) * width);
278
+ }
279
+ gFlushStats.copyUs += static_cast<std::int64_t>(time_us_64() - startUs);
280
+ return rows;
281
+ }
282
+
283
+ void rasterFramebufferChunk(std::uint16_t *dst, int width, int rows, int x0, int y, void *user)
284
+ {
285
+ const auto *source = static_cast<const std::uint16_t *>(user);
286
+ if (!source) return;
287
+ const std::uint64_t startUs = time_us_64();
288
+ for (int row = 0; row < rows; ++row) {
289
+ std::copy_n(source + static_cast<std::size_t>(y + row) * kPanelWidth + x0,
290
+ width,
291
+ dst + static_cast<std::size_t>(row) * width);
292
+ }
293
+ gFlushStats.copyUs += static_cast<std::int64_t>(time_us_64() - startUs);
294
+ }
295
+
296
+ void streamPreparedRect(int x0, int y0, int x1, int y1, PanelStreamRasterFn raster, void *user)
297
+ {
298
+ if (!raster) return;
299
+ gFlushStats.callCount++;
300
+ const int width = x1 - x0 + 1;
301
+ int y = y0;
302
+ int active = 0;
303
+ int rows = std::min(gQspi.flushRows, y1 - y + 1);
304
+ raster(gDmaChunk[active], width, rows, x0, y, user);
305
+ y += rows;
306
+ const std::uint64_t windowStartUs = time_us_64();
307
+ setWindow(x0, y0, x1 + 1, y1 + 1);
308
+ gFlushStats.setWindowUs += static_cast<std::int64_t>(time_us_64() - windowStartUs);
309
+ select();
310
+ writePixelRegister(0x2c);
311
+ channel_config_set_dreq(&gQspi.dmaConfig, pio_get_dreq(gQspi.pio, gQspi.sm, true));
312
+ startDma(gDmaChunk[active], width * rows);
313
+ if (gQspi.flushDepth <= 1) {
314
+ waitDma();
315
+ while (y <= y1) {
316
+ rows = std::min(gQspi.flushRows, y1 - y + 1);
317
+ raster(gDmaChunk[0], width, rows, x0, y, user);
318
+ startDma(gDmaChunk[0], width * rows);
319
+ waitDma();
320
+ y += rows;
321
+ }
322
+ } else {
323
+ while (y <= y1) {
324
+ const int next = 1 - active;
325
+ const int nextRows = std::min(gQspi.flushRows, y1 - y + 1);
326
+ raster(gDmaChunk[next], width, nextRows, x0, y, user);
327
+ waitDma();
328
+ startDma(gDmaChunk[next], width * nextRows);
329
+ active = next;
330
+ y += nextRows;
331
+ }
332
+ waitDma();
333
+ }
334
+ deselect();
335
+ }
336
+
337
+ } // namespace
338
+
339
+ void panelSpanFlushComplete();
340
+ void spanDmaIrqHandler();
341
+
342
+ bool panelInit()
343
+ {
344
+ if (gQspi.ready) return true;
345
+
346
+ gpio_init(kPinCs);
347
+ gpio_set_dir(kPinCs, GPIO_OUT);
348
+ gpio_put(kPinCs, 1);
349
+
350
+ gpio_init(kPinReset);
351
+ gpio_set_dir(kPinReset, GPIO_OUT);
352
+
353
+ const uint offset = pio_add_program(gQspi.pio, &qspi_4wire_data_program);
354
+ qspiProgramInit(gQspi.pio, gQspi.sm, offset);
355
+
356
+ gQspi.dma = dma_claim_unused_channel(true);
357
+ gQspi.dmaConfig = dma_channel_get_default_config(gQspi.dma);
358
+ channel_config_set_transfer_data_size(&gQspi.dmaConfig, DMA_SIZE_8);
359
+ channel_config_set_read_increment(&gQspi.dmaConfig, true);
360
+ channel_config_set_write_increment(&gQspi.dmaConfig, false);
361
+ channel_config_set_dreq(&gQspi.dmaConfig, pio_get_dreq(gQspi.pio, gQspi.sm, true));
362
+
363
+ // Async span flush: the channel's completion IRQ re-arms it for span B
364
+ // (single channel throughout — two channels chained on ONE shared DREQ can
365
+ // lose pacing credits at the handover, which matched the intermittent
366
+ // 100ms+ stalls of the earlier chain_to design).
367
+ irq_add_shared_handler(DMA_IRQ_1, spanDmaIrqHandler, PICO_SHARED_IRQ_HANDLER_DEFAULT_ORDER_PRIORITY);
368
+ dma_irqn_set_channel_enabled(1, static_cast<uint>(gQspi.dma), true);
369
+ irq_set_enabled(DMA_IRQ_1, true);
370
+
371
+ resetPanel();
372
+ initRegisters();
373
+ gQspi.ready = true;
374
+ panelClear(0x0000);
375
+ return true;
376
+ }
377
+
378
+ void panelSetBrightness(int percent)
379
+ {
380
+ panelSpanFlushComplete();
381
+ if (percent < 0) percent = 0;
382
+ if (percent > 100) percent = 100;
383
+ gQspi.brightness = percent;
384
+ if (!gQspi.ready) return;
385
+ const auto value = static_cast<std::uint8_t>((percent * 255) / 100);
386
+ writeCommandData(0x51, value);
387
+ }
388
+
389
+ void panelSetFlushConfig(int rows, int depth)
390
+ {
391
+ if (rows > 0) gQspi.flushRows = std::clamp(rows, 1, kMaxDmaChunkRows);
392
+ if (depth > 0) gQspi.flushDepth = std::clamp(depth, 1, kMaxDmaDepth);
393
+ }
394
+
395
+ void panelSetVerticalScroll(int startRow)
396
+ {
397
+ panelSpanFlushComplete();
398
+ if (!gQspi.ready) return;
399
+ startRow %= kPanelHeight;
400
+ if (startRow < 0) startRow += kPanelHeight;
401
+
402
+ static bool regionDefined = false;
403
+ if (!regionDefined) {
404
+ // VSCRDEF: the whole panel is the scrolling area (TFA=0, VSA=600, BFA=0).
405
+ select();
406
+ writeRegister(0x33);
407
+ writeQspiByte(0x00);
408
+ writeQspiByte(0x00);
409
+ writeQspiByte(static_cast<std::uint8_t>(kPanelHeight >> 8));
410
+ writeQspiByte(static_cast<std::uint8_t>(kPanelHeight & 0xff));
411
+ writeQspiByte(0x00);
412
+ writeQspiByte(0x00);
413
+ deselect();
414
+ regionDefined = true;
415
+ }
416
+
417
+ select();
418
+ writeRegister(0x37);
419
+ writeQspiByte(static_cast<std::uint8_t>(startRow >> 8));
420
+ writeQspiByte(static_cast<std::uint8_t>(startRow & 0xff));
421
+ deselect();
422
+ }
423
+
424
+ void panelFlushRect(const std::uint16_t *pixels, int stridePixels, int x0, int y0, int x1, int y1)
425
+ {
426
+ panelSpanFlushComplete();
427
+ const std::uint64_t totalStartUs = time_us_64();
428
+ if (!gQspi.ready || !pixels || stridePixels <= 0) return;
429
+ x0 = std::max(0, x0);
430
+ y0 = std::max(0, y0);
431
+ x1 = std::min(kPanelWidth - 1, x1);
432
+ y1 = std::min(kPanelHeight - 1, y1);
433
+ if (x0 > x1 || y0 > y1) return;
434
+ roundMemoryWindow(&x0, &y0, &x1, &y1);
435
+
436
+ if (stridePixels == kPanelWidth) {
437
+ streamPreparedRect(x0, y0, x1, y1, rasterFramebufferChunk, const_cast<std::uint16_t *>(pixels));
438
+ } else {
439
+ const int width = x1 - x0 + 1;
440
+ gFlushStats.callCount++;
441
+ const std::uint64_t windowStartUs = time_us_64();
442
+ setWindow(x0, y0, x1 + 1, y1 + 1);
443
+ gFlushStats.setWindowUs += static_cast<std::int64_t>(time_us_64() - windowStartUs);
444
+ select();
445
+ writePixelRegister(0x2c);
446
+ channel_config_set_dreq(&gQspi.dmaConfig, pio_get_dreq(gQspi.pio, gQspi.sm, true));
447
+ if (gQspi.flushDepth <= 1) {
448
+ for (int y = y0; y <= y1;) {
449
+ const int rows = prepareChunk(gDmaChunk[0], pixels, stridePixels, x0, y, y1, width);
450
+ startDma(gDmaChunk[0], width * rows);
451
+ waitDma();
452
+ y += rows;
453
+ }
454
+ } else {
455
+ int y = y0;
456
+ int active = 0;
457
+ int rows = prepareChunk(gDmaChunk[active], pixels, stridePixels, x0, y, y1, width);
458
+ startDma(gDmaChunk[active], width * rows);
459
+ y += rows;
460
+ while (y <= y1) {
461
+ const int next = 1 - active;
462
+ const int nextRows = prepareChunk(gDmaChunk[next], pixels, stridePixels, x0, y, y1, width);
463
+ waitDma();
464
+ startDma(gDmaChunk[next], width * nextRows);
465
+ active = next;
466
+ y += nextRows;
467
+ }
468
+ waitDma();
469
+ }
470
+ deselect();
471
+ }
472
+ gFlushStats.totalUs += static_cast<std::int64_t>(time_us_64() - totalStartUs);
473
+ }
474
+
475
+ void setPullThreshold(uint threshold)
476
+ {
477
+ pio_sm_set_enabled(gQspi.pio, gQspi.sm, false);
478
+ hw_write_masked(&gQspi.pio->sm[gQspi.sm].shiftctrl,
479
+ (threshold & 0x1fu) << PIO_SM0_SHIFTCTRL_PULL_THRESH_LSB,
480
+ PIO_SM0_SHIFTCTRL_PULL_THRESH_BITS);
481
+ // The OSR shift counter carries across a threshold change: after the byte
482
+ // phase it reads "8 consumed", which under a new threshold of 32 makes the
483
+ // SM clock out 24 stale bits before the first autopull — every pixel then
484
+ // lands 3 bytes late (uniform hue corruption). Restart clears the shift
485
+ // state so the first OUT pulls fresh data. FIFO is drained by the caller.
486
+ pio_sm_restart(gQspi.pio, gQspi.sm);
487
+ pio_sm_set_enabled(gQspi.pio, gQspi.sm, true);
488
+ }
489
+
490
+ // DMA completion IRQ: span A finished — re-arm the SAME channel for span B.
491
+ // One channel throughout keeps the PIO DREQ pacing credits coherent (two
492
+ // channels handing over on one DREQ can drop a credit at the boundary).
493
+ void spanDmaIrqHandler()
494
+ {
495
+ if (!dma_irqn_get_channel_status(1, static_cast<uint>(gQspi.dma))) return;
496
+ dma_irqn_acknowledge_channel(1, static_cast<uint>(gQspi.dma));
497
+ if (gSpanBWords > 0) {
498
+ const std::uint8_t *src = gSpanBSrc;
499
+ const std::uint32_t words = gSpanBWords;
500
+ gSpanBWords = 0;
501
+ gSpanBSrc = nullptr;
502
+ dma_channel_configure(gQspi.dma,
503
+ &gSpanWordConfig,
504
+ &gQspi.pio->txf[gQspi.sm],
505
+ src,
506
+ words,
507
+ true);
508
+ }
509
+ }
510
+
511
+ // Settles a pending asynchronous span flush: waits out the (possibly IRQ
512
+ // re-armed) DMA and the PIO FIFO, restores the byte-oriented autopull
513
+ // threshold, and raises CS. Must run before any other panel traffic (every
514
+ // public panel entry point calls it). A stall past 30ms dumps the DMA/PIO
515
+ // state once; past 60ms it aborts the transfer and resyncs so a hardware
516
+ // hiccup costs one glitched frame instead of a wedge.
517
+ void panelSpanFlushComplete()
518
+ {
519
+ if (!gSpanActive) return;
520
+ const std::uint64_t startUs = time_us_64();
521
+ bool dumped = false;
522
+ while (gSpanBWords > 0 || dma_channel_is_busy(gQspi.dma)) {
523
+ const std::uint64_t waitedUs = time_us_64() - startUs;
524
+ if (!dumped && waitedUs > 30000) {
525
+ dumped = true;
526
+ gSpanStallCount++;
527
+ std::printf("gea.rp2350.span_stall n=%d bpend=%u ctrl=%08x count=%u fdebug=%08x flevel=%08x\n",
528
+ gSpanStallCount,
529
+ static_cast<unsigned>(gSpanBWords),
530
+ static_cast<unsigned>(dma_hw->ch[gQspi.dma].ctrl_trig),
531
+ static_cast<unsigned>(dma_hw->ch[gQspi.dma].transfer_count),
532
+ static_cast<unsigned>(gQspi.pio->fdebug),
533
+ static_cast<unsigned>(gQspi.pio->flevel));
534
+ std::fflush(stdout);
535
+ }
536
+ if (waitedUs > 60000) {
537
+ dma_channel_abort(gQspi.dma);
538
+ gSpanBWords = 0;
539
+ gSpanBSrc = nullptr;
540
+ pio_sm_clear_fifos(gQspi.pio, gQspi.sm);
541
+ break;
542
+ }
543
+ tight_loop_contents();
544
+ }
545
+ gFlushStats.txWaitUs += static_cast<std::int64_t>(time_us_64() - startUs);
546
+ // Drain the word burst, then restore the byte threshold for commands.
547
+ waitQspiIdle();
548
+ setPullThreshold(8);
549
+ gpio_put(kPinCs, 1);
550
+ gSpanActive = false;
551
+ gFlushStats.totalUs += static_cast<std::int64_t>(time_us_64() - startUs);
552
+ }
553
+
554
+ void panelFlushFullWidthSpans(const std::uint16_t *span0, int rows0,
555
+ const std::uint16_t *span1, int rows1,
556
+ int gramY0)
557
+ {
558
+ const std::uint64_t totalStartUs = time_us_64();
559
+ if (!gQspi.ready) return;
560
+ if (rows0 <= 0 && rows1 <= 0) return;
561
+ if (rows0 <= 0) {
562
+ span0 = span1;
563
+ rows0 = rows1;
564
+ span1 = nullptr;
565
+ rows1 = 0;
566
+ }
567
+ if (!span0) return;
568
+
569
+ const int totalRows = rows0 + (span1 ? rows1 : 0);
570
+ if (gramY0 < 0 || gramY0 + totalRows > kPanelHeight) return;
571
+
572
+ panelSpanFlushComplete();
573
+
574
+ // Commit pending framebuffer writes, then DMA 32-bit words from the
575
+ // uncached PSRAM alias: word transactions run ~4x fewer QMI round-trips
576
+ // than bytes (uncached bytes measured ~15MB/s; cached bytes ~35MB/s but
577
+ // thrash the 16KB XIP cache that code executes through). The DMA
578
+ // byte-swaps each word so the wire order matches the byte stream, and the
579
+ // PIO autopull threshold is widened to 32 for the burst. The kick returns
580
+ // without waiting: span B is re-armed from the completion IRQ and the
581
+ // settle happens lazily at the next panel op, so the CPU builds the next
582
+ // frame while the QSPI drains. Note the cache-clean here also snapshots
583
+ // the framebuffer for the in-flight TX: CPU writes during the overlap sit
584
+ // in the (write-back) XIP cache and only reach raw PSRAM on eviction, so
585
+ // the visible tear window is limited to evicted lines.
586
+ xip_cache_clean_all();
587
+ auto uncachedAlias = [](const std::uint16_t *p) -> const std::uint16_t * {
588
+ const auto addr = reinterpret_cast<uintptr_t>(p);
589
+ if (addr >= 0x11000000u && addr < 0x12000000u) {
590
+ return reinterpret_cast<const std::uint16_t *>(addr + 0x04000000u);
591
+ }
592
+ return p;
593
+ };
594
+
595
+ gFlushStats.callCount++;
596
+ const std::uint64_t windowStartUs = time_us_64();
597
+ setWindow(0, gramY0, kPanelWidth, gramY0 + totalRows);
598
+ gFlushStats.setWindowUs += static_cast<std::int64_t>(time_us_64() - windowStartUs);
599
+ select();
600
+ writePixelRegister(0x2c);
601
+ // Drain the command bytes, then widen autopull to a full word (threshold
602
+ // 32 encodes as 0) so 32-bit FIFO pushes shift out completely.
603
+ waitQspiIdle();
604
+ setPullThreshold(0);
605
+
606
+ gSpanWordConfig = gQspi.dmaConfig;
607
+ channel_config_set_transfer_data_size(&gSpanWordConfig, DMA_SIZE_32);
608
+ channel_config_set_bswap(&gSpanWordConfig, true);
609
+ channel_config_set_dreq(&gSpanWordConfig, pio_get_dreq(gQspi.pio, gQspi.sm, true));
610
+
611
+ gFlushStats.chunkCount++;
612
+ gFlushStats.pixelCount += kPanelWidth * totalRows;
613
+ // Arm span B for the completion IRQ BEFORE triggering span A.
614
+ if (span1 && rows1 > 0) {
615
+ gSpanBSrc = reinterpret_cast<const std::uint8_t *>(uncachedAlias(span1));
616
+ gSpanBWords = static_cast<std::uint32_t>((kPanelWidth * rows1) / 2);
617
+ } else {
618
+ gSpanBSrc = nullptr;
619
+ gSpanBWords = 0;
620
+ }
621
+ gSpanActive = true;
622
+ dma_channel_configure(gQspi.dma,
623
+ &gSpanWordConfig,
624
+ &gQspi.pio->txf[gQspi.sm],
625
+ reinterpret_cast<const std::uint8_t *>(uncachedAlias(span0)),
626
+ static_cast<std::uint32_t>((kPanelWidth * rows0) / 2),
627
+ true);
628
+ gFlushStats.totalUs += static_cast<std::int64_t>(time_us_64() - totalStartUs);
629
+ }
630
+
631
+ void panelStreamRect(int x0, int y0, int x1, int y1, PanelStreamRasterFn raster, void *user)
632
+ {
633
+ panelSpanFlushComplete();
634
+ const std::uint64_t totalStartUs = time_us_64();
635
+ if (!gQspi.ready || !raster) return;
636
+ x0 = std::max(0, x0);
637
+ y0 = std::max(0, y0);
638
+ x1 = std::min(kPanelWidth - 1, x1);
639
+ y1 = std::min(kPanelHeight - 1, y1);
640
+ if (x0 > x1 || y0 > y1) return;
641
+ roundMemoryWindow(&x0, &y0, &x1, &y1);
642
+ streamPreparedRect(x0, y0, x1, y1, raster, user);
643
+ gFlushStats.totalUs += static_cast<std::int64_t>(time_us_64() - totalStartUs);
644
+ }
645
+
646
+ void panelClear(std::uint16_t color)
647
+ {
648
+ panelSpanFlushComplete();
649
+ const std::uint64_t totalStartUs = time_us_64();
650
+ static std::uint16_t row[kPanelWidth];
651
+ std::fill_n(row, kPanelWidth, color);
652
+ gFlushStats.callCount++;
653
+ const std::uint64_t windowStartUs = time_us_64();
654
+ setWindow(0, 0, kPanelWidth, kPanelHeight);
655
+ gFlushStats.setWindowUs += static_cast<std::int64_t>(time_us_64() - windowStartUs);
656
+ select();
657
+ writePixelRegister(0x2c);
658
+ channel_config_set_dreq(&gQspi.dmaConfig, pio_get_dreq(gQspi.pio, gQspi.sm, true));
659
+ for (int y = 0; y < kPanelHeight; ++y) {
660
+ startDma(row, kPanelWidth);
661
+ waitDma();
662
+ }
663
+ deselect();
664
+ gFlushStats.totalUs += static_cast<std::int64_t>(time_us_64() - totalStartUs);
665
+ }
666
+
667
+ PanelFlushStats panelFlushStatsRead()
668
+ {
669
+ return gFlushStats;
670
+ }
671
+
672
+ void panelFlushStatsReset()
673
+ {
674
+ gFlushStats = {};
675
+ }
676
+
677
+ } // namespace gea::rp2350