├── .clang-format ├── .clang-format_files ├── .devcontainer └── devcontainer.json ├── .github └── workflows │ ├── build.yaml │ └── codeql.yml ├── .gitignore ├── CMakeLists.txt ├── LICENSE.TXT ├── cmake ├── ansi_colours_import.cmake └── pico_sdk_import.cmake ├── docker-compose.yml ├── docker ├── Dockerfile ├── debug.env └── entrypoint.sh ├── docs ├── contributing.md ├── licenses.md └── third_party_licenses │ ├── bsd-3-clause.txt │ └── lgpl-3.0.txt ├── hacks ├── 88-buspirate.rules ├── BusPirate.sh ├── BusPirateSetup.sh ├── build_ASCII_struct.html ├── build_server.md ├── build_server_condensed.md ├── chk.sh ├── img │ ├── bus_pirate_vscode_cmake_settings.pdn │ └── bus_pirate_vscode_cmake_settings.png ├── macro.mcr ├── rtt_debugging.md ├── show_port_info.ps1 ├── test.tut └── translate-parse-h.html ├── img ├── bp5rev10-cover-angle.jpg └── teraterm-done.png ├── readme.md ├── scope.README.md └── src ├── CMakeLists.txt ├── binmode ├── binio.c ├── binio.h ├── binio_helpers.c ├── binio_helpers.h ├── binmodes.c ├── binmodes.h ├── dirtyproto.c ├── dirtyproto.h ├── fala.c ├── fala.h ├── falaio.c ├── falaio.h ├── irtoy-air.c ├── irtoy-air.h ├── irtoy-irman.c ├── irtoy-irman.h ├── legacy4third.c ├── legacy4third.h ├── logicanalyzer.c ├── logicanalyzer.h ├── logicanalyzer.pio ├── sump.c └── sump.h ├── boards ├── buspirate5.h ├── buspirate5xl.h ├── buspirate6.h ├── buspirate7.h ├── memmap_default_rp2040.ld ├── memmap_default_rp2350.ld └── memmap_psram_rp2350.ld ├── bytecode.h ├── command_struct.h ├── commands.c ├── commands.h ├── commands ├── 1wire │ ├── demos.c │ ├── demos.h │ ├── scan.c │ └── scan.h ├── 2wire │ ├── hw2w_sniff.c │ ├── hw2w_sniff.h │ ├── sle4442.c │ └── sle4442.h ├── global │ ├── a_auxio.c │ ├── a_auxio.h │ ├── bug.c │ ├── bug.h │ ├── button_scr.c │ ├── button_scr.h │ ├── cls.c │ ├── cls.h │ ├── cmd_binmode.c │ ├── cmd_binmode.h │ ├── cmd_convert.c │ ├── cmd_convert.h │ ├── cmd_mcu.c │ ├── cmd_mcu.h │ ├── cmd_selftest.c │ ├── cmd_selftest.h │ ├── disk.c │ ├── disk.h │ ├── dummy.c │ ├── dummy.h │ ├── dump.c │ ├── dump.h │ ├── freq.c │ ├── freq.h │ ├── h_help.c │ ├── h_help.h │ ├── i_info.c │ ├── i_info.h │ ├── image.c │ ├── image.h │ ├── l_bitorder.c │ ├── l_bitorder.h │ ├── logic.c │ ├── logic.h │ ├── macro.c │ ├── macro.h │ ├── otpdump.c │ ├── otpdump.h │ ├── ovrclk.c │ ├── ovrclk.h │ ├── p_pullups.c │ ├── p_pullups.h │ ├── pause.c │ ├── pause.h │ ├── pwm.c │ ├── pwm.h │ ├── script.c │ ├── script.h │ ├── smps.c │ ├── smps.h │ ├── tutorial.c │ ├── tutorial.h │ ├── v_adc.c │ ├── v_adc.h │ ├── w_psu.c │ └── w_psu.h ├── hdplxuart │ ├── bridge.c │ └── bridge.h ├── i2c │ ├── ddr.c │ ├── ddr.h │ ├── demos.c │ ├── demos.h │ ├── scan.c │ ├── scan.h │ ├── sniff.c │ ├── sniff.h │ └── sniff.md ├── i2s │ ├── sine.c │ └── sine.h ├── infrared │ ├── irtxrx.c │ ├── irtxrx.h │ ├── tvbgone-codes.h │ ├── tvbgone.c │ └── tvbgone.h ├── jtag │ ├── bluetag.c │ └── bluetag.h ├── spi │ ├── flash.c │ ├── flash.h │ ├── sniff.c │ ├── sniff.h │ ├── spiflash.c │ └── spiflash.h └── uart │ ├── bridge.c │ ├── bridge.h │ ├── glitch.c │ ├── glitch.h │ ├── glitch.pio │ ├── monitor.c │ ├── monitor.h │ ├── nmea.c │ ├── nmea.h │ ├── simcard.c │ └── simcard.h ├── debug_rtt.c ├── debug_rtt.h ├── debug_uart.c ├── debug_uart.h ├── dhara ├── bytes.h ├── error.c ├── error.h ├── journal.c ├── journal.h ├── map.c ├── map.h ├── nand.c └── nand.h ├── display ├── background.h ├── background_image_v4-orig.h ├── background_image_v4.h ├── backv2b-2.bmp ├── default.c ├── default.h ├── image.py ├── robot16.bmp ├── robot16.h ├── robot24.bmp ├── robot5x16.bmp ├── robot5x16.h ├── robot5xx16.bmp ├── robot5xx16.h ├── robot6x16.bmp ├── robot6x16.h ├── scope.c └── scope.h ├── displays.c ├── displays.h ├── fatfs ├── 00history.txt ├── 00readme.txt ├── diskio.c ├── diskio.h ├── ff.c ├── ff.h ├── ffconf.h ├── ffsystem.c ├── ffunicode.c ├── tf_card.c └── tf_card.h ├── font ├── font.h ├── hunter-12pt-16h13w.h ├── hunter-14pt-19h15w.h ├── hunter-20pt-21h21w.h ├── hunter-23pt-24h24w.h └── hunter.h ├── lib ├── arduino-ch32v003-swio │ ├── LICENSE │ ├── Makefile │ ├── README.md │ ├── arduino_ch32v003.c │ ├── arduino_ch32v003.h │ ├── flash.sh │ ├── main.c │ ├── swio.c │ ├── swio.h │ ├── uart.c │ └── uart.h ├── bluetag │ ├── CHANGELOG.md │ ├── Dockerfile │ ├── LICENSE │ ├── README.md │ ├── images │ │ ├── BlueTag.png │ │ └── BlueTagPinout.png │ └── src │ │ ├── blueTag.c │ │ ├── blueTag.h │ │ └── jep106.inc ├── i2c_address_list │ ├── 0x00-0x0F.md │ ├── 0x10-0x1F.md │ ├── 0x20-0x2F.md │ ├── 0x30-0x3F.md │ ├── 0x40-0x4F.md │ ├── 0x50-0x5F.md │ ├── 0x60-0x6F.md │ ├── 0x70-0x7F.md │ ├── LICENSES │ │ ├── MIT.txt │ │ └── Unlicense.txt │ ├── README.md │ ├── README.md.license │ ├── dev_i2c_addresses copy.py │ ├── dev_i2c_addresses.h │ ├── dev_i2c_addresses.ht │ ├── dev_i2c_addresses.py │ ├── special_cases.md │ └── troublesome_chips.md ├── minmea │ ├── COPYING │ ├── LICENSE.LGPL-3.0 │ ├── LICENSE.MIT │ ├── LICENSE.grants │ ├── README.md │ ├── example.c │ ├── gps.c │ ├── gps.h │ ├── minmea.c │ ├── minmea.h │ └── tests.c ├── ms5611 │ ├── LICENSE │ ├── README.md │ ├── ms5611.c │ └── ms5611.h ├── pico-i2c-sniff │ ├── .gitignore │ ├── CMakeLists.txt │ ├── LICENSE │ ├── README.md │ ├── hw2w_sniffer.pio │ ├── i2c_sniffer.pio │ ├── main.c │ ├── ram_fifo.c │ ├── ram_fifo.h │ └── test_i2c_sniffer │ │ └── status_tof │ │ └── status_tof.ino ├── pico_ir_nec │ ├── ir_loopback.c │ ├── nec_carrier_burst.pio │ ├── nec_carrier_control.pio │ ├── nec_receive.c │ ├── nec_receive.h │ ├── nec_receive.pio │ ├── nec_transmit.c │ └── nec_transmit.h ├── picofreq │ ├── LICENSE │ ├── picofreq.c │ └── picofreq.h ├── picorvd │ ├── PicoSWIO.cpp │ ├── ch32vswio.pio │ ├── debug_defines.h │ ├── picoswio.c │ └── picoswio.h ├── pio_pwm │ └── pwm.pio ├── rtt │ ├── Config │ │ └── SEGGER_RTT_Conf.h │ ├── Examples │ │ ├── Main_RTT_InputEchoApp.c │ │ ├── Main_RTT_MenuApp.c │ │ ├── Main_RTT_PrintfTest.c │ │ └── Main_RTT_SpeedTestApp.c │ ├── LICENSE.md │ ├── README.md │ ├── RTT │ │ ├── SEGGER_RTT.c │ │ ├── SEGGER_RTT.h │ │ ├── SEGGER_RTT_ASM_ARMv7M.S │ │ └── SEGGER_RTT_printf.c │ └── Syscalls │ │ ├── SEGGER_RTT_Syscalls_GCC.c │ │ ├── SEGGER_RTT_Syscalls_IAR.c │ │ ├── SEGGER_RTT_Syscalls_KEIL.c │ │ └── SEGGER_RTT_Syscalls_SES.c ├── sfud │ ├── LICENSE │ ├── README.md │ └── inc │ │ ├── app.c │ │ ├── sfud.c │ │ ├── sfud.h │ │ ├── sfud_cfg.h │ │ ├── sfud_def.h │ │ ├── sfud_flash_def.h │ │ ├── sfud_port-stm32.c │ │ ├── sfud_port.c │ │ └── sfud_sfdp.c ├── sigrok │ ├── pico_sdk_sigrok.c │ ├── pico_sdk_sigrok.h │ └── sr_device.h └── tsl2561 │ ├── LICENSE │ ├── README.md │ ├── driver_tsl2561.c │ └── driver_tsl2561.h ├── mjson ├── mjson.c └── mjson.h ├── mode ├── HD44780.c ├── HD44780.h ├── LCDSPI.c ├── LCDSPI.h ├── ST7735.c ├── ST7735.h ├── SW2W.c ├── SW2W.h ├── SW3W.c ├── SW3W.h ├── SWI2C.c ├── SWI2C.h ├── binloopback.c ├── binloopback.h ├── dio.c ├── dio.h ├── dummy1.c ├── dummy1.h ├── hiz.c ├── hiz.h ├── hw1wire.c ├── hw1wire.h ├── hw2wire.c ├── hw2wire.h ├── hw3wire.c ├── hw3wire.h ├── hwhduart.c ├── hwhduart.h ├── hwi2c.c ├── hwi2c.h ├── hwled.c ├── hwled.h ├── hwspi.c ├── hwspi.h ├── hwuart.c ├── hwuart.h ├── i2s.c ├── i2s.h ├── i2s_in.pio ├── i2s_out.pio ├── infrared-struct.h ├── infrared.c ├── infrared.h ├── jtag.c ├── jtag.h ├── sw1wire.c ├── sw1wire.h ├── usbpd-defs.h ├── usbpd.c └── usbpd.h ├── modes.c ├── modes.h ├── msc_disk.c ├── msc_disk.h ├── nand ├── LICENSE ├── README.md ├── nand.c ├── nand.h ├── nand_ftl_diskio.c ├── nand_ftl_diskio.h ├── spi.c ├── spi.h ├── spi_nand.c ├── spi_nand.h ├── sys_time.c └── sys_time.h ├── pio_config.h ├── pirate.c ├── pirate.h ├── pirate ├── amux.c ├── amux.h ├── apa102.pio ├── bio.c ├── bio.h ├── button.c ├── button.h ├── hw1wire.pio ├── hw1wire_pio.c ├── hw1wire_pio.h ├── hw2wire.pio ├── hw2wire_pio.c ├── hw2wire_pio.h ├── hw3wire.pio ├── hw3wire_pio.c ├── hw3wire_pio.h ├── hwi2c.pio ├── hwi2c_pio.c ├── hwi2c_pio.h ├── hwspi.c ├── hwspi.h ├── hwuart.pio ├── hwuart_pio.c ├── hwuart_pio.h ├── intercore_helpers.c ├── intercore_helpers.h ├── irio.pio ├── irio_pio.c ├── irio_pio.h ├── lcd.c ├── lcd.h ├── lsb.c ├── lsb.h ├── mcu.c ├── mcu.h ├── mem.c ├── mem.h ├── onewire_library.c ├── onewire_library.h ├── onewire_library.pio ├── psu.c ├── psu.h ├── pullup.c ├── pullup.h ├── pwm.pio ├── rc5.pio ├── rc5_2.pio ├── rc5_pio.c ├── rc5_pio.h ├── rgb.c ├── rgb.h ├── shift.c ├── shift.h ├── spisnif.pio ├── storage.c ├── storage.h └── ws2812.pio ├── platform ├── bpi5-rev10.c ├── bpi5-rev10.h ├── bpi5-rev8.c ├── bpi5-rev8.h ├── bpi5-rev9.c ├── bpi5-rev9.h ├── bpi5xl-rev0.c ├── bpi5xl-rev0.h ├── bpi6-rev2.c ├── bpi6-rev2.h ├── bpi7-rev0.c └── bpi7-rev0.h ├── printf-4.0.0 ├── .gitattributes ├── .travis.yml ├── LICENSE ├── Makefile ├── README.md ├── codecov.yml ├── printf.c ├── printf.h └── test │ ├── catch.hpp │ └── test_suite.cpp ├── queue.c ├── queue.h ├── syntax.c ├── syntax.h ├── syntax_struct.h ├── system_config.c ├── system_config.h ├── system_monitor.c ├── system_monitor.h ├── toolbars ├── logic_bar.c └── logic_bar.h ├── translation ├── base.c ├── base.h ├── bs-ba.h ├── editor │ ├── jquery-3.7.1.js │ ├── jquery-ui-1.14.1.dark │ │ ├── AUTHORS.txt │ │ ├── LICENSE.txt │ │ ├── external │ │ │ └── jquery │ │ │ │ └── jquery.js │ │ ├── images │ │ │ ├── ui-bg_glass_20_555555_1x400.png │ │ │ ├── ui-bg_glass_40_0078a3_1x400.png │ │ │ ├── ui-bg_glass_40_ffc73d_1x400.png │ │ │ ├── ui-bg_gloss-wave_25_333333_500x100.png │ │ │ ├── ui-bg_highlight-soft_80_eeeeee_1x100.png │ │ │ ├── ui-bg_inset-soft_25_000000_1x100.png │ │ │ ├── ui-bg_inset-soft_30_f58400_1x100.png │ │ │ ├── ui-icons_222222_256x240.png │ │ │ ├── ui-icons_4b8e0b_256x240.png │ │ │ ├── ui-icons_a83300_256x240.png │ │ │ ├── ui-icons_cccccc_256x240.png │ │ │ └── ui-icons_ffffff_256x240.png │ │ ├── index.html │ │ ├── jquery-ui.css │ │ ├── jquery-ui.js │ │ ├── jquery-ui.min.css │ │ ├── jquery-ui.min.js │ │ ├── jquery-ui.structure.css │ │ ├── jquery-ui.structure.min.css │ │ ├── jquery-ui.theme.css │ │ ├── jquery-ui.theme.min.css │ │ └── package.json │ └── translation_editor.html ├── en-us.h ├── history │ └── en-us.json ├── it-it.h ├── json2h.bat ├── json2h.py ├── pl-pl.h ├── templates │ ├── base.ht │ ├── bs-ba.json │ ├── it-it.json │ ├── pl-pl.json │ ├── translation.ht │ └── zh-cn.json └── zh-cn.h ├── tusb_config.h ├── ui ├── ui_button.c ├── ui_button.h ├── ui_cmdln.c ├── ui_cmdln.h ├── ui_config.c ├── ui_config.h ├── ui_const.c ├── ui_const.h ├── ui_display.c ├── ui_display.h ├── ui_flags.h ├── ui_format.c ├── ui_format.h ├── ui_help.c ├── ui_help.h ├── ui_info.c ├── ui_info.h ├── ui_init.c ├── ui_init.h ├── ui_lcd.c ├── ui_lcd.h ├── ui_mode.c ├── ui_mode.h ├── ui_parse.c ├── ui_parse.h ├── ui_process.c ├── ui_process.h ├── ui_prompt.c ├── ui_prompt.h ├── ui_statusbar.c ├── ui_statusbar.h ├── ui_term.c └── ui_term.h ├── usb_descriptors.c ├── usb_rx.c ├── usb_rx.h ├── usb_tx.c ├── usb_tx.h ├── wavegen.c ├── wavegen.h └── wavegen.pio /.clang-format: -------------------------------------------------------------------------------- 1 | BasedOnStyle: Mozilla 2 | IndentWidth: 4 3 | TabWidth: 4 4 | UseTab: Never 5 | ContinuationIndentWidth: 4 6 | ConstructorInitializerIndentWidth: 4 7 | AllowAllArgumentsOnNextLine: true 8 | AllowAllParametersOfDeclarationOnNextLine: true 9 | NamespaceIndentation: All 10 | SortIncludes: false 11 | InsertBraces: true 12 | BreakBeforeBraces: Attach 13 | ColumnLimit: 120 14 | UseCRLF: true 15 | AlwaysBreakAfterReturnType: None 16 | AlwaysBreakAfterDefinitionReturnType: None 17 | 18 | AlignConsecutiveBitFields: 19 | Enabled: false 20 | AllowShortEnumsOnASingleLine: false 21 | InsertTrailingCommas: Wrapped 22 | -------------------------------------------------------------------------------- /.devcontainer/devcontainer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "BusPirate v5+ Build Environment", 3 | "image": "wyatt3arp/buspirate_v5plus:latest", 4 | "dockerComposeFile": "../docker-compose.yml", 5 | "service": "dev", 6 | "workspaceFolder": "/project", 7 | "remoteUser": "build", 8 | "mounts": [ 9 | "source=${localWorkspaceFolder}/,target=/project,type=bind,consistency=cached" 10 | ] 11 | } -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | build/** 2 | build_*/** 3 | .vscode/** 4 | .env 5 | 6 | src/translation/history/new__en-us.json 7 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # == DO NEVER EDIT THE NEXT LINES for Raspberry Pi Pico VS Code Extension to work == 2 | if(WIN32) 3 | set(USERHOME $ENV{USERPROFILE}) 4 | else() 5 | set(USERHOME $ENV{HOME}) 6 | endif() 7 | if(WIN32) 8 | set(sdkVersion 2.0.0) 9 | set(toolchainVersion 13_2_Rel1) 10 | set(picotoolVersion 2.0.0) 11 | include(${USERHOME}/.pico-sdk/cmake/pico-vscode.cmake) 12 | endif() 13 | # ==================================================================================== 14 | cmake_minimum_required(VERSION 3.21) 15 | 16 | # Could use target_compile_features() instead of explicitly `set(C_STANDARD 23)` with `set(C_STANDARD_REQUIRED ON)` 17 | # but would need to list all the features relied upon, which can be a bit of a pain. 18 | # This may result in the use of /std:gnu2x or /std:c23 depending on compiler version. 19 | set(CMAKE_C_STANDARD 23) 20 | set(CMAKE_C_STANDARD_REQUIRED ON) 21 | set(CMAKE_CXX_STANDARD 17) 22 | 23 | # initalize pico_sdk from installed location 24 | # (note this can come from environment, CMake cache etc) 25 | #set(PICO_SDK_PATH "C:/pico113/pico-sdk") 26 | 27 | # Add my_pico_w.h 28 | set(PICO_BOARD_HEADER_DIRS ${CMAKE_CURRENT_LIST_DIR}/src/boards ) 29 | # Add my_pico_w.cmake 30 | set(PICO_BOARD_CMAKE_DIRS ${CMAKE_CURRENT_LIST_DIR}/src/boards ) 31 | # Add my_pico_w 32 | # 33 | 34 | if(DEFINED GIT_COMMIT_HASH) 35 | set(BP_FIRMWARE_HASH ${GIT_COMMIT_HASH}) 36 | else() 37 | set(BP_FIRMWARE_HASH "unknown") 38 | endif() 39 | message(GIT_COMMIT_HASH="${GIT_COMMIT_HASH}") 40 | message(BP_FIRMWARE_HASH="${BP_FIRMWARE_HASH}") 41 | 42 | if(${BP_PICO_PLATFORM} MATCHES "rp2350") 43 | set(PICO_PLATFORM "rp2350") #compile for 5XL and 6 44 | set(PICO_BOARD buspirate6) 45 | else() 46 | set(PICO_PLATFORM "rp2040") #compile for 5 rev8 and 5 rev10 47 | set(PICO_BOARD buspirate5) 48 | endif() 49 | 50 | 51 | 52 | # Pull in Raspberry Pi Pico SDK (must be before project) 53 | include(cmake/pico_sdk_import.cmake) 54 | 55 | project(bus_pirate C CXX ASM) 56 | 57 | 58 | add_subdirectory(src) 59 | -------------------------------------------------------------------------------- /LICENSE.TXT: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 Ian Lesnet, Where Labs LLC 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /cmake/ansi_colours_import.cmake: -------------------------------------------------------------------------------- 1 | # Author: Lior Shalmay 2 | # Description: This files imports the project "ansi_colours" (located at https://github.com/mina86/ansi_colours.git). 3 | # That project helps converting RGB colors to ANSI 256 colors, in order to support non-trurcolor terminals. 4 | # Copyright (c) 2024 Lior Shalmay 5 | # 6 | # Note: The ansi_colours project is distributed under LGPL3. If you don't want to 7 | # include that license then disable ANSI 256 color support (enabled by default). 8 | # For further license explanation, please look at the docs/licenses.md file. 9 | # copyright notice: 10 | # the used ansi_colours code (ansi256.c ansi_colours.h) is copyrighted by the following people: 11 | # Michał Nazarewicz 2018 12 | 13 | set(ANSI_COLOURS_GIT_URL "https://github.com/mina86/ansi_colours.git") 14 | set(ANSI_COLOURS_GIT_TAG "v1.2.2") 15 | set(ANSI_COLOURS_PATH "" CACHE PATH "Path to the ansi_colours library's source code") 16 | 17 | set(LEGACY_ANSI_COLOURS_ENABLED TRUE CACHE BOOL "Chooses to include the ansi_colours project or not to include it") 18 | 19 | if(USE_LGPL3) 20 | if(LEGACY_ANSI_COLOURS_ENABLED) 21 | if(NOT ANSI_COLOURS_PATH) 22 | include(FetchContent) 23 | set(FETCHCONTENT_BASE_DIR_SAVE ${FETCHCONTENT_BASE_DIR}) 24 | FetchContent_Declare( 25 | ansi_colours 26 | GIT_REPOSITORY ${ANSI_COLOURS_GIT_URL} 27 | GIT_TAG ${ANSI_COLOURS_GIT_TAG} 28 | ) 29 | FetchContent_Populate(ansi_colours) 30 | set(ANSI_COLOURS_PATH ${ansi_colours_SOURCE_DIR} CACHE PATH "Path to the ansi_colours library's source code" FORCE) 31 | endif() 32 | add_compile_definitions(ANSI_COLOR_256) 33 | include_directories(AFTER ${ANSI_COLOURS_PATH}/src/) 34 | add_library(lib_ansi_colours STATIC ${ANSI_COLOURS_PATH}/src/ansi256.c) 35 | endif() 36 | endif() 37 | -------------------------------------------------------------------------------- /docker-compose.yml: -------------------------------------------------------------------------------- 1 | services: 2 | base: 3 | image: "wyatt3arp/buspirate_v5plus:latest" 4 | build: ./docker 5 | network_mode: host 6 | privileged: false 7 | tty: true 8 | stdin_open: true 9 | user: "${UID}:${GID}" 10 | volumes: 11 | - .:/project 12 | working_dir: '/project' 13 | 14 | dev: 15 | extends: 16 | service: base 17 | environment: 18 | - MODE=development 19 | 20 | dev-debug: 21 | extends: 22 | service: base 23 | environment: 24 | - MODE=debug 25 | devices: 26 | - ${BP_PORT0:-/dev/ttyACM0} 27 | - ${BP_PORT1:-/dev/ttyACM1} 28 | volumes: 29 | - /dev/bus/usb:/dev/bus/usb 30 | -------------------------------------------------------------------------------- /docker/debug.env: -------------------------------------------------------------------------------- 1 | # update these to your mapped USB ports 2 | BP_PORT0=/dev/ttyACM0 3 | BP_PORT1=/dev/ttyACM1 4 | -------------------------------------------------------------------------------- /docker/entrypoint.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if [ -z "$1" ]; then 4 | bash 5 | elif [[ "$1" == "build-clean" ]]; then 6 | cd /project; 7 | mkdir build; 8 | cd build; 9 | rm -rf *; 10 | cmake ../; 11 | make; 12 | else 13 | echo "Running $1" 14 | set -ex 15 | bash -c "$1" 16 | fi 17 | -------------------------------------------------------------------------------- /docs/contributing.md: -------------------------------------------------------------------------------- 1 | # Contributing.md 2 | This document contains all the rules and conventions that contributors must follow. 3 | 4 | All the content in this document is copyrighted by the following authors: 5 | * Copyright (c) 2024 Lior Shalmay 6 | 7 | ## Coding Convention 8 | TBD 9 | 10 | ## Copyrights 11 | You may copyright your contributed code, under the following rules: 12 | 13 | * You must add your name to the "copyright notices" section in `docs/licenses.md`. 14 | * You must use the following signature `Copyright (c) []`, 15 | see the above copyright also as an example. 16 | * If you contributed a new file, you may place the copyright notice at the top of the file. 17 | * If you modify an existing file, add your copyright notice under the previous one, with the `Modified by` designation beforehand. 18 | * If there is no previous copyright notice, add your designation somewhere at the top of the file. 19 | * You must not copyright code that is not yours! 20 | 21 | ## Licensing 22 | You must contribute your code under the MIT license. 23 | 24 | ### 3rd party code 25 | You may use 3rd party library in you contribution. 26 | but then you must follow these rules: 27 | 28 | * You must make sure that the library's license is compatible with MIT license. 29 | * You must document the library and the related copyright notices in `docs/licenses.md`. 30 | * You must save a copy of the 3rd party library license in `docs/third_party_licenses`. 31 | * You must document which source files in this project are using the library in `docs/licenses.md`. 32 | * You must provide a way to fetch the library code from outside of this project. 33 | * Depending on the license you may need to provide a way to compile this project without the library. 34 | 35 | 36 | -------------------------------------------------------------------------------- /docs/third_party_licenses/bsd-3-clause.txt: -------------------------------------------------------------------------------- 1 | Copyright 2 | 3 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 4 | 5 | 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 6 | 7 | 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in 8 | the documentation and/or other materials provided with the distribution. 9 | 10 | 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this 11 | software without specific prior written permission. 12 | 13 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 14 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS 15 | BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 16 | GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 17 | LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 18 | -------------------------------------------------------------------------------- /hacks/88-buspirate.rules: -------------------------------------------------------------------------------- 1 | # BusPirate 5 / 5XL / 6 -- OPTIONAL udev rules 2 | # 3 | # copy this file to `/etc/udev/rules.conf/88-buspirate.rules 4 | # 5 | # This file is ENTIRELY optional. It does the following: 6 | # 7 | # 1. Sets the group owner to `dialout` 8 | # 9 | # 2. Sets the permissions to 0660 to allow `dialout` group read/write access 10 | # 11 | # 2. Creates two symlinks with friendlier names: 12 | # /dev/buspirate-%n := serial console (interactive use) 13 | # /dev/buspirate-bin-%n := binary mode interfaces 14 | # 15 | # Note that the `%n` value will correspond to the `/dev/tty%n` value. 16 | # (There is no simple way to force these to number sequentially from 17 | # zero without holes in the numbering.) 18 | # 19 | 20 | SUBSYSTEM=="tty", ATTRS{idVendor}=="1209", ATTRS{idProduct}=="7331", ENV{ID_USB_INTERFACE_NUM}=="00", SYMLINK+="buspirate-%n", MODE="660", GROUP="dialout" 21 | SUBSYSTEM=="tty", ATTRS{idVendor}=="1209", ATTRS{idProduct}=="7331", ENV{ID_USB_INTERFACE_NUM}=="02", SYMLINK+="buspirate-bin-%n", MODE="660", GROUP="dialout" 22 | 23 | SUBSYSTEM=="usb", ATTRS{idVendor}=="1209", ATTRS{idProduct}=="7331", SYMLINK+="buspirate-uf2-%n", MODE="660", GROUP="dialout" 24 | SUBSYSTEM=="usb", ATTRS{idVendor}=="1209", ATTRS{idProduct}=="7332", SYMLINK+="buspirate-uf2-%n", MODE="660", GROUP="dialout" 25 | SUBSYSTEM=="usb", ATTRS{idVendor}=="2e8a", ATTRS{idProduct}=="000f", SYMLINK+="raspberry-pi-uf2-%n", MODE="660", GROUP="dialout" 26 | -------------------------------------------------------------------------------- /hacks/build_ASCII_struct.html: -------------------------------------------------------------------------------- 1 | 6 |
7 | 8 | 14 | -------------------------------------------------------------------------------- /hacks/chk.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # exit immediately if a command exits with a non-zero status 4 | # -e exits on error 5 | # -u errors on undefined variables 6 | # -x prints commands before execution 7 | # -o (for option) pipefail exits on command pipe failures 8 | # Some gotchas and workarounds are documented well at following: 9 | # https://vaneyckt.io/posts/safer_bash_scripts_with_set_euxo_pipefail/ 10 | # 11 | # The shell does **_NOT_** exit if the command that fails is: 12 | # * part of the command list immediately following a `while` or `until` keyword; 13 | # * part of the test following the `if` or `elif` reserved words; 14 | # * part of any command executed in a `&&` or `||` list, except the command following the final `&&` or `||`; 15 | # * any command in a pipeline, except the last command in the pipeline; or 16 | # * if the command's return value is being inverted with `!` 17 | set -euxo pipefail 18 | 19 | # First version: 20 | # * Current working directory must be depot root. 21 | # * Run as `./hacks/chk.sh` 22 | # TODO: 23 | # * [ ] Automatically set proper working directory (depot root, parent of script directory) 24 | # * [ ] Add cmd-line option `--clean` to do clean build 25 | # * [ ] Add cmd-line option `--translations` to generate updated translation files 26 | # * [ ] Detect errors and stop script when detected 27 | # * [x] Maybe set bash to exit on errors ... `set -e`? 28 | 29 | # update CMake for both rp2040 builds and rp2350 builds 30 | cmake -S . -B build_rp2040 -DPICO_SDK_FETCH_FROM_GIT=TRUE 31 | cmake -S . -B build_rp2350 -DPICO_SDK_FETCH_FROM_GIT=TRUE -DBP_PICO_PLATFORM=rp2350 32 | 33 | # optionally, do a clean build each time 34 | cmake --build ./build_rp2040 --parallel --target clean 35 | cmake --build ./build_rp2350 --parallel --target clean 36 | 37 | # optionally, update the translation files 38 | # TODO: Run `./src/translation/json2h.py` to generate updated translation files 39 | python ./src/translation/json2h.py 40 | 41 | # build everything 42 | cmake --build ./build_rp2040 --parallel --target all 43 | cmake --build ./build_rp2350 --parallel --target all 44 | 45 | 46 | -------------------------------------------------------------------------------- /hacks/img/bus_pirate_vscode_cmake_settings.pdn: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DangerousPrototypes/BusPirate5-firmware/c3ac15d7ce16e710c05117b1614dcef9854187d4/hacks/img/bus_pirate_vscode_cmake_settings.pdn -------------------------------------------------------------------------------- /hacks/img/bus_pirate_vscode_cmake_settings.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DangerousPrototypes/BusPirate5-firmware/c3ac15d7ce16e710c05117b1614dcef9854187d4/hacks/img/bus_pirate_vscode_cmake_settings.png -------------------------------------------------------------------------------- /hacks/macro.mcr: -------------------------------------------------------------------------------- 1 | # Example of a macro file. 2 | # Lines starting with '#' are comments 3 | # Lines starting with '#!' are usage instructions and are printed when 4 | # requesting macro id 0 5 | # Every macro line is composed of an an id (>0), a separator ':' and a 6 | # macro in bus syntax 7 | 8 | #! Get status 9 | 1:{ 0:125 0xc0 } 10 | 11 | #! ClearTrqStatus 12 | 2: {d:125 0x00 0x00 } 13 | 14 | #! setPacketType GFSK 15 | 3: {d:125 0x00 0x00 } 16 | 17 | #! setRfFrequency 2.4GHz 18 | 4:{ d:125 0x86 0xb8 0x9d 0x89} 19 | -------------------------------------------------------------------------------- /hacks/test.tut: -------------------------------------------------------------------------------- 1 | # This is a sample tutorial! 2 | # Welcome! 3 | # This is some syntax, hit enter to execute it! 4 | [0x00 0xff r:2] 5 | # This is a comment! It's not executed! 6 | # Here's a full on command! 7 | # Hit enter to execute it! 8 | pause 9 | # Did it pause? -------------------------------------------------------------------------------- /hacks/translate-parse-h.html: -------------------------------------------------------------------------------- 1 | 6 |
7 | 8 | 56 | -------------------------------------------------------------------------------- /img/bp5rev10-cover-angle.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DangerousPrototypes/BusPirate5-firmware/c3ac15d7ce16e710c05117b1614dcef9854187d4/img/bp5rev10-cover-angle.jpg -------------------------------------------------------------------------------- /img/teraterm-done.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DangerousPrototypes/BusPirate5-firmware/c3ac15d7ce16e710c05117b1614dcef9854187d4/img/teraterm-done.png -------------------------------------------------------------------------------- /src/binmode/binio_helpers.c: -------------------------------------------------------------------------------- 1 | // #include 2 | #include 3 | #include "pico/stdlib.h" 4 | #include "pirate.h" 5 | #include "queue.h" 6 | #include "usb_rx.h" 7 | #include "usb_tx.h" 8 | #include "pirate/bio.h" 9 | #include "system_config.h" 10 | #include "bytecode.h" //needed because modes.h has some functions that use it TODO: move all the opt args and bytecode stuff to a single helper file 11 | #include "command_struct.h" //needed for same reason as bytecode and needs same fix 12 | #include "modes.h" 13 | 14 | void script_send(const char* c, uint32_t len) { 15 | for (uint32_t i = 0; i < len; i++) { 16 | bin_tx_fifo_put(c[i]); 17 | } 18 | } 19 | 20 | void script_reset(void) { 21 | modes[system_config.mode].protocol_cleanup(); // switch to HiZ 22 | modes[0].protocol_setup_exc(); // disables power supply etc. 23 | 24 | // POWER|PULLUP|AUX|MOSI|CLK|MISO|CS 25 | static const char pin_labels[][5] = { "BIO0", "BIO1", "BIO2", "BIO3", "BIO4", "BIO5", "BIO6", "BIO7" }; 26 | system_bio_update_purpose_and_label(true, BIO0, BP_PIN_MODE, pin_labels[0]); 27 | system_bio_update_purpose_and_label(true, BIO1, BP_PIN_MODE, pin_labels[1]); 28 | system_bio_update_purpose_and_label(true, BIO2, BP_PIN_MODE, pin_labels[2]); 29 | system_bio_update_purpose_and_label(true, BIO3, BP_PIN_MODE, pin_labels[3]); 30 | system_bio_update_purpose_and_label(true, BIO4, BP_PIN_MODE, pin_labels[4]); 31 | system_bio_update_purpose_and_label(true, BIO5, BP_PIN_MODE, pin_labels[5]); 32 | system_bio_update_purpose_and_label(true, BIO6, BP_PIN_MODE, pin_labels[6]); 33 | system_bio_update_purpose_and_label(true, BIO7, BP_PIN_MODE, pin_labels[7]); 34 | } -------------------------------------------------------------------------------- /src/binmode/binio_helpers.h: -------------------------------------------------------------------------------- 1 | void script_reset(void); 2 | // void script_print(const char *str); 3 | void script_send(const char* c, uint32_t len); 4 | -------------------------------------------------------------------------------- /src/binmode/binmodes.h: -------------------------------------------------------------------------------- 1 | void binmode_setup(void); 2 | void binmode_service(void); 3 | void binmode_cleanup(void); 4 | void binmode_load_save_config(bool save); 5 | 6 | enum { 7 | BINMODE_USE_SUMPLA = 0, 8 | BINMODE_USE_DIRTYPROTO, 9 | BINMODE_USE_ARDUINO_CH32V003_SWIO, 10 | BINMODE_USE_LEGACY4THIRD, 11 | BINMODE_USE_FALA, 12 | BINMODE_USE_IRTOY_IRMAN, 13 | BINMODE_USE_IRTOY_AIR, 14 | BINMODE_MAXPROTO 15 | }; 16 | 17 | typedef struct _binmode { 18 | bool lock_terminal; 19 | bool can_save_config; 20 | bool reset_to_hiz; 21 | bool pullup_enabled; 22 | bool button_to_exit; 23 | float psu_en_voltage; 24 | float psu_en_current; 25 | const char* binmode_name; 26 | void (*binmode_setup)(void); 27 | void (*binmode_setup_message)(void); 28 | void (*binmode_service)(void); 29 | void (*binmode_cleanup)(void); 30 | void (*binmode_hook_mode_exc)(void); 31 | } binmode_t; // Add a typedef name for the struct. 32 | 33 | extern const binmode_t binmodes[BINMODE_MAXPROTO]; // Use the typedef name for the struct. -------------------------------------------------------------------------------- /src/binmode/dirtyproto.h: -------------------------------------------------------------------------------- 1 | void dirtyproto_mode(void); 2 | extern const char dirtyproto_mode_name[]; -------------------------------------------------------------------------------- /src/binmode/fala.h: -------------------------------------------------------------------------------- 1 | #ifndef FALA_H 2 | #define FALA_H 3 | 4 | typedef struct { 5 | uint32_t base_frequency; 6 | uint32_t oversample; 7 | uint32_t actual_sample_frequency; 8 | uint8_t debug_level; 9 | } FalaConfig; 10 | 11 | extern FalaConfig fala_config; 12 | 13 | // Function declarations 14 | void fala_set_freq(uint32_t freq); 15 | void fala_set_oversample(uint32_t oversample_rate); 16 | void fala_set_triggers(uint8_t trigger_pin, uint8_t trigger_level); 17 | void fala_start(void); 18 | void fala_stop(void); 19 | void fala_print_result(void); 20 | 21 | void fala_start_hook(void); 22 | void fala_stop_hook(void); 23 | void fala_notify_hook(void); 24 | bool fala_notify_register(void (*hook)()); 25 | void fala_notify_unregister(void (*hook)()); 26 | void fala_mode_change_hook(void); 27 | 28 | #endif // FALA_H -------------------------------------------------------------------------------- /src/binmode/falaio.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef FALAIO_H 3 | #define FALAIO_H 4 | 5 | // Global variables 6 | extern const char falaio_name[]; 7 | 8 | // Function declarations 9 | void falaio_setup(void); 10 | void falaio_setup_message(void); 11 | void falaio_cleanup(void); 12 | void falaio_notify(void); 13 | void falaio_service(void); 14 | 15 | #endif // FALAIO_H 16 | -------------------------------------------------------------------------------- /src/binmode/irtoy-air.h: -------------------------------------------------------------------------------- 1 | #ifndef IRTOY_AIR_H 2 | #define IRTOY_AIR_H 3 | 4 | // Global variables 5 | extern const char irtoy_air_name[]; 6 | 7 | // Function declarations 8 | void irtoy_air_setup(void); 9 | void irtoy_air_cleanup(void); 10 | void irtoy_air_service(void); 11 | 12 | #endif // IRTOY_AIR_H -------------------------------------------------------------------------------- /src/binmode/irtoy-irman.h: -------------------------------------------------------------------------------- 1 | #ifndef IRTOY_IRMAN_H 2 | #define IRTOY_IRMAN_H 3 | 4 | // Global variables 5 | extern const char irtoy_irman_name[]; 6 | 7 | // Function declarations 8 | void irtoy_irman_setup(void); 9 | void irtoy_irman_cleanup(void); 10 | void irtoy_irman_service(void); 11 | 12 | #endif // IRTOY_IRMAN_H -------------------------------------------------------------------------------- /src/binmode/legacy4third.h: -------------------------------------------------------------------------------- 1 | void legacy4third_mode(void); 2 | extern const char legacy4third_mode_name[]; 3 | -------------------------------------------------------------------------------- /src/binmode/logicanalyzer.h: -------------------------------------------------------------------------------- 1 | #define LA_BUFFER_SIZE (32768 * 4) 2 | bool logicanalyzer_setup(void); 3 | int logicanalyzer_status(void); 4 | void logic_analyzer_dump(uint8_t* txbuf); 5 | bool logic_analyzer_is_done(void); 6 | void logic_analyser_done(void); 7 | uint32_t logic_analyzer_configure( 8 | float freq, uint32_t samples, uint32_t trigger_mask, uint32_t trigger_direction, bool edge, bool interrupt); 9 | void logic_analyzer_arm(bool led_indicator_enable); 10 | bool logic_analyzer_cleanup(void); 11 | void logic_analyzer_enable_status_leds(bool enable); 12 | void logicanalyzer_reset_led(void); 13 | uint32_t logic_analyzer_get_start_ptr(uint32_t sample_count); 14 | uint32_t logic_analyzer_get_current_ptr(void); 15 | uint32_t logic_analyzer_get_end_ptr(void); 16 | void logic_analyzer_reset_ptr(void); 17 | uint8_t logic_analyzer_read_ptr(uint32_t read_pointer); 18 | void logic_analyzer_set_base_pin(uint8_t base_pin); 19 | uint32_t logic_analyzer_get_samples_from_zero(void); 20 | uint32_t logic_analyzer_compute_actual_sample_frequency(float desired_frequency, float* div_out); -------------------------------------------------------------------------------- /src/boards/buspirate5.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 Raspberry Pi (Trading) Ltd. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | // ----------------------------------------------------- 8 | // NOTE: THIS HEADER IS ALSO INCLUDED BY ASSEMBLER SO 9 | // SHOULD ONLY CONSIST OF PREPROCESSOR DIRECTIVES 10 | // ----------------------------------------------------- 11 | 12 | // This header may be included by other board headers as "boards/pico.h" 13 | 14 | // pico_cmake_set PICO_PLATFORM=rp2040 15 | 16 | #ifndef _BOARDS_BP5_RP2040_H 17 | #define _BOARDS_BP5_RP2040_H 18 | 19 | // For board detection 20 | #define BUSPIRATE5_RP2040 21 | 22 | // --- FLASH --- 23 | 24 | #define PICO_BOOT_STAGE2_CHOOSE_W25Q080 1 25 | 26 | #ifndef PICO_FLASH_SPI_CLKDIV 27 | #define PICO_FLASH_SPI_CLKDIV 2 28 | #endif 29 | 30 | // pico_cmake_set_default PICO_FLASH_SIZE_BYTES = (2 * 1024 * 1024) 31 | #ifndef PICO_FLASH_SIZE_BYTES 32 | #define PICO_FLASH_SIZE_BYTES (16 * 1024 * 1024) 33 | #endif 34 | 35 | #ifndef PICO_RP2040_B0_SUPPORTED 36 | #define PICO_RP2040_B0_SUPPORTED 1 37 | #endif 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /src/boards/buspirate5xl.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 Raspberry Pi (Trading) Ltd. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | // ----------------------------------------------------- 8 | // NOTE: THIS HEADER IS ALSO INCLUDED BY ASSEMBLER SO 9 | // SHOULD ONLY CONSIST OF PREPROCESSOR DIRECTIVES 10 | // ----------------------------------------------------- 11 | 12 | // This header may be included by other board headers as "boards/pico.h" 13 | 14 | // pico_cmake_set PICO_PLATFORM=rp2350 15 | 16 | #ifndef _BOARDS_BP5XL_2350A_H 17 | #define _BOARDS_BP5XL_2350A_H 18 | 19 | // For board detection 20 | #define BUSPIRATE5XL_2350A 21 | 22 | // --- RP2350 VARIANT --- 23 | #define PICO_RP2350A 1 24 | 25 | #ifndef PICO_RP2040_B0_SUPPORTED 26 | #define PICO_RP2040_B0_SUPPORTED 1 27 | #endif 28 | 29 | #ifndef PICO_RP2350_A2_SUPPORTED 30 | #define PICO_RP2350_A2_SUPPORTED 1 31 | #endif 32 | 33 | // --- FLASH --- 34 | 35 | #define PICO_BOOT_STAGE2_CHOOSE_W25Q080 1 36 | 37 | #ifndef PICO_FLASH_SPI_CLKDIV 38 | #define PICO_FLASH_SPI_CLKDIV 2 39 | #endif 40 | 41 | #ifndef PICO_FLASH_SIZE_BYTES 42 | #define PICO_FLASH_SIZE_BYTES (16 * 1024 * 1024) 43 | #endif 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /src/boards/buspirate6.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 Raspberry Pi (Trading) Ltd. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | // ----------------------------------------------------- 8 | // NOTE: THIS HEADER IS ALSO INCLUDED BY ASSEMBLER SO 9 | // SHOULD ONLY CONSIST OF PREPROCESSOR DIRECTIVES 10 | // ----------------------------------------------------- 11 | 12 | // This header may be included by other board headers as "boards/pico.h" 13 | 14 | // pico_cmake_set PICO_PLATFORM=rp2350 15 | 16 | #ifndef _BOARDS_BP6_2350B_H 17 | #define _BOARDS_BP6_2350B_H 18 | 19 | // For board detection 20 | #define BUSPIRATE6_2350B 21 | 22 | // --- RP2350 VARIANT --- 23 | #define PICO_RP2350B 1 24 | 25 | #ifndef PICO_RP2040_B0_SUPPORTED 26 | #define PICO_RP2040_B0_SUPPORTED 1 27 | #endif 28 | 29 | #ifndef PICO_RP2350_A2_SUPPORTED 30 | #define PICO_RP2350_A2_SUPPORTED 1 31 | #endif 32 | 33 | // --- FLASH --- 34 | 35 | #define PICO_BOOT_STAGE2_CHOOSE_W25Q080 1 36 | 37 | #ifndef PICO_FLASH_SPI_CLKDIV 38 | #define PICO_FLASH_SPI_CLKDIV 2 39 | #endif 40 | 41 | #ifndef PICO_FLASH_SIZE_BYTES 42 | #define PICO_FLASH_SIZE_BYTES (16 * 1024 * 1024) 43 | #endif 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /src/boards/buspirate7.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 Raspberry Pi (Trading) Ltd. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | // ----------------------------------------------------- 8 | // NOTE: THIS HEADER IS ALSO INCLUDED BY ASSEMBLER SO 9 | // SHOULD ONLY CONSIST OF PREPROCESSOR DIRECTIVES 10 | // ----------------------------------------------------- 11 | 12 | // This header may be included by other board headers as "boards/pico.h" 13 | 14 | // pico_cmake_set PICO_PLATFORM=rp2350 15 | 16 | #ifndef _BOARDS_BP7_2350B_H 17 | #define _BOARDS_BP7_2350B_H 18 | 19 | // For board detection 20 | #define BUSPIRATE7_2350B 21 | 22 | // --- RP2350 VARIANT --- 23 | #define PICO_RP2350B 1 24 | 25 | #ifndef PICO_RP2040_B0_SUPPORTED 26 | #define PICO_RP2040_B0_SUPPORTED 1 27 | #endif 28 | 29 | #ifndef PICO_RP2350_A2_SUPPORTED 30 | #define PICO_RP2350_A2_SUPPORTED 1 31 | #endif 32 | 33 | // --- FLASH --- 34 | 35 | #define PICO_BOOT_STAGE2_CHOOSE_W25Q080 1 36 | 37 | #ifndef PICO_FLASH_SPI_CLKDIV 38 | #define PICO_FLASH_SPI_CLKDIV 2 39 | #endif 40 | 41 | #ifndef PICO_FLASH_SIZE_BYTES 42 | #define PICO_FLASH_SIZE_BYTES (16 * 1024 * 1024) 43 | #endif 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /src/command_struct.h: -------------------------------------------------------------------------------- 1 | #define MAX_COMMAND_LENGTH 10 2 | 3 | typedef struct command_result { 4 | uint8_t number_format; 5 | bool success; 6 | bool exit; 7 | bool no_value; 8 | bool default_value; 9 | bool error; 10 | bool help_flag; 11 | } command_result; 12 | 13 | struct _global_command_struct { 14 | char command[MAX_COMMAND_LENGTH]; //command line string to execute command 15 | bool allow_hiz; //allow execution in high impedance mode 16 | void (*func)(struct command_result* res); //function to execute 17 | uint32_t help_text; // translation string to show when -h is used, 0x00 = command can manage it's own extended help 18 | }; 19 | 20 | struct _mode_command_struct { 21 | char command[MAX_COMMAND_LENGTH]; //command line string to execute command 22 | void (*func)(struct command_result* res); //function to execute 23 | uint32_t description_text; // shown in help and command lists 24 | bool supress_fala_capture; //global follow along logic analyzer is disabled, can be managed within the command 25 | }; 26 | 27 | struct command_response { 28 | bool error; 29 | uint32_t data; 30 | }; 31 | 32 | struct command_attributes { 33 | bool has_value; 34 | bool has_dot; 35 | bool has_colon; 36 | bool has_string; 37 | uint8_t command; // the actual command called 38 | uint8_t number_format; // DEC/HEX/BIN 39 | uint32_t value; // integer value parsed from command line 40 | uint32_t dot; // value after . 41 | uint32_t colon; // value after : 42 | }; 43 | -------------------------------------------------------------------------------- /src/commands.h: -------------------------------------------------------------------------------- 1 | #ifndef _UI_COMMAND_H 2 | #define _UI_COMMAND_H 3 | extern const struct _global_command_struct commands[]; 4 | extern const uint32_t commands_count; 5 | #endif 6 | -------------------------------------------------------------------------------- /src/commands/1wire/demos.h: -------------------------------------------------------------------------------- 1 | void onewire_test_ds18b20_conversion(struct command_result* res); -------------------------------------------------------------------------------- /src/commands/1wire/scan.h: -------------------------------------------------------------------------------- 1 | void onewire_test_romsearch(struct command_result* res); -------------------------------------------------------------------------------- /src/commands/2wire/hw2w_sniff.h: -------------------------------------------------------------------------------- 1 | void hw2w_sniff(struct command_result* res); -------------------------------------------------------------------------------- /src/commands/2wire/sle4442.h: -------------------------------------------------------------------------------- 1 | void sle4442(struct command_result* res); 2 | -------------------------------------------------------------------------------- /src/commands/global/a_auxio.h: -------------------------------------------------------------------------------- 1 | void auxio_high_handler(struct command_result* res); 2 | void auxio_low_handler(struct command_result* res); 3 | void auxio_input_handler(struct command_result* res); 4 | -------------------------------------------------------------------------------- /src/commands/global/bug.h: -------------------------------------------------------------------------------- 1 | void bug_handler(struct command_result* res); 2 | bool bug_e9_seems_fixed(bool pullup, uint8_t bio_pin, bool verbose); -------------------------------------------------------------------------------- /src/commands/global/button_scr.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "pirate/button.h" 3 | 4 | void button_scr_handler(struct command_result* res); 5 | bool button_exec(enum button_codes button_code); 6 | -------------------------------------------------------------------------------- /src/commands/global/cls.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "pico/stdlib.h" 3 | #include "pirate.h" 4 | #include "system_config.h" 5 | #include "command_struct.h" 6 | #include "ui/ui_term.h" 7 | #include "ui/ui_statusbar.h" 8 | #include "ui/ui_help.h" 9 | #include "ui/ui_flags.h" 10 | 11 | static const char* const usage[] = { 12 | "cls", 13 | "Clear and refresh the terminal screen: cls", 14 | "Note: will attempt to detect and initialize VT100 ANSI terminal", 15 | }; 16 | 17 | static const struct ui_help_options options[] = { 0 }; 18 | 19 | void ui_display_clear(struct command_result* res) { 20 | BP_ASSERT_CORE0(); 21 | if (ui_help_show(res->help_flag, usage, count_of(usage), &options[0], count_of(options))) { 22 | return; 23 | } 24 | 25 | if (!system_config.terminal_ansi_color) { 26 | printf("cls command is only supported in VT100 terminal mode"); 27 | return; 28 | } 29 | 30 | ui_term_detect(); // Do we detect a VT100 ANSI terminal? what is the size? 31 | ui_term_init(); // Initialize VT100 if ANSI terminal 32 | if (system_config.terminal_ansi_color && system_config.terminal_ansi_statusbar) { 33 | ui_statusbar_init(); 34 | ui_statusbar_update_blocking(); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/commands/global/cls.h: -------------------------------------------------------------------------------- 1 | void ui_display_clear(struct command_result* res); -------------------------------------------------------------------------------- /src/commands/global/cmd_binmode.h: -------------------------------------------------------------------------------- 1 | void cmd_binmode_handler(struct command_result* res); 2 | -------------------------------------------------------------------------------- /src/commands/global/cmd_convert.h: -------------------------------------------------------------------------------- 1 | void cmd_convert_base(uint32_t value, uint32_t num_bits); 2 | void cmd_convert_base_handler(struct command_result* res); 3 | void cmd_convert_inverse_handler(struct command_result* res); 4 | -------------------------------------------------------------------------------- /src/commands/global/cmd_mcu.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "pico/stdlib.h" 3 | #include "pirate.h" 4 | #include "pirate/mcu.h" 5 | #include "system_config.h" 6 | #include "command_struct.h" 7 | #include "msc_disk.h" 8 | #include "ui/ui_statusbar.h" 9 | 10 | void cmd_mcu_reset(void) { 11 | mcu_reset(); 12 | } 13 | 14 | void cmd_mcu_reboot_handler(struct command_result* res) { 15 | ui_statusbar_deinit(); 16 | busy_wait_ms(100); 17 | cmd_mcu_reset(); 18 | } 19 | 20 | void cmd_mcu_jump_to_bootloader(void) { 21 | mcu_jump_to_bootloader(); 22 | } 23 | 24 | void cmd_mcu_jump_to_bootloader_handler(struct command_result* res) { 25 | 26 | printf("Jump to bootloader for firmware upgrades\r\n\r\n%s\r\n", BP_HARDWARE_VERSION); 27 | printf("Firmware download:\r\nhttps://forum.buspirate.com/t/bus-pirate-5-auto-build-main-branch/20/999999\r\n"); 28 | #if BP_VER == 5 29 | printf("Hardware revision: %d\r\n", BP_REV); 30 | printf("Firmware file: bus_pirate5_rev%d.uf2\r\n", BP_REV); 31 | printf("A USB disk named \"RPI-RP2\" will appear\r\n"); 32 | #elif BP_VER == XL5 33 | printf("Firmware file: bus_pirate5xl.uf2\r\n"); 34 | printf("A USB disk named \"RP2350\" will appear\r\n"); 35 | #elif BP_VER == 6 36 | printf("Firmware file: bus_pirate6.uf2\r\n"); 37 | printf("A USB disk named \"RP2350\" will appear\r\n"); 38 | #elif BP_VER == 7 39 | printf("Firmware file: bus_pirate7.uf2\r\n"); 40 | printf("A USB disk named \"BP_BOOT\" will appear\r\n"); 41 | #else 42 | #error "Unknown Bus Pirate version in cmd_mcu.c" 43 | #endif 44 | printf("Drag a firmware file to the disk to upgrade\r\n"); 45 | 46 | // check help 47 | if (res->help_flag) { 48 | return; 49 | } 50 | printf("Later Alligator!"); 51 | ui_statusbar_deinit(); 52 | eject_usbmsdrive(); 53 | busy_wait_ms(200); 54 | cmd_mcu_jump_to_bootloader(); 55 | } -------------------------------------------------------------------------------- /src/commands/global/cmd_mcu.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include "pico/stdlib.h" 3 | #include "pirate.h" 4 | #include "pirate/mcu.h" 5 | #include "system_config.h" 6 | 7 | void cmd_mcu_reset(void); 8 | void cmd_mcu_reboot_handler(struct command_result* res); 9 | void cmd_mcu_jump_to_bootloader(void); 10 | void cmd_mcu_jump_to_bootloader_handler(struct command_result* res); -------------------------------------------------------------------------------- /src/commands/global/cmd_selftest.h: -------------------------------------------------------------------------------- 1 | void cmd_selftest_handler(struct command_result* res); 2 | void cmd_selftest(void); -------------------------------------------------------------------------------- /src/commands/global/disk.h: -------------------------------------------------------------------------------- 1 | void disk_hex_handler(struct command_result* res); 2 | void disk_cat_handler(struct command_result* res); 3 | void disk_mkdir_handler(struct command_result* res); 4 | void disk_cd_handler(struct command_result* res); 5 | void disk_rm_handler(struct command_result* res); 6 | void disk_ls_handler(struct command_result* res); 7 | uint8_t disk_format(void); 8 | void disk_format_handler(struct command_result* res); 9 | void disk_label_handler(struct command_result* res); 10 | -------------------------------------------------------------------------------- /src/commands/global/dummy.h: -------------------------------------------------------------------------------- 1 | void dummy_handler(struct command_result* res); -------------------------------------------------------------------------------- /src/commands/global/dump.h: -------------------------------------------------------------------------------- 1 | void dump_handler(struct command_result* res); 2 | -------------------------------------------------------------------------------- /src/commands/global/freq.h: -------------------------------------------------------------------------------- 1 | void freq_cont(struct command_result* res); 2 | void freq_single(struct command_result* res); 3 | 4 | uint32_t freq_measure(int32_t pin, int refresh); 5 | uint32_t freq_configure_disable(void); 6 | uint32_t freq_configure_enable(void); 7 | 8 | float freq_measure_period(uint gpio); 9 | float freq_measure_duty_cycle(uint gpio); 10 | void freq_display_hz(float* freq_hz_value, float* freq_friendly_value, uint8_t* freq_friendly_units); 11 | void freq_display_ns(float* freq_ns_value, float* period_friendly_value, uint8_t* period_friendly_units); 12 | 13 | void freq_measure_period_irq(void); -------------------------------------------------------------------------------- /src/commands/global/h_help.h: -------------------------------------------------------------------------------- 1 | void help_mode(void); 2 | void help_global(void); 3 | void help_handler(struct command_result* res); 4 | -------------------------------------------------------------------------------- /src/commands/global/i_info.h: -------------------------------------------------------------------------------- 1 | void i_info_handler(struct command_result* res); -------------------------------------------------------------------------------- /src/commands/global/image.h: -------------------------------------------------------------------------------- 1 | void image_handler(struct command_result* res); -------------------------------------------------------------------------------- /src/commands/global/l_bitorder.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include "pico/stdlib.h" 4 | #include "pirate.h" 5 | #include "system_config.h" 6 | #include "command_struct.h" 7 | #include "ui/ui_term.h" 8 | #include "ui/ui_help.h" 9 | 10 | void bitorder_msb(void) { 11 | system_config.bit_order = 0; 12 | } 13 | 14 | void bitorder_msb_handler(struct command_result* res) { 15 | bitorder_msb(); 16 | printf("%s%s:%s %s 0b%s1%s0000000", 17 | ui_term_color_notice(), 18 | GET_T(T_MODE_BITORDER), 19 | ui_term_color_reset(), 20 | GET_T(T_MODE_BITORDER_MSB), 21 | ui_term_color_info(), 22 | ui_term_color_reset()); 23 | } 24 | 25 | void bitorder_lsb(void) { 26 | system_config.bit_order = 1; 27 | } 28 | 29 | void bitorder_lsb_handler(struct command_result* res) { 30 | bitorder_lsb(); 31 | printf("%s%s:%s %s 0b0000000%s1%s", 32 | ui_term_color_notice(), 33 | GET_T(T_MODE_BITORDER), 34 | ui_term_color_reset(), 35 | GET_T(T_MODE_BITORDER_LSB), 36 | ui_term_color_info(), 37 | ui_term_color_reset()); 38 | } -------------------------------------------------------------------------------- /src/commands/global/l_bitorder.h: -------------------------------------------------------------------------------- 1 | 2 | void bitorder_msb(void); 3 | void bitorder_msb_handler(struct command_result* res); 4 | void bitorder_lsb(void); 5 | void bitorder_lsb_handler(struct command_result* res); -------------------------------------------------------------------------------- /src/commands/global/logic.h: -------------------------------------------------------------------------------- 1 | void logic_handler(struct command_result* res); -------------------------------------------------------------------------------- /src/commands/global/macro.h: -------------------------------------------------------------------------------- 1 | void macro_handler(struct command_result* res); -------------------------------------------------------------------------------- /src/commands/global/otpdump.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | void otpdump_handler(struct command_result* res); -------------------------------------------------------------------------------- /src/commands/global/ovrclk.h: -------------------------------------------------------------------------------- 1 | void ovrclk_handler(struct command_result* res); -------------------------------------------------------------------------------- /src/commands/global/p_pullups.h: -------------------------------------------------------------------------------- 1 | void pullups_init(void); 2 | void pullups_enable_handler(struct command_result* res); 3 | void pullups_disable_handler(struct command_result* res); 4 | void pullups_enable(void); 5 | void pullups_disable(void); -------------------------------------------------------------------------------- /src/commands/global/pause.h: -------------------------------------------------------------------------------- 1 | void pause_handler(struct command_result* res); -------------------------------------------------------------------------------- /src/commands/global/pwm.h: -------------------------------------------------------------------------------- 1 | void pwm_configure_enable(struct command_result* res); 2 | void pwm_configure_disable(struct command_result* res); 3 | uint8_t pwm_freq_find( 4 | float* freq_hz_value, float* pwm_hz_actual, float* pwm_ns_actual, uint32_t* pwm_divider, uint32_t* pwm_top); 5 | -------------------------------------------------------------------------------- /src/commands/global/script.h: -------------------------------------------------------------------------------- 1 | bool script_exec(char* location, bool pause_for_input, bool show_comments, bool show_tip, bool exit_on_error); 2 | void script_handler(struct command_result* res); -------------------------------------------------------------------------------- /src/commands/global/smps.h: -------------------------------------------------------------------------------- 1 | void smps_handler(struct command_result* res); -------------------------------------------------------------------------------- /src/commands/global/tutorial.h: -------------------------------------------------------------------------------- 1 | void tutorial_handler(struct command_result* res); -------------------------------------------------------------------------------- /src/commands/global/v_adc.h: -------------------------------------------------------------------------------- 1 | void adc_measure_single(struct command_result* res); 2 | void adc_measure_cont(struct command_result* res); 3 | -------------------------------------------------------------------------------- /src/commands/global/w_psu.h: -------------------------------------------------------------------------------- 1 | bool psucmd_init(void); 2 | void psucmd_enable_handler(struct command_result* res); 3 | uint32_t psucmd_enable(float volts, float current, bool current_limit_override); 4 | void psucmd_disable_handler(struct command_result* res); 5 | void psucmd_disable(void); 6 | void psucmd_irq_callback(void); 7 | void psucmd_over_current(void); -------------------------------------------------------------------------------- /src/commands/hdplxuart/bridge.h: -------------------------------------------------------------------------------- 1 | void hduart_bridge_handler(struct command_result* res); -------------------------------------------------------------------------------- /src/commands/i2c/ddr.h: -------------------------------------------------------------------------------- 1 | void ddr5_handler(struct command_result* res); -------------------------------------------------------------------------------- /src/commands/i2c/demos.h: -------------------------------------------------------------------------------- 1 | void demo_tsl2561(struct command_result* res); 2 | void demo_ms5611(struct command_result* res); 3 | void demo_si7021(struct command_result* res); -------------------------------------------------------------------------------- /src/commands/i2c/scan.h: -------------------------------------------------------------------------------- 1 | void i2c_search_addr(struct command_result* res); -------------------------------------------------------------------------------- /src/commands/i2c/sniff.h: -------------------------------------------------------------------------------- 1 | void i2c_sniff(struct command_result* res); -------------------------------------------------------------------------------- /src/commands/i2s/sine.h: -------------------------------------------------------------------------------- 1 | void sine_handler(struct command_result* res); -------------------------------------------------------------------------------- /src/commands/infrared/irtxrx.h: -------------------------------------------------------------------------------- 1 | void irrx_handler(struct command_result *res); 2 | void irtx_handler(struct command_result *res); -------------------------------------------------------------------------------- /src/commands/infrared/tvbgone.h: -------------------------------------------------------------------------------- 1 | void tvbgone_player(struct command_result *res); -------------------------------------------------------------------------------- /src/commands/jtag/bluetag.h: -------------------------------------------------------------------------------- 1 | void bluetag_handler(struct command_result* res); -------------------------------------------------------------------------------- /src/commands/spi/flash.h: -------------------------------------------------------------------------------- 1 | void flash(struct command_result* res); 2 | void load(struct command_result* res); -------------------------------------------------------------------------------- /src/commands/spi/sniff.h: -------------------------------------------------------------------------------- 1 | void sniff_handler(struct command_result* res); -------------------------------------------------------------------------------- /src/commands/spi/spiflash.h: -------------------------------------------------------------------------------- 1 | void spiflash_probe(void); 2 | bool spiflash_init(sfud_flash* flash_info); 3 | bool spiflash_erase(sfud_flash* flash_info); 4 | bool spiflash_erase_verify( 5 | uint32_t start_address, uint32_t end_address, uint32_t buf_size, uint8_t* buf, sfud_flash* flash_info); 6 | bool spiflash_write_test( 7 | uint32_t start_address, uint32_t end_address, uint32_t buf_size, uint8_t* buf, sfud_flash* flash_info); 8 | bool spiflash_write_verify( 9 | uint32_t start_address, uint32_t end_address, uint32_t buf_size, uint8_t* buf, sfud_flash* flash_info); 10 | bool spiflash_dump(uint32_t start_address, 11 | uint32_t end_address, 12 | uint32_t buf_size, 13 | uint8_t* buf, 14 | sfud_flash* flash_info, 15 | const char* file_name); 16 | bool spiflash_load(uint32_t start_address, 17 | uint32_t end_address, 18 | uint32_t buf_size, 19 | uint8_t* buf, 20 | sfud_flash* flash_info, 21 | const char* file_name); 22 | bool spiflash_verify(uint32_t start_address, 23 | uint32_t end_address, 24 | uint32_t buf_size, 25 | uint8_t* buf, 26 | uint8_t* buf2, 27 | sfud_flash* flash_info, 28 | const char* file_name); 29 | bool spiflash_force_dump(uint32_t start_address, 30 | uint32_t end_address, 31 | uint32_t buf_size, 32 | uint8_t* buf, 33 | sfud_flash* flash_info, 34 | const char* file_name); -------------------------------------------------------------------------------- /src/commands/uart/bridge.h: -------------------------------------------------------------------------------- 1 | void uart_bridge_handler(struct command_result* res); -------------------------------------------------------------------------------- /src/commands/uart/glitch.h: -------------------------------------------------------------------------------- 1 | #ifndef UART_GLITCH 2 | void uart_glitch_handler(struct command_result* res); 3 | #define UART_GLITCH 4 | #endif // UART_GLITCH -------------------------------------------------------------------------------- /src/commands/uart/glitch.pio: -------------------------------------------------------------------------------- 1 | ; 2 | ; PIO State Machine to handle timing and "on" time of a glitching 3 | ; device. 4 | ; 5 | 6 | .program uart_glitch 7 | 8 | .wrap_target 9 | pull ; get the "on" time of the glitch pulse 10 | mov x OSR ; store it in X 11 | pull ; get the number of edges in the trigger character 12 | mov y OSR ; store it in Y 13 | pull ; get the delay before starting glitch pulse (just hold on for now) 14 | 15 | trigger_loop: 16 | wait 0 pin 0 ; idle state of TX line is high, wait for it to go low 17 | wait 1 pin 0 ; wait for it to go back up 18 | jmp y-- trigger_loop ; decrement 19 | 20 | mov y OSR ; now set the delay time to the y register 21 | 22 | delay_loop: 23 | jmp y-- delay_loop ; decrement delay before turning on the output 24 | 25 | set pins 1 ; OK, turn it on now 26 | 27 | high_loop: 28 | jmp x-- high_loop ; decrement the glitch pulse high time 29 | set pins 0 ; turn it off 30 | 31 | .wrap 32 | 33 | % c-sdk { 34 | #include "hardware/clocks.h" 35 | static inline void uart_glitch_program_init(PIO pio, uint sm, uint offset, uint glitch_pin, uint tx_pin) { 36 | pio_sm_config c = uart_glitch_program_get_default_config(offset); 37 | 38 | sm_config_set_set_pins (&c, glitch_pin, 1); 39 | sm_config_set_in_pins(&c, tx_pin); 40 | 41 | pio_gpio_init(pio, glitch_pin); 42 | pio_sm_set_consecutive_pindirs(pio, sm, glitch_pin, 1, true); 43 | pio_sm_set_consecutive_pindirs(pio, sm, tx_pin, 1, false); 44 | 45 | // 100MHz = 10ns per instruction 46 | float div = (float)clock_get_hz(clk_sys) / (100e6); 47 | sm_config_set_clkdiv(&c, div); 48 | 49 | pio_sm_init(pio, sm, offset, &c); 50 | pio_sm_set_enabled(pio, sm, true); 51 | } 52 | %} -------------------------------------------------------------------------------- /src/commands/uart/monitor.h: -------------------------------------------------------------------------------- 1 | void uart_monitor_handler(struct command_result* res); -------------------------------------------------------------------------------- /src/commands/uart/nmea.h: -------------------------------------------------------------------------------- 1 | void nmea_decode_handler(struct command_result* res); -------------------------------------------------------------------------------- /src/commands/uart/simcard.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "pico/stdlib.h" 3 | #include 4 | #include "hardware/uart.h" 5 | #include "pirate.h" 6 | #include "system_config.h" 7 | #include "command_struct.h" 8 | #include "ui/ui_term.h" 9 | #include "ui/ui_help.h" 10 | #include "bytecode.h" 11 | #include "mode/hwuart.h" 12 | #include "pirate/button.h" 13 | #include "usb_rx.h" 14 | #include "usb_tx.h" 15 | #include "hwuart.pio.h" 16 | #include "pirate/bio.h" 17 | #include "pio_config.h" 18 | 19 | //static struct _pio_config pio_config; 20 | 21 | static const char* const usage[] = { 22 | "sim\t[-h(elp)]", 23 | }; 24 | 25 | static const struct ui_help_options options[] = { 26 | { 1, "", T_HELP_UART_BRIDGE }, // command help 27 | { 0, "-h", T_HELP_FLAG }, // help 28 | }; 29 | 30 | void simcard_handler(struct command_result* res) { 31 | if (ui_help_show(res->help_flag, usage, count_of(usage), &options[0], count_of(options))) { 32 | return; 33 | } 34 | if (!ui_help_check_vout_vref()) { 35 | return; 36 | } 37 | 38 | // uart_rx_program_init(M_I2C_PIO, M_I2C_PIO_SM, pio_loaded_offset, bio2bufiopin[BIO0], 9600); 39 | // bool success = pio_claim_free_sm_and_add_program_for_gpio_range(&uart_rx_program, &pio_config.pio, 40 | // &pio_config.sm, &pio_config.offset, bio2bufiopin[BIO0], 1, true); hard_assert(success); printf("PIO: pio=%d, 41 | // sm=%d, offset=%d\r\n", PIO_NUM(pio_config.pio), pio_config.sm, pio_config.offset); 42 | // pio_remove_program_and_unclaim_sm(&uart_rx_program, pio_config.pio, pio_config.sm, pio_config.offset); 43 | } -------------------------------------------------------------------------------- /src/commands/uart/simcard.h: -------------------------------------------------------------------------------- 1 | void simcard_handler(struct command_result* res); -------------------------------------------------------------------------------- /src/debug_uart.h: -------------------------------------------------------------------------------- 1 | 2 | struct _debug_uart { 3 | uart_inst_t(*const uart); 4 | uint8_t rx_pin; 5 | uint8_t tx_pin; 6 | int irq; 7 | }; 8 | 9 | extern struct _debug_uart debug_uart[]; 10 | extern int debug_uart_number; 11 | 12 | void debug_uart_init(int uart_number, bool dbrx, bool dbtx, bool terminal_label); 13 | void debug_tx(char c); 14 | bool debug_rx(char* c); -------------------------------------------------------------------------------- /src/dhara/bytes.h: -------------------------------------------------------------------------------- 1 | /* Dhara - NAND flash management layer 2 | * Copyright (C) 2013 Daniel Beer 3 | * 4 | * Permission to use, copy, modify, and/or distribute this software for any 5 | * purpose with or without fee is hereby granted, provided that the above 6 | * copyright notice and this permission notice appear in all copies. 7 | * 8 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 9 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 10 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 11 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 12 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 13 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15 | */ 16 | 17 | #ifndef DHARA_BYTES_H_ 18 | #define DHARA_BYTES_H_ 19 | 20 | #include 21 | 22 | static inline uint16_t dhara_r16(const uint8_t *data) 23 | { 24 | return ((uint16_t)data[0]) | 25 | (((uint16_t)data[1]) << 8); 26 | } 27 | 28 | static inline void dhara_w16(uint8_t *data, uint16_t v) 29 | { 30 | data[0] = v; 31 | data[1] = v >> 8; 32 | } 33 | 34 | static inline uint32_t dhara_r32(const uint8_t *data) 35 | { 36 | return ((uint32_t)data[0]) | 37 | (((uint32_t)data[1]) << 8) | 38 | (((uint32_t)data[2]) << 16) | 39 | (((uint32_t)data[3]) << 24); 40 | } 41 | 42 | static inline void dhara_w32(uint8_t *data, uint32_t v) 43 | { 44 | data[0] = v; 45 | data[1] = v >> 8; 46 | data[2] = v >> 16; 47 | data[3] = v >> 24; 48 | } 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /src/dhara/error.c: -------------------------------------------------------------------------------- 1 | /* Dhara - NAND flash management layer 2 | * Copyright (C) 2013 Daniel Beer 3 | * 4 | * Permission to use, copy, modify, and/or distribute this software for any 5 | * purpose with or without fee is hereby granted, provided that the above 6 | * copyright notice and this permission notice appear in all copies. 7 | * 8 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 9 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 10 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 11 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 12 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 13 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15 | */ 16 | 17 | #include 18 | #include "error.h" 19 | 20 | const char *dhara_strerror(dhara_error_t err) 21 | { 22 | static const char *const messages[DHARA_E_MAX] = { 23 | [DHARA_E_NONE] = "No error", 24 | [DHARA_E_BAD_BLOCK] = "Bad page/eraseblock", 25 | [DHARA_E_ECC] = "ECC failure", 26 | [DHARA_E_TOO_BAD] = "Too many bad blocks", 27 | [DHARA_E_RECOVER] = "Journal recovery is required", 28 | [DHARA_E_JOURNAL_FULL] = "Journal is full", 29 | [DHARA_E_NOT_FOUND] = "No such sector", 30 | [DHARA_E_MAP_FULL] = "Sector map is full", 31 | [DHARA_E_CORRUPT_MAP] = "Sector map is corrupted" 32 | }; 33 | const char *msg = NULL; 34 | 35 | if ((err >= 0) && (err < DHARA_E_MAX)) 36 | msg = messages[err]; 37 | 38 | if (msg) 39 | return msg; 40 | 41 | return "Unknown error"; 42 | } 43 | -------------------------------------------------------------------------------- /src/dhara/error.h: -------------------------------------------------------------------------------- 1 | /* Dhara - NAND flash management layer 2 | * Copyright (C) 2013 Daniel Beer 3 | * 4 | * Permission to use, copy, modify, and/or distribute this software for any 5 | * purpose with or without fee is hereby granted, provided that the above 6 | * copyright notice and this permission notice appear in all copies. 7 | * 8 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 9 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 10 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 11 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 12 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 13 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15 | */ 16 | 17 | #ifndef DHARA_ERROR_H_ 18 | #define DHARA_ERROR_H_ 19 | 20 | typedef enum { 21 | DHARA_E_NONE = 0, 22 | DHARA_E_BAD_BLOCK, 23 | DHARA_E_ECC, 24 | DHARA_E_TOO_BAD, 25 | DHARA_E_RECOVER, 26 | DHARA_E_JOURNAL_FULL, 27 | DHARA_E_NOT_FOUND, 28 | DHARA_E_MAP_FULL, 29 | DHARA_E_CORRUPT_MAP, 30 | DHARA_E_MAX 31 | } dhara_error_t; 32 | 33 | /* Produce a human-readable error message. This function is kept in a 34 | * separate compilation unit and can be omitted to reduce binary size. 35 | */ 36 | const char *dhara_strerror(dhara_error_t err); 37 | 38 | /* Save an error */ 39 | static inline void dhara_set_error(dhara_error_t *err, dhara_error_t v) 40 | { 41 | if (err) 42 | *err = v; 43 | } 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /src/display/background.h: -------------------------------------------------------------------------------- 1 | struct lcd_background_image_info { 2 | const unsigned char* bitmap; 3 | const uint8_t text_background_color[2]; 4 | }; -------------------------------------------------------------------------------- /src/display/backv2b-2.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DangerousPrototypes/BusPirate5-firmware/c3ac15d7ce16e710c05117b1614dcef9854187d4/src/display/backv2b-2.bmp -------------------------------------------------------------------------------- /src/display/default.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "pico/stdlib.h" 4 | #include "pico/multicore.h" 5 | #include "pirate.h" 6 | #include "system_config.h" 7 | #include "command_struct.h" 8 | #include "hardware/uart.h" 9 | // #include "hiz.h" 10 | #include "pirate/bio.h" 11 | #include "pico/stdlib.h" 12 | #include "hardware/pio.h" 13 | #include "hardware/dma.h" 14 | #include "hardware/adc.h" 15 | #include "hardware/irq.h" 16 | #include "hardware/spi.h" 17 | #include "font/font.h" 18 | // #include "font/hunter-23pt-24h24w.h" 19 | // #include "font/hunter-20pt-21h21w.h" 20 | // #include "font/hunter-14pt-19h15w.h" 21 | // #include "font/hunter-12pt-16h13w.h" 22 | // #include "font/background.h" 23 | // #include "font/background_image_v4.h" 24 | #include "ui/ui_flags.h" 25 | #include "ui/ui_lcd.h" 26 | #include "ui/ui_prompt.h" 27 | #include "ui/ui_parse.h" 28 | #include "ui/ui_cmdln.h" 29 | #include "usb_rx.h" 30 | #include "pirate/intercore_helpers.h" 31 | 32 | void disp_default_settings(void) {} 33 | 34 | void disp_default_help(void) {} 35 | 36 | void disp_default_cleanup(void) {} 37 | 38 | uint32_t disp_default_periodic(void) { 39 | return 0; 40 | } 41 | 42 | uint32_t disp_default_setup(void) { 43 | return 1; 44 | } 45 | 46 | uint32_t disp_default_setup_exc(void) { 47 | icm_core0_send_message_synchronous(BP_ICM_DISABLE_LCD_UPDATES); 48 | icm_core0_send_message_synchronous(BP_ICM_FORCE_LCD_UPDATE); 49 | return 1; 50 | } 51 | 52 | uint32_t disp_default_commands(struct command_result* result) { 53 | return 0; 54 | } 55 | 56 | void disp_default_lcd_update(uint32_t flags) { 57 | ui_lcd_update(flags); 58 | } 59 | 60 | /* For Emacs: 61 | * Local Variables: 62 | * mode:c 63 | * indent-tabs-mode:t 64 | * tab-width:4 65 | * c-basic-offset:4 66 | * End: 67 | * For VIM: 68 | * vim:set softtabstop=4 shiftwidth=4 tabstop=4: 69 | */ 70 | -------------------------------------------------------------------------------- /src/display/default.h: -------------------------------------------------------------------------------- 1 | #ifndef _DISP_DEFAULT_H_ 2 | #define _DISP_DEFAULT_H_ 3 | uint32_t disp_default_setup(void); 4 | uint32_t disp_default_setup_exc(void); 5 | void disp_default_cleanup(void); 6 | void disp_default_settings(void); 7 | void disp_default_help(void); 8 | void disp_default_lcd_update(uint32_t flags); 9 | #endif 10 | -------------------------------------------------------------------------------- /src/display/robot16.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DangerousPrototypes/BusPirate5-firmware/c3ac15d7ce16e710c05117b1614dcef9854187d4/src/display/robot16.bmp -------------------------------------------------------------------------------- /src/display/robot24.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DangerousPrototypes/BusPirate5-firmware/c3ac15d7ce16e710c05117b1614dcef9854187d4/src/display/robot24.bmp -------------------------------------------------------------------------------- /src/display/robot5x16.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DangerousPrototypes/BusPirate5-firmware/c3ac15d7ce16e710c05117b1614dcef9854187d4/src/display/robot5x16.bmp -------------------------------------------------------------------------------- /src/display/robot5xx16.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DangerousPrototypes/BusPirate5-firmware/c3ac15d7ce16e710c05117b1614dcef9854187d4/src/display/robot5xx16.bmp -------------------------------------------------------------------------------- /src/display/robot6x16.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DangerousPrototypes/BusPirate5-firmware/c3ac15d7ce16e710c05117b1614dcef9854187d4/src/display/robot6x16.bmp -------------------------------------------------------------------------------- /src/display/scope.h: -------------------------------------------------------------------------------- 1 | #ifndef _SCOPE_H_ 2 | #define _SCOPE_H_ 3 | uint32_t scope_setup(void); 4 | uint32_t scope_setup_exc(void); 5 | void scope_cleanup(void); 6 | void scope_settings(void); 7 | void scope_help(void); 8 | uint32_t scope_commands(struct command_result* result); 9 | void scope_periodic(void); 10 | void scope_lcd_update(uint32_t flags); 11 | extern volatile uint8_t scope_running; 12 | 13 | #endif 14 | -------------------------------------------------------------------------------- /src/displays.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "pico/stdlib.h" 3 | #include "pirate.h" 4 | #include "system_config.h" 5 | #include "bytecode.h" 6 | #include "command_struct.h" 7 | #include "commands.h" 8 | #include "displays.h" 9 | 10 | #include "display/default.h" 11 | #ifdef BP_USE_SCOPE 12 | #include "display/scope.h" 13 | #endif 14 | 15 | struct _display displays[MAXDISPLAY] = { 16 | { 17 | noperiodic, // service to regular poll whether a byte ahs arrived 18 | disp_default_setup, // setup UI 19 | disp_default_setup_exc, // real setup 20 | disp_default_cleanup, // cleanup for HiZ 21 | disp_default_settings, // display settings 22 | 0, // display small help about the protocol 23 | "Default", // friendly name (promptname) 24 | 0, // scope specific commands 25 | disp_default_lcd_update, // screen write 26 | }, 27 | #ifdef BP_USE_SCOPE 28 | { 29 | scope_periodic, // service to regular poll whether a byte ahs arrived 30 | scope_setup, // setup UI 31 | scope_setup_exc, // real setup 32 | scope_cleanup, // cleanup for HiZ 33 | scope_settings, // display settings 34 | scope_help, // display small help about the protocol 35 | "Scope", // friendly name (promptname) 36 | scope_commands, // scope specific commands 37 | scope_lcd_update, // scope screen write 38 | }, 39 | #endif 40 | }; 41 | /* For Emacs: 42 | * Local Variables: 43 | * mode:c 44 | * indent-tabs-mode:t 45 | * tab-width:4 46 | * c-basic-offset:4 47 | * End: 48 | * For VIM: 49 | * vim:set softtabstop=4 shiftwidth=4 tabstop=4: 50 | */ 51 | -------------------------------------------------------------------------------- /src/displays.h: -------------------------------------------------------------------------------- 1 | #ifndef __DISPLAYS_H__ 2 | #define __DISPLAYS_H__ 3 | // #include "pirate.h" 4 | 5 | enum { 6 | DISP_DEFAULT = 0, 7 | #ifdef BP_USE_SCOPE 8 | DISP_SCOPE, 9 | #endif 10 | MAXDISPLAY 11 | }; 12 | 13 | typedef struct _display { 14 | void (*display_periodic)(void); // regularly polled for events (byte arrival, etc.) 15 | uint32_t (*display_setup)(void); // setup UI 16 | uint32_t (*display_setup_exc)(void); // real setup 17 | void (*display_cleanup)(void); // cleanup for HiZ 18 | void (*display_settings)(void); // display settings 19 | void (*display_help)(void); // display protocol specific help 20 | char display_name[10]; // friendly name (promptname) 21 | uint32_t (*display_command)(struct command_result* result); // per mode command parser - ignored if 0 22 | void (*display_lcd_update)(uint32_t flags); // replacement for ui_lcd_update if non-0 23 | } _display; 24 | 25 | extern struct _display displays[MAXDISPLAY]; 26 | 27 | void nullfunc1(void); 28 | uint32_t nullfunc2(uint32_t c); 29 | uint32_t nullfunc3(void); 30 | void nullfunc4(uint32_t c); 31 | const char* nullfunc5(void); 32 | void nohelp(void); 33 | void noperiodic(void); 34 | #endif 35 | -------------------------------------------------------------------------------- /src/fatfs/00readme.txt: -------------------------------------------------------------------------------- 1 | FatFs Module Source Files R0.14b 2 | 3 | 4 | FILES 5 | 6 | 00readme.txt This file. 7 | 00history.txt Revision history. 8 | ff.c FatFs module. 9 | ffconf.h Configuration file of FatFs module. 10 | ff.h Common include file for FatFs and application module. 11 | diskio.h Common include file for FatFs and disk I/O module. 12 | diskio.c An example of glue function to attach existing disk I/O module to FatFs. 13 | ffunicode.c Optional Unicode utility functions. 14 | ffsystem.c An example of optional O/S related functions. 15 | 16 | 17 | Low level disk I/O module is not included in this archive because the FatFs 18 | module is only a generic file system layer and it does not depend on any specific 19 | storage device. You need to provide a low level disk I/O module written to 20 | control the storage device that attached to the target system. 21 | 22 | -------------------------------------------------------------------------------- /src/fatfs/tf_card.h: -------------------------------------------------------------------------------- 1 | #ifndef _TF_CARD_H_ 2 | #define _TF_CARD_H_ 3 | 4 | /* SPI pin assignment */ 5 | 6 | #include "fatfs/ff.h" /* Obtains integer types */ 7 | 8 | DSTATUS diskio_initialize(BYTE pdrv); 9 | DSTATUS diskio_status(BYTE pdrv); 10 | DRESULT diskio_read(BYTE pdrv, BYTE *buff, LBA_t sector, UINT count); 11 | DRESULT diskio_write(BYTE pdrv, const BYTE *buff, LBA_t sector, UINT count); 12 | DRESULT diskio_ioctl(BYTE pdrv, BYTE cmd, void *buff); 13 | 14 | #endif // _TF_CARD_H_ 15 | -------------------------------------------------------------------------------- /src/font/font.h: -------------------------------------------------------------------------------- 1 | typedef struct { 2 | const uint8_t width; // width in bits 3 | const uint8_t height; // height in bits 4 | const uint16_t offset; // start in font bitmap 5 | 6 | } FONT_CHAR_INFO; 7 | 8 | typedef struct { 9 | const uint8_t height_bytes; // number of bytes per column, The Dot Factory doesn't pack the data so often bits are 10 | // wasted/skipped TODO: fix the dot factory... 11 | const uint8_t start_char; // start character 12 | const uint8_t end_char; // end character 13 | const uint8_t right_padding; // pixels right padding needed 14 | const FONT_CHAR_INFO* lookup; // points to the character descriptors 15 | const uint8_t* bitmaps; // points to the bitmaps 16 | 17 | } FONT_INFO; -------------------------------------------------------------------------------- /src/lib/arduino-ch32v003-swio/LICENSE: -------------------------------------------------------------------------------- 1 | MIT No Attribution 2 | 3 | Copyright 2023 Mark Boldyrev 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this 6 | software and associated documentation files (the "Software"), to deal in the Software 7 | without restriction, including without limitation the rights to use, copy, modify, 8 | merge, publish, distribute, sublicense, and/or sell copies of the Software, and to 9 | permit persons to whom the Software is furnished to do so. 10 | 11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 12 | INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A 13 | PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 14 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 15 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 16 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------- /src/lib/arduino-ch32v003-swio/Makefile: -------------------------------------------------------------------------------- 1 | all: main.elf 2 | 3 | CFLAGS=-DF_CPU=16000000 -Wall -Wextra -O1 -mmcu=atmega328p 4 | 5 | main.elf: *.c *.h 6 | avr-gcc $(CFLAGS) *.c -o main.elf 7 | 8 | clean: 9 | rm -f main.elf 10 | -------------------------------------------------------------------------------- /src/lib/arduino-ch32v003-swio/arduino_ch32v003.h: -------------------------------------------------------------------------------- 1 | void arduino_ch32v003(); 2 | void arduino_ch32v003_cleanup(void); 3 | extern const char arduino_ch32v003_name[]; -------------------------------------------------------------------------------- /src/lib/arduino-ch32v003-swio/flash.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | avrdude -carduino -P /dev/ttyACM0 -p m328p -Uflash:w:main.elf:e 3 | -------------------------------------------------------------------------------- /src/lib/arduino-ch32v003-swio/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "uart.h" 5 | #include "swio.h" 6 | 7 | #define TARGET_POWER_PORT PORTB 8 | #define TARGET_POWER_DDR DDRB 9 | #define TARGET_POWER_BIT 1 10 | 11 | void target_power(int x) { 12 | if (x) 13 | TARGET_POWER_PORT |= _BV(TARGET_POWER_BIT); 14 | else 15 | TARGET_POWER_PORT &= ~_BV(TARGET_POWER_BIT); 16 | } 17 | 18 | #define PROTOCOL_START '!' 19 | #define PROTOCOL_ACK '+' 20 | #define PROTOCOL_TEST '?' 21 | #define PROTOCOL_POWER_ON 'p' 22 | #define PROTOCOL_POWER_OFF 'P' 23 | #define PROTOCOL_WRITE_REG 'w' 24 | #define PROTOCOL_READ_REG 'r' 25 | 26 | int main() { 27 | uint8_t reg; 28 | uint32_t val; 29 | 30 | // Make the target reset pin an output. 31 | TARGET_POWER_DDR |= _BV(TARGET_POWER_BIT); 32 | 33 | uart_init(); 34 | swio_init(); 35 | 36 | fputc(PROTOCOL_START, uart); 37 | while (1) { 38 | switch (fgetc(uart)) { 39 | case PROTOCOL_TEST: 40 | fputc(PROTOCOL_ACK, uart); 41 | break; 42 | case PROTOCOL_POWER_ON: 43 | target_power(1); 44 | fputc(PROTOCOL_ACK, uart); 45 | break; 46 | case PROTOCOL_POWER_OFF: 47 | target_power(0); 48 | fputc(PROTOCOL_ACK, uart); 49 | break; 50 | case PROTOCOL_WRITE_REG: 51 | fread(®, sizeof(uint8_t), 1, uart); 52 | fread(&val, sizeof(uint32_t), 1, uart); 53 | swio_write_reg(reg, val); 54 | fputc(PROTOCOL_ACK, uart); 55 | break; 56 | case PROTOCOL_READ_REG: 57 | fread(®, sizeof(uint8_t), 1, uart); 58 | val = swio_read_reg(reg); 59 | fwrite(&val, sizeof(uint32_t), 1, uart); 60 | break; 61 | } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /src/lib/arduino-ch32v003-swio/swio.h: -------------------------------------------------------------------------------- 1 | #ifndef SWIO_H 2 | #define SWIO_H 3 | 4 | // SWIO on PB0 5 | //#define SWIO_DDR DDRB 6 | //#define SWIO_PORT PORTB 7 | //#define SWIO_PIN PINB 8 | //#define SWIO_BIT 0 9 | 10 | void swio_init(); 11 | void swio_write_reg(uint8_t addr, uint32_t val); 12 | uint32_t swio_read_reg(uint8_t addr); 13 | 14 | #endif 15 | -------------------------------------------------------------------------------- /src/lib/arduino-ch32v003-swio/uart.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "uart.h" 3 | 4 | int _uart_putchar(char c, FILE *unused); 5 | int _uart_getchar(FILE *unused); 6 | FILE uart_file = FDEV_SETUP_STREAM(_uart_putchar, _uart_getchar, _FDEV_SETUP_READ | _FDEV_SETUP_WRITE); 7 | FILE *uart = &uart_file; 8 | 9 | void uart_init() { 10 | // Enable 2X clock. 11 | UCSR0A |= _BV(U2X0); 12 | 13 | // Set the baud rate divider. 14 | // 16M / 8 / (16 + 1) = 117647 bps (2% error) 15 | UBRR0L = 16; 16 | 17 | // Enable TX. 18 | UCSR0B |= _BV(TXEN0) | _BV(RXEN0); 19 | } 20 | 21 | int _uart_putchar(char c, FILE *unused) { 22 | (void)unused; 23 | 24 | // Wait for the UART to become ready. 25 | while (!(UCSR0A & _BV(UDRE0))) 26 | ; 27 | 28 | // Send. 29 | UDR0 = c; 30 | 31 | return 0; 32 | } 33 | 34 | int _uart_getchar(FILE *unused) { 35 | (void)*unused; 36 | 37 | // Wait for a character. 38 | while (!(UCSR0A & _BV(RXC0))) 39 | ; 40 | 41 | return UDR0; 42 | } 43 | -------------------------------------------------------------------------------- /src/lib/arduino-ch32v003-swio/uart.h: -------------------------------------------------------------------------------- 1 | #ifndef UART_H 2 | #define UART_H 3 | 4 | #include 5 | extern FILE *uart; 6 | 7 | void uart_init(); 8 | 9 | #endif 10 | -------------------------------------------------------------------------------- /src/lib/bluetag/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # CHANGELOG.md 2 | 3 | ## 1.0.2 (2024-11-19) 4 | 5 | Fixes: 6 | 7 | - JTAG scan function underwent a major change, should be more reliable now 8 | - SWD scan time is now optimized, should be much faster than before 9 | 10 | Features: 11 | - Updated default available channels from 9 to 16 12 | 13 | Others: 14 | - Updated description of the project with an image describing the pinout information 15 | 16 | ## 1.0.1 (2024-07-31) 17 | 18 | Fixes: 19 | 20 | - None 21 | 22 | Features: 23 | - Updated "jep106.inc" to include recent information (July 2024) 24 | 25 | Others: 26 | - Implemented github actions for online compilation 27 | - Added workflow to automatically generate uf2 binary on each release 28 | 29 | ## 1.0.0 (2021-09-29) 30 | 31 | Fixes: 32 | 33 | - None 34 | 35 | Features: 36 | 37 | - Initial release 38 | -------------------------------------------------------------------------------- /src/lib/bluetag/Dockerfile: -------------------------------------------------------------------------------- 1 | # Fetch ubuntu image 2 | FROM ubuntu:22.04 3 | 4 | # Install prerequisites 5 | RUN \ 6 | apt update && \ 7 | apt install -y git python3 && \ 8 | apt install -y cmake gcc-arm-none-eabi libnewlib-arm-none-eabi build-essential 9 | 10 | # Install Pico SDK 11 | RUN \ 12 | mkdir -p /project/src/ && \ 13 | cd /project/ && \ 14 | git clone https://github.com/raspberrypi/pico-sdk.git --branch master && \ 15 | cd pico-sdk/ && \ 16 | git submodule update --init && \ 17 | cd / 18 | 19 | # Set the Pico SDK environment variable 20 | ENV PICO_SDK_PATH=/project/pico-sdk/ 21 | 22 | # Copy in our source files 23 | COPY src/* /project/src/ 24 | 25 | # Build project 26 | RUN \ 27 | mkdir -p /project/src/build && \ 28 | cd /project/src/build && \ 29 | cmake .. && \ 30 | make 31 | 32 | # Command that will be invoked when the container starts 33 | ENTRYPOINT ["/bin/bash"] 34 | -------------------------------------------------------------------------------- /src/lib/bluetag/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2024 Aodrulez 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /src/lib/bluetag/images/BlueTag.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DangerousPrototypes/BusPirate5-firmware/c3ac15d7ce16e710c05117b1614dcef9854187d4/src/lib/bluetag/images/BlueTag.png -------------------------------------------------------------------------------- /src/lib/bluetag/images/BlueTagPinout.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DangerousPrototypes/BusPirate5-firmware/c3ac15d7ce16e710c05117b1614dcef9854187d4/src/lib/bluetag/images/BlueTagPinout.png -------------------------------------------------------------------------------- /src/lib/i2c_address_list/0x00-0x0F.md: -------------------------------------------------------------------------------- 1 | # 0x00 - 0x0F 2 | 3 | ## 0x00 4 | 5 | - Reserved - general call address 6 | 7 | ## 0x01 8 | 9 | - Reserved for CBUS compatibility 10 | 11 | ## 0x02 12 | 13 | - Reserved for I2C-compatible bus variants 14 | 15 | ## 0x03 16 | 17 | - Reserved for future use 18 | 19 | ## 0x04 20 | 21 | - Reserved for HS-mode controller 22 | 23 | ## 0x05 24 | 25 | - Reserved for HS-mode controller 26 | 27 | ## 0x06 28 | 29 | - Reserved for HS-mode controller 30 | 31 | ## 0x07 32 | 33 | - Reserved for HS-mode controller 34 | 35 | ## 0x0B 36 | 37 | - [LC709203F Fuel Gauge and Battery Monitor](https://www.adafruit.com/product/4712) (0x0B only) 38 | 39 | ## 0x0C 40 | 41 | - [MLX90393 3-Axis Magnetometer](https://www.adafruit.com/product/4022) (0x0C - 0x0F) 42 | 43 | ## 0x0D 44 | 45 | - [MLX90393 3-Axis Magnetometer](https://www.adafruit.com/product/4022) (0x0C - 0x0F) 46 | 47 | ## 0x0E 48 | 49 | - MAG3110 3-Axis Magnetometer (0x0E only) 50 | - [MLX90393 3-Axis Magnetometer](https://www.adafruit.com/product/4022) (0x0C - 0x0F) 51 | 52 | ## 0x0F 53 | 54 | - [MLX90393 3-Axis Magnetometer](https://www.adafruit.com/product/4022) (0x0C - 0x0F) 55 | -------------------------------------------------------------------------------- /src/lib/i2c_address_list/LICENSES/MIT.txt: -------------------------------------------------------------------------------- 1 | MIT License Copyright (c) 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is furnished 8 | to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice (including the next 11 | paragraph) shall be included in all copies or substantial portions of the 12 | Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 16 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS 17 | OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 18 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF 19 | OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | -------------------------------------------------------------------------------- /src/lib/i2c_address_list/LICENSES/Unlicense.txt: -------------------------------------------------------------------------------- 1 | This is free and unencumbered software released into the public domain. 2 | 3 | Anyone is free to copy, modify, publish, use, compile, sell, or distribute 4 | this software, either in source code form or as a compiled binary, for any 5 | purpose, commercial or non-commercial, and by any means. 6 | 7 | In jurisdictions that recognize copyright laws, the author or authors of this 8 | software dedicate any and all copyright interest in the software to the public 9 | domain. We make this dedication for the benefit of the public at large and 10 | to the detriment of our heirs and successors. We intend this dedication to 11 | be an overt act of relinquishment in perpetuity of all present and future 12 | rights to this software under copyright law. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 16 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS 17 | BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 18 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH 19 | THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. For more information, 20 | please refer to 21 | -------------------------------------------------------------------------------- /src/lib/i2c_address_list/README.md: -------------------------------------------------------------------------------- 1 | # I2C_Addresses 2 | 3 | List of I2C addresses for various devices by address range. 4 | 5 | ## Adding New I2C Addresses 6 | 7 | To add or update an I2C address, you can submit a pull request this repository. For 8 | instructions on how to submit a pull request (and working with `git` in general), 9 | see [this Learn guide on the subject](https://learn.adafruit.com/contribute-to-circuitpython-with-git-and-github/overview). 10 | 11 | To add a new I2C address, go to the markdown page associated with the 12 | first hex digit. For example, if you want to add a new device with 13 | an I2C address of `0x4E`, you would go add it to the `0x40-0x4F.md` 14 | page. 15 | 16 | Within that page, find the header for the I2C Address you'd like to 17 | add to. Again, using `0x4E` as an example address, you would find 18 | the header for it towards the end of the page. 19 | 20 | You should then add it as a list item containing the device name and 21 | the I2C address range(s) the device can take. For example, the `0x4E` 22 | device (say, the ABC1234 temperature sensor) would be added as follows: 23 | 24 | ```markdown 25 | - ABC1234 Temperature Sensor (0x4E) 26 | ``` 27 | 28 | If there is a product page associated with the device, you can add the link by using `[text](link)` notation: 29 | 30 | ```markdown 31 | - [ABC1234 Temperature Sensor](wwww.link_to_product_page.com) 32 | ``` 33 | 34 | > **_NOTE:_** Make sure to add the device under all the headers it can 35 | > use. For example, if a device can use `0x35`, `0x36`, and `0x61`, 36 | > you should add it under the `0x35` and `0x36` headers in `0x30-0x3F.md`, 37 | > and under the `0x61` header in `0x60-0x6F.md`. 38 | -------------------------------------------------------------------------------- /src/lib/i2c_address_list/README.md.license: -------------------------------------------------------------------------------- 1 | SPDX-FileCopyrightText: 2022 Kattni Rembor for Adafruit Industries 2 | 3 | SPDX-License-Identifier: MIT 4 | -------------------------------------------------------------------------------- /src/lib/i2c_address_list/dev_i2c_addresses.ht: -------------------------------------------------------------------------------- 1 | enum DEV_I2C_LIST{ 2 | DEV_I2C_LIST_NONE=0, 3 | %%%enum_list%%% 4 | }; 5 | 6 | static char const * const dev_i2c_addresses_text[]={ 7 | [DEV_I2C_LIST_NONE]="", 8 | %%%array_data%%% 9 | }; 10 | 11 | static const char *dev_i2c_addresses[]={ 12 | %%%pointer_array%%% 13 | }; -------------------------------------------------------------------------------- /src/lib/i2c_address_list/special_cases.md: -------------------------------------------------------------------------------- 1 | # Special cases: 2 | 3 | - PCA9685 can use any address between 0x40 to 0x7F. Some of these addresses are fixed. See the 4 | [datasheet](https://cdn-shop.adafruit.com/datasheets/PCA9685.pdf) for details. This chip is used in: 5 | - PWM/Servo Breakout 6 | - PWM/Servo Shield 7 | - PWM/Servo HAT 8 | - PWM/Servo Bonnet 9 | - PWM/Servo Wing 10 | - DC & Stepper Motor Shield 11 | - DC & Stepper Motor HAT 12 | - DC & Stepper Motor Bonnet 13 | - DC & Stepper Motor Wing 14 | - 0x00 - 0x07 and 0x78 - 0x7F are reserved I2C addresses 15 | -------------------------------------------------------------------------------- /src/lib/i2c_address_list/troublesome_chips.md: -------------------------------------------------------------------------------- 1 | # Troublesome chips: 2 | 3 | Some sensors or chips have non-standard behavior that causes issues when 4 | trying to use I2C. Here's a few of the ones to watch for 5 | 6 | - AGS20MA - Use a bus speed of 20-30 kHz. 7 | - ATECCx08 - Use slow-speed I2C to get out of sleep mode. 8 | - BNO055, BNO085 - Uses clock stretching, violates I2C protocol timing in some caes, and sometimes needs to be reset. Does not work well on i.MX RT10xx chips, ESP32, ESP32-S3. 9 | - CCS811 - Uses clock stretching. 10 | - LC709203F - Repeated start, clock stretching, sleep mode 11 | - MCP9600 (date codes 1845 or before) - bug: duplicate data from register. 12 | reads, perhaps due to clock stretching. 13 | - MCP9600, MCP9601 - Repeated start, clock stretching. Often will not 14 | respond to zero-length writes, so scanning the I2C bus to find the 15 | device can fail. 16 | - PN532 - Clock stretching. 17 | 18 | If you're using Raspberry Pi with these chips, check out our 19 | [guide on how to work-around clock stretching](https://learn.adafruit.com/circuitpython-on-raspberrypi-linux/i2c-clock-stretching). 20 | 21 | # Troublesome microcontrollers: 22 | 23 | - MicroChip Atmel SAMD21, SAMx5x - I2C bus frequency below 95 kHz not available when I2Cperipheral is drive with a 48 MHz clock, 24 | which is typical. CircuitPython checks for out-of-range bus frequencies. 25 | 26 | - Espressif ESP32-S3 - Use software that uses Espressif ESP-IDF v5.0.0 or later. ESP32-S3 has problems with I2C devices that do clock stretching or have other unusual timing behavior, when using versions of the ESP-IDF SDK _older_ than v5.0.0. ESP-IDF, provided by Espressif, is the underlying software used by CircuitPython and the Arduino `esp32` board support package. CircuitPython 9.0.0 and later and Arduino `esp32` v5.0.0 and later use ESP-IDF v5 and later. These versions support most I2C devices well. However, some of the troublesome chips listed above still don't work well or at all even with ESP-IDF v5. 27 | -------------------------------------------------------------------------------- /src/lib/minmea/COPYING: -------------------------------------------------------------------------------- 1 | DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE 2 | Version 2, December 2004 3 | 4 | Copyright (C) 2004 Sam Hocevar 5 | 6 | Everyone is permitted to copy and distribute verbatim or modified 7 | copies of this license document, and changing it is allowed as long 8 | as the name is changed. 9 | 10 | DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE 11 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 12 | 13 | 0. You just DO WHAT THE FUCK YOU WANT TO. 14 | -------------------------------------------------------------------------------- /src/lib/minmea/LICENSE.MIT: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 Kosma Moczek 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 6 | 7 | The above copyright notice and this permission notice (including the next paragraph) shall be included in all copies or substantial portions of the Software. 8 | 9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 10 | -------------------------------------------------------------------------------- /src/lib/minmea/LICENSE.grants: -------------------------------------------------------------------------------- 1 | At your option, if WTFPL is unacceptable for your legal department, I hereby 2 | explicitly grant you the right to use any the following licenses for minmea: 3 | 4 | 1. MIT License 5 | 2. LGPL-3.0 License or later 6 | 7 | See accompanying license files for full license text. 8 | -------------------------------------------------------------------------------- /src/lib/minmea/gps.h: -------------------------------------------------------------------------------- 1 | void process_gps(char *line); -------------------------------------------------------------------------------- /src/lib/ms5611/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2016 TE Connectivity 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /src/lib/ms5611/README.md: -------------------------------------------------------------------------------- 1 | # MS5611 Generic C Driver 2 | Generic C driver for the [MS5611 sensor](http://www.te.com/usa-en/product-CAT-BLPS0036.html) 3 | 4 | ![ms5611](http://www.te.com/content/dam/te-com/catalog/part/CAT/BLP/S00/CAT-BLPS0036-t1.jpg/jcr:content/renditions/product-details.png) 5 | 6 | The MS5611 sensor is a self-contained pressure and temperature sensor that is fully calibrated during manufacture. The sensor can operate from 1.5V to 3.6V. The sensor module includes a high-linearity pressure sensor and an ultra-low power 24 bit ΔΣ ADC with internal factory-calibrated coefficients. 7 | 8 | ### Specifications 9 | * Measures pressure from 10mbar to 1200mbar 10 | * Measures temperature from -40°C to 125°C 11 | * I2C communication 12 | * Fully calibrated 13 | * Fast response time 14 | * Very low power consumption 15 | 16 | 17 | ### Library features 18 | * Connection test 19 | * Reset 20 | * Aquisition resolution management 21 | * Temperature and pressure measurement 22 | 23 | 24 | **NB:** This driver is intended to provide an implementation example of the sensor communication protocol, in order to be usable you have to implement a proper I2C layer for your target platform. 25 | -------------------------------------------------------------------------------- /src/lib/pico-i2c-sniff/.gitignore: -------------------------------------------------------------------------------- 1 | build -------------------------------------------------------------------------------- /src/lib/pico-i2c-sniff/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Set minimum required version of CMake 2 | cmake_minimum_required(VERSION 3.12) 3 | 4 | # Include build functions from Pico SDK 5 | include($ENV{PICO_SDK_PATH}/external/pico_sdk_import.cmake) 6 | include($ENV{PICO_SDK_PATH}/tools/CMakeLists.txt) 7 | 8 | # Set name of project (as PROJECT_NAME) and C/C++ standards 9 | project(i2c_sniffer_pio C CXX ASM) 10 | set(CMAKE_C_STANDARD 11) 11 | set(CMAKE_CXX_STANDARD 17) 12 | 13 | # Creates a pico-sdk subdirectory in our project for the libraries 14 | pico_sdk_init() 15 | 16 | # Tell CMake where to find the executable source file 17 | add_executable(${PROJECT_NAME} 18 | main.c 19 | ram_fifo.c 20 | ) 21 | 22 | # Create C header file with the name .pio.h 23 | pico_generate_pio_header(${PROJECT_NAME} 24 | ${CMAKE_CURRENT_LIST_DIR}/i2c_sniffer.pio 25 | ) 26 | 27 | # Create map/bin/hex/uf2 files 28 | pico_add_extra_outputs(${PROJECT_NAME}) 29 | 30 | # Link to pico_stdlib (gpio, time, etc. functions) 31 | target_link_libraries(${PROJECT_NAME} 32 | pico_stdlib 33 | hardware_pio 34 | pico_multicore 35 | ) 36 | 37 | target_compile_definitions(${PROJECT_NAME} PUBLIC PICO_STDOUT_MUTEX=0 PICO_STDIO_ENABLE_CRLF_SUPPORT=0) 38 | 39 | # Enable usb output, disable uart output 40 | pico_enable_stdio_usb(${PROJECT_NAME} 1) 41 | pico_enable_stdio_uart(${PROJECT_NAME} 0) -------------------------------------------------------------------------------- /src/lib/pico-i2c-sniff/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 Juan Schiavoni 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /src/lib/pico-i2c-sniff/ram_fifo.c: -------------------------------------------------------------------------------- 1 | /** 2 | * FIFO in RAM. 3 | * (C) Juan Schiavoni 2021 4 | */ 5 | #include 6 | #include "ram_fifo.h" 7 | 8 | static uint32_t *capture_buf = NULL; 9 | 10 | static uint32_t capture_set = 0; 11 | static uint32_t capture_get = 0; 12 | static uint32_t capture_count = 0; 13 | static uint32_t capture_size = 0; 14 | 15 | bool ram_fifo_init(size_t size) { 16 | capture_buf = malloc(size * sizeof(uint32_t)); 17 | capture_size = size; 18 | capture_set = 0; 19 | capture_get = 0; 20 | capture_count = 0; 21 | 22 | return (capture_buf != NULL); 23 | } 24 | 25 | bool ram_fifo_is_empty(void){ 26 | return (capture_count == 0); 27 | } 28 | 29 | bool ram_fifo_set(uint32_t item) { 30 | if (capture_set >= capture_size){ 31 | capture_set = 0; 32 | } 33 | 34 | if (capture_count < capture_size) { 35 | capture_buf[capture_set++] = item; 36 | 37 | capture_count++; 38 | return true; 39 | } 40 | 41 | return false; 42 | } 43 | 44 | uint32_t ram_fifo_get(void) { 45 | if (capture_get >= capture_size){ 46 | capture_get = 0; 47 | } 48 | 49 | capture_count--; 50 | 51 | return capture_buf[capture_get++]; 52 | } -------------------------------------------------------------------------------- /src/lib/pico-i2c-sniff/ram_fifo.h: -------------------------------------------------------------------------------- 1 | /** 2 | * FIFO in RAM. 3 | * (C) Juan Schiavoni 2021 4 | */ 5 | #include 6 | #include "pico/types.h" 7 | 8 | /*! \brief Initialice the FIFO. 9 | * \ingroup ram_fifo 10 | * 11 | * This function don't block until there is space for the data to be insert. 12 | * Use ram_fifo_is_empty() to check if it is possible to inset to the. 13 | * 14 | * \param count quantity of items for FIFO 15 | * @return true if there is enough dynamic memory, false otherwise 16 | */ 17 | bool ram_fifo_init(size_t count); 18 | 19 | /*! \brief Check if the FIFO is empty 20 | * \ingroup ram_fifo 21 | * 22 | * @return true if the FIFO has room for more data, false otherwise 23 | */ 24 | bool ram_fifo_is_empty(void); 25 | 26 | /*! \brief Push data on to the FIFO. 27 | * \ingroup ram_fifo 28 | * 29 | * This function don't block until there is space for the data to be insert. 30 | * Use ram_fifo_is_empty() to check if it is possible to inset to the. 31 | * 32 | * \param item A 32 bit value to push on to the FIFO 33 | * @return true if the FIFO has room for the data, false otherwise 34 | */ 35 | bool ram_fifo_set(uint32_t item); 36 | 37 | /*! \brief Pop data from the FIFO. 38 | * \ingroup ram_fifo 39 | * 40 | * This function don't block until there is data ready to be read 41 | * Use ram_fifo_is_empty() to check if data is ready to be read. 42 | * 43 | * \return 32 bit unsigned data from the FIFO. 44 | */ 45 | uint32_t ram_fifo_get(void); -------------------------------------------------------------------------------- /src/lib/pico-i2c-sniff/test_i2c_sniffer/status_tof/status_tof.ino: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | // The Arduino two-wire interface uses a 7-bit number for the address, 4 | // and sets the last bit correctly based on reads and writes 5 | #define ADDRESS_DEFAULT 0b0101001 6 | #define XSHUT_PIN 17 // Pin de control de modo bajo consumo. 7 | #define RESULT_INTERRUPT_STATUS 0x13 8 | 9 | uint8_t last_status; // status of last I2C transmission 10 | 11 | void setup() { 12 | // Precaucion 13 | // El pin Shutdown del VL53L0X es activo bajo y no tolera 5V. Se puede quemar. 14 | pinMode( XSHUT_PIN, OUTPUT ); 15 | 16 | delay( 5 ); 17 | 18 | pinMode( XSHUT_PIN, INPUT ); 19 | 20 | //For power-up procedure t-boot max 1.2ms "Datasheet: 2.9 Power sequence" 21 | delay( 10 ); 22 | 23 | Wire.begin(); 24 | Wire.setClock(400000); 25 | 26 | Serial.begin(115200); // start serial for output 27 | Serial.println("Start status TOF"); 28 | } 29 | 30 | void loop() { 31 | // put your main code here, to run repeatedly: 32 | uint8_t val = readReg(RESULT_INTERRUPT_STATUS); 33 | 34 | Serial.print(millis()); 35 | Serial.print(" slave: "); 36 | Serial.print((ADDRESS_DEFAULT << 1), HEX); 37 | Serial.print(", register: "); 38 | Serial.print(RESULT_INTERRUPT_STATUS, HEX); 39 | Serial.print(", read status: "); 40 | Serial.println(val, HEX); 41 | 42 | delay(10); 43 | } 44 | 45 | // Read an 8-bit register 46 | uint8_t readReg(uint8_t reg) 47 | { 48 | uint8_t value; 49 | 50 | Wire.beginTransmission(ADDRESS_DEFAULT); 51 | Wire.write(reg); 52 | last_status = Wire.endTransmission(); 53 | 54 | Wire.requestFrom((uint8_t)ADDRESS_DEFAULT, (uint8_t)1); 55 | value = Wire.read(); 56 | 57 | return value; 58 | } 59 | -------------------------------------------------------------------------------- /src/lib/pico_ir_nec/nec_carrier_burst.pio: -------------------------------------------------------------------------------- 1 | ; 2 | ; Copyright (c) 2021 mjcross 3 | ; 4 | ; SPDX-License-Identifier: BSD-3-Clause 5 | ; 6 | 7 | 8 | .program nec_carrier_burst 9 | 10 | ; Generate bursts of carrier. 11 | ; 12 | ; Repeatedly wait for an IRQ to be set then clear it and generate 21 cycles of 13 | ; carrier with 25% duty cycle 14 | ; 15 | .define NUM_CYCLES 21 ; how many carrier cycles to generate 16 | .define BURST_IRQ 7 ; which IRQ should trigger a carrier burst 17 | .define public TICKS_PER_LOOP 4 ; the number of instructions in the loop (for timing) 18 | 19 | .wrap_target 20 | set X, (NUM_CYCLES - 1) ; initialise the loop counter 21 | wait 1 irq BURST_IRQ ; wait for the IRQ then clear it 22 | cycle_loop: 23 | set pins, 1 ; set the pin high (1 cycle) 24 | set pins, 0 [1] ; set the pin low (2 cycles) 25 | jmp X--, cycle_loop ; (1 more cycle) 26 | .wrap 27 | 28 | 29 | % c-sdk { 30 | static inline void nec_carrier_burst_program_init(PIO pio, uint sm, uint offset, uint pin, float freq) { 31 | // Create a new state machine configuration 32 | // 33 | pio_sm_config c = nec_carrier_burst_program_get_default_config (offset); 34 | 35 | // Map the SET pin group to one pin, namely the `pin` 36 | // parameter to this function. 37 | // 38 | sm_config_set_set_pins (&c, pin, 1); 39 | 40 | // Set the GPIO function of the pin (connect the PIO to the pad) 41 | // 42 | pio_gpio_init (pio, pin); 43 | 44 | // Set the pin direction to output at the PIO 45 | // 46 | pio_sm_set_consecutive_pindirs (pio, sm, pin, 1, true); 47 | 48 | // Set the clock divider to generate the required frequency 49 | // 50 | float div = clock_get_hz (clk_sys) / (freq * nec_carrier_burst_TICKS_PER_LOOP); 51 | sm_config_set_clkdiv (&c, div); 52 | 53 | // Apply the configuration to the state machine 54 | // 55 | pio_sm_init (pio, sm, offset, &c); 56 | 57 | // Set the state machine running 58 | // 59 | pio_sm_set_enabled (pio, sm, true); 60 | } 61 | %} 62 | -------------------------------------------------------------------------------- /src/lib/pico_ir_nec/nec_receive.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2021 mjcross 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | #include "pico/stdlib.h" 8 | #include "hardware/pio.h" 9 | 10 | // public API 11 | int nec_rx_init(uint pin); 12 | void nec_rx_deinit(uint pin_num); 13 | bool nec_decode_frame(uint32_t *frame, uint8_t *p_address, uint8_t *p_data); 14 | ir_rx_status_t nec_get_frame(uint32_t *rx_frame) ; 15 | void nec_rx_drain_fifo(void) ; 16 | -------------------------------------------------------------------------------- /src/lib/pico_ir_nec/nec_transmit.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2021 mjcross 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | #include "pico/stdlib.h" 8 | #include "hardware/pio.h" 9 | 10 | // public API 11 | 12 | int nec_tx_init(uint pin,uint32_t mod_freq); 13 | void nec_tx_deinit(uint pin_num); 14 | uint32_t nec_encode_frame(uint8_t address, uint8_t data); 15 | void nec_send_frame(uint32_t tx_frame); 16 | void nec_write(uint32_t *data); 17 | bool nec_tx_wait_idle(void); 18 | -------------------------------------------------------------------------------- /src/lib/picofreq/picofreq.h: -------------------------------------------------------------------------------- 1 | #ifndef IRIO_PIO_H 2 | #define IRIO_PIO_H 3 | 4 | // Function declarations 5 | void freq_counter_init(int pin); 6 | void gate_timer_init(int pin); 7 | void freq_counter_start(void); 8 | void dma_handler(void); 9 | void gpio_fall_irq_handler(uint gpio, uint32_t events); 10 | bool freq_counter_value_ready(void); 11 | int freq_counter_value(void); 12 | int edge_counter_frequency(void); 13 | #endif // IRIO_PIO_H -------------------------------------------------------------------------------- /src/lib/picorvd/picoswio.h: -------------------------------------------------------------------------------- 1 | void ch32vswio_reset(int pin, int dirpin); 2 | uint32_t ch32vswio_get(uint32_t addr); 3 | void ch32vswio_put(uint32_t addr, uint32_t data); 4 | void ch32vswio_cleanup(void); -------------------------------------------------------------------------------- /src/lib/pio_pwm/pwm.pio: -------------------------------------------------------------------------------- 1 | ; 2 | ; Copyright (c) 2020 Raspberry Pi (Trading) Ltd. 3 | ; 4 | ; SPDX-License-Identifier: BSD-3-Clause 5 | ; 6 | 7 | ; Side-set pin 0 is used for PWM output 8 | .pio_version 0 // only requires PIO version 0 9 | 10 | .program pwm 11 | .side_set 2 opt 12 | 13 | pull noblock side 0b00 ; Pull from FIFO to OSR if available, else copy X to OSR. 14 | mov x, osr ; Copy most-recently-pulled value back to scratch X 15 | mov y, isr ; ISR contains PWM period. Y used as counter. 16 | countloop: 17 | jmp x!=y noset ; Set pin high if X == Y, keep the two paths length matched 18 | jmp skip side 0b11 19 | noset: 20 | nop ; Single dummy cycle to keep the two paths the same length 21 | skip: 22 | jmp y-- countloop ; Loop until Y hits 0, then pull a fresh PWM value from FIFO 23 | 24 | % c-sdk { 25 | static inline void pwm_program_init(PIO pio, uint sm, uint offset, uint pin) { 26 | pio_gpio_init(pio, pin); 27 | pio_gpio_init(pio, pin+1); 28 | pio_sm_set_consecutive_pindirs(pio, sm, pin, 2, true); 29 | pio_sm_config c = pwm_program_get_default_config(offset); 30 | sm_config_set_sideset_pins(&c, pin); 31 | pio_sm_init(pio, sm, offset, &c); 32 | } 33 | %} 34 | -------------------------------------------------------------------------------- /src/lib/rtt/LICENSE.md: -------------------------------------------------------------------------------- 1 | 2 | SEGGER Microcontroller GmbH 3 | The Embedded Experts 4 | 5 | (c) 1995 - 2021 SEGGER Microcontroller GmbH 6 | www.segger.com Support: support@segger.com 7 | 8 | SEGGER RTT Real Time Transfer for embedded targets 9 | 10 | 11 | All rights reserved. 12 | 13 | SEGGER strongly recommends to not make any changes 14 | to or modify the source code of this software in order to stay 15 | compatible with the RTT protocol and J-Link. 16 | 17 | Redistribution and use in source and binary forms, with or 18 | without modification, are permitted provided that the following 19 | condition is met: 20 | 21 | - Redistributions of source code must retain the above copyright 22 | notice, this condition and the following disclaimer. 23 | 24 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 25 | CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 26 | INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 27 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 28 | DISCLAIMED. IN NO EVENT SHALL SEGGER Microcontroller BE LIABLE FOR 29 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 30 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 31 | OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 32 | OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 33 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 34 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE 35 | USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 36 | DAMAGE. 37 | -------------------------------------------------------------------------------- /src/lib/rtt/README.md: -------------------------------------------------------------------------------- 1 | RTT 2 | === 3 | 4 | SEGGER RTT Sources 5 | 6 | https://www.segger.com/products/debug-probes/j-link/technology/about-real-time-transfer 7 | https://wiki.segger.com/RTT 8 | 9 | ## Included files 10 | 11 | * `RTT/` 12 | * `SEGGER_RTT.c` - Main module for RTT. 13 | * `SEGGER_RTT.h` - Main header for RTT. 14 | * `SEGGER_RTT_ASM_ARMv7M.S` - Assembly-optimized implementation of RTT functions for ARMv7M processors. 15 | * `SEGGER_RTT_Printf.c` - Simple implementation of printf (`SEGGER_RTT_Printf()`) to write formatted strings via RTT. 16 | * `Syscalls/` 17 | * `SEGGER_RTT_Syscalls_*.c` - Low-level syscalls to retarget `printf()` to RTT with different toolchains. 18 | * `Config/` 19 | * `SEGGER_RTT_Conf.h` - RTT configuration file. 20 | * `Examples/` 21 | * `Main_RTT_InputEchoApp.c` - Example application which echoes input on Channel 0. 22 | * `Main_RTT_MenuApp.c` - Example application to demonstrate RTT bi-directional functionality. 23 | * `Main_RTT_PrintfTest.c` - Example application to test RTT's simple printf implementation. 24 | * `Main_RTT_SpeedTestApp.c` - Example application to measure RTT performance. (Requires embOS) 25 | -------------------------------------------------------------------------------- /src/lib/sfud/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016-2018 Armink (armink.ztl@gmail.com) 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining 6 | a copy of this software and associated documentation files (the 7 | 'Software'), to deal in the Software without restriction, including 8 | without limitation the rights to use, copy, modify, merge, publish, 9 | distribute, sublicense, and/or sell copies of the Software, and to 10 | permit persons to whom the Software is furnished to do so, subject to 11 | the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be 14 | included in all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 19 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 20 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 21 | TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 22 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------- /src/lib/sfud/inc/sfud_cfg.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the Serial Flash Universal Driver Library. 3 | * 4 | * Copyright (c) 2016-2018, Armink, 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining 7 | * a copy of this software and associated documentation files (the 8 | * 'Software'), to deal in the Software without restriction, including 9 | * without limitation the rights to use, copy, modify, merge, publish, 10 | * distribute, sublicense, and/or sell copies of the Software, and to 11 | * permit persons to whom the Software is furnished to do so, subject to 12 | * the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be 15 | * included in all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, 18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 20 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 21 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 22 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 23 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | * 25 | * Function: It is the configure head file for this library. 26 | * Created on: 2016-04-23 27 | */ 28 | 29 | #ifndef _SFUD_CFG_H_ 30 | #define _SFUD_CFG_H_ 31 | 32 | #define SFUD_DEBUG_MODE 33 | 34 | #define SFUD_USING_SFDP 35 | 36 | // #define SFUD_USING_FAST_READ 37 | 38 | #define SFUD_USING_FLASH_INFO_TABLE 39 | 40 | enum { 41 | SFUD_SST25_DEVICE_INDEX = 0, 42 | }; 43 | 44 | #define SFUD_FLASH_DEVICE_TABLE \ 45 | { \ 46 | [SFUD_SST25_DEVICE_INDEX] = {.name = "SST25VF016B", .spi.name = "SPI1"}, \ 47 | } 48 | 49 | //#define SFUD_USING_QSPI 50 | 51 | #endif /* _SFUD_CFG_H_ */ 52 | -------------------------------------------------------------------------------- /src/lib/sfud/inc/sfud_port-stm32.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DangerousPrototypes/BusPirate5-firmware/c3ac15d7ce16e710c05117b1614dcef9854187d4/src/lib/sfud/inc/sfud_port-stm32.c -------------------------------------------------------------------------------- /src/lib/sigrok/pico_sdk_sigrok.h: -------------------------------------------------------------------------------- 1 | void pico_sdk_sigrok_no_usb(void); 2 | void pico_sdk_sigrok_usb(void); -------------------------------------------------------------------------------- /src/lib/tsl2561/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 - present LibDriver 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /src/mode/HD44780.h: -------------------------------------------------------------------------------- 1 | 2 | 3 | void HD44780_setup(void); 4 | void HD44780_cleanup(void); 5 | uint32_t HD44780_write(uint32_t d); 6 | uint32_t HD44780_read(void); 7 | void HD44780_writenibble(uint8_t rs, uint8_t d); 8 | void HD44780_init(uint8_t lines); 9 | void HD44780_reset(void); 10 | void HD44780_macro(uint32_t macro); 11 | -------------------------------------------------------------------------------- /src/mode/LCDSPI.h: -------------------------------------------------------------------------------- 1 | 2 | uint32_t LCDSPI_send(uint32_t d); 3 | uint32_t LCDSPI_read(void); 4 | void LCDSPI_macro(uint32_t macro); 5 | void LCDSPI_setup(void); 6 | void LCDSPI_setup_exc(void); 7 | void LCDSPI_cleanup(void); 8 | void LCDSPI_pins(void); 9 | void LCDSPI_settings(void); 10 | 11 | enum { 12 | HD44780 = 0, 13 | #ifdef DISPLAY_USE_ST7735 14 | ST7735, 15 | #endif 16 | MAXDISPLAYS 17 | }; 18 | -------------------------------------------------------------------------------- /src/mode/ST7735.h: -------------------------------------------------------------------------------- 1 | 2 | 3 | void ST7735_setup(void); 4 | void ST7735_cleanup(void); 5 | uint32_t ST7735_send(uint32_t d); 6 | uint32_t ST7735_read(void); 7 | void ST7735_macro(uint32_t macro); 8 | void ST7735_writedat(uint8_t d); 9 | void ST7735_writecmd(uint8_t c); 10 | void ST7735_sendinitseq(const uint8_t* addr); 11 | 12 | #define ST7735_NOP 0x00 13 | #define ST7735_SWRESET 0x01 14 | #define ST7735_RDDID 0x04 15 | #define ST7735_RDDST 0x09 16 | 17 | #define ST7735_SLPIN 0x10 18 | #define ST7735_SLPOUT 0x11 19 | #define ST7735_PTLON 0x12 20 | #define ST7735_NORON 0x13 21 | 22 | #define ST7735_INVOFF 0x20 23 | #define ST7735_INVON 0x21 24 | #define ST7735_DISPOFF 0x28 25 | #define ST7735_DISPON 0x29 26 | #define ST7735_CASET 0x2A 27 | #define ST7735_RASET 0x2B 28 | #define ST7735_RAMWR 0x2C 29 | #define ST7735_RAMRD 0x2E 30 | 31 | #define ST7735_PTLAR 0x30 32 | #define ST7735_COLMOD 0x3A 33 | #define ST7735_MADCTL 0x36 34 | 35 | #define ST7735_FRMCTR1 0xB1 36 | #define ST7735_FRMCTR2 0xB2 37 | #define ST7735_FRMCTR3 0xB3 38 | #define ST7735_INVCTR 0xB4 39 | #define ST7735_DISSET5 0xB6 40 | 41 | #define ST7735_PWCTR1 0xC0 42 | #define ST7735_PWCTR2 0xC1 43 | #define ST7735_PWCTR3 0xC2 44 | #define ST7735_PWCTR4 0xC3 45 | #define ST7735_PWCTR5 0xC4 46 | #define ST7735_VMCTR1 0xC5 47 | 48 | #define ST7735_RDID1 0xDA 49 | #define ST7735_RDID2 0xDB 50 | #define ST7735_RDID3 0xDC 51 | #define ST7735_RDID4 0xDD 52 | 53 | #define ST7735_PWCTR6 0xFC 54 | 55 | #define ST7735_GMCTRP1 0xE0 56 | #define ST7735_GMCTRN1 0xE1 57 | -------------------------------------------------------------------------------- /src/mode/SW3W.h: -------------------------------------------------------------------------------- 1 | 2 | void SW3W_start(void); 3 | void SW3W_startr(void); 4 | void SW3W_stop(void); 5 | void SW3W_stopr(void); 6 | uint32_t SW3W_send(uint32_t d); 7 | uint32_t SW3W_read(void); 8 | void SW3W_clkh(void); 9 | void SW3W_clkl(void); 10 | void SW3W_dath(void); 11 | void SW3W_datl(void); 12 | uint32_t SW3W_dats(void); 13 | void SW3W_clk(void); 14 | uint32_t SW3W_bitr(void); 15 | uint32_t SW3W_period(void); 16 | void SW3W_macro(uint32_t macro); 17 | void SW3W_setup(void); 18 | void SW3W_setup_exc(void); 19 | void SW3W_cleanup(void); 20 | void SW3W_pins(void); 21 | void SW3W_settings(void); 22 | void SW3W_help(void); 23 | 24 | #define SW3WPERIODMENU "\r\nPeriodd in us (>20)\r\nperiod> " 25 | #define SW3WCSMENU "\r\nCS mode\r\n 1. CS\r\n 2. !CS*\r\ncs> " 26 | #define SW3WODMENU \ 27 | "\r\nSelect output type:\r\n 1. Normal (H=3.3V, L=GND)*\r\n 2. Open drain (H=Hi-Z, L=GND)\r\noutput> " 28 | #define SW3WCPOLMENU "\r\nClock polarity\r\n 1. idle low\r\n 2. idle high*\r\ncpol> " 29 | #define SW3WCPHAMENU "\r\nClock phase\r\n 1. leading edge\r\n 2. trailing edge*\r\ncpha> " 30 | -------------------------------------------------------------------------------- /src/mode/SWI2C.h: -------------------------------------------------------------------------------- 1 | // TODO: Short/pullup detection 2 | // TODO: read/write mode tracking 3 | // TODO: speed validation 4 | void SWI2C_start(void); 5 | void SWI2C_stop(void); 6 | uint32_t SWI2C_write(uint32_t d); 7 | uint32_t SWI2C_read(void); 8 | void SWI2C_macro(uint32_t macro); 9 | void SWI2C_setup(void); 10 | void SWI2C_setup_exc(void); 11 | void SWI2C_cleanup(void); 12 | void SWI2C_pins(void); 13 | void SWI2C_settings(void); 14 | void SWI2C_help(void); 15 | void I2C_search(void); 16 | 17 | #define SWI2CSPEEDMENU "\r\nSpeed\r\n 1. 100kHz\r\n 2. 400Khz\r\nspeed> " 18 | 19 | #define LA_SWI2C_PERIOD_100KHZ (((100000000 / 100) / 4) / (10000000 / 72000)) / 10 20 | #define LA_SWI2C_PERIOD_400KHZ (((100000000 / 400) / 4) / (10000000 / 72000)) / 10 21 | -------------------------------------------------------------------------------- /src/mode/binloopback.h: -------------------------------------------------------------------------------- 1 | void binloopback_open(struct _bytecode* result, struct _bytecode* next); // start 2 | void binloopback_open_read(struct _bytecode* result, struct _bytecode* next); // start with read 3 | void binloopback_close(struct _bytecode* result, struct _bytecode* next); // stop 4 | void binloopback_write(struct _bytecode* result, struct _bytecode* next); 5 | void binloopback_read(struct _bytecode* result, struct _bytecode* next); 6 | void binloopback_macro(uint32_t macro); 7 | uint32_t binloopback_setup(void); 8 | uint32_t binloopback_setup_exc(void); 9 | void binloopback_cleanup(void); 10 | void binloopback_pins(void); 11 | void binloopback_settings(void); 12 | void binloopback_printerror(void); 13 | void binloopback_help(void); 14 | void binloopback_periodic(void); 15 | 16 | typedef struct _binloopback_mode_config { 17 | 18 | uint32_t blocking; 19 | bool async_print; 20 | } _binloopback_mode_config; 21 | 22 | extern const struct _mode_command_struct binloopback_commands[]; 23 | extern const uint32_t binloopback_commands_count; -------------------------------------------------------------------------------- /src/mode/dio.h: -------------------------------------------------------------------------------- 1 | 2 | void dio_write(struct _bytecode* result, struct _bytecode* next); 3 | void dio_read(struct _bytecode* result, struct _bytecode* next); 4 | void dio_start(struct _bytecode* result, struct _bytecode* next); 5 | void dio_stop(struct _bytecode* result, struct _bytecode* next); 6 | 7 | // full duplex commands not currently implemented 8 | void dio_startr(void); 9 | void dio_stopr(void); 10 | 11 | // passes the number in (1) = 1 for mode based macros 12 | void dio_macro(uint32_t macro); 13 | 14 | // a periodic service call for doing things async. 15 | uint32_t dio_periodic(void); 16 | 17 | // setup functions 18 | uint32_t dio_setup(void); 19 | uint32_t dio_setup_exc(void); 20 | void dio_cleanup(void); 21 | bool dio_preflight_sanity_check(void); 22 | 23 | // displayed in the 'i' command 24 | void dio_settings(void); 25 | 26 | uint32_t dio_get_speed(void); 27 | 28 | const char* dio_pins(void); 29 | 30 | // old bitwise commands not currently needed because we don't bitbang anymore 31 | void dio_clkh(void); 32 | void dio_clkl(void); 33 | void dio_dath(void); 34 | void dio_datl(void); 35 | uint32_t dio_dats(void); 36 | void dio_clk(void); 37 | uint32_t dio_bitr(void); 38 | 39 | void dio_help(void); 40 | 41 | extern const struct _mode_command_struct dio_commands[]; 42 | extern const uint32_t dio_commands_count; 43 | -------------------------------------------------------------------------------- /src/mode/dummy1.h: -------------------------------------------------------------------------------- 1 | 2 | void dummy1_write(struct _bytecode* result, struct _bytecode* next); 3 | void dummy1_read(struct _bytecode* result, struct _bytecode* next); 4 | void dummy1_start(struct _bytecode* result, struct _bytecode* next); 5 | void dummy1_stop(struct _bytecode* result, struct _bytecode* next); 6 | 7 | // full duplex commands not currently implemented 8 | void dummy1_startr(void); 9 | void dummy1_stopr(void); 10 | 11 | // passes the number in (1) = 1 for mode based macros 12 | void dummy1_macro(uint32_t macro); 13 | 14 | // a periodic service call for doing things async. 15 | void dummy1_periodic(void); 16 | 17 | // setup functions 18 | uint32_t dummy1_setup(void); 19 | uint32_t dummy1_setup_exc(void); 20 | void dummy1_cleanup(void); 21 | 22 | // displayed in the 'i' command 23 | void dummy1_settings(void); 24 | 25 | const char* dummy1_pins(void); 26 | 27 | // old bitwise commands not currently needed because we don't bitbang anymore 28 | void dummy1_clkh(void); 29 | void dummy1_clkl(void); 30 | void dummy1_dath(void); 31 | void dummy1_datl(void); 32 | uint32_t dummy1_dats(void); 33 | void dummy1_clk(void); 34 | uint32_t dummy1_bitr(void); 35 | 36 | void dummy1_help(void); 37 | 38 | extern const struct _mode_command_struct dummy1_commands[]; 39 | extern const uint32_t dummy1_commands_count; 40 | -------------------------------------------------------------------------------- /src/mode/hiz.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "pico/stdlib.h" 3 | #include "pirate.h" 4 | #include "system_config.h" 5 | #include "command_struct.h" 6 | #include "ui/ui_term.h" 7 | #include "hiz.h" 8 | #include "pirate/bio.h" 9 | #include "commands/global/w_psu.h" 10 | #include "commands/global/p_pullups.h" 11 | #include "ui/ui_help.h" 12 | 13 | const char* hiz_pins(void) { 14 | return "-\t-\t-\t-\t-\t-\t-\t-"; 15 | } 16 | 17 | const char* hiz_error(void) { 18 | return GET_T(T_MODE_ERROR_NO_EFFECT_HIZ); 19 | } 20 | 21 | void hiz_cleanup(void) {} 22 | 23 | uint32_t hiz_setup(void) { 24 | return 1; 25 | } 26 | 27 | // this is called duringmode changes; takes care pwm, vpu and psu is turned off, also AUX to input 28 | uint32_t hiz_setup_exec(void) { 29 | // turn everything off 30 | bio_init(); // make all pins safe 31 | psucmd_disable(); // turn off power supply 32 | pullups_disable(); // deactivate 33 | system_config.freq_active = 0; 34 | system_config.pwm_active = 0; 35 | system_config.aux_active = 0; 36 | for (int i = 0; i < count_of(bio2bufiopin); i++) { 37 | system_bio_update_purpose_and_label(false, i, BP_PIN_IO, 0); 38 | } 39 | return 1; 40 | } 41 | 42 | // command configuration 43 | const struct _mode_command_struct hiz_commands[] = { 0 }; 44 | const uint32_t hiz_commands_count = count_of(hiz_commands); 45 | 46 | void hiz_help(void) { 47 | printf("%sHiZ is a safe mode.\r\nIO pins, power and pull-ups are disabled.\r\n", ui_term_color_info()); 48 | printf("To enter an active mode type 'm' and press enter.\r\n"); 49 | ui_help_mode_commands(hiz_commands, hiz_commands_count); 50 | } 51 | -------------------------------------------------------------------------------- /src/mode/hiz.h: -------------------------------------------------------------------------------- 1 | const char* hiz_pins(void); 2 | const char* hiz_error(void); 3 | void hiz_cleanup(void); 4 | uint32_t hiz_setup(void); 5 | uint32_t hiz_setup_exec(void); 6 | void hiz_help(void); 7 | 8 | extern const uint32_t hiz_commands_count; 9 | extern const struct _mode_command_struct hiz_commands[]; 10 | -------------------------------------------------------------------------------- /src/mode/hw1wire.h: -------------------------------------------------------------------------------- 1 | /*/ 2 | void hw1wire_start(void); 3 | void hw1wire_startr(void); 4 | void hw1wire_stop(void); 5 | void hw1wire_stopr(void); 6 | uint32_t hw1wire_send(uint32_t d); 7 | uint32_t hw1wire_read(void); 8 | void hw1wire_clkh(void); 9 | void hw1wire_clkl(void); 10 | void hw1wire_dath(void); 11 | void hw1wire_datl(void); 12 | uint32_t hw1wire_dats(void); 13 | void hw1wire_clk(void); 14 | uint32_t hw1wire_bitr(void); 15 | uint32_t hw1wire_period(void); 16 | void hw1wire_macro(uint32_t macro); 17 | */ 18 | uint32_t hw1wire_setup(void); 19 | uint32_t hw1wire_setup_exc(void); 20 | void hw1wire_cleanup(void); 21 | void hw1wire_pins(void); 22 | void hw1wire_settings(void); 23 | void hw1wire_start(struct _bytecode* result, struct _bytecode* next); 24 | void hw1wire_write(struct _bytecode* result, struct _bytecode* next); 25 | void hw1wire_read(struct _bytecode* result, struct _bytecode* next); 26 | void hw1wire_macro(uint32_t macro); 27 | void hw1wire_help(void); 28 | uint32_t hw1wire_get_speed(void); 29 | bool hw1wire_preflight_sanity_check(void); 30 | 31 | extern const struct _mode_command_struct hw1wire_commands[]; 32 | extern const uint32_t hw1wire_commands_count; 33 | /*/ 34 | unsigned char OWReset(void); 35 | unsigned char OWBit(unsigned char c); 36 | unsigned char OWByte(unsigned char OWbyte); 37 | void DS1wireReset(void); 38 | void DS1wireID(unsigned char famID); 39 | unsigned char OWFirst(void); 40 | unsigned char OWNext(void); 41 | unsigned char OWSearch(void); 42 | unsigned char OWVerify(void); 43 | unsigned char docrc8(unsigned char value); 44 | 45 | #define OWWriteByte(d) OWByte(d) 46 | #define OWReadByte() OWByte(0xFF) 47 | #define OWReadBit() OWBit(1) 48 | #define OWWriteBit(b) OWBit(b) 49 | */ -------------------------------------------------------------------------------- /src/mode/hw2wire.h: -------------------------------------------------------------------------------- 1 | void hw2wire_start(struct _bytecode* result, struct _bytecode* next); 2 | void hw2wire_start_alt(struct _bytecode* result, struct _bytecode* next); 3 | void hw2wire_stop(struct _bytecode* result, struct _bytecode* next); 4 | void hw2wire_stop_alt(struct _bytecode* result, struct _bytecode* next); 5 | void hw2wire_write(struct _bytecode* result, struct _bytecode* next); 6 | void hw2wire_read(struct _bytecode* result, struct _bytecode* next); 7 | void hw2wire_tick_clock(struct _bytecode* result, struct _bytecode* next); 8 | void hw2wire_set_clk_high(struct _bytecode* result, struct _bytecode* next); 9 | void hw2wire_set_clk_low(struct _bytecode* result, struct _bytecode* next); 10 | void hw2wire_set_dat_high(struct _bytecode* result, struct _bytecode* next); 11 | void hw2wire_set_dat_low(struct _bytecode* result, struct _bytecode* next); 12 | void hw2wire_read_bit(struct _bytecode* result, struct _bytecode* next); 13 | void hw2wire_macro(uint32_t macro); 14 | uint32_t hw2wire_setup(void); 15 | uint32_t hw2wire_setup_exc(void); 16 | void hw2wire_cleanup(void); 17 | // void hw2wire_pins(void); 18 | void hw2wire_settings(void); 19 | void hw2wire_printI2Cflags(void); 20 | void hw2wire_help(void); 21 | uint32_t hw2wire_get_speed(void); 22 | bool hw2wire_preflight_sanity_check(void); 23 | 24 | typedef struct _hw2wire_mode_config { 25 | uint32_t baudrate; 26 | // uint32_t baudrate_actual; 27 | uint32_t data_bits; 28 | bool ack_pending; 29 | bool read; 30 | bool start_sent; 31 | } _hw2wire_mode_config; 32 | 33 | extern const struct _mode_command_struct hw2wire_commands[]; 34 | extern const uint32_t hw2wire_commands_count; 35 | extern struct _hw2wire_mode_config hw2wire_mode_config; 36 | -------------------------------------------------------------------------------- /src/mode/hw3wire.h: -------------------------------------------------------------------------------- 1 | void hw3wire_start(struct _bytecode* result, struct _bytecode* next); 2 | void hw3wire_start_alt(struct _bytecode* result, struct _bytecode* next); 3 | void hw3wire_stop(struct _bytecode* result, struct _bytecode* next); 4 | void hw3wire_stop_alt(struct _bytecode* result, struct _bytecode* next); 5 | void hw3wire_write(struct _bytecode* result, struct _bytecode* next); 6 | void hw3wire_read(struct _bytecode* result, struct _bytecode* next); 7 | void hw3wire_tick_clock(struct _bytecode* result, struct _bytecode* next); 8 | void hw3wire_set_clk_high(struct _bytecode* result, struct _bytecode* next); 9 | void hw3wire_set_clk_low(struct _bytecode* result, struct _bytecode* next); 10 | void hw3wire_set_dat_high(struct _bytecode* result, struct _bytecode* next); 11 | void hw3wire_set_dat_low(struct _bytecode* result, struct _bytecode* next); 12 | void hw3wire_read_bit(struct _bytecode* result, struct _bytecode* next); 13 | void hw3wire_macro(uint32_t macro); 14 | uint32_t hw3wire_setup(void); 15 | uint32_t hw3wire_setup_exc(void); 16 | void hw3wire_cleanup(void); 17 | // void hw3wire_pins(void); 18 | void hw3wire_settings(void); 19 | void hw3wire_printI2Cflags(void); 20 | void hw3wire_help(void); 21 | uint32_t hw3wire_get_speed(void); 22 | bool hw3wire_preflight_sanity_check(void); 23 | 24 | typedef struct _hw3wire_mode_config { 25 | uint32_t baudrate; 26 | // uint32_t baudrate_actual; 27 | uint32_t cs_idle; 28 | bool read_with_write; 29 | } _hw3wire_mode_config; 30 | 31 | extern const struct _mode_command_struct hw3wire_commands[]; 32 | extern const uint32_t hw3wire_commands_count; 33 | //extern struct _hw3wire_mode_config hw3wire_mode_config; 34 | -------------------------------------------------------------------------------- /src/mode/hwhduart.h: -------------------------------------------------------------------------------- 1 | void hwhduart_open(struct _bytecode* result, struct _bytecode* next); // start 2 | void hwhduart_open_read(struct _bytecode* result, struct _bytecode* next); 3 | void hwhduart_stop_alt(struct _bytecode* result, struct _bytecode* next); 4 | void hwhduart_start_alt(struct _bytecode* result, struct _bytecode* next); // start with read 5 | void hwhduart_close(struct _bytecode* result, struct _bytecode* next); // stop 6 | void hwhduart_write(struct _bytecode* result, struct _bytecode* next); 7 | void hwhduart_read(struct _bytecode* result, struct _bytecode* next); 8 | void hwhduart_macro(uint32_t macro); 9 | uint32_t hwhduart_setup(void); 10 | uint32_t hwhduart_setup_exc(void); 11 | void hwhduart_cleanup(void); 12 | void hwhduart_pins(void); 13 | void hwhduart_settings(void); 14 | void hwhduart_printerror(void); 15 | void hwhduart_help(void); 16 | void hwhduart_periodic(void); 17 | uint32_t hwhduart_get_speed(void); 18 | bool hwhduart_preflight_sanity_check(void); 19 | 20 | /* 21 | typedef struct _uart_mode_config{ 22 | uint32_t baudrate; 23 | uint32_t baudrate_actual; 24 | uint32_t data_bits; 25 | uint32_t stop_bits; 26 | uint32_t parity; 27 | uint32_t blocking; 28 | bool async_print; 29 | }_uart_mode_config; 30 | */ 31 | extern const struct _mode_command_struct hwhduart_commands[]; 32 | extern const uint32_t hwhduart_commands_count; -------------------------------------------------------------------------------- /src/mode/hwi2c.h: -------------------------------------------------------------------------------- 1 | 2 | void hwi2c_start(struct _bytecode* result, struct _bytecode* next); 3 | void hwi2c_stop(struct _bytecode* result, struct _bytecode* next); 4 | void hwi2c_write(struct _bytecode* result, struct _bytecode* next); 5 | void hwi2c_read(struct _bytecode* result, struct _bytecode* next); 6 | void hwi2c_macro(uint32_t macro); 7 | uint32_t hwi2c_setup(void); 8 | uint32_t hwi2c_setup_exc(void); 9 | void hwi2c_cleanup(void); 10 | // void hwi2c_pins(void); 11 | void hwi2c_settings(void); 12 | void hwi2c_printI2Cflags(void); 13 | void hwi2c_help(void); 14 | uint8_t hwi2c_checkshort(void); 15 | uint32_t hwi2c_get_speed(void); 16 | void hwi2c_set_speed(uint32_t speed_hz); 17 | void hwi2c_set_databits(uint32_t bits); 18 | bool hwi2c_preflight_sanity_check(void); 19 | 20 | typedef struct _i2c_mode_config { 21 | uint32_t baudrate; 22 | // uint32_t baudrate_actual; 23 | uint32_t data_bits; 24 | bool clock_stretch; 25 | bool ack_pending; 26 | bool read; 27 | bool start_sent; 28 | } _i2c_mode_config; 29 | 30 | extern const struct _mode_command_struct hwi2c_commands[]; 31 | extern const uint32_t hwi2c_commands_count; 32 | -------------------------------------------------------------------------------- /src/mode/hwled.h: -------------------------------------------------------------------------------- 1 | 2 | void hwled_start(struct _bytecode* result, struct _bytecode* next); 3 | void hwled_stop(struct _bytecode* result, struct _bytecode* next); 4 | void hwled_write(struct _bytecode* result, struct _bytecode* next); 5 | void hwled_read(struct _bytecode* result, struct _bytecode* next); 6 | void hwled_macro(uint32_t macro); 7 | uint32_t hwled_setup(void); 8 | uint32_t hwled_setup_exc(void); 9 | void hwled_cleanup(void); 10 | // void hwled_pins(void); 11 | void hwled_settings(void); 12 | void hwled_printI2Cflags(void); 13 | void hwled_help(void); 14 | uint32_t hwled_get_speed(void); 15 | void hwled_wait_idle(void); 16 | bool hwled_preflight_sanity_check(void); 17 | 18 | typedef struct _led_mode_config { 19 | uint32_t num_leds; 20 | uint32_t device; 21 | uint32_t baudrate; 22 | } _led_mode_config; 23 | 24 | extern const struct _mode_command_struct hwled_commands[]; 25 | extern const uint32_t hwled_commands_count; -------------------------------------------------------------------------------- /src/mode/hwspi.h: -------------------------------------------------------------------------------- 1 | void spi_start(struct _bytecode* result, struct _bytecode* next); 2 | void spi_startr(struct _bytecode* result, struct _bytecode* next); 3 | void spi_stop(struct _bytecode* result, struct _bytecode* next); 4 | void spi_stopr(struct _bytecode* result, struct _bytecode* next); 5 | void spi_write(struct _bytecode* result, struct _bytecode* next); 6 | void spi_read(struct _bytecode* result, struct _bytecode* next); 7 | void spi_macro(uint32_t macro); 8 | uint32_t spi_setup(void); 9 | uint32_t spi_binmode_get_config_length(void); 10 | uint32_t spi_binmode_setup(uint8_t* config); 11 | uint32_t spi_setup_exc(void); 12 | void spi_cleanup(void); 13 | void spi_pins(void); 14 | void spi_settings(void); 15 | void spi_printSPIflags(void); 16 | void spi_help(void); 17 | uint32_t spi_get_speed(void); 18 | bool spi_preflight_sanity_check(void); 19 | 20 | // special for binmode and lcd 21 | void spi_setcpol(uint32_t val); 22 | void spi_setcpha(uint32_t val); 23 | void spi_setbr(uint32_t val); 24 | void spi_setdff(uint32_t val); 25 | void spi_setlsbfirst(uint32_t val); 26 | void spi_set_cs_idle(uint32_t val); 27 | void spi_set_cs(uint8_t cs); 28 | uint8_t spi_xfer(const uint8_t out); 29 | 30 | uint32_t spi_read_simple(void); 31 | void spi_write_simple(uint32_t data); 32 | 33 | typedef struct _spi_mode_config { 34 | uint32_t baudrate; 35 | uint32_t baudrate_actual; 36 | uint32_t data_bits; 37 | uint32_t clock_polarity; 38 | uint32_t clock_phase; 39 | uint32_t cs_idle; 40 | uint32_t dff; 41 | bool read_with_write; 42 | bool binmode; 43 | } _spi_mode_config; 44 | 45 | extern const struct _mode_command_struct hwspi_commands[]; 46 | extern const uint32_t hwspi_commands_count; 47 | -------------------------------------------------------------------------------- /src/mode/hwuart.h: -------------------------------------------------------------------------------- 1 | void hwuart_open(struct _bytecode* result, struct _bytecode* next); // start 2 | void hwuart_open_read(struct _bytecode* result, struct _bytecode* next); // start with read 3 | void hwuart_close(struct _bytecode* result, struct _bytecode* next); // stop 4 | void hwuart_write(struct _bytecode* result, struct _bytecode* next); 5 | void hwuart_read(struct _bytecode* result, struct _bytecode* next); 6 | void hwuart_macro(uint32_t macro); 7 | uint32_t hwuart_setup(void); 8 | uint32_t hwuart_setup_exc(void); 9 | void hwuart_cleanup(void); 10 | void hwuart_pins(void); 11 | void hwuart_settings(void); 12 | void hwuart_printerror(void); 13 | void hwuart_help(void); 14 | void hwuart_periodic(void); 15 | void hwuart_wait_done(void); 16 | uint32_t hwuart_get_speed(void); 17 | bool hwuart_preflight_sanity_check(void); 18 | 19 | typedef struct _uart_mode_config { 20 | uint32_t baudrate; 21 | uint32_t baudrate_actual; 22 | uint32_t data_bits; 23 | uint32_t stop_bits; 24 | uint32_t parity; 25 | uint32_t blocking; 26 | bool async_print; 27 | uint32_t flow_control; 28 | uint32_t invert; 29 | } _uart_mode_config; 30 | 31 | extern const struct _mode_command_struct hwuart_commands[]; 32 | extern const uint32_t hwuart_commands_count; -------------------------------------------------------------------------------- /src/mode/i2s.h: -------------------------------------------------------------------------------- 1 | 2 | void i2s_write(struct _bytecode* result, struct _bytecode* next); 3 | void i2s_read(struct _bytecode* result, struct _bytecode* next); 4 | void i2s_start(struct _bytecode* result, struct _bytecode* next); 5 | void i2s_stop(struct _bytecode* result, struct _bytecode* next); 6 | 7 | // full duplex commands not currently implemented 8 | void i2s_startr(struct _bytecode* result, struct _bytecode* next); 9 | void i2s_stopr(struct _bytecode* result, struct _bytecode* next); 10 | 11 | // a periodic service call for doing things async. 12 | void i2s_periodic(void); 13 | 14 | // setup functions 15 | uint32_t i2s_setup(void); 16 | uint32_t i2s_setup_exc(void); 17 | void i2s_cleanup(void); 18 | 19 | // displayed in the 'i' command 20 | void i2s_settings(void); 21 | 22 | const char* i2s_pins(void); 23 | 24 | // old bitwise commands not currently needed because we don't bitbang anymore 25 | void i2s_clkh(struct _bytecode* result, struct _bytecode* next); 26 | void i2s_clkl(struct _bytecode* result, struct _bytecode* next); 27 | void i2s_dath(struct _bytecode* result, struct _bytecode* next); 28 | void i2s_datl(struct _bytecode* result, struct _bytecode* next); 29 | void i2s_dats(struct _bytecode* result, struct _bytecode* next); 30 | void i2s_clk(struct _bytecode* result, struct _bytecode* next); 31 | void i2s_bitr(struct _bytecode* result, struct _bytecode* next); 32 | 33 | void i2s_help(void); 34 | 35 | extern const struct _mode_command_struct i2s_commands[]; 36 | extern const uint32_t i2s_commands_count; 37 | typedef struct _i2s_mode_config { 38 | uint32_t freq; 39 | uint32_t bits; 40 | } _i2s_mode_config; 41 | extern struct _i2s_mode_config i2s_mode_config; 42 | extern struct _pio_config i2s_pio_config_out, i2s_pio_config_in; -------------------------------------------------------------------------------- /src/mode/i2s_in.pio: -------------------------------------------------------------------------------- 1 | ; MIT license 2 | ; Source: https://github.com/mryndzionek/rp2040_pico_sdk_playground 3 | 4 | .program i2s_in 5 | 6 | .side_set 2 7 | 8 | .wrap_target 9 | public entry_point: 10 | set x, 30 side 0b00 11 | bitloop1: 12 | in pins, 1 side 0b01 13 | jmp x-- bitloop1 side 0b00 14 | in pins, 1 side 0b01 15 | set x, 30 side 0b10 ; LR transition happens on 32nd bit clock falling edge 16 | 17 | bitloop0: 18 | nop side 0b11 19 | jmp x-- bitloop0 side 0b10 20 | nop side 0b11 21 | .wrap 22 | 23 | % c-sdk { 24 | #include "hardware/clocks.h" 25 | 26 | static inline void i2s_in_program_init(PIO pio, uint sm, uint offset, uint samplerate, uint data_pin, uint clock_pin_base) { 27 | pio_sm_config sm_config = i2s_in_program_get_default_config(offset); 28 | 29 | sm_config_set_in_pins(&sm_config, data_pin); 30 | sm_config_set_sideset_pins(&sm_config, clock_pin_base); 31 | sm_config_set_in_shift(&sm_config, false, true, 32); 32 | sm_config_set_fifo_join(&sm_config, PIO_FIFO_JOIN_RX); 33 | 34 | sm_config_set_clkdiv(&sm_config, clock_get_hz(clk_sys) / (samplerate * 32 * 2 * 2.0f)); 35 | 36 | pio_sm_init(pio, sm, offset, &sm_config); 37 | 38 | uint pin_mask = (1u << data_pin) | (0b11 << clock_pin_base); 39 | pio_sm_set_pindirs_with_mask(pio, sm, (0u << data_pin) | (0b11 << clock_pin_base), pin_mask); 40 | pio_sm_set_pins(pio, sm, 0); // clear pins 41 | 42 | pio_gpio_init(pio, data_pin); 43 | pio_gpio_init(pio, clock_pin_base); 44 | pio_gpio_init(pio, clock_pin_base + 1); 45 | 46 | //gpio_pull_down(data_pin); 47 | 48 | pio_sm_exec(pio, sm, pio_encode_jmp(offset + i2s_in_offset_entry_point)); 49 | pio_sm_set_enabled(pio, sm, true); 50 | } 51 | 52 | %} 53 | -------------------------------------------------------------------------------- /src/mode/infrared-struct.h: -------------------------------------------------------------------------------- 1 | // enum to define return codes from nec_get_frame() 2 | typedef enum { 3 | IR_RX_NO_FRAME = 0, 4 | IR_RX_FRAME_OK, 5 | IR_RX_FRAME_ERROR 6 | } ir_rx_status_t; -------------------------------------------------------------------------------- /src/mode/infrared.h: -------------------------------------------------------------------------------- 1 | 2 | void infrared_write(struct _bytecode* result, struct _bytecode* next); 3 | void infrared_read(struct _bytecode* result, struct _bytecode* next); 4 | void infrared_start(struct _bytecode* result, struct _bytecode* next); 5 | void infrared_stop(struct _bytecode* result, struct _bytecode* next); 6 | 7 | // full duplex commands not currently implemented 8 | void infrared_startr(void); 9 | void infrared_stopr(void); 10 | 11 | // passes the number in (1) = 1 for mode based macros 12 | void infrared_macro(uint32_t macro); 13 | 14 | // a periodic service call for doing things async. 15 | void infrared_periodic(void); 16 | 17 | // setup functions 18 | uint32_t infrared_setup(void); 19 | uint32_t infrared_setup_exc(void); 20 | void infrared_cleanup(void); 21 | bool infrared_preflight_sanity_check(void); 22 | 23 | // displayed in the 'i' command 24 | void infrared_settings(void); 25 | 26 | const char* infrared_pins(void); 27 | 28 | void infrared_help(void); 29 | 30 | void infrared_wait_idle(void); 31 | 32 | uint32_t infrared_get_speed(void); 33 | 34 | //for pausing the PIO programs while other programs use the hardware 35 | void infrared_setup_resume(void); 36 | void infrared_cleanup_temp(void); 37 | 38 | extern const struct _mode_command_struct infrared_commands[]; 39 | extern const uint32_t infrared_commands_count; 40 | 41 | typedef struct _infrared_mode_config { 42 | uint32_t rx_sensor; 43 | uint32_t protocol; 44 | uint32_t tx_freq; 45 | } _infrared_mode_config; 46 | -------------------------------------------------------------------------------- /src/mode/jtag.h: -------------------------------------------------------------------------------- 1 | uint32_t jtag_setup(void); 2 | uint32_t jtag_setup_exc(void); 3 | void jtag_cleanup(void); 4 | bool jtag_preflight_sanity_check(void); 5 | void jtag_pins(void); 6 | void jtag_settings(void); 7 | void jtag_help(void); 8 | uint32_t jtag_get_speed(void); 9 | 10 | 11 | extern const struct _mode_command_struct jtag_commands[]; 12 | extern const uint32_t jtag_commands_count; 13 | -------------------------------------------------------------------------------- /src/mode/sw1wire.h: -------------------------------------------------------------------------------- 1 | 2 | void ONEWIRE_start(void); 3 | void ONEWIRE_startr(void); 4 | void ONEWIRE_stop(void); 5 | void ONEWIRE_stopr(void); 6 | uint32_t ONEWIRE_send(uint32_t d); 7 | uint32_t ONEWIRE_read(void); 8 | void ONEWIRE_clkh(void); 9 | void ONEWIRE_clkl(void); 10 | void ONEWIRE_dath(void); 11 | void ONEWIRE_datl(void); 12 | uint32_t ONEWIRE_dats(void); 13 | void ONEWIRE_clk(void); 14 | uint32_t ONEWIRE_bitr(void); 15 | uint32_t ONEWIRE_period(void); 16 | void ONEWIRE_macro(uint32_t macro); 17 | void ONEWIRE_setup(void); 18 | void ONEWIRE_setup_exc(void); 19 | void ONEWIRE_cleanup(void); 20 | void ONEWIRE_pins(void); 21 | void ONEWIRE_settings(void); 22 | 23 | unsigned char OWReset(void); 24 | unsigned char OWBit(unsigned char c); 25 | unsigned char OWByte(unsigned char OWbyte); 26 | void DS1wireReset(void); 27 | void DS1wireID(unsigned char famID); 28 | unsigned char OWFirst(void); 29 | unsigned char OWNext(void); 30 | unsigned char OWSearch(void); 31 | unsigned char OWVerify(void); 32 | unsigned char docrc8(unsigned char value); 33 | 34 | #define OWWriteByte(d) OWByte(d) 35 | #define OWReadByte() OWByte(0xFF) 36 | #define OWReadBit() OWBit(1) 37 | #define OWWriteBit(b) OWBit(b) 38 | -------------------------------------------------------------------------------- /src/mode/usbpd.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "pico/stdlib.h" 3 | #include 4 | #include "pirate.h" 5 | #include "system_config.h" 6 | #include "command_struct.h" 7 | #include "bytecode.h" 8 | #include "hwi2c.h" 9 | #include "ui/ui_help.h" 10 | #include "ui/ui_term.h" 11 | #include "system_config.h" 12 | #include "commands/global/w_psu.h" 13 | 14 | #include "usbpd.h" 15 | 16 | #define I2C_ADDR_FUSB302_WRITE 0x44 17 | #define I2C_ADDR_FUSB302_READ 0x45 18 | 19 | #define I2C_REG_ID 1 20 | 21 | 22 | static void usbpd_sniff(struct command_result* res) { 23 | // STUB 24 | } 25 | 26 | const struct _mode_command_struct usbpd_commands[] = { 27 | { 28 | .command="sniff", 29 | .func=&usbpd_sniff, 30 | .description_text=T_I2C_SNIFF, 31 | .supress_fala_capture=true 32 | }, 33 | }; 34 | const uint32_t usbpd_commands_count = count_of(usbpd_commands); 35 | 36 | uint32_t usbpd_setup(void) { 37 | hwi2c_set_speed(400000); 38 | hwi2c_set_databits(8); 39 | 40 | return 1; 41 | } 42 | 43 | uint32_t usbpd_setup_exc(void) { 44 | uint32_t retval = hwi2c_setup_exc(); 45 | if (retval != 1) { 46 | return retval; 47 | } 48 | 49 | // 5V power on 50 | psucmd_enable(5.0, 20.0, false); 51 | 52 | sleep_ms(500); 53 | 54 | struct _bytecode result; 55 | hwi2c_start(&result, NULL); 56 | result.out_data = I2C_ADDR_FUSB302_WRITE; 57 | hwi2c_write(&result, NULL); 58 | result.out_data = I2C_REG_ID; 59 | hwi2c_write(&result, NULL); 60 | hwi2c_start(&result, NULL); 61 | result.out_data = I2C_ADDR_FUSB302_READ; 62 | hwi2c_write(&result, NULL); 63 | struct _bytecode next; 64 | next.command = SYN_STOP; 65 | hwi2c_read(&result, &next); 66 | hwi2c_stop(&result, NULL); 67 | 68 | return result.error; 69 | } 70 | 71 | void usbpd_cleanup(void) { 72 | hwi2c_cleanup(); 73 | } 74 | 75 | void usbpd_help(void) { 76 | printf("USBPD Plank\r\n"); 77 | 78 | ui_help_mode_commands(usbpd_commands, usbpd_commands_count); 79 | } 80 | 81 | void usbpd_settings(void) { 82 | // STUB 83 | } 84 | -------------------------------------------------------------------------------- /src/mode/usbpd.h: -------------------------------------------------------------------------------- 1 | uint32_t usbpd_setup(void); 2 | uint32_t usbpd_setup_exc(void); 3 | void usbpd_cleanup(void); 4 | 5 | void usbpd_help(void); 6 | void usbpd_settings(void); 7 | 8 | extern const struct _mode_command_struct usbpd_commands[]; 9 | extern const uint32_t usbpd_commands_count; 10 | -------------------------------------------------------------------------------- /src/msc_disk.h: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2019 Ha Thach (tinyusb.org) 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | * 24 | */ 25 | 26 | // remove and insert the usbms drive to force the host to sync its contents 27 | void refresh_usbmsdrive(void); 28 | 29 | // remove the usb drive and prepare to make it read only on the host 30 | void prepare_usbmsdrive_readonly(void); 31 | 32 | // insert the usbms drive to expose it to the host 33 | void insert_usbmsdrive(void); 34 | 35 | // make the usb drive appear read write on the host 36 | void make_usbmsdrive_writable(void); 37 | 38 | // remove before jump to bootloader 39 | void eject_usbmsdrive(void); 40 | -------------------------------------------------------------------------------- /src/nand/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Andrew Loebs 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /src/nand/nand.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file main.c 3 | * @author Andrew Loebs 4 | * @brief Main application 5 | * 6 | */ 7 | 8 | #include 9 | #include "pico/stdlib.h" 10 | #include "pirate.h" 11 | #include "pirate/mem.h" 12 | #include "nand/spi.h" 13 | #include "nand/sys_time.h" 14 | #include "fatfs/ff.h" 15 | #include "fatfs/ffconf.h" 16 | 17 | // private function prototypes 18 | // static void clock_config(void); 19 | 20 | // private variables 21 | FATFS nand_fs; // file system object 22 | 23 | // application main function 24 | int nand_init(void) { 25 | // setup clock 26 | // clock_config(); 27 | sys_time_init(); 28 | } 29 | -------------------------------------------------------------------------------- /src/nand/nand.h: -------------------------------------------------------------------------------- 1 | int nand_init(void); 2 | bool nand_mount(void); 3 | -------------------------------------------------------------------------------- /src/nand/nand_ftl_diskio.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file nand_ftl_diskio.h 3 | * @author Andrew Loebs 4 | * @brief Header file of the nand ftl diskio module 5 | * 6 | * Glue layer between fatfs diskio and dhara ftl. 7 | * 8 | */ 9 | 10 | #ifndef __NAND_FTL_DISKIO_H 11 | #define __NAND_FTL_DISKIO_H 12 | 13 | // #include "../fatfs/diskio.h" // types from the diskio driver 14 | // #include "../fatfs/ff.h" // BYTE type 15 | 16 | DSTATUS diskio_initialize(BYTE drv); 17 | DSTATUS diskio_status(BYTE drv); 18 | DRESULT diskio_read(BYTE drv, BYTE* buff, LBA_t sector, UINT count); 19 | DRESULT diskio_write(BYTE drv, const BYTE* buff, LBA_t sector, UINT count); 20 | DRESULT diskio_ioctl(BYTE drv, BYTE cmd, void* buff); 21 | 22 | #endif // __NAND_FTL_DISKIO_H 23 | -------------------------------------------------------------------------------- /src/nand/spi.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file spi.h 3 | * @author Andrew Loebs 4 | * @brief Header file of the spi module 5 | * 6 | * SPI1 master driver (interfaces SPI NAND flash chip) 7 | * 8 | */ 9 | 10 | #ifndef __SPI_H 11 | #define __SPI_H 12 | 13 | #include 14 | #include 15 | 16 | /// @brief SPI return statuses 17 | #define SPI_RET_OK 0 18 | #define SPI_RET_TIMEOUT -1 19 | #define SPI_RET_NULL_PTR -2 20 | 21 | /// @brief Initializes the spi driver 22 | void nand_spi_init(void); 23 | 24 | /// @brief Writes data to the bus 25 | /// @note Caller is expected to drive the chip select line for the relevant device 26 | int nand_spi_write(const uint8_t* write_buff, size_t write_len, uint32_t timeout_ms); 27 | 28 | /// @brief Reads data from the bus 29 | /// @note Caller is expected to drive the chip select line for the relevant device 30 | /// @note Transmits 0x00 on the MOSI line during the transaction 31 | int nand_spi_read(uint8_t* read_buff, size_t read_len, uint32_t timeout_ms); 32 | 33 | /// @brief Writes/reads data to/from to the bus 34 | /// @note Caller is expected to drive the chip select line for the relevant device 35 | int nand_spi_write_read(const uint8_t* write_buff, uint8_t* read_buff, size_t transfer_len, uint32_t timeout_ms); 36 | 37 | #endif // __SPI_H 38 | -------------------------------------------------------------------------------- /src/nand/sys_time.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file sys_time.c 3 | * @author Andrew Loebs 4 | * @brief Implementation file of the sys time module 5 | * 6 | */ 7 | #include 8 | #include "pico/stdlib.h" 9 | #include "pirate.h" 10 | #include "pico/time.h" 11 | #include "nand/sys_time.h" 12 | // #include "../st/ll/stm32l4xx_ll_utils.h" 13 | // #include "../st/stm32l4xx.h" 14 | // #include "../st/system_stm32l4xx.h" 15 | 16 | // defines 17 | #define SYSTICK_PREEMPT_PRIORITY 0 18 | #define SYSTICK_SUB_PRIORITY 0 19 | 20 | // private variables 21 | uint32_t sys_time_ms = 0; 22 | 23 | bool _sys_time_increment(repeating_timer_t* mst) { 24 | sys_time_ms++; 25 | return true; 26 | } 27 | 28 | // public function definitions 29 | void sys_time_init(void) { 30 | sys_time_ms = 0; 31 | 32 | // setup 1 ms sys tick 33 | static repeating_timer_t mst; 34 | add_repeating_timer_ms(-1, _sys_time_increment, NULL, &mst); 35 | } 36 | /* 37 | void _sys_time_increment(void) 38 | { 39 | sys_time_ms++; 40 | }*/ 41 | 42 | uint32_t sys_time_get_ms(void) { 43 | return sys_time_ms; 44 | } 45 | 46 | uint32_t sys_time_get_elapsed(uint32_t start) { 47 | return sys_time_ms - start; 48 | } 49 | 50 | // TODO: add unit test for this function 51 | // normal case 52 | // current time overlapped, end time not overlapped 53 | // current time overlapped, end time overlapped 54 | // current time not overlapped, end time overlapped 55 | // all above cases when duration is 0 56 | bool sys_time_is_elapsed(uint32_t start, uint32_t duration_ms) { 57 | return (sys_time_get_elapsed(start) >= duration_ms); 58 | } 59 | 60 | void sys_time_delay(uint32_t duration_ms) { 61 | uint32_t start = sys_time_ms; 62 | while (!sys_time_is_elapsed(start, duration_ms)) 63 | ; 64 | } -------------------------------------------------------------------------------- /src/nand/sys_time.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file sys_time.h 3 | * @author Andrew Loebs 4 | * @brief Header file of the sys time module 5 | * 6 | * Exposes a millisecond time to the system (driven by systick) and provides 7 | * functions for comparing times (with wrap-around) and blocking delays. 8 | * 9 | */ 10 | 11 | #ifndef __SYS_TIME_H 12 | #define __SYS_TIME_H 13 | 14 | #include 15 | #include 16 | 17 | /// @brief Resets the system time and enables sys tick interrupt 18 | void sys_time_init(void); 19 | 20 | /// @brief Increments the system time counter -- should only be called by interrupt! 21 | // void _sys_time_increment(void); 22 | 23 | /// @brief Returns system time counter (which tracks milliseconds) 24 | uint32_t sys_time_get_ms(void); 25 | 26 | /// @brief Returns the number of milliseconds elapsed since the start value 27 | uint32_t sys_time_get_elapsed(uint32_t start); 28 | 29 | /// @brief Checks whether a given time duration has elapsed since a given start time 30 | bool sys_time_is_elapsed(uint32_t start, uint32_t duration_ms); 31 | 32 | /// @brief Blocking delay for a given duration 33 | void sys_time_delay(uint32_t duration_ms); 34 | 35 | #endif // __SYS_TIME_H 36 | -------------------------------------------------------------------------------- /src/pio_config.h: -------------------------------------------------------------------------------- 1 | struct _pio_config { 2 | PIO pio; 3 | uint sm; 4 | uint offset; 5 | const struct pio_program* program; 6 | }; 7 | 8 | static inline bool pio_sm_check_idle (PIO pio, int sm) { 9 | // Correct way to detect the state machine is idle because of an empty FIFO: 10 | // 1. Clear the (latching) state machine stall bit 11 | // 2. Check if the state machine TX fifo is empty 12 | // 3. THEN check if the state machine stall bit is set 13 | uint32_t SM_STALL_MASK = 1u << (PIO_FDEBUG_TXSTALL_LSB + sm); 14 | pio->fdebug = SM_STALL_MASK; // writing a 1 clears the bit 15 | 16 | // NOTE: the order of these operations *DOES* matter! 17 | bool result = 18 | pio_sm_is_tx_fifo_empty(pio, sm) && 19 | (pio->fdebug & SM_STALL_MASK); 20 | return result; 21 | } 22 | 23 | static inline bool pio_sm_wait_idle (PIO pio, int sm, uint32_t timeout) { 24 | // Wait for the state machine to become idle 25 | while (!pio_sm_check_idle(pio, sm)) { 26 | timeout--; 27 | if (timeout == 0) { 28 | return false; 29 | } 30 | } 31 | return true; 32 | } -------------------------------------------------------------------------------- /src/pirate/amux.h: -------------------------------------------------------------------------------- 1 | void amux_init(void); 2 | // select AMUX input source, use the channel defines from the platform header 3 | // only effects the 4067CD analog mux, you cannot get the current measurement from here 4 | bool amux_select_input(uint16_t channel); 5 | // set the AMUX input source using the BIO pin number 6 | bool amux_select_bio(uint8_t bio); 7 | // read from AMUX using channel list in platform header file 8 | uint32_t amux_read(uint8_t channel); 9 | // read from presently selected AMUX channel 10 | uint32_t amux_read_present_channel(void); 11 | // read from AMUX using BIO pin number 12 | uint32_t amux_read_bio(uint8_t bio); 13 | // this is actually on a different ADC and not the AMUX 14 | // but this is the best place for it I think 15 | // voltage is not /2 so we can use the full range of the ADC 16 | uint32_t amux_read_current(void); 17 | // read all the AMUX channels and the current sense 18 | // place into the global arrays hw_adc_raw and hw_adc_voltage 19 | void amux_sweep(void); 20 | 21 | // reset the averaging of all channels, start with the current value 22 | // useful if you expect a step-change of the inputs 23 | extern bool reset_adc_average; 24 | 25 | // use power-of-two values for efficient division 26 | #define ADC_AVG_TIMES 64 27 | 28 | inline uint32_t get_adc_average(uint32_t avgsum) 29 | { 30 | // add ADC_AVG_TIMES/2 before division for correct rounding instead of cutting of decimals 31 | return ((avgsum+(ADC_AVG_TIMES/2))/ADC_AVG_TIMES); 32 | } 33 | -------------------------------------------------------------------------------- /src/pirate/bio.h: -------------------------------------------------------------------------------- 1 | 2 | void bio_init(void); 3 | void bio_buf_pin_init(uint8_t bio); 4 | void bio_buf_output(uint8_t bio); 5 | void bio_buf_input(uint8_t bio); 6 | void bio_output(uint8_t bio); 7 | void bio_input(uint8_t bio); 8 | void bio_put(uint8_t bio, bool value); 9 | bool bio_get(uint8_t bio); 10 | void bio_set_function(uint8_t bio, uint8_t function); 11 | void bio_buf_test(uint8_t bufio, uint8_t bufdir); 12 | -------------------------------------------------------------------------------- /src/pirate/button.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // initialize all buttons 4 | void button_init(void); 5 | // example irq callback handler, copy for your own uses 6 | void button_irq_enable(uint8_t button_id, gpio_irq_callback_t callback); 7 | // enable the irq for button button_id 8 | void button_irq_disable(uint8_t button_id); 9 | // example irq callback handler, copy for your own uses 10 | void button_irq_callback(uint gpio, uint32_t events); 11 | // poll the value of button button_id 12 | bool button_get(uint8_t button_id); 13 | // check for interrupt and clear interrupt flag 14 | 15 | enum button_codes { 16 | BP_BUTT_NO_PRESS = 0, 17 | BP_BUTT_SHORT_PRESS, 18 | BP_BUTT_LONG_PRESS, 19 | // BP_BUTT_DOUBLE_TAP, 20 | BP_BUTT_MAX 21 | }; 22 | 23 | enum button_codes button_check_press(uint8_t button_id); 24 | -------------------------------------------------------------------------------- /src/pirate/hw1wire_pio.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021 Stefan Althöfer 3 | * 4 | * OWxxxx functions might fall under Maxxim copyriht. 5 | * 6 | * Demo code for PIO 1-Wire interface 7 | */ 8 | 9 | struct owobj { 10 | PIO pio; /* pio object (pio0/pio1) */ 11 | uint sm; /* state machine number */ 12 | uint offset; /* onewire code offset in PIO instr. memory */ 13 | uint pin; /* Pin number for 1wire data signal */ 14 | uint dir; /* Pin number for buffer manipulation */ 15 | 16 | // Search state global variables 17 | unsigned char ROM_NO[8]; 18 | int LastDiscrepancy; 19 | int LastFamilyDiscrepancy; 20 | int LastDeviceFlag; 21 | unsigned char crc8; 22 | }; 23 | void onewire_init(uint pin, uint dir); 24 | void onewire_cleanup(void); 25 | void pio_sm_trace(PIO pio, uint sm, uint usleep); 26 | void onewire_set_fifo_thresh(uint thresh); 27 | int onewire_reset(void); 28 | void onewire_wait_for_idle(void); 29 | void onewire_tx_byte(uint byte); 30 | void onewire_tx_byte_spu(uint byte); 31 | void onewire_end_spu(void); 32 | uint onewire_rx_byte(void); 33 | void onewire_triplet(int* id_bit, int* cmp_id_bit, unsigned char* search_direction); 34 | unsigned char calc_crc8_buf(unsigned char* data, int len); 35 | int onewire_select(unsigned char* romid); 36 | unsigned char calc_crc8(unsigned char data); 37 | int OWSearch(struct owobj* search_owobj); 38 | int OWSearchReset(struct owobj* search_owobj); 39 | int OWFirst(struct owobj* search_owobj); 40 | int OWNext(struct owobj* search_owobj); 41 | void onewire_test_ds18b20_scratchpad(void); 42 | void onewire_test_spu(void); 43 | void onewire_test_wordlength(void); 44 | -------------------------------------------------------------------------------- /src/pirate/hw2wire_pio.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2021 Raspberry Pi (Trading) Ltd. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | #ifndef _PIO_I2C_H 7 | #define _PIO_I2C_H 8 | 9 | #include "hw2wire.pio.h" 10 | 11 | void pio_hw2wire_init(uint sda, uint scl, uint dir_sda, uint dir_scl, uint baudrate); 12 | void pio_hw2wire_cleanup(void); 13 | 14 | void pio_hw2wire_put16(uint16_t data); 15 | void pio_hw2wire_get16(uint8_t* data); 16 | 17 | void pio_hw2wire_reset(void); 18 | void pio_hw2wire_clock_tick(void); 19 | void pio_hw2wire_set_mask(uint32_t pin_mask, uint32_t pin_value); 20 | void pio_hw2wire_start(void); 21 | void pio_hw2wire_stop(void); 22 | void pio_hw2wire_restart(void); 23 | #endif -------------------------------------------------------------------------------- /src/pirate/hw3wire_pio.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2021 Raspberry Pi (Trading) Ltd. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | #ifndef _PIO_I2C_H 7 | #define _PIO_I2C_H 8 | 9 | void pio_hw3wire_init(uint mosi, uint sclk, uint miso, uint32_t freq); 10 | void pio_hw3wire_cleanup(void); 11 | 12 | void pio_hw3wire_put16(uint16_t data); 13 | void pio_hw3wire_get16(uint8_t* data); 14 | 15 | void pio_hw3wire_reset(void); 16 | void pio_hw3wire_clock_tick(void); 17 | void pio_hw3wire_set_mask(uint32_t pin_mask, uint32_t pin_value); 18 | void pio_hw3wire_start(void); 19 | void pio_hw3wire_stop(void); 20 | void pio_hw3wire_restart(void); 21 | #endif -------------------------------------------------------------------------------- /src/pirate/hwspi.h: -------------------------------------------------------------------------------- 1 | void hwspi_init(uint8_t data_bits, uint8_t cpol, uint8_t cpha); 2 | void hwspi_deinit(void); 3 | void hwspi_select(void); 4 | void hwspi_deselect(void); 5 | void hwspi_write(uint32_t data); 6 | void hwspi_write_n(uint8_t* data, uint8_t count); 7 | void hwspi_write_32(const uint32_t data, uint8_t count); 8 | uint32_t hwspi_read(void); 9 | void hwspi_read_n(uint8_t* data, uint32_t count); 10 | uint32_t hwspi_write_read(uint8_t data); 11 | -------------------------------------------------------------------------------- /src/pirate/hwuart_pio.h: -------------------------------------------------------------------------------- 1 | void hwuart_pio_init(uint8_t data_bits, uint8_t parity, uint8_t stop_bits, uint32_t baud); 2 | void hwuart_pio_deinit(); 3 | bool hwuart_pio_read(uint32_t* raw, uint8_t* cooked); 4 | void hwuart_pio_write(uint32_t data); -------------------------------------------------------------------------------- /src/pirate/irio_pio.h: -------------------------------------------------------------------------------- 1 | int irio_pio_rx_init(uint pin_demod); 2 | void irio_pio_rx_deinit(uint pin_num); 3 | int irio_pio_tx_init(uint pin_num, uint32_t mod_freq); 4 | void irio_pio_tx_deinit(uint pin_num); 5 | 6 | void irio_pio_tx_set_mod_freq(float mod_freq); 7 | 8 | void irio_pio_rxtx_drain_fifo(void); 9 | bool irio_pio_tx_wait_idle(void); 10 | 11 | ir_rx_status_t irio_pio_rx_frame_printf(uint32_t *rx_frame); 12 | void irio_pio_tx_write(uint32_t *data); 13 | 14 | void irio_pio_tx_frame_write(float mod_freq, uint16_t pairs, uint32_t *buffer); 15 | bool irio_pio_rx_frame_buf(float *mod_freq, uint16_t *us, uint16_t *pairs, uint32_t *buffer); 16 | 17 | void irio_pio_rx_reset_mod_freq(void); 18 | -------------------------------------------------------------------------------- /src/pirate/lcd.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "pico/stdlib.h" 3 | #include "pirate.h" 4 | #include "pirate/shift.h" 5 | 6 | void lcd_init(void) { 7 | gpio_set_function(DISPLAY_CS, GPIO_FUNC_SIO); 8 | gpio_put(DISPLAY_CS, 1); 9 | gpio_set_dir(DISPLAY_CS, GPIO_OUT); 10 | 11 | gpio_set_function(DISPLAY_DP, GPIO_FUNC_SIO); 12 | gpio_put(DISPLAY_DP, 1); 13 | gpio_set_dir(DISPLAY_DP, GPIO_OUT); 14 | 15 | #if BP_HW_IOEXP_595 16 | //nothing to do 17 | #elif BP_HW_IOEXP_NONE 18 | gpio_set_function(DISPLAY_BACKLIGHT, GPIO_FUNC_SIO); 19 | gpio_put(DISPLAY_BACKLIGHT, 0); 20 | gpio_set_dir(DISPLAY_BACKLIGHT, GPIO_OUT); 21 | 22 | gpio_set_function(DISPLAY_RESET, GPIO_FUNC_SIO); 23 | gpio_put(DISPLAY_RESET, 1); 24 | gpio_set_dir(DISPLAY_RESET, GPIO_OUT); 25 | #else 26 | #error "Unknown platform version in lcd.c" 27 | #endif 28 | } 29 | 30 | void lcd_backlight_enable(bool enable) { 31 | #if BP_HW_IOEXP_595 32 | if (enable) { 33 | shift_clear_set_wait(0, (DISPLAY_BACKLIGHT)); 34 | } else { 35 | shift_clear_set_wait((DISPLAY_BACKLIGHT), 0); 36 | } 37 | #elif BP_HW_IOEXP_NONE 38 | gpio_put(DISPLAY_BACKLIGHT, enable); 39 | #else 40 | #error "Unknown platform version in lcd.c" 41 | #endif 42 | } 43 | 44 | // perform a hardware reset of the LCD according to datasheet specs 45 | void lcd_reset(void) { 46 | #if BP_HW_IOEXP_595 47 | shift_clear_set_wait(DISPLAY_RESET, 0); 48 | busy_wait_us(20); 49 | shift_clear_set_wait(0, DISPLAY_RESET); 50 | busy_wait_ms(100); 51 | #elif BP_HW_IOEXP_NONE 52 | gpio_put(DISPLAY_RESET, 0); 53 | busy_wait_us(20); 54 | gpio_put(DISPLAY_RESET, 1); 55 | busy_wait_ms(100); 56 | #else 57 | #error "Unknown platform version in lcd.c" 58 | #endif 59 | } -------------------------------------------------------------------------------- /src/pirate/lcd.h: -------------------------------------------------------------------------------- 1 | void lcd_init(void); 2 | void lcd_backlight_enable(bool enable); 3 | // perform a hardware reset of the LCD according to datasheet specs 4 | void lcd_reset(void); -------------------------------------------------------------------------------- /src/pirate/lsb.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "pico/stdlib.h" 3 | #include "pirate.h" 4 | 5 | // format a number of num_bits into LSB format 6 | uint32_t lsb_convert(uint32_t d, uint8_t num_bits) { 7 | uint32_t result = 0, mask = 0x80000000; 8 | for (uint32_t i = 0; i < 32; i++) { 9 | if ((d)&mask) { 10 | result |= (1 << (i)); 11 | } 12 | mask >>= 1; 13 | } 14 | return (result >> (32 - num_bits)); 15 | } 16 | 17 | // format a number of num_bits into MSB or LSB format 18 | // bit_order: 0=MSB, 1=LSB 19 | void lsb_get(uint32_t* d, uint8_t num_bits, bool bit_order) { 20 | if (!bit_order) { 21 | return; // 0=MSB 22 | } 23 | (*d) = lsb_convert(*d, num_bits); 24 | } -------------------------------------------------------------------------------- /src/pirate/lsb.h: -------------------------------------------------------------------------------- 1 | // format a number of num_bits into LSB format 2 | uint32_t lsb_convert(uint32_t d, uint8_t num_bits); 3 | // format a number of num_bits into MSB or LSB format 4 | // bit_order: 0=MSB, 1=LSB 5 | void lsb_get(uint32_t* d, uint8_t num_bits, bool bit_order); -------------------------------------------------------------------------------- /src/pirate/mcu.h: -------------------------------------------------------------------------------- 1 | uint64_t mcu_get_unique_id(void); 2 | void mcu_reset(void); 3 | void mcu_jump_to_bootloader(void); 4 | uint8_t mcu_detect_revision(void); -------------------------------------------------------------------------------- /src/pirate/mem.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file mem.c 3 | * @author Andrew Loebs 4 | * @brief Implementation file of the memory management module 5 | * 6 | */ 7 | // Modified by Ian Lesnet 18 Dec 2023 for Bus Pirate 5 8 | #include 9 | #include "pico/stdlib.h" 10 | #include "pirate.h" 11 | #include "pirate/mem.h" 12 | #include 13 | #include "system_config.h" 14 | 15 | // private variables 16 | static uint8_t mem_buffer[BIG_BUFFER_SIZE] __attribute__((aligned(32768))); // 128k ... this is 50% of the total RAM! 17 | static bool allocated = false; 18 | 19 | // public function definitions 20 | uint8_t* mem_alloc(size_t size, uint32_t owner) { 21 | if (!allocated && size <= sizeof(mem_buffer)) { 22 | allocated = true; 23 | system_config.big_buffer_owner = owner; 24 | return mem_buffer; 25 | } else { 26 | printf("Error: the big buffer is already allocated to #%d", system_config.big_buffer_owner); 27 | return NULL; 28 | } 29 | } 30 | 31 | void mem_free(uint8_t* ptr) { 32 | if (ptr == mem_buffer) { 33 | allocated = false; 34 | system_config.big_buffer_owner = BP_BIG_BUFFER_NONE; 35 | } 36 | } -------------------------------------------------------------------------------- /src/pirate/mem.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file mem.h 3 | * @author Andrew Loebs 4 | * @brief Header file of the memory management module 5 | * 6 | * A simple module to manage allocation of a single nand page buffer. 7 | * 8 | * This was made in response to many modules (shell_command, spi_nand), 9 | * needing temporary access to a page-sized array, and not wanting to 10 | * create that array on the stack or allocate it statically for the lifetime 11 | * of the application. This is not the page buffer used by the flash translation 12 | * layer. 13 | * 14 | * 15 | */ 16 | 17 | #ifndef __MEM_H 18 | #define __MEM_H 19 | 20 | #include 21 | #include 22 | 23 | enum big_buffer_owners { 24 | BP_BIG_BUFFER_NONE = 0, 25 | BP_BIG_BUFFER_SCOPE, 26 | BP_BIG_BUFFER_LA, 27 | BP_BIG_BUFFER_DISKFORMAT, 28 | }; 29 | 30 | /// @brief Attempts to allocate a nand page buffer. 31 | /// @return Pointer to the buffer if available, NULL if not available 32 | /// @note Return value should always be checked against null. 33 | /// @note Max size: SPI_NAND_PAGE_SIZE + SPI_NAND_OOB_SIZE 34 | uint8_t* mem_alloc(size_t size, uint32_t owner); 35 | 36 | /// @brief Frees the allocated nand page buffer 37 | /// @param ptr pointer to the nand page buffer 38 | void mem_free(uint8_t* ptr); 39 | 40 | #endif // __MEM_H 41 | -------------------------------------------------------------------------------- /src/pirate/onewire_library.h: -------------------------------------------------------------------------------- 1 | 2 | 3 | typedef struct { 4 | PIO pio; 5 | uint sm; 6 | uint jmp_reset; 7 | int offset; 8 | int gpio; 9 | } OW; 10 | 11 | bool ow_init(uint8_t bits_per_word, uint bufdir, uint inpin); 12 | void ow_send(uint data); 13 | uint8_t ow_read(void); 14 | bool ow_reset(void); 15 | int ow_romsearch(uint64_t* romcodes, int maxdevs, uint command); 16 | void ow_cleanup(void); -------------------------------------------------------------------------------- /src/pirate/psu.h: -------------------------------------------------------------------------------- 1 | enum psu_errors { 2 | PSU_OK = 0, 3 | PSU_ERROR_FUSE_TRIPPED, 4 | PSU_ERROR_VOUT_LOW, 5 | PSU_ERROR_BACKFLOW 6 | }; 7 | 8 | struct psu_status_t { 9 | float voltage_requested; 10 | float voltage_actual; 11 | uint32_t voltage_actual_i; 12 | uint16_t voltage_dac_value; 13 | float current_requested; 14 | float current_actual; 15 | uint32_t current_actual_i; 16 | uint16_t current_dac_value; 17 | bool current_limit_override; 18 | }; 19 | 20 | extern struct psu_status_t psu_status; 21 | 22 | void psu_init(void); 23 | uint32_t psu_enable(float volts, float current, bool current_limit_override); 24 | void psu_disable(void); 25 | void psu_measure(uint32_t* vout, uint32_t* isense, uint32_t* vreg, bool* fuse); 26 | uint32_t psu_measure_vout(void); 27 | uint32_t psu_measure_vreg(void); 28 | uint32_t psu_measure_current(void); 29 | bool psu_fuse_ok(void); 30 | void psu_vreg_enable(bool enable); 31 | void psu_current_limit_override(bool enable); 32 | -------------------------------------------------------------------------------- /src/pirate/pullup.h: -------------------------------------------------------------------------------- 1 | enum { 2 | PULLX_OFF=0, 3 | PULLX_1K3, 4 | PULLX_1K5, 5 | PULLX_1K8, 6 | PULLX_2K2, 7 | PULLX_3K2, 8 | PULLX_4K7, 9 | PULLX_10K, 10 | PULLX_1M, 11 | }; 12 | 13 | struct pullx_options_t { 14 | uint8_t pull; 15 | const char name[5]; 16 | uint8_t resistors; // Use a uint8_t to store the boolean values as bitfields 17 | }; 18 | 19 | extern const struct pullx_options_t pullx_options[9]; 20 | extern uint8_t pullx_value[8]; 21 | extern uint8_t pullx_direction; 22 | 23 | void pullup_init(void); 24 | void pullup_enable(void); 25 | void pullup_disable(void); 26 | 27 | void pullx_set_all_test(uint16_t resistor_mask, uint16_t direction_mask); 28 | void pullx_set_all_update(uint8_t pull, bool pull_up); 29 | void pullx_set_pin(uint8_t pin, uint8_t pull, bool pull_up); 30 | bool pullx_update(void); 31 | void pullx_get_pin(uint8_t pin, uint8_t *pull, bool *pull_up); -------------------------------------------------------------------------------- /src/pirate/pwm.pio: -------------------------------------------------------------------------------- 1 | ; 2 | ; Copyright (c) 2020 Raspberry Pi (Trading) Ltd. 3 | ; 4 | ; SPDX-License-Identifier: BSD-3-Clause 5 | ; 6 | 7 | ; Side-set pin 0 is used for PWM output 8 | .pio_version 0 // only requires PIO version 0 9 | 10 | .program pwm 11 | .side_set 1 opt 12 | 13 | pull noblock side 0 ; Pull from FIFO to OSR if available, else copy X to OSR. 14 | mov x, osr ; Copy most-recently-pulled value back to scratch X 15 | mov y, isr ; ISR contains PWM period. Y used as counter. 16 | countloop: 17 | jmp x!=y noset ; Set pin high if X == Y, keep the two paths length matched 18 | jmp skip side 1 19 | noset: 20 | nop ; Single dummy cycle to keep the two paths the same length 21 | skip: 22 | jmp y-- countloop ; Loop until Y hits 0, then pull a fresh PWM value from FIFO 23 | 24 | % c-sdk { 25 | static inline void pwm_program_init(PIO pio, uint sm, uint offset, uint pin) { 26 | pio_gpio_init(pio, pin); 27 | pio_sm_set_consecutive_pindirs(pio, sm, pin, 1, true); 28 | pio_sm_config c = pwm_program_get_default_config(offset); 29 | sm_config_set_sideset_pins(&c, pin); 30 | pio_sm_init(pio, sm, offset, &c); 31 | } 32 | %} 33 | -------------------------------------------------------------------------------- /src/pirate/rc5_pio.h: -------------------------------------------------------------------------------- 1 | int rc5_rx_init(uint pin_num); 2 | int rc5_tx_init(uint pin_num, uint32_t mod_freq); 3 | void rc5_rx_deinit(uint pin_num); 4 | void rc5_tx_deinit(uint pin_num); 5 | void rc5_send(uint32_t *data); 6 | ir_rx_status_t rc5_receive(uint32_t *rx_frame); 7 | void rc5_test(void); 8 | bool rc5_tx_wait_idle(void); 9 | void rc5_drain_fifo(void); -------------------------------------------------------------------------------- /src/pirate/rgb.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | typedef enum _led_effect { 4 | LED_EFFECT_DISABLED = 0, 5 | LED_EFFECT_SOLID = 1, 6 | LED_EFFECT_ANGLE_WIPE = 2, 7 | LED_EFFECT_CENTER_WIPE = 3, 8 | LED_EFFECT_CLOCKWISE_WIPE = 4, 9 | LED_EFFECT_TOP_SIDE_WIPE = 5, 10 | LED_EFFECT_SCANNER = 6, 11 | LED_EFFECT_GENTLE_GLOW = 7, 12 | 13 | LED_EFFECT_PARTY_MODE, // NOTE: This must be the last effect 14 | MAX_LED_EFFECT, 15 | } led_effect_t; 16 | #define DEFAULT_LED_EFFECT = LED_EFFECT_GENTLE_GLOW; 17 | 18 | static_assert(LED_EFFECT_DISABLED == 0, 19 | "LED_EFFECT_DISABLED must be zero"); // when used as boolean, also relied upon in party mode handling 20 | static_assert(MAX_LED_EFFECT - 1 == LED_EFFECT_PARTY_MODE, "LED_EFFECT_PARTY_MODE must be the last effect"); 21 | 22 | // TODO: review and provide a more useful client-focused API. 23 | // TODO: adjust to use RGB color type instead of uint32_t. 24 | void rgb_init(void); 25 | void rgb_put(uint32_t color); 26 | void rgb_irq_enable(bool enable); 27 | void rgb_set_all(uint8_t r, uint8_t g, uint8_t b); 28 | void rgb_set_effect(led_effect_t new_effect); 29 | -------------------------------------------------------------------------------- /src/pirate/shift.h: -------------------------------------------------------------------------------- 1 | void shift_init(void); 2 | void shift_output_enable(bool enable); 3 | // set and clear bits on shift register, with selectable spinlock (spi_busy_wait) 4 | void shift_clear_set(uint16_t clear_bits, uint16_t set_bits, bool busy_wait); 5 | // set and clear bits on shift registers, spinlock (spi_busy_wait) enabled 6 | void shift_clear_set_wait(uint16_t clear_bits, uint16_t set_bits); 7 | -------------------------------------------------------------------------------- /src/pirate/storage.h: -------------------------------------------------------------------------------- 1 | #ifndef PIRATE__STORAGE_H 2 | #define PIRATE__STORAGE_H 3 | 4 | void storage_init(void); 5 | bool storage_detect(void); 6 | uint8_t storage_mount(void); 7 | void storage_unmount(void); 8 | uint8_t storage_format(void); 9 | void storage_file_error(uint8_t res); 10 | bool storage_save_binary_blob_rollover(char* data, uint32_t ptr, uint32_t size, uint32_t rollover); 11 | 12 | typedef enum _mode_config_format { 13 | MODE_CONFIG_FORMAT_DECIMAL, 14 | MODE_CONFIG_FORMAT_HEXSTRING, 15 | } mode_config_format_t; 16 | 17 | typedef struct _mode_config_t { 18 | char tag[30]; 19 | uint32_t* config; 20 | mode_config_format_t formatted_as; 21 | } mode_config_t; 22 | uint32_t storage_load_config(void); 23 | uint32_t storage_save_config(void); 24 | uint32_t storage_save_mode(const char* filename, const mode_config_t* config_t, uint8_t count); 25 | uint32_t storage_load_mode(const char* filename, const mode_config_t* config_t, uint8_t count); 26 | bool storage_file_exists(const char* filepath); 27 | bool storage_ls(const char* location, const char* ext, const uint8_t flags); 28 | 29 | extern const char storage_fat_type_labels[5][8]; 30 | 31 | #define LS_FILES 0x01 32 | #define LS_DIRS 0x02 33 | #define LS_SIZE 0x04 34 | #define LS_SUMM 0x08 35 | #define LS_ALL (LS_FILES | LS_DIRS | LS_SIZE | LS_SUMM) 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /src/platform/bpi5-rev10.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "pico/stdlib.h" 3 | #include "pirate.h" 4 | #include "hardware/adc.h" 5 | #include "pico/bootrom.h" 6 | 7 | //TODO: move all this nonsense to the system config 8 | uint16_t hw_adc_raw[HW_ADC_COUNT]; 9 | uint32_t hw_adc_voltage[HW_ADC_COUNT]; 10 | uint32_t hw_adc_avgsum_voltage[HW_ADC_COUNT]; 11 | 12 | const uint8_t bio2bufiopin[] = 13 | { 14 | BUFIO0, 15 | BUFIO1, 16 | BUFIO2, 17 | BUFIO3, 18 | BUFIO4, 19 | BUFIO5, 20 | BUFIO6, 21 | BUFIO7}; 22 | // here we map the short names to 23 | // the buffer direction pin number 24 | const uint8_t bio2bufdirpin[] = 25 | { 26 | BUFDIR0, 27 | BUFDIR1, 28 | BUFDIR2, 29 | BUFDIR3, 30 | BUFDIR4, 31 | BUFDIR5, 32 | BUFDIR6, 33 | BUFDIR7}; 34 | // Pin names for terminal and LCD display, in order 35 | const char hw_pin_label_ordered[][5] = { 36 | "Vout", 37 | "IO0", 38 | "IO1", 39 | "IO2", 40 | "IO3", 41 | "IO4", 42 | "IO5", 43 | "IO6", 44 | "IO7", 45 | "GND"}; 46 | 47 | // name text and background color for the terminal 48 | const uint32_t hw_pin_label_ordered_color[][2] = { 49 | {BP_COLOR_FULLBLACK, BP_COLOR_RED}, 50 | {BP_COLOR_FULLBLACK, BP_COLOR_ORANGE}, 51 | {BP_COLOR_FULLBLACK, BP_COLOR_YELLOW}, 52 | {BP_COLOR_FULLBLACK, BP_COLOR_GREEN}, 53 | {BP_COLOR_FULLBLACK, BP_COLOR_BLUE}, 54 | {BP_COLOR_FULLBLACK, BP_COLOR_PURPLE}, 55 | {BP_COLOR_FULLBLACK, BP_COLOR_BROWN}, 56 | {BP_COLOR_FULLBLACK, BP_COLOR_GREY}, 57 | {BP_COLOR_FULLBLACK, BP_COLOR_WHITE}, 58 | {BP_COLOR_FULLWHITE, BP_COLOR_FULLBLACK}}; 59 | -------------------------------------------------------------------------------- /src/platform/bpi5-rev8.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "pico/stdlib.h" 3 | #include "pirate.h" 4 | #include "platform/bpi5-rev8.h" 5 | 6 | //TODO: move all this nonsense to the system config 7 | uint16_t hw_adc_raw[HW_ADC_COUNT]; 8 | uint32_t hw_adc_voltage[HW_ADC_COUNT]; 9 | uint32_t hw_adc_avgsum_voltage[HW_ADC_COUNT]; 10 | 11 | const char hw_pin_label_ordered[][5] = { 12 | "Vout", 13 | "IO0", 14 | "IO1", 15 | "IO2", 16 | "IO3", 17 | "IO4", 18 | "IO5", 19 | "IO6", 20 | "IO7", 21 | "GND" 22 | }; 23 | const uint32_t hw_pin_label_ordered_color[][2] = { 24 | {BP_COLOR_FULLBLACK, BP_COLOR_RED}, 25 | {BP_COLOR_FULLBLACK, BP_COLOR_ORANGE}, 26 | {BP_COLOR_FULLBLACK, BP_COLOR_YELLOW}, 27 | {BP_COLOR_FULLBLACK, BP_COLOR_GREEN}, 28 | {BP_COLOR_FULLBLACK, BP_COLOR_BLUE}, 29 | {BP_COLOR_FULLBLACK, BP_COLOR_PURPLE}, 30 | {BP_COLOR_FULLBLACK, BP_COLOR_BROWN}, 31 | {BP_COLOR_FULLBLACK, BP_COLOR_GREY}, 32 | {BP_COLOR_FULLBLACK, BP_COLOR_WHITE}, 33 | {BP_COLOR_FULLWHITE, BP_COLOR_FULLBLACK} 34 | }; 35 | -------------------------------------------------------------------------------- /src/platform/bpi5-rev9.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "pico/stdlib.h" 3 | #include "pirate.h" 4 | #include "hardware/adc.h" 5 | #include "pico/bootrom.h" 6 | 7 | //TODO: move all this nonsense to the system config 8 | uint16_t hw_adc_raw[HW_ADC_COUNT]; 9 | uint32_t hw_adc_voltage[HW_ADC_COUNT]; 10 | uint32_t hw_adc_avgsum_voltage[HW_ADC_COUNT]; 11 | -------------------------------------------------------------------------------- /src/platform/bpi5xl-rev0.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "pico/stdlib.h" 3 | #include "pirate.h" 4 | #include "hardware/adc.h" 5 | #include "pico/bootrom.h" 6 | 7 | //TODO: move all this nonsense to the system config 8 | uint16_t hw_adc_raw[HW_ADC_COUNT]; 9 | uint32_t hw_adc_voltage[HW_ADC_COUNT]; 10 | uint32_t hw_adc_avgsum_voltage[HW_ADC_COUNT]; 11 | 12 | const uint8_t bio2bufiopin[] = 13 | { 14 | BUFIO0, 15 | BUFIO1, 16 | BUFIO2, 17 | BUFIO3, 18 | BUFIO4, 19 | BUFIO5, 20 | BUFIO6, 21 | BUFIO7}; 22 | // here we map the short names to 23 | // the buffer direction pin number 24 | const uint8_t bio2bufdirpin[] = 25 | { 26 | BUFDIR0, 27 | BUFDIR1, 28 | BUFDIR2, 29 | BUFDIR3, 30 | BUFDIR4, 31 | BUFDIR5, 32 | BUFDIR6, 33 | BUFDIR7}; 34 | // Pin names for terminal and LCD display, in order 35 | const char hw_pin_label_ordered[][5] = { 36 | "Vout", 37 | "IO0", 38 | "IO1", 39 | "IO2", 40 | "IO3", 41 | "IO4", 42 | "IO5", 43 | "IO6", 44 | "IO7", 45 | "GND"}; 46 | 47 | // name text and background color for the terminal 48 | const uint32_t hw_pin_label_ordered_color[][2] = { 49 | {BP_COLOR_FULLBLACK, BP_COLOR_RED}, 50 | {BP_COLOR_FULLBLACK, BP_COLOR_ORANGE}, 51 | {BP_COLOR_FULLBLACK, BP_COLOR_YELLOW}, 52 | {BP_COLOR_FULLBLACK, BP_COLOR_GREEN}, 53 | {BP_COLOR_FULLBLACK, BP_COLOR_BLUE}, 54 | {BP_COLOR_FULLBLACK, BP_COLOR_PURPLE}, 55 | {BP_COLOR_FULLBLACK, BP_COLOR_BROWN}, 56 | {BP_COLOR_FULLBLACK, BP_COLOR_GREY}, 57 | {BP_COLOR_FULLBLACK, BP_COLOR_WHITE}, 58 | {BP_COLOR_FULLWHITE, BP_COLOR_FULLBLACK}}; 59 | -------------------------------------------------------------------------------- /src/platform/bpi6-rev2.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "pico/stdlib.h" 3 | #include "pirate.h" 4 | #include "hardware/adc.h" 5 | #include "pico/bootrom.h" 6 | 7 | //TODO: move all this nonsense to the system config 8 | uint16_t hw_adc_raw[HW_ADC_COUNT]; 9 | uint32_t hw_adc_voltage[HW_ADC_COUNT]; 10 | uint32_t hw_adc_avgsum_voltage[HW_ADC_COUNT]; 11 | 12 | const uint8_t bio2bufiopin[] = 13 | { 14 | BUFIO0, 15 | BUFIO1, 16 | BUFIO2, 17 | BUFIO3, 18 | BUFIO4, 19 | BUFIO5, 20 | BUFIO6, 21 | BUFIO7}; 22 | // here we map the short names to 23 | // the buffer direction pin number 24 | const uint8_t bio2bufdirpin[] = 25 | { 26 | BUFDIR0, 27 | BUFDIR1, 28 | BUFDIR2, 29 | BUFDIR3, 30 | BUFDIR4, 31 | BUFDIR5, 32 | BUFDIR6, 33 | BUFDIR7}; 34 | // Pin names for terminal and LCD display, in order 35 | const char hw_pin_label_ordered[][5] = { 36 | "Vout", 37 | "IO0", 38 | "IO1", 39 | "IO2", 40 | "IO3", 41 | "IO4", 42 | "IO5", 43 | "IO6", 44 | "IO7", 45 | "GND"}; 46 | 47 | // name text and background color for the terminal 48 | const uint32_t hw_pin_label_ordered_color[][2] = { 49 | {BP_COLOR_FULLBLACK, BP_COLOR_RED}, 50 | {BP_COLOR_FULLBLACK, BP_COLOR_ORANGE}, 51 | {BP_COLOR_FULLBLACK, BP_COLOR_YELLOW}, 52 | {BP_COLOR_FULLBLACK, BP_COLOR_GREEN}, 53 | {BP_COLOR_FULLBLACK, BP_COLOR_BLUE}, 54 | {BP_COLOR_FULLBLACK, BP_COLOR_PURPLE}, 55 | {BP_COLOR_FULLBLACK, BP_COLOR_BROWN}, 56 | {BP_COLOR_FULLBLACK, BP_COLOR_GREY}, 57 | {BP_COLOR_FULLBLACK, BP_COLOR_WHITE}, 58 | {BP_COLOR_FULLWHITE, BP_COLOR_FULLBLACK}}; 59 | -------------------------------------------------------------------------------- /src/platform/bpi7-rev0.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "pico/stdlib.h" 3 | #include "pirate.h" 4 | #include "hardware/adc.h" 5 | #include "pico/bootrom.h" 6 | 7 | //TODO: move all this nonsense to the system config 8 | uint16_t hw_adc_raw[HW_ADC_COUNT]; 9 | uint32_t hw_adc_voltage[HW_ADC_COUNT]; 10 | uint32_t hw_adc_avgsum_voltage[HW_ADC_COUNT]; 11 | 12 | const uint8_t bio2bufiopin[] = 13 | { 14 | BUFIO0, 15 | BUFIO1, 16 | BUFIO2, 17 | BUFIO3, 18 | BUFIO4, 19 | BUFIO5, 20 | BUFIO6, 21 | BUFIO7}; 22 | // here we map the short names to 23 | // the buffer direction pin number 24 | const uint8_t bio2bufdirpin[] = 25 | { 26 | BUFDIR0, 27 | BUFDIR1, 28 | BUFDIR2, 29 | BUFDIR3, 30 | BUFDIR4, 31 | BUFDIR5, 32 | BUFDIR6, 33 | BUFDIR7}; 34 | // Pin names for terminal and LCD display, in order 35 | const char hw_pin_label_ordered[][5] = { 36 | "Vout", 37 | "IO0", 38 | "IO1", 39 | "IO2", 40 | "IO3", 41 | "IO4", 42 | "IO5", 43 | "IO6", 44 | "IO7", 45 | "GND"}; 46 | 47 | // name text and background color for the terminal 48 | const uint32_t hw_pin_label_ordered_color[][2] = { 49 | {BP_COLOR_FULLBLACK, BP_COLOR_RED}, 50 | {BP_COLOR_FULLBLACK, BP_COLOR_ORANGE}, 51 | {BP_COLOR_FULLBLACK, BP_COLOR_YELLOW}, 52 | {BP_COLOR_FULLBLACK, BP_COLOR_GREEN}, 53 | {BP_COLOR_FULLBLACK, BP_COLOR_BLUE}, 54 | {BP_COLOR_FULLBLACK, BP_COLOR_PURPLE}, 55 | {BP_COLOR_FULLBLACK, BP_COLOR_BROWN}, 56 | {BP_COLOR_FULLBLACK, BP_COLOR_GREY}, 57 | {BP_COLOR_FULLBLACK, BP_COLOR_WHITE}, 58 | {BP_COLOR_FULLWHITE, BP_COLOR_FULLBLACK}}; 59 | -------------------------------------------------------------------------------- /src/printf-4.0.0/.gitattributes: -------------------------------------------------------------------------------- 1 | # ignore test path 2 | test/* linguist-vendored 3 | -------------------------------------------------------------------------------- /src/printf-4.0.0/.travis.yml: -------------------------------------------------------------------------------- 1 | # Use a C++11 distro 2 | dist: trusty 3 | sudo: required 4 | 5 | # Enable C++ support 6 | language: cpp 7 | 8 | # Compiler selection 9 | compiler: gcc 10 | 11 | env: 12 | global: 13 | # coverity key 14 | - secure: "NKZbBnMALGIIQJy/s2kc3EST/stw+gjhtrGq0jkbsWr7Wx3FH+lmLeHNsDXRnD1VbpG02c5YsLllqz9OVu+0yxWGepvKNmCz1cNITIALEHbrax8/Af9LzPRL/QZxS/Qe11sMuySp4X16mFBUyxMd/X+I9i96Xf1vKkZABklYD1Q=" 15 | 16 | # addons 17 | addons: 18 | apt: 19 | packages: 20 | - gcc-6 21 | - g++-6 22 | sources: 23 | - ubuntu-toolchain-r-test 24 | 25 | coverity_scan: 26 | project: 27 | name: "mpaland/printf" 28 | description: "Tiny printf implementation" 29 | notification_email: marco@paland.com 30 | build_command_prepend: "make clean" 31 | build_command: "make" 32 | branch_pattern: master 33 | 34 | before_install: 35 | # connect coverity 36 | - echo -n | openssl s_client -connect scan.coverity.com:443 | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' | sudo tee -a /etc/ssl/certs/ca- 37 | 38 | # Active branches 39 | branches: 40 | only: 41 | - master 42 | 43 | script: 44 | # Link gcc-6 and g++-6 to their standard commands 45 | - sudo rm /usr/bin/gcc 46 | - sudo rm /usr/bin/g++ 47 | - sudo ln -s /usr/bin/gcc-6 /usr/bin/gcc 48 | - sudo ln -s /usr/bin/g++-6 /usr/bin/g++ 49 | # Export CC and CXX 50 | - export CC=/usr/bin/gcc-6 51 | - export CXX=/usr/bin/g++-6 52 | # Check versions of gcc, g++ 53 | - gcc -v && g++ -v 54 | # Run build commands 55 | - make 56 | # execute the text suite 57 | - bin/test_suite -d yes 58 | # coverall profiling 59 | - tmp/cov/test_suite 60 | 61 | after_success: 62 | ## Report to codecov 63 | - bash <(curl -s https://codecov.io/bash) 64 | -------------------------------------------------------------------------------- /src/printf-4.0.0/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Marco Paland 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /src/printf-4.0.0/codecov.yml: -------------------------------------------------------------------------------- 1 | ignore: 2 | - "test" # ignore the test folder 3 | -------------------------------------------------------------------------------- /src/syntax.h: -------------------------------------------------------------------------------- 1 | SYNTAX_STATUS syntax_compile(void); 2 | SYNTAX_STATUS syntax_run(void); 3 | SYNTAX_STATUS syntax_post(void); 4 | -------------------------------------------------------------------------------- /src/syntax_struct.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DangerousPrototypes/BusPirate5-firmware/c3ac15d7ce16e710c05117b1614dcef9854187d4/src/syntax_struct.h -------------------------------------------------------------------------------- /src/system_monitor.h: -------------------------------------------------------------------------------- 1 | bool monitor(bool current_sense); 2 | void monitor_init(void); 3 | void monitor_reset(void); 4 | void monitor_force_update(void); 5 | bool monitor_get_voltage_char(uint8_t pin, uint8_t digit, char* c); 6 | bool monitor_get_voltage_ptr(uint8_t pin, char** c); 7 | bool monitor_get_current_ptr(char** c); 8 | bool monitor_get_current_char(uint8_t digit, char* c); 9 | 10 | void monitor_clear_voltage(void); 11 | void monitor_clear_current(void); 12 | bool monitor_voltage_changed(void); 13 | bool monitor_current_changed(void); 14 | -------------------------------------------------------------------------------- /src/toolbars/logic_bar.h: -------------------------------------------------------------------------------- 1 | #ifndef LOGIC_BAR_H 2 | #define LOGIC_BAR_H 3 | 4 | // Function declarations 5 | void la_draw_frame(void); 6 | void logic_bar_redraw(uint32_t start_pos, uint32_t total_samples); 7 | void la_periodic(void); 8 | bool logic_bar_start(void); 9 | void logic_bar_stop(void); 10 | void logic_bar_hide(void); 11 | void logic_bar_show(void); 12 | void logic_bar_navigate(void); 13 | void logic_bar_update(void); 14 | void logic_bar_config(char low, char high); 15 | 16 | #endif // LOGIC_BAR_H -------------------------------------------------------------------------------- /src/translation/editor/jquery-ui-1.14.1.dark/LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright OpenJS Foundation and other contributors, https://openjsf.org/ 2 | 3 | This software consists of voluntary contributions made by many 4 | individuals. For exact contribution history, see the revision history 5 | available at https://github.com/jquery/jquery-ui 6 | 7 | The following license applies to all parts of this software except as 8 | documented below: 9 | 10 | ==== 11 | 12 | Permission is hereby granted, free of charge, to any person obtaining 13 | a copy of this software and associated documentation files (the 14 | "Software"), to deal in the Software without restriction, including 15 | without limitation the rights to use, copy, modify, merge, publish, 16 | distribute, sublicense, and/or sell copies of the Software, and to 17 | permit persons to whom the Software is furnished to do so, subject to 18 | the following conditions: 19 | 20 | The above copyright notice and this permission notice shall be 21 | included in all copies or substantial portions of the Software. 22 | 23 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 24 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 25 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 26 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 27 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 28 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 29 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 30 | 31 | ==== 32 | 33 | Copyright and related rights for sample code are waived via CC0. Sample 34 | code is defined as all source code contained within the demos directory. 35 | 36 | CC0: http://creativecommons.org/publicdomain/zero/1.0/ 37 | 38 | ==== 39 | 40 | All files located in the node_modules and external directories are 41 | externally maintained libraries used by this software which have their 42 | own licenses; we recommend you read them, as their terms may differ from 43 | the terms above. 44 | -------------------------------------------------------------------------------- /src/translation/editor/jquery-ui-1.14.1.dark/images/ui-bg_glass_20_555555_1x400.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DangerousPrototypes/BusPirate5-firmware/c3ac15d7ce16e710c05117b1614dcef9854187d4/src/translation/editor/jquery-ui-1.14.1.dark/images/ui-bg_glass_20_555555_1x400.png -------------------------------------------------------------------------------- /src/translation/editor/jquery-ui-1.14.1.dark/images/ui-bg_glass_40_0078a3_1x400.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DangerousPrototypes/BusPirate5-firmware/c3ac15d7ce16e710c05117b1614dcef9854187d4/src/translation/editor/jquery-ui-1.14.1.dark/images/ui-bg_glass_40_0078a3_1x400.png -------------------------------------------------------------------------------- /src/translation/editor/jquery-ui-1.14.1.dark/images/ui-bg_glass_40_ffc73d_1x400.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DangerousPrototypes/BusPirate5-firmware/c3ac15d7ce16e710c05117b1614dcef9854187d4/src/translation/editor/jquery-ui-1.14.1.dark/images/ui-bg_glass_40_ffc73d_1x400.png -------------------------------------------------------------------------------- /src/translation/editor/jquery-ui-1.14.1.dark/images/ui-bg_gloss-wave_25_333333_500x100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DangerousPrototypes/BusPirate5-firmware/c3ac15d7ce16e710c05117b1614dcef9854187d4/src/translation/editor/jquery-ui-1.14.1.dark/images/ui-bg_gloss-wave_25_333333_500x100.png -------------------------------------------------------------------------------- /src/translation/editor/jquery-ui-1.14.1.dark/images/ui-bg_highlight-soft_80_eeeeee_1x100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DangerousPrototypes/BusPirate5-firmware/c3ac15d7ce16e710c05117b1614dcef9854187d4/src/translation/editor/jquery-ui-1.14.1.dark/images/ui-bg_highlight-soft_80_eeeeee_1x100.png -------------------------------------------------------------------------------- /src/translation/editor/jquery-ui-1.14.1.dark/images/ui-bg_inset-soft_25_000000_1x100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DangerousPrototypes/BusPirate5-firmware/c3ac15d7ce16e710c05117b1614dcef9854187d4/src/translation/editor/jquery-ui-1.14.1.dark/images/ui-bg_inset-soft_25_000000_1x100.png -------------------------------------------------------------------------------- /src/translation/editor/jquery-ui-1.14.1.dark/images/ui-bg_inset-soft_30_f58400_1x100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DangerousPrototypes/BusPirate5-firmware/c3ac15d7ce16e710c05117b1614dcef9854187d4/src/translation/editor/jquery-ui-1.14.1.dark/images/ui-bg_inset-soft_30_f58400_1x100.png -------------------------------------------------------------------------------- /src/translation/editor/jquery-ui-1.14.1.dark/images/ui-icons_222222_256x240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DangerousPrototypes/BusPirate5-firmware/c3ac15d7ce16e710c05117b1614dcef9854187d4/src/translation/editor/jquery-ui-1.14.1.dark/images/ui-icons_222222_256x240.png -------------------------------------------------------------------------------- /src/translation/editor/jquery-ui-1.14.1.dark/images/ui-icons_4b8e0b_256x240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DangerousPrototypes/BusPirate5-firmware/c3ac15d7ce16e710c05117b1614dcef9854187d4/src/translation/editor/jquery-ui-1.14.1.dark/images/ui-icons_4b8e0b_256x240.png -------------------------------------------------------------------------------- /src/translation/editor/jquery-ui-1.14.1.dark/images/ui-icons_a83300_256x240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DangerousPrototypes/BusPirate5-firmware/c3ac15d7ce16e710c05117b1614dcef9854187d4/src/translation/editor/jquery-ui-1.14.1.dark/images/ui-icons_a83300_256x240.png -------------------------------------------------------------------------------- /src/translation/editor/jquery-ui-1.14.1.dark/images/ui-icons_cccccc_256x240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DangerousPrototypes/BusPirate5-firmware/c3ac15d7ce16e710c05117b1614dcef9854187d4/src/translation/editor/jquery-ui-1.14.1.dark/images/ui-icons_cccccc_256x240.png -------------------------------------------------------------------------------- /src/translation/editor/jquery-ui-1.14.1.dark/images/ui-icons_ffffff_256x240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DangerousPrototypes/BusPirate5-firmware/c3ac15d7ce16e710c05117b1614dcef9854187d4/src/translation/editor/jquery-ui-1.14.1.dark/images/ui-icons_ffffff_256x240.png -------------------------------------------------------------------------------- /src/translation/json2h.bat: -------------------------------------------------------------------------------- 1 | python json2h.py 2 | pause -------------------------------------------------------------------------------- /src/translation/templates/base.ht: -------------------------------------------------------------------------------- 1 | #ifndef _TRANSLATION_BASE 2 | #define _TRANSLATION_BASE 3 | 4 | // WARNING -- DO NOT DIRECTLY EDIT `src/translation/base.h` -- WARNING 5 | // =============================================================== 6 | // NOTE: GENERATED FILE -- DO NOT EDIT DIRECTLY 7 | // This file is auto-generated by `src/translation/json2h.py`. 8 | // To edit items that appear in this file: 9 | // * items within `enum T_translations{}` are automatically generated 10 | // from the parsing of `src/translation/en-us.h` 11 | // * other items may be edited in the source template 12 | // at `src/translation/templates/base.ht` 13 | 14 | 15 | 16 | typedef enum _language_idx_t { // these are based on IETF codes for the translation 17 | language_idx_en_us, 18 | language_idx_pl_pl, 19 | language_idx_bs_latn_ba, 20 | language_idx_it_it, 21 | // language_idx_zh_cmn_cn, 22 | 23 | 24 | COUNT_OF_LANGUAGE_IDX, // leave this as the final enum value 25 | } language_idx_t; 26 | 27 | enum T_translations{ 28 | %%%enum_list%%% 29 | T_LAST_ITEM_ALWAYS_AT_THE_END //LEAVE THIS ITEM AT THE END!!! It helps the compiler report errors if there are missing translations 30 | }; 31 | 32 | const char * GET_T(enum T_translations index); 33 | void translation_init(void); 34 | void translation_set(language_idx_t language); 35 | const char* get_current_language_name(void); 36 | language_idx_t get_current_language_idx(void); 37 | const char* get_language_name(language_idx_t language_idx); 38 | 39 | #endif -------------------------------------------------------------------------------- /src/translation/templates/translation.ht: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // NOTE: GENERATED FILE -- DO NOT EDIT DIRECTLY 4 | // This file is auto-generated by `src/translations/json2h.py`. 5 | // Entirely new strings should be added to `src/translations/en-us.h` 6 | // New or modified translations of a string should be added to the 7 | // language-specific JSON file, which can be found in directory 8 | // `src/translations/templates/`. 9 | 10 | #include "translation/base.h" 11 | static char const * const %%%variable_name%%%[T_LAST_ITEM_ALWAYS_AT_THE_END]={ 12 | %%%array_data%%% 13 | }; 14 | -------------------------------------------------------------------------------- /src/ui/ui_button.h: -------------------------------------------------------------------------------- 1 | bool ui_button_exec(void); -------------------------------------------------------------------------------- /src/ui/ui_config.h: -------------------------------------------------------------------------------- 1 | void ui_config_main_menu(struct command_result* res); -------------------------------------------------------------------------------- /src/ui/ui_const.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "pico/stdlib.h" 3 | #include "pirate.h" //for translations 4 | -------------------------------------------------------------------------------- /src/ui/ui_const.h: -------------------------------------------------------------------------------- 1 | static const int ui_const_input_output[] = { T_INPUT, T_OUTPUT }; 2 | 3 | enum ui_const_freq_measures { 4 | freq_ns, 5 | freq_us, 6 | freq_ms, 7 | freq_hz, 8 | freq_khz, 9 | freq_mhz, 10 | freq_percent 11 | }; 12 | 13 | // Lower case for detecting user input 14 | static const char ui_const_freq_slugs[][4] = { "ns", "us", "ms", "hz", "khz", "mhz", "%" }; 15 | // Pretty labels to display frequency and period 16 | static const char ui_const_freq_labels[][4] = { "ns", "us", "ms", "Hz", "kHz", "MHz", "%" }; 17 | // short version of freq labels to show in constrained spaces (eg toolbar) 18 | static const char ui_const_freq_labels_short[][2] = { "n", "u", "m", "H", "K", "M", "%" }; 19 | // global constants 20 | static const char ui_const_bit_orders[][4] = { "MSB", "LSB" }; 21 | 22 | static const char ui_const_pin_states[][6] = { "OFF", "ON", "GND", "PWM", "FREQ", "ERR" }; 23 | 24 | enum ui_const_display_formats_enum { 25 | df_auto, 26 | df_hex, 27 | df_dec, 28 | // df_oct, 29 | df_bin, 30 | df_ascii 31 | }; 32 | 33 | static const char ui_const_display_formats[][6] = { "Auto", 34 | "HEX", 35 | "DEC", 36 | //"OCT", 37 | "BIN", 38 | "ASCII" }; 39 | 40 | static const char ascii_hex[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' }; -------------------------------------------------------------------------------- /src/ui/ui_display.h: -------------------------------------------------------------------------------- 1 | #ifndef UI_DISPLAY_H 2 | #define UI_DISPLAY_H 3 | void ui_display_enable(struct command_attributes* attributes, struct command_response* response); 4 | void ui_display_int_display_format(struct command_result* res); 5 | void ui_display_enable_args(struct command_result* res); 6 | #endif 7 | -------------------------------------------------------------------------------- /src/ui/ui_flags.h: -------------------------------------------------------------------------------- 1 | 2 | typedef enum _ui_update_flag_t { 3 | UI_UPDATE_NONE = 0u, 4 | UI_UPDATE_IMAGE = (1u << 0), 5 | UI_UPDATE_INFOBAR = (1u << 1), 6 | UI_UPDATE_NAMES = (1u << 2), 7 | UI_UPDATE_LABELS = (1u << 3), 8 | UI_UPDATE_VOLTAGES = (1u << 4), 9 | UI_UPDATE_CURRENT = (1u << 5), 10 | UI_UPDATE_FORCE = (1u << 6), // force label update 11 | // space for one more UI update flag before this changes from uint8_t to uint16_t.... 12 | 13 | UI_UPDATE_ALL = ( 14 | UI_UPDATE_IMAGE | 15 | UI_UPDATE_INFOBAR | 16 | UI_UPDATE_NAMES | 17 | UI_UPDATE_LABELS | 18 | UI_UPDATE_VOLTAGES | 19 | UI_UPDATE_CURRENT | 20 | 0u 21 | ), 22 | } ui_update_flag_t; 23 | 24 | // if size grew, need to check all uses of this enum to ensure larger size is OK 25 | // Likely yes, but ... safer to check. 26 | _Static_assert(sizeof(ui_update_flag_t) == sizeof(uint8_t), "ui_update_flag_t larger than byte; review of code required"); 27 | -------------------------------------------------------------------------------- /src/ui/ui_format.h: -------------------------------------------------------------------------------- 1 | void ui_format_print_number(uint32_t d); 2 | uint32_t ui_format_bitorder(uint32_t d); 3 | void ui_format_print_number_2(struct command_attributes* attributes, uint32_t* value); 4 | void ui_format_print_number_3(uint32_t value, uint32_t num_bits, uint32_t display_format); 5 | uint32_t ui_format_bitorder_manual(uint32_t* d, uint8_t num_bits, bool bit_order); 6 | uint32_t ui_format_lsb(uint32_t d, uint8_t num_bits); -------------------------------------------------------------------------------- /src/ui/ui_help.h: -------------------------------------------------------------------------------- 1 | typedef struct ui_help_options { 2 | uint help; // should be a section handling designator 3 | const char command[9]; // ugh 4 | uint description; // translation key 5 | } ui_help_options_t; 6 | 7 | void ui_help_options(const struct ui_help_options(*help), uint32_t count); 8 | void ui_help_usage(const char* const flash_usage[], uint32_t count); 9 | bool ui_help_show(bool help_flag, 10 | const char* const usage[], 11 | uint32_t count_of_usage, 12 | const struct ui_help_options* options, 13 | uint32_t count_of_options); 14 | bool ui_help_check_vout_vref(void); 15 | bool ui_help_sanity_check(bool vout, uint8_t pullup_mask); 16 | void ui_help_mode_commands(const struct _mode_command_struct* commands, uint32_t count); 17 | void ui_help_error(uint32_t error); 18 | void ui_help_mode_commands_exec(const struct _mode_command_struct* commands, uint32_t count, const char* mode); -------------------------------------------------------------------------------- /src/ui/ui_info.h: -------------------------------------------------------------------------------- 1 | void ui_info_print_toolbar(void); 2 | void ui_info_print_pin_names(void); 3 | void ui_info_print_pin_labels(void); 4 | void ui_info_print_pin_voltage(bool refresh); 5 | -------------------------------------------------------------------------------- /src/ui/ui_init.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "pico/stdlib.h" 3 | #include 4 | 5 | #include "pirate.h" 6 | #include "hardware/uart.h" 7 | #include "bytecode.h" 8 | #include "command_struct.h" 9 | #include "modes.h" 10 | #include "ui/ui_const.h" 11 | #include "ui_cmdln.h" 12 | 13 | // initializes the ui variables 14 | void ui_init(void) { 15 | cmdln_init(); 16 | } 17 | -------------------------------------------------------------------------------- /src/ui/ui_init.h: -------------------------------------------------------------------------------- 1 | void ui_init(void); -------------------------------------------------------------------------------- /src/ui/ui_lcd.h: -------------------------------------------------------------------------------- 1 | void lcd_configure(void); 2 | void lcd_clear(void); 3 | void ui_lcd_update(uint32_t update_flags); 4 | void lcd_write_background(const unsigned char* image); 5 | void lcd_screensaver_disable(void); 6 | void lcd_screensaver_enable(void); 7 | void lcd_set_bounding_box(uint16_t xs, uint16_t xe, uint16_t ys, uint16_t ye); 8 | void lcd_write_command(uint8_t command); 9 | void lcd_write_data(uint8_t data); 10 | void lcd_enable(void); 11 | void lcd_disable(void); 12 | void menu_update(uint8_t current, uint8_t next); 13 | void lcd_screensaver_alarm_reset(void); 14 | 15 | extern const uint8_t colors_pallet[][2]; 16 | // Setup the text and background pixel colors 17 | enum lcd_colors { 18 | LCD_RED, 19 | LCD_ORANGE, 20 | LCD_YELLOW, 21 | LCD_GREEN, 22 | LCD_BLUE, 23 | LCD_PURPLE, 24 | LCD_BROWN, 25 | LCD_GREY, 26 | LCD_WHITE, 27 | LCD_BLACK, 28 | }; 29 | -------------------------------------------------------------------------------- /src/ui/ui_mode.h: -------------------------------------------------------------------------------- 1 | void ui_mode_enable(struct command_attributes* attributes, struct command_response* response); 2 | void ui_mode_int_display_format(struct command_result* res); 3 | void ui_mode_enable_args(struct command_result* res); -------------------------------------------------------------------------------- /src/ui/ui_parse.h: -------------------------------------------------------------------------------- 1 | 2 | 3 | // gets all number accepted formats 4 | bool ui_parse_get_int(struct prompt_result* result, uint32_t* value); 5 | 6 | // get DEC (base 10) with eXit option 7 | bool ui_parse_get_uint32(struct prompt_result* result, uint32_t* value); 8 | 9 | bool ui_parse_get_string(struct prompt_result* result, char* str, uint8_t* size); 10 | 11 | // get float with eXit option 12 | bool ui_parse_get_float(struct prompt_result* result, float* value); 13 | bool ui_parse_get_delimited_sequence(struct prompt_result* result, char delimiter, uint32_t* value); 14 | bool ui_parse_get_units(struct prompt_result* result, char* units, uint8_t length, uint8_t* unit_type); 15 | bool ui_parse_get_macro(struct prompt_result* result, uint32_t* value); 16 | bool ui_parse_get_attributes(struct prompt_result* result, uint32_t* attr, uint8_t len); 17 | bool ui_parse_get_bool(struct prompt_result* result, bool* value); 18 | 19 | bool ui_parse_get_colon(uint32_t* value); 20 | bool ui_parse_get_dot(uint32_t* value); 21 | 22 | void ui_parse_consume_whitespace(void); 23 | -------------------------------------------------------------------------------- /src/ui/ui_process.h: -------------------------------------------------------------------------------- 1 | 2 | bool ui_process_commands(void); 3 | bool ui_process_syntax(void); -------------------------------------------------------------------------------- /src/ui/ui_statusbar.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | void ui_statusbar_update_blocking(); 3 | void ui_statusbar_update_from_core1(uint32_t update_flags); 4 | void ui_statusbar_init(void); 5 | void ui_statusbar_deinit(void); 6 | -------------------------------------------------------------------------------- /src/ui/ui_term.h: -------------------------------------------------------------------------------- 1 | #ifndef UI_TERM_H 2 | #define UI_TERM_H 3 | // enum to know which color type is supported 4 | typedef enum ui_term_type { 5 | UI_TERM_NO_COLOR = 0, 6 | UI_TERM_FULL_COLOR, 7 | #ifdef ANSI_COLOR_256 8 | UI_TERM_256 9 | #endif 10 | } ui_term_type_e; 11 | 12 | void ui_term_init(void); 13 | bool ui_term_detect(void); 14 | 15 | void ui_term_color_text(uint32_t rgb); 16 | void ui_term_color_background(uint32_t rgb); 17 | uint32_t ui_term_color_text_background(uint32_t rgb_text, uint32_t rgb_background); 18 | uint32_t ui_term_color_text_background_buf(char* buf, size_t buffLen, uint32_t rgb_text, uint32_t rgb_background); 19 | char* ui_term_color_reset(void); 20 | char* ui_term_color_prompt(void); 21 | char* ui_term_color_info(void); 22 | char* ui_term_color_notice(void); 23 | char* ui_term_color_warning(void); 24 | char* ui_term_color_error(void); 25 | char* ui_term_color_num_float(void); 26 | char* ui_term_color_pacman(void); 27 | char* ui_term_cursor_show(void); 28 | char* ui_term_cursor_hide(void); 29 | #ifndef UI_TERM_STRUCT 30 | typedef struct ui_term_progress_bar_struct { 31 | uint8_t previous_pct; 32 | uint8_t progress_cnt; 33 | bool indicator_state; 34 | } ui_term_progress_bar_t; 35 | #define UI_TERM_STRUCT 36 | #endif 37 | void ui_term_progress_bar_draw(ui_term_progress_bar_t* pb); 38 | void ui_term_progress_bar_update(uint32_t current, uint32_t total, ui_term_progress_bar_t* pb); 39 | void ui_term_progress_bar_cleanup(ui_term_progress_bar_t* pb); 40 | 41 | uint32_t ui_term_get_user_input(void); 42 | bool ui_term_cmdln_char_insert(char* c); 43 | bool ui_term_cmdln_char_backspace(void); 44 | bool ui_term_cmdln_char_delete(void); 45 | void ui_term_cmdln_fkey(char* c); 46 | void ui_term_cmdln_arrow_keys(char* c); 47 | int ui_term_cmdln_history(int ptr); 48 | char ui_term_cmdln_wait_char(char c); 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /src/usb_rx.h: -------------------------------------------------------------------------------- 1 | #include "queue.h" 2 | extern queue_t rx_fifo; 3 | extern queue_t bin_rx_fifo; 4 | void rx_fifo_init(void); 5 | void rx_uart_init_irq(void); 6 | void rx_usb_init(void); 7 | void rx_from_rtt_terminal(void); // get terminal input from RTT until queue full or RTT input is empty 8 | 9 | void rx_fifo_add(char* c); 10 | bool rx_fifo_try_get(char* c); 11 | void rx_fifo_get_blocking(char* c); 12 | bool rx_fifo_try_peek(char* c); 13 | void rx_fifo_peek_blocking(char* c); 14 | 15 | void bin_rx_fifo_add(char* c); 16 | void bin_rx_fifo_get_blocking(char* c); 17 | void bin_rx_fifo_available_bytes(uint16_t* cnt); 18 | bool bin_rx_fifo_try_get(char* c); 19 | -------------------------------------------------------------------------------- /src/usb_tx.h: -------------------------------------------------------------------------------- 1 | void tx_fifo_init(void); 2 | void tx_fifo_service(void); 3 | void tx_fifo_put(char* c); 4 | void tx_fifo_try_put(char* c); 5 | void tx_sb_start(uint32_t valid_characters_in_status_bar); 6 | void bin_tx_fifo_put(const char c); 7 | void bin_tx_fifo_service(void); 8 | bool bin_tx_not_empty(void); 9 | bool bin_tx_fifo_try_get(char* c); 10 | 11 | extern char tx_sb_buf[1024]; 12 | 13 | // extern queue_t sample_fifo; -------------------------------------------------------------------------------- /src/wavegen.h: -------------------------------------------------------------------------------- 1 | void wavegen_args(struct command_result* res); -------------------------------------------------------------------------------- /src/wavegen.pio: -------------------------------------------------------------------------------- 1 | ; 2 | ; Copyright (c) 2020 Raspberry Pi (Trading) Ltd. 3 | ; 4 | ; SPDX-License-Identifier: BSD-3-Clause 5 | ; 6 | 7 | .program wavegen 8 | 9 | ; Repeatedly get one word of data from the TX FIFO, stalling when the FIFO is 10 | ; empty. Write the least significant bit to the OUT pin group. 11 | 12 | .wrap_target 13 | out pins, 8 14 | .wrap 15 | 16 | ;loop: 17 | ; pull 18 | ; out pins, 2 19 | ; jmp loop 20 | 21 | % c-sdk { 22 | static inline void wavegen_program_init(PIO pio, uint sm, uint offset, uint pin) { 23 | pio_sm_set_enabled(pio, sm, false); 24 | pio_sm_clear_fifos(pio, sm); 25 | pio_sm_restart(pio, sm); 26 | 27 | pio_sm_config c = wavegen_program_get_default_config(offset); 28 | 29 | // Map the state machine's OUT pin group to one pin, namely the `pin` 30 | // parameter to this function. 31 | sm_config_set_out_pins(&c, pin, 8); 32 | // Set this pin's GPIO function (connect PIO to the pad) 33 | for(uint8_t i=0; i<8; i++) 34 | pio_gpio_init(pio, pin+i); 35 | 36 | // Set the pin direction to output at the PIO 37 | pio_sm_set_consecutive_pindirs(pio, sm, pin, 8, true); 38 | 39 | //sm_config_set_out_shift(&c, false, true, 8); 40 | sm_config_set_out_shift(&c, true, true, 8); 41 | 42 | sm_config_set_clkdiv(&c, 1); 43 | 44 | // Load our configuration, and jump to the start of the program 45 | pio_sm_init(pio, sm, offset, &c); 46 | // Set the state machine running 47 | pio_sm_set_enabled(pio, sm, true); 48 | 49 | } 50 | %} 51 | --------------------------------------------------------------------------------