├── .gitignore ├── LICENSE ├── README.md ├── doc ├── VERA Programmer's Reference.md ├── composite video timing.xlsx ├── datasheets │ └── WM8524_v4.1.pdf ├── ntsc vertical timing.jpg ├── ntsc │ ├── 525-daa.gif │ ├── AVR PAL color generator.url │ ├── Batsocks - Monochrome Composite Video.url │ ├── Characteristics of B,G-PAL and M-NTSC television systems.url │ ├── NTSC_vectorograph.png │ ├── YIQ - Wikipedia.url │ ├── analog-video-18-728.jpg │ └── ntsc.gif ├── testcode.txt ├── vera-module v0.3.pdf ├── vera-module v0.4.pdf ├── vera-module v0.5.pdf ├── vera-module v0.6.pdf ├── vera-module v0.7.pdf ├── vera-module v0.8.pdf ├── vera-module.docx ├── vera-module.pdf ├── vera_module_impl_v0.4.bin ├── vera_module_impl_v0.4_3cd1219.bin ├── vera_module_impl_v0.5.bin ├── vera_module_impl_v0.6.bin ├── vera_module_impl_v0.7.bin ├── vera_module_impl_v0.8.bin ├── vera_module_impl_v0.9_rev4.bin └── w65c02s.pdf ├── fpga ├── .gitignore ├── program.sh ├── source │ ├── .gitignore │ ├── addr_data.v │ ├── audio │ │ ├── .gitignore │ │ ├── audio.v │ │ ├── audio_fifo.v │ │ ├── dacif.v │ │ ├── pcm.v │ │ ├── psg.v │ │ └── sim │ │ │ ├── audio_attr_ram.v │ │ │ ├── dpram.v │ │ │ ├── sim.sh │ │ │ ├── tb.gtkw │ │ │ └── tb.v │ ├── dpram.v │ ├── generated │ │ ├── palette_ram │ │ │ ├── constraints │ │ │ │ └── palette_ram.ldc │ │ │ ├── dummy_file.txt │ │ │ ├── misc │ │ │ │ ├── palette_ram_palette_ram_copy.mem │ │ │ │ ├── palette_ram_tmpl.v │ │ │ │ └── palette_ram_tmpl.vhd │ │ │ ├── palette_ram.cfg │ │ │ ├── palette_ram.ipx │ │ │ ├── rtl │ │ │ │ ├── palette_ram.v │ │ │ │ └── palette_ram_bb.v │ │ │ └── testbench │ │ │ │ ├── dut_inst.v │ │ │ │ ├── dut_params.v │ │ │ │ └── tb_top.v │ │ └── sprite_ram │ │ │ ├── constraints │ │ │ └── sprite_ram.ldc │ │ │ ├── misc │ │ │ ├── sprite_ram_tmpl.v │ │ │ └── sprite_ram_tmpl.vhd │ │ │ ├── rtl │ │ │ ├── sprite_ram.v │ │ │ └── sprite_ram_bb.v │ │ │ ├── sprite_ram.cfg │ │ │ ├── sprite_ram.ipx │ │ │ ├── sprite_ram_init.mem │ │ │ └── testbench │ │ │ ├── dut_inst.v │ │ │ ├── dut_params.v │ │ │ └── tb_top.v │ ├── graphics │ │ ├── composer.v │ │ ├── layer_line_buffer.v │ │ ├── layer_renderer.v │ │ ├── sprite_line_buffer.v │ │ └── sprite_renderer.v │ ├── main_ram.v │ ├── mult_accum.v │ ├── palette_ram.mem │ ├── reset_sync.v │ ├── sim │ │ ├── .gitignore │ │ ├── audio_attr_ram.v │ │ ├── layer_renderer_state.txt │ │ ├── palette_ram.v │ │ ├── sim.sh │ │ ├── sprite_ram.v │ │ ├── sprite_renderer_state.txt │ │ ├── tb.gtkw │ │ └── tb.v │ ├── spi │ │ ├── sim │ │ │ ├── .gitignore │ │ │ ├── sim.sh │ │ │ ├── tb.gtkw │ │ │ └── tb.v │ │ └── spictrl.v │ ├── tools │ │ ├── .gitignore │ │ ├── generate_palette │ │ └── generate_palette.c │ ├── top.v │ ├── vera_module.ldc │ ├── vera_module.pdc │ ├── vera_module.sdc │ ├── video │ │ ├── gen-sinlut.py │ │ ├── video_composite.v │ │ ├── video_modulator.v │ │ ├── video_modulator_coslut.v │ │ ├── video_modulator_mult_u8xu8_pair.v │ │ ├── video_modulator_sinlut.v │ │ └── video_vga.v │ └── vram_if.v ├── vera_module.rdf └── vera_module1.sty ├── misc ├── 8bitguy.png ├── 8bitguy_original.png ├── audiosim │ ├── Makefile │ ├── audiosim │ └── main.c ├── bootloader │ ├── .gitignore │ ├── Makefile │ └── bootloader.a65 ├── c64-char-rom.bin ├── font8x16.bin ├── imgconv │ ├── .gitignore │ ├── Makefile │ ├── imgconv.c │ ├── lodepng.c │ └── lodepng.h ├── tests │ ├── 1bpptest │ │ ├── .gitignore │ │ ├── 1bpptest.s │ │ ├── Makefile │ │ ├── common │ │ └── img.raw │ ├── common │ │ ├── Makefile.common │ │ ├── lib.inc │ │ ├── lib.s │ │ ├── regs.inc │ │ └── x16.cfg │ ├── fos-rom │ │ ├── .gitignore │ │ ├── Makefile │ │ ├── cli.inc │ │ ├── cli.s │ │ ├── common │ │ ├── fat32.inc │ │ ├── fat32.s │ │ ├── fat32_util.inc │ │ ├── fat32_util.s │ │ ├── font8x8.bin │ │ ├── jumptable.s │ │ ├── jumptable_to_inc.py │ │ ├── main.s │ │ ├── ps2.inc │ │ ├── ps2.s │ │ ├── sdcard.inc │ │ ├── sdcard.s │ │ ├── text_display.inc │ │ ├── text_display.s │ │ ├── text_input.inc │ │ ├── text_input.s │ │ ├── vera.inc │ │ ├── vera.s │ │ └── x16-rom.cfg │ ├── fos-test │ │ ├── .gitignore │ │ ├── Makefile │ │ ├── Makefile.common │ │ ├── lib.inc │ │ ├── main.s │ │ ├── regs.inc │ │ └── x16.cfg │ ├── fos │ │ ├── .gitignore │ │ ├── Makefile │ │ ├── cli.inc │ │ ├── cli.s │ │ ├── common │ │ ├── fat32.inc │ │ ├── fat32.s │ │ ├── fat32_util.inc │ │ ├── fat32_util.s │ │ ├── font8x8.bin │ │ ├── main.s │ │ ├── sdcard.inc │ │ ├── sdcard.s │ │ ├── text_display.inc │ │ ├── text_display.s │ │ ├── text_input.inc │ │ └── text_input.s │ ├── pcmtest │ │ ├── .gitignore │ │ ├── Makefile │ │ ├── common │ │ ├── okay-bye.raw │ │ └── pcmtest.s │ └── psgtest │ │ ├── .gitignore │ │ ├── Makefile │ │ ├── common │ │ ├── music.bin │ │ └── psgtest.s ├── testvera │ ├── .gitignore │ ├── .vscode │ │ ├── c_cpp_properties.json │ │ └── settings.json │ ├── Makefile │ └── testvera.c ├── tileconv │ ├── .gitignore │ ├── .vscode │ │ └── settings.json │ ├── Makefile │ ├── lodepng.c │ ├── lodepng.h │ ├── tileconv │ └── tileconv.c ├── tiles.png └── x16load │ ├── .gitignore │ ├── Makefile │ └── x16load.c ├── pcb ├── rev0 │ ├── .gitignore │ ├── DESCRIPTION │ ├── component placement.pdf │ ├── gerbers │ │ ├── vera-module gerbers.zip │ │ ├── vera-module.GBL │ │ ├── vera-module.GBO │ │ ├── vera-module.GBS │ │ ├── vera-module.GML │ │ ├── vera-module.GTL │ │ ├── vera-module.GTO │ │ ├── vera-module.GTP │ │ ├── vera-module.GTS │ │ ├── vera-module.TXT │ │ ├── vera-module.dri │ │ └── vera-module.gpi │ ├── vera-module bill of materials.xlsx │ ├── vera-module schematics.pdf │ ├── vera-module top.png │ ├── vera-module.brd │ └── vera-module.sch ├── rev1 │ ├── .gitignore │ ├── DESCRIPTION │ ├── gerbers │ │ ├── vera-module.GBL │ │ ├── vera-module.GBO │ │ ├── vera-module.GBS │ │ ├── vera-module.GML │ │ ├── vera-module.GTL │ │ ├── vera-module.GTO │ │ ├── vera-module.GTP │ │ ├── vera-module.GTS │ │ └── vera-module.TXT │ ├── vera-module bom.csv │ ├── vera-module bom.xlsx │ ├── vera-module.brd │ ├── vera-module.sch │ └── vera-module_rev1_gerbers.zip ├── rev2 │ ├── .gitignore │ ├── fp-lib-table │ ├── step │ │ ├── CUI_MD-40S.step │ │ ├── CUI_RCJ-014.step │ │ ├── Crystal_SMD_5032-2Pin_5.0x3.2mm.wrl │ │ ├── ICD15S13E4GV00LFc.stp │ │ └── c-2041021-3-b-3d.stp │ ├── sym-lib-table │ ├── vera-module-rev2-cache.lib │ ├── vera-module-rev2.kicad_pcb │ ├── vera-module-rev2.pro │ ├── vera-module-rev2.sch │ ├── vera-module.lib │ └── vera-module.pretty │ │ ├── ICD15S13E4GV00LF.kicad_mod │ │ ├── KCDX-5S-N.kicad_mod │ │ ├── MD-40S.kicad_mod │ │ ├── RCJ-014.kicad_mod │ │ └── x16logo.kicad_mod ├── rev3 │ ├── .gitignore │ ├── fp-lib-table │ ├── step │ │ ├── CUI_MD-40S.step │ │ ├── CUI_RCJ-014.step │ │ ├── Crystal_SMD_5032-2Pin_5.0x3.2mm.wrl │ │ ├── ICD15S13E4GV00LFc.stp │ │ └── c-2041021-3-b-3d.stp │ ├── sym-lib-table │ ├── vera-module-rev3-cache.lib │ ├── vera-module-rev3.kicad_pcb │ ├── vera-module-rev3.pro │ ├── vera-module-rev3.sch │ ├── vera-module.lib │ └── vera-module.pretty │ │ ├── ICD15S13E4GV00LF.kicad_mod │ │ ├── KCDX-5S-N.kicad_mod │ │ ├── MD-40S.kicad_mod │ │ ├── RCJ-014.kicad_mod │ │ ├── x16logo.kicad_mod │ │ └── x16plogo.kicad_mod ├── rev4 │ ├── .gitignore │ ├── fp-lib-table │ ├── step │ │ ├── CUI_MD-40S.step │ │ ├── CUI_RCJ-014.step │ │ ├── Crystal_SMD_5032-2Pin_5.0x3.2mm.wrl │ │ ├── ICD15S13E4GV00LFc.stp │ │ └── c-2041021-3-b-3d.stp │ ├── sym-lib-table │ ├── vera-module-rev4-cache.lib │ ├── vera-module-rev4.kicad_pcb │ ├── vera-module-rev4.pro │ ├── vera-module-rev4.sch │ ├── vera-module.dcm │ ├── vera-module.lib │ └── vera-module.pretty │ │ ├── ICD15S13E4GV00LF.kicad_mod │ │ ├── KCDX-5S-N.kicad_mod │ │ ├── MD-40S.kicad_mod │ │ ├── RCJ-014.kicad_mod │ │ ├── x16logo.kicad_mod │ │ └── x16plogo.kicad_mod ├── vera rev1.zip ├── vera rev2.zip ├── vera rev3.zip └── vera rev4.zip └── programmer ├── programmer_tool ├── .gitignore ├── Makefile ├── README.md ├── flash.c ├── flash.h ├── lib.c ├── lib.h ├── main.c ├── usb.c └── usb.h └── stm32 ├── .gitignore ├── Makefile ├── dfu-convert.py ├── flash.c ├── flash.h ├── iopins.h ├── lib ├── assert.c ├── buf_reader.h ├── buf_writer.h ├── clock.c ├── clock.h ├── cmsis_gcc.h ├── common.h ├── config.h ├── core_cm0.h ├── core_cmFunc.h ├── core_cmInstr.h ├── io.h ├── lib.c ├── lib.h ├── linkerscript ├── list_node.h ├── lltimer.c ├── lltimer.h ├── mcu.h ├── rtt.c ├── rtt.h ├── startup.c └── stm32f070x6.h ├── main.c ├── os ├── os.h ├── task.c ├── task.h ├── timer.c └── timer.h ├── spi.c ├── spi.h ├── usb.c ├── usb.h ├── usb ├── stm32f0xx_hal.h ├── stm32f0xx_hal_def.h ├── stm32f0xx_hal_pcd.c ├── stm32f0xx_hal_pcd.h ├── stm32f0xx_hal_pcd_ex.c ├── stm32f0xx_hal_pcd_ex.h ├── usbd_conf.c ├── usbd_conf.h ├── usbd_core.c ├── usbd_core.h ├── usbd_ctlreq.c ├── usbd_ctlreq.h ├── usbd_def.h ├── usbd_ioreq.c └── usbd_ioreq.h ├── usbd_cdc.c ├── usbd_cdc.h ├── usbd_cdc_if.c └── usbd_cdc_if.h /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 Frank van den Hoef 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 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # VERA module - Video Embedded Retro Adapter 2 | This repository contains the files related to the VERA module. This module is developed for the Commander X16 computer by The 8-Bit Guy. 3 | 4 | **NOTE**: The Commander X16 logo is part of the Commander X16 project and should not be used when the module is used with other projects. 5 | -------------------------------------------------------------------------------- /doc/composite video timing.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/X16Community/vera-module/6e8bea68a5a04687149e27b1b7b3726fb01405f4/doc/composite video timing.xlsx -------------------------------------------------------------------------------- /doc/datasheets/WM8524_v4.1.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/X16Community/vera-module/6e8bea68a5a04687149e27b1b7b3726fb01405f4/doc/datasheets/WM8524_v4.1.pdf -------------------------------------------------------------------------------- /doc/ntsc vertical timing.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/X16Community/vera-module/6e8bea68a5a04687149e27b1b7b3726fb01405f4/doc/ntsc vertical timing.jpg -------------------------------------------------------------------------------- /doc/ntsc/525-daa.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/X16Community/vera-module/6e8bea68a5a04687149e27b1b7b3726fb01405f4/doc/ntsc/525-daa.gif -------------------------------------------------------------------------------- /doc/ntsc/AVR PAL color generator.url: -------------------------------------------------------------------------------- 1 | [InternetShortcut] 2 | URL=http://trznadel.info/kuba/avr/index2.php 3 | -------------------------------------------------------------------------------- /doc/ntsc/Batsocks - Monochrome Composite Video.url: -------------------------------------------------------------------------------- 1 | [InternetShortcut] 2 | URL=http://www.batsocks.co.uk/readme/video_timing.htm 3 | -------------------------------------------------------------------------------- /doc/ntsc/Characteristics of B,G-PAL and M-NTSC television systems.url: -------------------------------------------------------------------------------- 1 | [InternetShortcut] 2 | URL=https://pe2bz.philpem.me.uk/Misc/-%20Video/NTSC-PAL-etc-Formats/pal_ntsc.html 3 | -------------------------------------------------------------------------------- /doc/ntsc/NTSC_vectorograph.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/X16Community/vera-module/6e8bea68a5a04687149e27b1b7b3726fb01405f4/doc/ntsc/NTSC_vectorograph.png -------------------------------------------------------------------------------- /doc/ntsc/YIQ - Wikipedia.url: -------------------------------------------------------------------------------- 1 | [InternetShortcut] 2 | URL=https://en.wikipedia.org/wiki/YIQ 3 | -------------------------------------------------------------------------------- /doc/ntsc/analog-video-18-728.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/X16Community/vera-module/6e8bea68a5a04687149e27b1b7b3726fb01405f4/doc/ntsc/analog-video-18-728.jpg -------------------------------------------------------------------------------- /doc/ntsc/ntsc.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/X16Community/vera-module/6e8bea68a5a04687149e27b1b7b3726fb01405f4/doc/ntsc/ntsc.gif -------------------------------------------------------------------------------- /doc/testcode.txt: -------------------------------------------------------------------------------- 1 | *=$0200 2 | LDA #$10 3 | STA $8000 4 | LDA #$00 5 | STA $8001 6 | STA $8002 7 | LDX #0 8 | LOOP 9 | TXA 10 | STA $8003 11 | LDA #$6E 12 | STA $8003 13 | INX 14 | BNE LOOP 15 | 16 | LDY #10 17 | LOOP2 18 | LDA #$20 19 | STA $8003 20 | LDA #$6E 21 | STA $8003 22 | INX 23 | BNE LOOP2 24 | 25 | RTS 26 | 27 | 28 | *=$0200 29 | LDA #$10 30 | STA $8000 31 | LDA #$00 32 | STA $8001 33 | STA $8002 34 | LDX #79 35 | LDA #$02 36 | 37 | STA $8003 38 | STA $8003 39 | RTS 40 | -------------------------------------------------------------------------------- /doc/vera-module v0.3.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/X16Community/vera-module/6e8bea68a5a04687149e27b1b7b3726fb01405f4/doc/vera-module v0.3.pdf -------------------------------------------------------------------------------- /doc/vera-module v0.4.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/X16Community/vera-module/6e8bea68a5a04687149e27b1b7b3726fb01405f4/doc/vera-module v0.4.pdf -------------------------------------------------------------------------------- /doc/vera-module v0.5.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/X16Community/vera-module/6e8bea68a5a04687149e27b1b7b3726fb01405f4/doc/vera-module v0.5.pdf -------------------------------------------------------------------------------- /doc/vera-module v0.6.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/X16Community/vera-module/6e8bea68a5a04687149e27b1b7b3726fb01405f4/doc/vera-module v0.6.pdf -------------------------------------------------------------------------------- /doc/vera-module v0.7.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/X16Community/vera-module/6e8bea68a5a04687149e27b1b7b3726fb01405f4/doc/vera-module v0.7.pdf -------------------------------------------------------------------------------- /doc/vera-module v0.8.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/X16Community/vera-module/6e8bea68a5a04687149e27b1b7b3726fb01405f4/doc/vera-module v0.8.pdf -------------------------------------------------------------------------------- /doc/vera-module.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/X16Community/vera-module/6e8bea68a5a04687149e27b1b7b3726fb01405f4/doc/vera-module.docx -------------------------------------------------------------------------------- /doc/vera-module.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/X16Community/vera-module/6e8bea68a5a04687149e27b1b7b3726fb01405f4/doc/vera-module.pdf -------------------------------------------------------------------------------- /doc/vera_module_impl_v0.4.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/X16Community/vera-module/6e8bea68a5a04687149e27b1b7b3726fb01405f4/doc/vera_module_impl_v0.4.bin -------------------------------------------------------------------------------- /doc/vera_module_impl_v0.4_3cd1219.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/X16Community/vera-module/6e8bea68a5a04687149e27b1b7b3726fb01405f4/doc/vera_module_impl_v0.4_3cd1219.bin -------------------------------------------------------------------------------- /doc/vera_module_impl_v0.5.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/X16Community/vera-module/6e8bea68a5a04687149e27b1b7b3726fb01405f4/doc/vera_module_impl_v0.5.bin -------------------------------------------------------------------------------- /doc/vera_module_impl_v0.6.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/X16Community/vera-module/6e8bea68a5a04687149e27b1b7b3726fb01405f4/doc/vera_module_impl_v0.6.bin -------------------------------------------------------------------------------- /doc/vera_module_impl_v0.7.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/X16Community/vera-module/6e8bea68a5a04687149e27b1b7b3726fb01405f4/doc/vera_module_impl_v0.7.bin -------------------------------------------------------------------------------- /doc/vera_module_impl_v0.8.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/X16Community/vera-module/6e8bea68a5a04687149e27b1b7b3726fb01405f4/doc/vera_module_impl_v0.8.bin -------------------------------------------------------------------------------- /doc/vera_module_impl_v0.9_rev4.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/X16Community/vera-module/6e8bea68a5a04687149e27b1b7b3726fb01405f4/doc/vera_module_impl_v0.9_rev4.bin -------------------------------------------------------------------------------- /doc/w65c02s.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/X16Community/vera-module/6e8bea68a5a04687149e27b1b7b3726fb01405f4/doc/w65c02s.pdf -------------------------------------------------------------------------------- /fpga/.gitignore: -------------------------------------------------------------------------------- 1 | *.html 2 | .floorplanner.ini 3 | .ng_run_manager.ini 4 | .setting.ini 5 | .recovery 6 | *.log 7 | impl/ 8 | vera_module_tcr.dir/ 9 | *.dmp 10 | *.xml 11 | *.vcd 12 | *.bak 13 | -------------------------------------------------------------------------------- /fpga/program.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | if [ ! -f "../programmer/programmer_tool/obj/programmer_tool" ]; then 3 | make -C ../programmer/programmer_tool 4 | fi 5 | 6 | ../programmer/programmer_tool/obj/programmer_tool -I impl/vera_module_impl.bin -B 7 | -------------------------------------------------------------------------------- /fpga/source/.gitignore: -------------------------------------------------------------------------------- 1 | .vscode/ 2 | -------------------------------------------------------------------------------- /fpga/source/audio/.gitignore: -------------------------------------------------------------------------------- 1 | *.vcd 2 | -------------------------------------------------------------------------------- /fpga/source/audio/audio.v: -------------------------------------------------------------------------------- 1 | //`default_nettype none 2 | 3 | module audio( 4 | input wire rst, 5 | input wire clk, 6 | 7 | // PSG interface 8 | input wire [5:0] attr_addr, 9 | input wire [7:0] attr_wrdata, 10 | input wire attr_write, 11 | 12 | // Register interface 13 | input wire [7:0] sample_rate, 14 | input wire mode_stereo, 15 | input wire mode_16bit, 16 | input wire [3:0] volume, 17 | 18 | // Audio FIFO interface 19 | input wire fifo_reset, 20 | input wire [7:0] fifo_wrdata, 21 | input wire fifo_write, 22 | output wire fifo_full, 23 | output wire fifo_almost_empty, 24 | output wire fifo_empty, 25 | 26 | // I2S audio output 27 | output wire i2s_lrck, 28 | output wire i2s_bck, 29 | output wire i2s_data); 30 | 31 | wire next_sample; 32 | wire [15:0] psg_left; 33 | wire [15:0] psg_right; 34 | 35 | wire [15:0] pcm_left; 36 | wire [15:0] pcm_right; 37 | 38 | ////////////////////////////////////////////////////////////////////////// 39 | // Programmable Sound Generator 40 | ////////////////////////////////////////////////////////////////////////// 41 | psg psg( 42 | .rst(rst), 43 | .clk(clk), 44 | 45 | // PSG interface 46 | .attr_addr(attr_addr), 47 | .attr_wrdata(attr_wrdata), 48 | .attr_write(attr_write), 49 | 50 | .next_sample(next_sample), 51 | 52 | // Audio output 53 | .left_audio(psg_left), 54 | .right_audio(psg_right)); 55 | 56 | ////////////////////////////////////////////////////////////////////////// 57 | // PCM playback 58 | ////////////////////////////////////////////////////////////////////////// 59 | pcm pcm( 60 | .rst(rst), 61 | .clk(clk), 62 | 63 | .next_sample(next_sample), 64 | 65 | // Register interface 66 | .sample_rate(sample_rate), 67 | .mode_stereo(mode_stereo), 68 | .mode_16bit(mode_16bit), 69 | .volume(volume), 70 | 71 | // Audio FIFO interface 72 | .fifo_reset(fifo_reset), 73 | .fifo_wrdata(fifo_wrdata), 74 | .fifo_write(fifo_write), 75 | .fifo_full(fifo_full), 76 | .fifo_almost_empty(fifo_almost_empty), 77 | .fifo_empty(fifo_empty), 78 | 79 | // Audio output 80 | .left_audio(pcm_left), 81 | .right_audio(pcm_right)); 82 | 83 | ////////////////////////////////////////////////////////////////////////// 84 | // I2S DAC interface 85 | ////////////////////////////////////////////////////////////////////////// 86 | 87 | wire [16:0] psg_l = {psg_left[15], psg_left}; 88 | wire [16:0] psg_r = {psg_right[15], psg_right}; 89 | wire [16:0] pcm_l = {pcm_left[15], pcm_left}; 90 | wire [16:0] pcm_r = {pcm_right[15], pcm_right}; 91 | 92 | wire [16:0] mix_l = psg_l + pcm_l; 93 | wire [16:0] mix_r = psg_r + pcm_r; 94 | 95 | wire [23:0] left_data = {mix_l, 7'b0}; 96 | wire [23:0] right_data = {mix_r, 7'b0}; 97 | 98 | dacif dacif( 99 | .rst(rst), 100 | .clk(clk), 101 | 102 | // Sample input 103 | .next_sample(next_sample), 104 | .left_data(left_data), 105 | .right_data(right_data), 106 | 107 | // I2S audio output 108 | .i2s_lrck(i2s_lrck), 109 | .i2s_bck(i2s_bck), 110 | .i2s_data(i2s_data)); 111 | 112 | endmodule 113 | -------------------------------------------------------------------------------- /fpga/source/audio/audio_fifo.v: -------------------------------------------------------------------------------- 1 | //`default_nettype none 2 | 3 | module audio_fifo( 4 | input wire clk, 5 | input wire rst, 6 | 7 | input wire [7:0] wrdata, 8 | input wire wr_en, 9 | 10 | output reg [7:0] rddata, 11 | input wire rd_en, 12 | 13 | output wire empty, 14 | output wire almost_empty, 15 | output wire full); 16 | 17 | reg [11:0] wridx_r = 0; 18 | reg [11:0] rdidx_r = 0; 19 | 20 | reg [7:0] mem_r [4095:0]; 21 | 22 | wire [11:0] wridx_next = wridx_r + 12'd1; 23 | wire [11:0] rdidx_next = rdidx_r + 12'd1; 24 | wire [11:0] fifo_count = wridx_r - rdidx_r; 25 | 26 | assign empty = (wridx_r == rdidx_r); 27 | assign full = (wridx_next == rdidx_r); 28 | assign almost_empty = fifo_count < 12'd1024; 29 | 30 | always @(posedge clk) begin 31 | if (rst) begin 32 | wridx_r <= 0; 33 | rdidx_r <= 0; 34 | rddata <= 0; 35 | 36 | end else begin 37 | if (wr_en && !full) begin 38 | mem_r[wridx_r] <= wrdata; 39 | wridx_r <= wridx_next; 40 | end 41 | 42 | if (rd_en && !empty) begin 43 | rddata <= mem_r[rdidx_r]; 44 | rdidx_r <= rdidx_next; 45 | end 46 | end 47 | end 48 | 49 | endmodule 50 | -------------------------------------------------------------------------------- /fpga/source/audio/dacif.v: -------------------------------------------------------------------------------- 1 | //`default_nettype none 2 | 3 | module dacif( 4 | input wire rst, 5 | input wire clk, 6 | 7 | // Sample input 8 | output wire next_sample, 9 | input wire [23:0] left_data, // 2's complement signed left data 10 | input wire [23:0] right_data, // 2's complement signed right data 11 | 12 | // I2S audio output 13 | output reg i2s_lrck, 14 | output wire i2s_bck, 15 | output wire i2s_data); 16 | 17 | // Generate LRCK 18 | reg [7:0] div_r; 19 | wire [7:0] div_max = 8'd255; 20 | 21 | always @(posedge clk or posedge rst) begin 22 | if (rst) begin 23 | div_r <= 'd0; 24 | i2s_lrck <= 0; 25 | end else begin 26 | if (div_r == div_max) begin 27 | i2s_lrck <= !i2s_lrck; 28 | div_r <= 0; 29 | end else begin 30 | div_r <= div_r + 8'd1; 31 | end 32 | end 33 | end 34 | 35 | reg lrck_r; 36 | always @(posedge clk) lrck_r <= i2s_lrck; 37 | 38 | // Generate BCK 39 | reg bck_r; 40 | always @(posedge clk or posedge rst) begin 41 | if (rst) begin 42 | bck_r <= 0; 43 | end else begin 44 | bck_r <= !bck_r; 45 | end 46 | end 47 | 48 | assign i2s_bck = bck_r; 49 | 50 | // Generate start signals 51 | wire start_left = lrck_r && !i2s_lrck; 52 | wire start_right = !lrck_r && i2s_lrck; 53 | assign next_sample = start_left; 54 | 55 | // Shift register and sample buffer 56 | reg [23:0] right_sample_r; 57 | reg [24:0] shiftreg_r; 58 | 59 | always @(posedge clk or posedge rst) begin 60 | if (rst) begin 61 | shiftreg_r <= 0; 62 | right_sample_r <= 0; 63 | end else begin 64 | if (bck_r) begin 65 | shiftreg_r <= {shiftreg_r[23:0], 1'b0}; 66 | end 67 | 68 | if (start_left) begin 69 | shiftreg_r <= {1'b0, left_data}; 70 | right_sample_r <= right_data; 71 | end 72 | if (start_right) begin 73 | shiftreg_r <= {1'b0, right_sample_r}; 74 | end 75 | end 76 | end 77 | 78 | assign i2s_data = shiftreg_r[24]; 79 | 80 | endmodule 81 | -------------------------------------------------------------------------------- /fpga/source/audio/sim/audio_attr_ram.v: -------------------------------------------------------------------------------- 1 | ../../sim/audio_attr_ram.v -------------------------------------------------------------------------------- /fpga/source/audio/sim/dpram.v: -------------------------------------------------------------------------------- 1 | ../../dpram.v -------------------------------------------------------------------------------- /fpga/source/audio/sim/sim.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | iverilog -DSIM=1 -Wall -Wno-timescale -Wno-implicit-dimensions -g2001 -gno-xtypes -gstrict-ca-eval -gstrict-expr-width -y. -y.. tb.v 4 | ./a.out 5 | rm -f a.out 6 | -------------------------------------------------------------------------------- /fpga/source/audio/sim/tb.gtkw: -------------------------------------------------------------------------------- 1 | [*] 2 | [*] GTKWave Analyzer v3.3.86 (w)1999-2017 BSI 3 | [*] Sun Mar 8 12:40:10 2020 4 | [*] 5 | [dumpfile] "/c/Work/vera-module/fpga/source/audio/sim/tb.vcd" 6 | [dumpfile_mtime] "Sun Mar 8 12:39:17 2020" 7 | [dumpfile_size] 20699755 8 | [savefile] "/c/Work/vera-module/fpga/source/audio/sim/tb.gtkw" 9 | [timestart] 2239700000 10 | [size] 2560 1387 11 | [pos] -9 -23 12 | *-24.924294 2247300000 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 13 | [treeopen] tb. 14 | [treeopen] tb.audio. 15 | [treeopen] tb.audio.pcm. 16 | [treeopen] tb.audio.psg. 17 | [sst_width] 261 18 | [signals_width] 284 19 | [sst_expanded] 1 20 | [sst_vpaned_height] 583 21 | @28 22 | tb.audio.clk 23 | tb.audio.rst 24 | @200 25 | - 26 | @28 27 | tb.audio.i2s_bck 28 | tb.audio.i2s_lrck 29 | tb.audio.i2s_data 30 | @200 31 | - 32 | @28 33 | tb.audio.next_sample 34 | @200 35 | - 36 | -PSG 37 | @20000 38 | - 39 | - 40 | - 41 | - 42 | @200 43 | - 44 | @24 45 | tb.audio.psg.state_r[1:0] 46 | @22 47 | tb.audio.psg.cur_working_data[25:0] 48 | @24 49 | tb.audio.psg.cur_phase[19:0] 50 | @8022 51 | tb.audio.psg.signal_saw[5:0] 52 | tb.audio.psg.signal_pw[5:0] 53 | tb.audio.psg.signal_triangle[5:0] 54 | tb.audio.psg.signal_noise[5:0] 55 | @200 56 | - 57 | @8420 58 | tb.audio.psg.signed_signal[5:0] 59 | tb.audio.psg.right_audio[15:0] 60 | @20000 61 | - 62 | - 63 | @22 64 | tb.audio.left_data[23:0] 65 | tb.audio.right_data[23:0] 66 | @200 67 | - 68 | @28 69 | tb.audio.pcm.audio_fifo.almost_empty 70 | tb.audio.pcm.fifo_empty 71 | tb.audio.pcm.fifo_full 72 | @24 73 | tb.audio.pcm.audio_fifo.fifo_count[12:0] 74 | @8022 75 | tb.audio.pcm.audio_fifo.wrdata[7:0] 76 | @28 77 | tb.audio.pcm.audio_fifo.wr_en 78 | @200 79 | - 80 | @22 81 | tb.audio.pcm.sr_accum_r[7:0] 82 | @28 83 | tb.audio.pcm.new_sample 84 | @200 85 | - 86 | @28 87 | tb.audio.pcm.fifo_read 88 | @22 89 | tb.audio.pcm.fifo_rddata[7:0] 90 | @200 91 | - 92 | @24 93 | tb.audio.pcm.state_r[2:0] 94 | @8420 95 | tb.audio.pcm.left_audio[15:0] 96 | tb.audio.pcm.right_audio[15:0] 97 | [pattern_trace] 1 98 | [pattern_trace] 0 99 | -------------------------------------------------------------------------------- /fpga/source/dpram.v: -------------------------------------------------------------------------------- 1 | //`default_nettype none 2 | 3 | module dpram #(parameter ADDR_WIDTH = 8, DATA_WIDTH = 8) ( 4 | input wire wr_clk, 5 | input wire [ADDR_WIDTH-1:0] wr_addr, 6 | input wire wr_en, 7 | input wire [DATA_WIDTH-1:0] wr_data, 8 | 9 | input wire rd_clk, 10 | input wire [ADDR_WIDTH-1:0] rd_addr, 11 | output reg [DATA_WIDTH-1:0] rd_data); 12 | 13 | reg [DATA_WIDTH-1:0] mem [(1<, 20 | rd_clk_i=>, 21 | rst_i=>, 22 | wr_clk_en_i=>, 23 | rd_en_i=>, 24 | rd_clk_en_i=>, 25 | wr_en_i=>, 26 | ben_i=>, 27 | wr_data_i=>, 28 | wr_addr_i=>, 29 | rd_addr_i=>, 30 | rd_data_o=> 31 | ); 32 | -------------------------------------------------------------------------------- /fpga/source/generated/palette_ram/palette_ram.cfg: -------------------------------------------------------------------------------- 1 | { 2 | "INIT_FILE_FORMAT": "hex", 3 | "INIT_FILE": "source/palette_ram.mem", 4 | "REGMODE": false, 5 | "BYTE_ENABLE": true, 6 | "RDATA_WIDTH": 16, 7 | "WDATA_WIDTH": 16, 8 | "RADDR_DEPTH": 256, 9 | "INIT_MODE": "mem_file", 10 | "WADDR_DEPTH": 256 11 | } -------------------------------------------------------------------------------- /fpga/source/generated/palette_ram/palette_ram.ipx: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /fpga/source/generated/palette_ram/rtl/palette_ram_bb.v: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | Verilog netlist generated by IPGEN Radiant Software (64-bit) 2.0.1.281.2 3 | Soft IP Version: 1.1.0 4 | Wed Apr 15 20:30:31 2020 5 | *******************************************************************************/ 6 | /******************************************************************************* 7 | Wrapper Module generated per user settings. 8 | *******************************************************************************/ 9 | module palette_ram (wr_clk_i, rd_clk_i, rst_i, wr_clk_en_i, rd_en_i, 10 | rd_clk_en_i, wr_en_i, ben_i, wr_data_i, wr_addr_i, rd_addr_i, rd_data_o)/* synthesis syn_black_box syn_declare_black_box=1 */; 11 | input wr_clk_i; 12 | input rd_clk_i; 13 | input rst_i; 14 | input wr_clk_en_i; 15 | input rd_en_i; 16 | input rd_clk_en_i; 17 | input wr_en_i; 18 | input [1:0] ben_i; 19 | input [15:0] wr_data_i; 20 | input [7:0] wr_addr_i; 21 | input [7:0] rd_addr_i; 22 | output [15:0] rd_data_o; 23 | endmodule -------------------------------------------------------------------------------- /fpga/source/generated/palette_ram/testbench/dut_inst.v: -------------------------------------------------------------------------------- 1 | palette_ram u_palette_ram(.wr_clk_i(wr_clk_i), 2 | .rd_clk_i(rd_clk_i), 3 | .rst_i(rst_i), 4 | .wr_clk_en_i(wr_clk_en_i), 5 | .rd_en_i(rd_en_i), 6 | .rd_clk_en_i(rd_clk_en_i), 7 | .wr_en_i(wr_en_i), 8 | .ben_i(ben_i), 9 | .wr_data_i(wr_data_i), 10 | .wr_addr_i(wr_addr_i), 11 | .rd_addr_i(rd_addr_i), 12 | .rd_data_o(rd_data_o)); 13 | -------------------------------------------------------------------------------- /fpga/source/generated/sprite_ram/misc/sprite_ram_tmpl.v: -------------------------------------------------------------------------------- 1 | sprite_ram __(.wr_clk_i( ), 2 | .rd_clk_i( ), 3 | .rst_i( ), 4 | .wr_clk_en_i( ), 5 | .rd_en_i( ), 6 | .rd_clk_en_i( ), 7 | .wr_en_i( ), 8 | .ben_i( ), 9 | .wr_data_i( ), 10 | .wr_addr_i( ), 11 | .rd_addr_i( ), 12 | .rd_data_o( )); 13 | -------------------------------------------------------------------------------- /fpga/source/generated/sprite_ram/misc/sprite_ram_tmpl.vhd: -------------------------------------------------------------------------------- 1 | component sprite_ram is 2 | port( 3 | wr_clk_i: in std_logic; 4 | rd_clk_i: in std_logic; 5 | rst_i: in std_logic; 6 | wr_clk_en_i: in std_logic; 7 | rd_en_i: in std_logic; 8 | rd_clk_en_i: in std_logic; 9 | wr_en_i: in std_logic; 10 | ben_i: in std_logic_vector(3 downto 0); 11 | wr_data_i: in std_logic_vector(31 downto 0); 12 | wr_addr_i: in std_logic_vector(7 downto 0); 13 | rd_addr_i: in std_logic_vector(7 downto 0); 14 | rd_data_o: out std_logic_vector(31 downto 0) 15 | ); 16 | end component; 17 | 18 | __: sprite_ram port map( 19 | wr_clk_i=>, 20 | rd_clk_i=>, 21 | rst_i=>, 22 | wr_clk_en_i=>, 23 | rd_en_i=>, 24 | rd_clk_en_i=>, 25 | wr_en_i=>, 26 | ben_i=>, 27 | wr_data_i=>, 28 | wr_addr_i=>, 29 | rd_addr_i=>, 30 | rd_data_o=> 31 | ); 32 | -------------------------------------------------------------------------------- /fpga/source/generated/sprite_ram/rtl/sprite_ram_bb.v: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | Verilog netlist generated by IPGEN Radiant Software (64-bit) 2.0.1.281.2 3 | Soft IP Version: 1.1.0 4 | Wed Apr 15 20:29:57 2020 5 | *******************************************************************************/ 6 | /******************************************************************************* 7 | Wrapper Module generated per user settings. 8 | *******************************************************************************/ 9 | module sprite_ram (wr_clk_i, rd_clk_i, rst_i, wr_clk_en_i, rd_en_i, 10 | rd_clk_en_i, wr_en_i, ben_i, wr_data_i, wr_addr_i, rd_addr_i, rd_data_o)/* synthesis syn_black_box syn_declare_black_box=1 */; 11 | input wr_clk_i; 12 | input rd_clk_i; 13 | input rst_i; 14 | input wr_clk_en_i; 15 | input rd_en_i; 16 | input rd_clk_en_i; 17 | input wr_en_i; 18 | input [3:0] ben_i; 19 | input [31:0] wr_data_i; 20 | input [7:0] wr_addr_i; 21 | input [7:0] rd_addr_i; 22 | output [31:0] rd_data_o; 23 | endmodule -------------------------------------------------------------------------------- /fpga/source/generated/sprite_ram/sprite_ram.cfg: -------------------------------------------------------------------------------- 1 | { 2 | "REGMODE": false, 3 | "BYTE_ENABLE": true, 4 | "RDATA_WIDTH": 32, 5 | "WDATA_WIDTH": 32, 6 | "RADDR_DEPTH": 256, 7 | "INIT_MODE": "all_zero", 8 | "WADDR_DEPTH": 256 9 | } -------------------------------------------------------------------------------- /fpga/source/generated/sprite_ram/sprite_ram.ipx: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /fpga/source/generated/sprite_ram/sprite_ram_init.mem: -------------------------------------------------------------------------------- 1 | 0 2 | 0 3 | 0 4 | 0 5 | 0 6 | 0 7 | 0 8 | 0 9 | 0 10 | 0 11 | 0 12 | 0 13 | 0 14 | 0 15 | 0 16 | 0 17 | 0 18 | 0 19 | 0 20 | 0 21 | 0 22 | 0 23 | 0 24 | 0 25 | 0 26 | 0 27 | 0 28 | 0 29 | 0 30 | 0 31 | 0 32 | 0 33 | 0 34 | 0 35 | 0 36 | 0 37 | 0 38 | 0 39 | 0 40 | 0 41 | 0 42 | 0 43 | 0 44 | 0 45 | 0 46 | 0 47 | 0 48 | 0 49 | 0 50 | 0 51 | 0 52 | 0 53 | 0 54 | 0 55 | 0 56 | 0 57 | 0 58 | 0 59 | 0 60 | 0 61 | 0 62 | 0 63 | 0 64 | 0 65 | 0 66 | 0 67 | 0 68 | 0 69 | 0 70 | 0 71 | 0 72 | 0 73 | 0 74 | 0 75 | 0 76 | 0 77 | 0 78 | 0 79 | 0 80 | 0 81 | 0 82 | 0 83 | 0 84 | 0 85 | 0 86 | 0 87 | 0 88 | 0 89 | 0 90 | 0 91 | 0 92 | 0 93 | 0 94 | 0 95 | 0 96 | 0 97 | 0 98 | 0 99 | 0 100 | 0 101 | 0 102 | 0 103 | 0 104 | 0 105 | 0 106 | 0 107 | 0 108 | 0 109 | 0 110 | 0 111 | 0 112 | 0 113 | 0 114 | 0 115 | 0 116 | 0 117 | 0 118 | 0 119 | 0 120 | 0 121 | 0 122 | 0 123 | 0 124 | 0 125 | 0 126 | 0 127 | 0 128 | 0 129 | 0 130 | 0 131 | 0 132 | 0 133 | 0 134 | 0 135 | 0 136 | 0 137 | 0 138 | 0 139 | 0 140 | 0 141 | 0 142 | 0 143 | 0 144 | 0 145 | 0 146 | 0 147 | 0 148 | 0 149 | 0 150 | 0 151 | 0 152 | 0 153 | 0 154 | 0 155 | 0 156 | 0 157 | 0 158 | 0 159 | 0 160 | 0 161 | 0 162 | 0 163 | 0 164 | 0 165 | 0 166 | 0 167 | 0 168 | 0 169 | 0 170 | 0 171 | 0 172 | 0 173 | 0 174 | 0 175 | 0 176 | 0 177 | 0 178 | 0 179 | 0 180 | 0 181 | 0 182 | 0 183 | 0 184 | 0 185 | 0 186 | 0 187 | 0 188 | 0 189 | 0 190 | 0 191 | 0 192 | 0 193 | 0 194 | 0 195 | 0 196 | 0 197 | 0 198 | 0 199 | 0 200 | 0 201 | 0 202 | 0 203 | 0 204 | 0 205 | 0 206 | 0 207 | 0 208 | 0 209 | 0 210 | 0 211 | 0 212 | 0 213 | 0 214 | 0 215 | 0 216 | 0 217 | 0 218 | 0 219 | 0 220 | 0 221 | 0 222 | 0 223 | 0 224 | 0 225 | 0 226 | 0 227 | 0 228 | 0 229 | 0 230 | 0 231 | 0 232 | 0 233 | 0 234 | 0 235 | 0 236 | 0 237 | 0 238 | 0 239 | 0 240 | 0 241 | 0 242 | 0 243 | 0 244 | 0 245 | 0 246 | 0 247 | 0 248 | 0 249 | 0 250 | 0 251 | 0 252 | 0 253 | 0 254 | 0 255 | 0 256 | 0 257 | -------------------------------------------------------------------------------- /fpga/source/generated/sprite_ram/testbench/dut_inst.v: -------------------------------------------------------------------------------- 1 | sprite_ram u_sprite_ram(.wr_clk_i(wr_clk_i), 2 | .rd_clk_i(rd_clk_i), 3 | .rst_i(rst_i), 4 | .wr_clk_en_i(wr_clk_en_i), 5 | .rd_en_i(rd_en_i), 6 | .rd_clk_en_i(rd_clk_en_i), 7 | .wr_en_i(wr_en_i), 8 | .ben_i(ben_i), 9 | .wr_data_i(wr_data_i), 10 | .wr_addr_i(wr_addr_i), 11 | .rd_addr_i(rd_addr_i), 12 | .rd_data_o(rd_data_o)); 13 | -------------------------------------------------------------------------------- /fpga/source/graphics/layer_line_buffer.v: -------------------------------------------------------------------------------- 1 | //`default_nettype none 2 | 3 | module layer_line_buffer( 4 | input wire rst, 5 | input wire clk, 6 | 7 | input wire active_render_buffer, 8 | 9 | // Renderer interface 10 | input wire [9:0] renderer_wr_idx, 11 | input wire [7:0] renderer_wr_data, 12 | input wire renderer_wr_en, 13 | 14 | // Composer interface 15 | input wire [9:0] composer_rd_idx, 16 | output reg [7:0] composer_rd_data); 17 | 18 | wire active_composer_buffer = !active_render_buffer; 19 | 20 | // linebuf_a and linebuf_b are used for the lower 512 pixels of the two lines 21 | // linebuf_c is used for the upper 256 pixels of the two lines 22 | 23 | wire [8:0] wr_addr_a = renderer_wr_idx[8:0]; 24 | wire [8:0] wr_addr_b = renderer_wr_idx[8:0]; 25 | wire [8:0] wr_addr_c = {active_render_buffer, renderer_wr_idx[7:0]}; 26 | wire wr_en_a = renderer_wr_en && !renderer_wr_idx[9] && !active_render_buffer; 27 | wire wr_en_b = renderer_wr_en && !renderer_wr_idx[9] && active_render_buffer; 28 | wire wr_en_c = renderer_wr_en && renderer_wr_idx[9]; 29 | 30 | wire [8:0] rd_addr_a = composer_rd_idx[8:0]; 31 | wire [8:0] rd_addr_b = composer_rd_idx[8:0]; 32 | wire [8:0] rd_addr_c = {active_composer_buffer, composer_rd_idx[7:0]}; 33 | wire [7:0] rd_data_a, rd_data_b, rd_data_c; 34 | 35 | dpram #(.ADDR_WIDTH(9), .DATA_WIDTH(8)) linebuf_a(.wr_clk(clk), .wr_addr(wr_addr_a), .wr_data(renderer_wr_data), .wr_en(wr_en_a), .rd_clk(clk), .rd_addr(rd_addr_a), .rd_data(rd_data_a)); 36 | dpram #(.ADDR_WIDTH(9), .DATA_WIDTH(8)) linebuf_b(.wr_clk(clk), .wr_addr(wr_addr_b), .wr_data(renderer_wr_data), .wr_en(wr_en_b), .rd_clk(clk), .rd_addr(rd_addr_b), .rd_data(rd_data_b)); 37 | dpram #(.ADDR_WIDTH(9), .DATA_WIDTH(8)) linebuf_c(.wr_clk(clk), .wr_addr(wr_addr_c), .wr_data(renderer_wr_data), .wr_en(wr_en_c), .rd_clk(clk), .rd_addr(rd_addr_c), .rd_data(rd_data_c)); 38 | 39 | 40 | reg rd_idx9_r; 41 | always @(posedge clk) rd_idx9_r <= composer_rd_idx[9]; 42 | 43 | always @* begin 44 | if (!rd_idx9_r) begin 45 | composer_rd_data = !active_composer_buffer ? rd_data_a : rd_data_b; 46 | end else begin 47 | composer_rd_data = rd_data_c; 48 | end 49 | end 50 | 51 | endmodule 52 | -------------------------------------------------------------------------------- /fpga/source/mult_accum.v: -------------------------------------------------------------------------------- 1 | //`default_nettype none 2 | 3 | module mult_accum ( 4 | input wire clk, 5 | 6 | input wire [15:0] input_a_16, 7 | input wire [15:0] input_b_16, 8 | input wire mult_enabled, 9 | input wire reset_accum, 10 | input wire accumulate, 11 | input wire add_or_sub, 12 | 13 | output wire [31:0] output_32); 14 | 15 | pmi_dsp i_mult16x16 ( // port interfaces 16 | .A(input_a_16), 17 | .B(input_b_16), 18 | .C(input_b_16), // This is used to pass through the original value of the cache 19 | .D(input_a_16), // This is used to pass through the original value of the cache 20 | .O(output_32), 21 | .CLK(clk), 22 | .CE(1'b1), 23 | .IRSTTOP(1'b0), 24 | .IRSTBOT(1'b0), 25 | .ORSTTOP(reset_accum), 26 | .ORSTBOT(reset_accum), 27 | .AHOLD(1'b0), 28 | .BHOLD(1'b0), 29 | .CHOLD(1'b0), 30 | .DHOLD(1'b0), 31 | .OHOLDTOP(!accumulate), 32 | .OHOLDBOT(!accumulate), 33 | .OLOADTOP(!mult_enabled), // We are using the LOAD to switch between the multiplier output and (effectively) input C 34 | .OLOADBOT(!mult_enabled), // We are using the LOAD to switch between the multiplier output and (effectively) input D 35 | .ADDSUBTOP(add_or_sub), 36 | .ADDSUBBOT(add_or_sub), 37 | .CO(), 38 | .CI(1'b0), 39 | .ACCUMCI(1'b0), 40 | .ACCUMCO(), 41 | .SIGNEXTIN(1'b0), 42 | .SIGNEXTOUT() 43 | ); 44 | defparam i_mult16x16.TOPOUTPUT_SELECT = 2'b00; // Adder output (non registered) 45 | defparam i_mult16x16.BOTOUTPUT_SELECT = 2'b00; // Adder output (non registered) 46 | defparam i_mult16x16.A_SIGNED = 1'b1; //Signed Inputs 47 | defparam i_mult16x16.B_SIGNED = 1'b1; 48 | 49 | defparam i_mult16x16.TOPADDSUB_CARRYSELECT = 2'b10; // 10: Cascade ACCUMOUT from lower Adder/Subtractor 50 | 51 | defparam i_mult16x16.TOPADDSUB_LOWERINPUT = 2'b10; // We send the output (the 16 upper bits) of the 16x16 multiplier to the lower side of the top accumilator 52 | defparam i_mult16x16.TOPADDSUB_UPPERINPUT = 1'b0; // We send the output of the top (output) flip-flop to the upper side of the top accumilator 53 | defparam i_mult16x16.BOTADDSUB_LOWERINPUT = 2'b10; // We send the output (the 16 lower bits) of the 16x16 multiplier to the lower side of the bottom accumilator 54 | defparam i_mult16x16.BOTADDSUB_UPPERINPUT = 1'b0; // We send the output of the bottom (output) flip-flop to the upper side of the top accumilator 55 | 56 | 57 | endmodule -------------------------------------------------------------------------------- /fpga/source/palette_ram.mem: -------------------------------------------------------------------------------- 1 | 0000 2 | 0fff 3 | 0800 4 | 0afe 5 | 0c4c 6 | 00c5 7 | 000a 8 | 0ee7 9 | 0d85 10 | 0640 11 | 0f77 12 | 0333 13 | 0777 14 | 0af6 15 | 008f 16 | 0bbb 17 | 0000 18 | 0111 19 | 0222 20 | 0333 21 | 0444 22 | 0555 23 | 0666 24 | 0777 25 | 0888 26 | 0999 27 | 0aaa 28 | 0bbb 29 | 0ccc 30 | 0ddd 31 | 0eee 32 | 0fff 33 | 0211 34 | 0433 35 | 0644 36 | 0866 37 | 0a88 38 | 0c99 39 | 0fbb 40 | 0211 41 | 0422 42 | 0633 43 | 0844 44 | 0a55 45 | 0c66 46 | 0f77 47 | 0200 48 | 0411 49 | 0611 50 | 0822 51 | 0a22 52 | 0c33 53 | 0f33 54 | 0200 55 | 0400 56 | 0600 57 | 0800 58 | 0a00 59 | 0c00 60 | 0f00 61 | 0221 62 | 0443 63 | 0664 64 | 0886 65 | 0aa8 66 | 0cc9 67 | 0feb 68 | 0211 69 | 0432 70 | 0653 71 | 0874 72 | 0a95 73 | 0cb6 74 | 0fd7 75 | 0210 76 | 0431 77 | 0651 78 | 0862 79 | 0a82 80 | 0ca3 81 | 0fc3 82 | 0210 83 | 0430 84 | 0640 85 | 0860 86 | 0a80 87 | 0c90 88 | 0fb0 89 | 0121 90 | 0343 91 | 0564 92 | 0786 93 | 09a8 94 | 0bc9 95 | 0dfb 96 | 0121 97 | 0342 98 | 0463 99 | 0684 100 | 08a5 101 | 09c6 102 | 0bf7 103 | 0120 104 | 0241 105 | 0461 106 | 0582 107 | 06a2 108 | 08c3 109 | 09f3 110 | 0120 111 | 0240 112 | 0360 113 | 0480 114 | 05a0 115 | 06c0 116 | 07f0 117 | 0121 118 | 0343 119 | 0465 120 | 0686 121 | 08a8 122 | 09ca 123 | 0bfc 124 | 0121 125 | 0242 126 | 0364 127 | 0485 128 | 05a6 129 | 06c8 130 | 07f9 131 | 0020 132 | 0141 133 | 0162 134 | 0283 135 | 02a4 136 | 03c5 137 | 03f6 138 | 0020 139 | 0041 140 | 0061 141 | 0082 142 | 00a2 143 | 00c3 144 | 00f3 145 | 0122 146 | 0344 147 | 0466 148 | 0688 149 | 08aa 150 | 09cc 151 | 0bff 152 | 0122 153 | 0244 154 | 0366 155 | 0488 156 | 05aa 157 | 06cc 158 | 07ff 159 | 0022 160 | 0144 161 | 0166 162 | 0288 163 | 02aa 164 | 03cc 165 | 03ff 166 | 0022 167 | 0044 168 | 0066 169 | 0088 170 | 00aa 171 | 00cc 172 | 00ff 173 | 0112 174 | 0334 175 | 0456 176 | 0668 177 | 088a 178 | 09ac 179 | 0bcf 180 | 0112 181 | 0224 182 | 0346 183 | 0458 184 | 056a 185 | 068c 186 | 079f 187 | 0002 188 | 0114 189 | 0126 190 | 0238 191 | 024a 192 | 035c 193 | 036f 194 | 0002 195 | 0014 196 | 0016 197 | 0028 198 | 002a 199 | 003c 200 | 003f 201 | 0112 202 | 0334 203 | 0546 204 | 0768 205 | 098a 206 | 0b9c 207 | 0dbf 208 | 0112 209 | 0324 210 | 0436 211 | 0648 212 | 085a 213 | 096c 214 | 0b7f 215 | 0102 216 | 0214 217 | 0416 218 | 0528 219 | 062a 220 | 083c 221 | 093f 222 | 0102 223 | 0204 224 | 0306 225 | 0408 226 | 050a 227 | 060c 228 | 070f 229 | 0212 230 | 0434 231 | 0646 232 | 0868 233 | 0a8a 234 | 0c9c 235 | 0fbe 236 | 0211 237 | 0423 238 | 0635 239 | 0847 240 | 0a59 241 | 0c6b 242 | 0f7d 243 | 0201 244 | 0413 245 | 0615 246 | 0826 247 | 0a28 248 | 0c3a 249 | 0f3c 250 | 0201 251 | 0403 252 | 0604 253 | 0806 254 | 0a08 255 | 0c09 256 | 0f0b 257 | -------------------------------------------------------------------------------- /fpga/source/reset_sync.v: -------------------------------------------------------------------------------- 1 | //`default_nettype none 2 | 3 | module reset_sync( 4 | input wire async_rst_in, 5 | input wire clk, 6 | output wire reset_out); 7 | 8 | reg dff_r, dff_rr; 9 | 10 | always @(posedge clk or posedge async_rst_in) begin 11 | if (async_rst_in) begin 12 | dff_r <= 1'b1; 13 | dff_rr <= 1'b1; 14 | 15 | end else begin 16 | dff_r <= 1'b0; 17 | dff_rr <= dff_r; 18 | end 19 | end 20 | 21 | assign reset_out = dff_rr; 22 | 23 | endmodule 24 | -------------------------------------------------------------------------------- /fpga/source/sim/.gitignore: -------------------------------------------------------------------------------- 1 | *.vcd 2 | -------------------------------------------------------------------------------- /fpga/source/sim/audio_attr_ram.v: -------------------------------------------------------------------------------- 1 | //`default_nettype none 2 | 3 | module audio_attr_ram( 4 | input wire wr_clk_i, 5 | input wire rd_clk_i, 6 | input wire wr_clk_en_i, 7 | input wire rd_en_i, 8 | input wire rd_clk_en_i, 9 | input wire wr_en_i, 10 | input wire [7:0] wr_data_i, 11 | input wire [5:0] wr_addr_i, 12 | input wire [3:0] rd_addr_i, 13 | output reg [31:0] rd_data_o); 14 | 15 | reg [31:0] mem[0:15]; 16 | 17 | always @(posedge wr_clk_i) begin 18 | if (wr_en_i) begin 19 | if (wr_addr_i[1:0] == 2'd0) mem[wr_addr_i[5:2]][7:0] <= wr_data_i; 20 | if (wr_addr_i[1:0] == 2'd1) mem[wr_addr_i[5:2]][15:8] <= wr_data_i; 21 | if (wr_addr_i[1:0] == 2'd2) mem[wr_addr_i[5:2]][23:16] <= wr_data_i; 22 | if (wr_addr_i[1:0] == 2'd3) mem[wr_addr_i[5:2]][31:24] <= wr_data_i; 23 | end 24 | end 25 | 26 | always @(posedge rd_clk_i) begin 27 | rd_data_o <= mem[rd_addr_i]; 28 | end 29 | 30 | initial begin: INIT 31 | integer i; 32 | for (i=0; i<16; i=i+1) begin 33 | mem[i] = 0; 34 | end 35 | end 36 | 37 | endmodule 38 | -------------------------------------------------------------------------------- /fpga/source/sim/layer_renderer_state.txt: -------------------------------------------------------------------------------- 1 | 000 WAIT_START 2 | 001 FETCH_MAP 3 | 010 WAIT_FETCH_MAP 4 | 011 FETCH_TILE 5 | 100 WAIT_FETCH_TILE 6 | 101 RENDER 7 | -------------------------------------------------------------------------------- /fpga/source/sim/palette_ram.v: -------------------------------------------------------------------------------- 1 | //`default_nettype none 2 | 3 | module palette_ram( 4 | input wire wr_clk_i, 5 | input wire rd_clk_i, 6 | input wire wr_clk_en_i, 7 | input wire rd_en_i, 8 | input wire rd_clk_en_i, 9 | input wire wr_en_i, 10 | input wire [1:0] ben_i, 11 | input wire [15:0] wr_data_i, 12 | input wire [7:0] wr_addr_i, 13 | input wire [7:0] rd_addr_i, 14 | output reg [15:0] rd_data_o); 15 | 16 | reg [15:0] mem[0:255]; 17 | 18 | always @(posedge wr_clk_i) begin 19 | if (wr_en_i) begin 20 | if (ben_i[1]) mem[wr_addr_i][15:8] <= wr_data_i[15:8]; 21 | if (ben_i[0]) mem[wr_addr_i][7:0] <= wr_data_i[7:0]; 22 | end 23 | end 24 | 25 | always @(posedge rd_clk_i) begin 26 | rd_data_o <= mem[rd_addr_i]; 27 | end 28 | 29 | initial begin: INIT 30 | mem[0] = 16'h000; 31 | mem[1] = 16'hFFF; 32 | mem[2] = 16'h800; 33 | mem[3] = 16'hAFE; 34 | mem[4] = 16'hC4C; 35 | mem[5] = 16'h0C5; 36 | mem[6] = 16'h00A; 37 | mem[7] = 16'hEE7; 38 | mem[8] = 16'hD85; 39 | mem[9] = 16'h640; 40 | mem[10] = 16'hF77; 41 | mem[11] = 16'h333; 42 | mem[12] = 16'h777; 43 | mem[13] = 16'hAF6; 44 | mem[14] = 16'h08F; 45 | mem[15] = 16'hBBB; 46 | end 47 | 48 | endmodule 49 | 50 | -------------------------------------------------------------------------------- /fpga/source/sim/sim.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | iverilog -Wall -Wno-timescale -Wno-implicit-dimensions -g2001 -gno-xtypes -gstrict-ca-eval -gstrict-expr-width -y. -y.. -y../video -y../graphics -y../uart -y../spi -y../audio tb.v 4 | ./a.out 5 | rm -f a.out 6 | -------------------------------------------------------------------------------- /fpga/source/sim/sprite_ram.v: -------------------------------------------------------------------------------- 1 | //`default_nettype none 2 | 3 | module sprite_ram( 4 | input wire wr_clk_i, 5 | input wire rd_clk_i, 6 | input wire wr_clk_en_i, 7 | input wire rd_en_i, 8 | input wire rd_clk_en_i, 9 | input wire wr_en_i, 10 | input wire [3:0] ben_i, 11 | input wire [31:0] wr_data_i, 12 | input wire [7:0] wr_addr_i, 13 | input wire [7:0] rd_addr_i, 14 | output reg [31:0] rd_data_o); 15 | 16 | reg [31:0] mem[0:255]; 17 | 18 | always @(posedge wr_clk_i) begin 19 | if (wr_en_i) begin 20 | if (ben_i[3]) mem[wr_addr_i][31:24] <= wr_data_i[31:24]; 21 | if (ben_i[2]) mem[wr_addr_i][23:16] <= wr_data_i[23:16]; 22 | if (ben_i[1]) mem[wr_addr_i][15:8] <= wr_data_i[15:8]; 23 | if (ben_i[0]) mem[wr_addr_i][7:0] <= wr_data_i[7:0]; 24 | end 25 | end 26 | 27 | always @(posedge rd_clk_i) begin 28 | rd_data_o <= mem[rd_addr_i]; 29 | end 30 | 31 | initial begin: INIT 32 | integer i; 33 | for (i=0; i<256; i=i+1) begin 34 | mem[i] = 0; 35 | end 36 | 37 | mem[2][11:0] = 'h100; // addr 38 | mem[2][15] = 1; // mode 39 | mem[2][25:16] = 10'd60; // x 40 | mem[3][9:0] = 10'd3; // y 41 | mem[3][16] = 0; // hflip 42 | mem[3][17] = 0; // vflip 43 | mem[3][19:18] = 3'd1; // z 44 | mem[3][23:20] = 0; // collision mask 45 | mem[3][27:24] = 0; // palette offset 46 | mem[3][29:28] = 2'd2; // width 47 | mem[3][31:30] = 2'd1; // height 48 | 49 | // mem[10][9:0] = 10'd200; // x 50 | // mem[10][10] = 0; // hflip 51 | // mem[10][11] = 0; // vflip 52 | // mem[10][15:12] = 0; // palette_offset 53 | // mem[10][24:16] = 9'd5; // y 54 | // mem[10][25] = 1; // mode 55 | // mem[10][27:26] = 3'd1; // z 56 | // mem[10][43:32] = 'h100; // addr 57 | // mem[10][45:44] = 4'd2; // width 58 | // mem[10][47:46] = 4'd1; // height 59 | 60 | end 61 | 62 | endmodule 63 | -------------------------------------------------------------------------------- /fpga/source/sim/sprite_renderer_state.txt: -------------------------------------------------------------------------------- 1 | 00 FIND_SPRITE 2 | 01 WAIT_FETCH 3 | 10 RENDER 4 | 11 DONE 5 | -------------------------------------------------------------------------------- /fpga/source/sim/tb.gtkw: -------------------------------------------------------------------------------- 1 | [*] 2 | [*] GTKWave Analyzer v3.3.86 (w)1999-2017 BSI 3 | [*] Fri Mar 13 11:27:28 2020 4 | [*] 5 | [dumpfile] "/c/Work/vera-module/fpga/source/sim/tb.vcd" 6 | [dumpfile_mtime] "Fri Mar 13 11:25:33 2020" 7 | [dumpfile_size] 713655 8 | [savefile] "/c/Work/vera-module/fpga/source/sim/tb.gtkw" 9 | [timestart] 4521000 10 | [size] 2560 1387 11 | [pos] 0 23 12 | *-20.223043 7460000 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 13 | [treeopen] tb. 14 | [treeopen] tb.top. 15 | [sst_width] 261 16 | [signals_width] 332 17 | [sst_expanded] 1 18 | [sst_vpaned_height] 689 19 | @200 20 | -External bus 21 | @28 22 | tb.top.clk 23 | tb.top.reset 24 | tb.phi2 25 | @22 26 | tb.top.extbus_a[4:0] 27 | tb.top.extbus_d[7:0] 28 | @28 29 | tb.top.extbus_cs_n 30 | tb.top.extbus_wr_n 31 | tb.top.extbus_rd_n 32 | tb.top.extbus_irq_n 33 | @200 34 | -Internal 35 | @28 36 | tb.top.bus_read 37 | tb.top.bus_write 38 | @200 39 | - 40 | @22 41 | tb.top.rdaddr_r[4:0] 42 | tb.top.wraddr_r[4:0] 43 | tb.top.access_addr[4:0] 44 | @200 45 | - 46 | @28 47 | tb.top.do_read 48 | tb.top.do_write 49 | @22 50 | tb.top.write_data[7:0] 51 | @28 52 | tb.top.fetch_ahead_next 53 | tb.top.fetch_ahead_r 54 | @200 55 | - 56 | @28 57 | tb.top.bus_read 58 | tb.top.bus_write 59 | tb.top.do_write 60 | @22 61 | tb.top.write_data[7:0] 62 | tb.top.vram_addr_0_r[16:0] 63 | tb.top.vram_addr_incr_0_r[3:0] 64 | tb.top.vram_addr_1_r[16:0] 65 | tb.top.vram_addr_incr_1_r[3:0] 66 | @200 67 | - 68 | @22 69 | tb.top.ib_addr_r[16:0] 70 | tb.top.ib_wrdata_r[7:0] 71 | @28 72 | tb.top.ib_do_access_r 73 | tb.top.ib_write_r 74 | @22 75 | tb.top.vram_rddata[7:0] 76 | @28 77 | tb.top.save_result_r 78 | tb.top.save_result_port_r 79 | @22 80 | tb.top.vram_addr_new[16:0] 81 | @200 82 | - 83 | @22 84 | tb.top.vram_addr_0_r[16:0] 85 | tb.top.vram_data0_r[7:0] 86 | tb.top.vram_addr_1_r[16:0] 87 | tb.top.vram_data1_r[7:0] 88 | @200 89 | - 90 | @28 91 | tb.top.l0_renderer.bitmap_mode 92 | tb.top.l0_renderer.render_busy_r 93 | @23 94 | tb.top.l0_renderer.bus_addr[14:0] 95 | @22 96 | tb.top.l0_renderer.pixels_per_word_minus1[3:0] 97 | [pattern_trace] 1 98 | [pattern_trace] 0 99 | -------------------------------------------------------------------------------- /fpga/source/spi/sim/.gitignore: -------------------------------------------------------------------------------- 1 | *.vcd 2 | -------------------------------------------------------------------------------- /fpga/source/spi/sim/sim.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | iverilog -Wall -Wno-timescale -Wno-implicit-dimensions -g2001 -gno-xtypes -gstrict-ca-eval -gstrict-expr-width -y. -y.. tb.v 4 | ./a.out 5 | rm -f a.out 6 | -------------------------------------------------------------------------------- /fpga/source/spi/sim/tb.gtkw: -------------------------------------------------------------------------------- 1 | [*] 2 | [*] GTKWave Analyzer v3.3.86 (w)1999-2017 BSI 3 | [*] Sat Mar 14 12:26:58 2020 4 | [*] 5 | [dumpfile] "/c/Work/vera-module/fpga/source/spi/sim/tb.vcd" 6 | [dumpfile_mtime] "Sat Mar 14 12:26:47 2020" 7 | [dumpfile_size] 26935 8 | [savefile] "/c/Work/vera-module/fpga/source/spi/sim/tb.gtkw" 9 | [timestart] 0 10 | [size] 2223 1169 11 | [pos] 225 140 12 | *-19.858435 1173000 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 13 | [treeopen] tb. 14 | [sst_width] 261 15 | [signals_width] 332 16 | [sst_expanded] 1 17 | [sst_vpaned_height] 566 18 | @28 19 | tb.spictrl.rst 20 | tb.spictrl.clk 21 | @22 22 | tb.spictrl.txdata[7:0] 23 | @28 24 | tb.spictrl.txstart 25 | @22 26 | tb.spictrl.rxdata[7:0] 27 | @28 28 | tb.spictrl.busy 29 | tb.spictrl.slow 30 | tb.spictrl.spi_sck 31 | tb.spictrl.spi_mosi 32 | tb.spictrl.spi_miso 33 | @200 34 | - 35 | - 36 | - 37 | - 38 | - 39 | - 40 | @29 41 | tb.spictrl.clk_pulse 42 | [pattern_trace] 1 43 | [pattern_trace] 0 44 | -------------------------------------------------------------------------------- /fpga/source/spi/sim/tb.v: -------------------------------------------------------------------------------- 1 | `timescale 1 ns / 1 ps 2 | //`default_nettype none 3 | 4 | module tb(); 5 | 6 | initial begin 7 | $dumpfile("tb.vcd"); 8 | $dumpvars(0, tb); 9 | end 10 | 11 | initial begin 12 | // #3000000 $finish; 13 | #30000 $finish; 14 | end 15 | 16 | // Generate 25MHz sysclk 17 | reg clk = 0; 18 | always #20 clk = !clk; 19 | 20 | reg rst = 1; 21 | always #200 rst = 0; 22 | 23 | reg [7:0] txdata = 0; 24 | reg txstart = 0; 25 | wire [7:0] rxdata; 26 | wire busy; 27 | reg slow = 0; 28 | 29 | spictrl spictrl( 30 | .rst(rst), 31 | .clk(clk), 32 | 33 | // Register interface 34 | .txdata(txdata), 35 | .txstart(txstart), 36 | .rxdata(rxdata), 37 | .busy(busy), 38 | 39 | .slow(slow), 40 | 41 | // SPI interface 42 | .spi_sck(), 43 | .spi_mosi(), 44 | .spi_miso(1'b1)); 45 | 46 | initial begin 47 | #1000; 48 | 49 | @(negedge clk); 50 | 51 | txdata = 8'h55; 52 | txstart = 1; 53 | 54 | @(negedge clk); 55 | 56 | txstart = 0; 57 | 58 | #1000; 59 | 60 | @(negedge clk); 61 | slow = 1; 62 | txstart = 1; 63 | 64 | @(negedge clk); 65 | 66 | txstart = 0; 67 | 68 | end 69 | 70 | 71 | 72 | endmodule 73 | -------------------------------------------------------------------------------- /fpga/source/spi/spictrl.v: -------------------------------------------------------------------------------- 1 | //`default_nettype none 2 | 3 | module spictrl( 4 | input wire rst, 5 | input wire clk, 6 | 7 | // Register interface 8 | input wire [7:0] txdata, 9 | input wire txstart, 10 | output wire [7:0] rxdata, 11 | output wire busy, 12 | 13 | input wire slow, 14 | 15 | // SPI interface 16 | output wire spi_sck, 17 | output wire spi_mosi, 18 | input wire spi_miso); 19 | 20 | reg [3:0] bitcnt_r; 21 | assign busy = (bitcnt_r != 'd0); 22 | 23 | reg [7:0] tx_shift_r, rx_shift_r; 24 | 25 | assign spi_mosi = tx_shift_r[7]; 26 | assign rxdata = rx_shift_r; 27 | 28 | reg [4:0] div_cnt_r; 29 | always @(posedge clk or posedge rst) begin 30 | if (rst) begin 31 | div_cnt_r <= 0; 32 | end else begin 33 | div_cnt_r <= div_cnt_r + 5'd1; 34 | end 35 | end 36 | 37 | wire clk_pulse = slow ? (div_cnt_r == 'd31) : 1'b1; 38 | 39 | reg clk_r; 40 | assign spi_sck = clk_r; 41 | 42 | always @(posedge clk or posedge rst) begin 43 | if (rst) begin 44 | tx_shift_r <= 0; 45 | rx_shift_r <= 0; 46 | bitcnt_r <= 0; 47 | clk_r <= 0; 48 | 49 | end else begin 50 | if (busy) begin 51 | if (clk_pulse) begin 52 | clk_r <= !clk_r; 53 | if (clk_r) begin 54 | tx_shift_r <= {tx_shift_r[6:0], 1'b0}; 55 | bitcnt_r <= bitcnt_r - 4'd1; 56 | end else begin 57 | rx_shift_r <= {rx_shift_r[6:0], spi_miso}; 58 | end 59 | end 60 | 61 | end else begin 62 | if (txstart) begin 63 | tx_shift_r <= txdata; 64 | bitcnt_r <= 4'd8; 65 | end 66 | end 67 | end 68 | end 69 | 70 | endmodule 71 | -------------------------------------------------------------------------------- /fpga/source/tools/.gitignore: -------------------------------------------------------------------------------- 1 | ./generate_palette 2 | -------------------------------------------------------------------------------- /fpga/source/tools/generate_palette: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/X16Community/vera-module/6e8bea68a5a04687149e27b1b7b3726fb01405f4/fpga/source/tools/generate_palette -------------------------------------------------------------------------------- /fpga/source/tools/generate_palette.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | uint16_t commodore_palette[] = { 6 | 0x000, // Commodore 16 color 7 | 0xFFF, 8 | 0x800, 9 | 0xAFE, 10 | 0xC4C, 11 | 0x0C5, 12 | 0x00A, 13 | 0xEE7, 14 | 0xD85, 15 | 0x640, 16 | 0xF77, 17 | 0x333, 18 | 0x777, 19 | 0xAF6, 20 | 0x08F, 21 | 0xBBB, 22 | }; 23 | 24 | struct RGB { 25 | unsigned char R; 26 | unsigned char G; 27 | unsigned char B; 28 | }; 29 | 30 | struct HSV { 31 | double H; 32 | double S; 33 | double V; 34 | }; 35 | 36 | struct RGB HSVToRGB(struct HSV hsv) { 37 | double r = 0, g = 0, b = 0; 38 | 39 | if (hsv.S == 0) { 40 | r = hsv.V; 41 | g = hsv.V; 42 | b = hsv.V; 43 | } else { 44 | int i; 45 | double f, p, q, t; 46 | 47 | if (hsv.H == 360) 48 | hsv.H = 0; 49 | else 50 | hsv.H = hsv.H / 60; 51 | 52 | i = (int)trunc(hsv.H); 53 | f = hsv.H - i; 54 | 55 | p = hsv.V * (1.0 - hsv.S); 56 | q = hsv.V * (1.0 - (hsv.S * f)); 57 | t = hsv.V * (1.0 - (hsv.S * (1.0 - f))); 58 | 59 | switch (i) { 60 | case 0: 61 | r = hsv.V; 62 | g = t; 63 | b = p; 64 | break; 65 | 66 | case 1: 67 | r = q; 68 | g = hsv.V; 69 | b = p; 70 | break; 71 | 72 | case 2: 73 | r = p; 74 | g = hsv.V; 75 | b = t; 76 | break; 77 | 78 | case 3: 79 | r = p; 80 | g = q; 81 | b = hsv.V; 82 | break; 83 | 84 | case 4: 85 | r = t; 86 | g = p; 87 | b = hsv.V; 88 | break; 89 | 90 | default: 91 | r = hsv.V; 92 | g = p; 93 | b = q; 94 | break; 95 | } 96 | } 97 | 98 | struct RGB rgb; 99 | rgb.R = r * 15; 100 | rgb.G = g * 15; 101 | rgb.B = b * 15; 102 | 103 | return rgb; 104 | } 105 | 106 | int main() { 107 | // Commodore palette 108 | for (int i = 0; i < 16; i++) { 109 | printf("%04x\n", commodore_palette[i]); 110 | } 111 | 112 | // Grayscale ramp 113 | for (int i = 0; i < 16; i++) { 114 | printf("%04x\n", (i << 8) | (i << 4) | (i << 0)); 115 | } 116 | 117 | // General purpose palette 118 | for (int hue = 0; hue < 8; hue++) { 119 | for (int saturation = 0; saturation < 4; saturation++) { 120 | for (int value = 0; value < 7; value++) { 121 | struct HSV hsv; 122 | hsv.H = (double)hue / 8.0 * 360.0; 123 | hsv.S = (double)(saturation + 1) / 4.0; 124 | hsv.V = (double)(value + 1) / 7.0; 125 | 126 | struct RGB rgb = HSVToRGB(hsv); 127 | uint16_t entry = (rgb.R << 8) | (rgb.G << 4) | (rgb.B << 0); 128 | printf("%04x\n", entry); 129 | } 130 | } 131 | } 132 | return 0; 133 | } 134 | -------------------------------------------------------------------------------- /fpga/source/vera_module.ldc: -------------------------------------------------------------------------------- 1 | # 25MHz system clock 2 | create_clock -name {clk25} -period 40 [get_ports clk25] 3 | 4 | # 8MHz read/write clocks 5 | create_clock -name {wrclk} -period 125 [get_pins -hierarchical wraddr_r/clock] 6 | create_clock -name {rdclk} -period 125 [get_pins rdaddr_r/clock] 7 | 8 | # Define clock domains to be independent 9 | set_clock_groups -group [get_clocks clk25] -group [get_clocks {rdclk wrclk}] -asynchronous 10 | 11 | set_output_delay -clock [get_clocks clk25] 10 [get_ports {vga_r[0] vga_r[1] vga_r[2] vga_r[3] vga_g[0] vga_g[1] vga_g[2] vga_g[3] vga_b[0] vga_b[1] vga_b[2] vga_b[3] vga_hsync vga_vsync}] 12 | -------------------------------------------------------------------------------- /fpga/source/vera_module.pdc: -------------------------------------------------------------------------------- 1 | # Clock 2 | ldc_set_location -site {35} [get_ports clk25] 3 | 4 | # Bus 5 | ldc_set_location -site {28} [get_ports extbus_cs_n] 6 | ldc_set_location -site {36} [get_ports extbus_rd_n] 7 | ldc_set_location -site {31} [get_ports extbus_wr_n] 8 | 9 | ldc_set_location -site {40} [get_ports {extbus_a[0]}] 10 | ldc_set_location -site {39} [get_ports {extbus_a[1]}] 11 | ldc_set_location -site {37} [get_ports {extbus_a[2]}] 12 | ldc_set_location -site {41} [get_ports {extbus_a[3]}] 13 | ldc_set_location -site {34} [get_ports {extbus_a[4]}] 14 | 15 | ldc_set_location -site {27} [get_ports {extbus_d[0]}] 16 | ldc_set_location -site {26} [get_ports {extbus_d[1]}] 17 | ldc_set_location -site {25} [get_ports {extbus_d[2]}] 18 | ldc_set_location -site {23} [get_ports {extbus_d[3]}] 19 | ldc_set_location -site {21} [get_ports {extbus_d[4]}] 20 | ldc_set_location -site {20} [get_ports {extbus_d[5]}] 21 | ldc_set_location -site {19} [get_ports {extbus_d[6]}] 22 | ldc_set_location -site {18} [get_ports {extbus_d[7]}] 23 | 24 | ldc_set_location -site {32} [get_ports extbus_irq_n] 25 | 26 | # VGA 27 | ldc_set_location -site {10} [get_ports {vga_r[0]}] 28 | ldc_set_location -site {11} [get_ports {vga_r[1]}] 29 | ldc_set_location -site {12} [get_ports {vga_r[2]}] 30 | ldc_set_location -site {13} [get_ports {vga_r[3]}] 31 | ldc_set_location -site {3} [get_ports {vga_g[0]}] 32 | ldc_set_location -site {4} [get_ports {vga_g[1]}] 33 | ldc_set_location -site {6} [get_ports {vga_g[2]}] 34 | ldc_set_location -site {9} [get_ports {vga_g[3]}] 35 | ldc_set_location -site {46} [get_ports {vga_b[0]}] 36 | ldc_set_location -site {47} [get_ports {vga_b[1]}] 37 | ldc_set_location -site {48} [get_ports {vga_b[2]}] 38 | ldc_set_location -site {2} [get_ports {vga_b[3]}] 39 | ldc_set_location -site {44} [get_ports vga_hsync] 40 | ldc_set_location -site {45} [get_ports vga_vsync] 41 | 42 | # SPI 43 | ldc_set_location -site {15} [get_ports spi_sck] 44 | ldc_set_location -site {14} [get_ports spi_mosi] 45 | ldc_set_location -site {17} [get_ports spi_miso] 46 | ldc_set_location -site {16} [get_ports spi_ssel_n_sd] 47 | 48 | # Audio 49 | ldc_set_location -site {43} [get_ports audio_lrck] 50 | ldc_set_location -site {38} [get_ports audio_bck] 51 | ldc_set_location -site {42} [get_ports audio_data] 52 | 53 | ldc_set_vcc -core 1.2 54 | -------------------------------------------------------------------------------- /fpga/source/vera_module.sdc: -------------------------------------------------------------------------------- 1 | # 25MHz system clock 2 | create_clock -name {clk25} -period 40 [get_ports clk25] 3 | 4 | #create_clock -name {wrclk} -period 125 [get_pins -hierarchical wraddr_r/clock] 5 | #create_clock -name {rdclk} -period 125 [get_pins rdaddr_r/clock] 6 | #create_clock -name {buscs} -period 125 [get_ports extbus_cs_n] 7 | create_clock -name {buswr} -period 125 [get_ports extbus_wr_n] 8 | create_clock -name {busrd} -period 125 [get_ports extbus_rd_n] 9 | #set_input_delay -clock [get_clocks buswr] -10 -clock_fall [get_ports {extbus_d[0] extbus_d[1] extbus_d[2] extbus_d[3] extbus_d[4] extbus_d[5] extbus_d[6] extbus_d[7]}] 10 | #set_clock_latency 10 -source -late [get_clocks buswr] 11 | set_clock_latency 10 -source -early [get_clocks buswr] 12 | set_clock_latency 10 -source -early [get_clocks busrd] 13 | 14 | # Define clock domains to be independent 15 | set_clock_groups -group [get_clocks clk25] -group [get_clocks {buscs buswr busrd}] -asynchronous 16 | 17 | set_output_delay -clock [get_clocks clk25] 10 [get_ports {vga_r[0] vga_r[1] vga_r[2] vga_r[3] vga_g[0] vga_g[1] vga_g[2] vga_g[3] vga_b[0] vga_b[1] vga_b[2] vga_b[3] vga_hsync vga_vsync}] 18 | -------------------------------------------------------------------------------- /fpga/source/video/gen-sinlut.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3.7 2 | import math 3 | 4 | for i in range(512): 5 | phase = i / 512.0 * (2.0 * math.pi) 6 | 7 | val = round(math.sin(phase) * 100) & 255 8 | 9 | print(f' 9\'d{i}: value <= 8\'d{val};') 10 | -------------------------------------------------------------------------------- /fpga/source/video/video_modulator_mult_u8xu8_pair.v: -------------------------------------------------------------------------------- 1 | //`default_nettype none 2 | 3 | module video_modulator_mult_u8xu8_pair ( 4 | input wire clk, 5 | 6 | input wire [7:0] input_1a_8, 7 | input wire [7:0] input_1b_8, 8 | input wire [7:0] input_2a_8, 9 | input wire [7:0] input_2b_8, 10 | 11 | output wire [15:0] output_1_16, 12 | output wire [15:0] output_2_16); 13 | 14 | wire [31:0] output_32; 15 | assign output_1_16 = output_32[15:0]; 16 | assign output_2_16 = output_32[31:16]; 17 | 18 | pmi_dsp mult8x8 ( // port interfaces 19 | .A({input_2a_8, input_1a_8}), 20 | .B({input_2b_8, input_1b_8}), 21 | .C(16'b0), 22 | .D(16'b0), 23 | .O(output_32), 24 | .CLK(clk), 25 | .CE(1'b1), 26 | .IRSTTOP(1'b0), 27 | .IRSTBOT(1'b0), 28 | .ORSTTOP(1'b0), 29 | .ORSTBOT(1'b0), 30 | .AHOLD(1'b0), 31 | .BHOLD(1'b0), 32 | .CHOLD(1'b0), 33 | .DHOLD(1'b0), 34 | .OHOLDTOP(1'b0), 35 | .OHOLDBOT(1'b0), 36 | .OLOADTOP(1'b0), 37 | .OLOADBOT(1'b0), 38 | .ADDSUBTOP(1'b0), 39 | .ADDSUBBOT(1'b0), 40 | .CO(), 41 | .CI(1'b0), 42 | .ACCUMCI(1'b0), 43 | .ACCUMCO(), 44 | .SIGNEXTIN(1'b0), 45 | .SIGNEXTOUT() 46 | ); 47 | defparam mult8x8.TOPOUTPUT_SELECT = 2'b10; //Mult8x8 data output 48 | defparam mult8x8.BOTOUTPUT_SELECT = 2'b10; //Mult8x8 data output 49 | defparam mult8x8.A_SIGNED = 1'b0; //Unsigned Inputs 50 | defparam mult8x8.B_SIGNED = 1'b0; //Unsigned Inputs 51 | 52 | endmodule 53 | -------------------------------------------------------------------------------- /fpga/source/video/video_vga.v: -------------------------------------------------------------------------------- 1 | //`default_nettype none 2 | 3 | module video_vga( 4 | input wire rst, 5 | input wire clk, 6 | 7 | // Palette interface 8 | input wire [11:0] palette_rgb_data, 9 | 10 | output wire next_frame, 11 | output wire next_line, 12 | output wire next_pixel, 13 | output wire vblank_pulse, 14 | 15 | // VGA interface 16 | output reg [3:0] vga_r, 17 | output reg [3:0] vga_g, 18 | output reg [3:0] vga_b, 19 | output reg vga_hsync, 20 | output reg vga_vsync); 21 | 22 | assign next_pixel = 1'b1; 23 | 24 | // 25 | // Video timing (640x480@60Hz) 26 | // 27 | parameter H_ACTIVE = 640; 28 | parameter H_FRONT_PORCH = 16; 29 | parameter H_SYNC = 96; 30 | parameter H_BACK_PORCH = 48; 31 | parameter H_TOTAL = H_ACTIVE + H_FRONT_PORCH + H_SYNC + H_BACK_PORCH; 32 | 33 | parameter V_ACTIVE = 480; 34 | parameter V_FRONT_PORCH = 10; 35 | parameter V_SYNC = 2; 36 | parameter V_BACK_PORCH = 33; 37 | parameter V_TOTAL = V_ACTIVE + V_FRONT_PORCH + V_SYNC + V_BACK_PORCH; 38 | 39 | reg [9:0] x_counter = 0; 40 | reg [9:0] y_counter = 0; 41 | 42 | wire h_last = (x_counter == H_TOTAL - 1); 43 | wire v_last = (y_counter == V_TOTAL - 1); 44 | wire v_last2 = (y_counter == V_TOTAL - 2); // Start rendering one line earlier 45 | 46 | always @(posedge clk or posedge rst) begin 47 | if (rst) begin 48 | `ifdef __ICARUS__ 49 | x_counter <= 10'd750; 50 | y_counter <= 10'd523; 51 | `else 52 | x_counter <= 10'd0; 53 | y_counter <= 10'd0; 54 | `endif 55 | 56 | end else begin 57 | x_counter <= h_last ? 10'd0 : (x_counter + 10'd1); 58 | if (h_last) 59 | y_counter <= v_last ? 10'd0 : (y_counter + 10'd1); 60 | end 61 | end 62 | 63 | wire hsync = (x_counter >= H_ACTIVE + H_FRONT_PORCH && x_counter < H_ACTIVE + H_FRONT_PORCH + H_SYNC); 64 | wire vsync = (y_counter >= V_ACTIVE + V_FRONT_PORCH && y_counter < V_ACTIVE + V_FRONT_PORCH + V_SYNC); 65 | wire h_active = (x_counter < H_ACTIVE); 66 | wire v_active = (y_counter < V_ACTIVE); 67 | wire active = h_active && v_active; 68 | 69 | assign vblank_pulse = h_last && (y_counter == V_ACTIVE - 1); 70 | 71 | assign next_frame = h_last && v_last2; 72 | assign next_line = h_last; 73 | 74 | // Compensate pipeline delays 75 | reg [1:0] hsync_r, vsync_r, active_r; 76 | always @(posedge clk) hsync_r <= {hsync_r[0], hsync}; 77 | always @(posedge clk) vsync_r <= {vsync_r[0], vsync}; 78 | always @(posedge clk) active_r <= {active_r[0], active}; 79 | 80 | always @(posedge clk or posedge rst) begin 81 | if (rst) begin 82 | vga_r <= 4'd0; 83 | vga_g <= 4'd0; 84 | vga_b <= 4'd0; 85 | vga_hsync <= 1; 86 | vga_vsync <= 1; 87 | 88 | end else begin 89 | if (active_r[1]) begin 90 | vga_r <= palette_rgb_data[11:8]; 91 | vga_g <= palette_rgb_data[7:4]; 92 | vga_b <= palette_rgb_data[3:0]; 93 | end else begin 94 | vga_r <= 4'd0; 95 | vga_g <= 4'd0; 96 | vga_b <= 4'd0; 97 | end 98 | 99 | vga_hsync <= ~hsync_r[1]; 100 | vga_vsync <= ~vsync_r[1]; 101 | end 102 | end 103 | 104 | endmodule 105 | -------------------------------------------------------------------------------- /misc/8bitguy.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/X16Community/vera-module/6e8bea68a5a04687149e27b1b7b3726fb01405f4/misc/8bitguy.png -------------------------------------------------------------------------------- /misc/8bitguy_original.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/X16Community/vera-module/6e8bea68a5a04687149e27b1b7b3726fb01405f4/misc/8bitguy_original.png -------------------------------------------------------------------------------- /misc/audiosim/Makefile: -------------------------------------------------------------------------------- 1 | 2 | all: 3 | $(CC) -Wall -O0 -g -o audiosim main.c -lm 4 | -------------------------------------------------------------------------------- /misc/audiosim/audiosim: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/X16Community/vera-module/6e8bea68a5a04687149e27b1b7b3726fb01405f4/misc/audiosim/audiosim -------------------------------------------------------------------------------- /misc/audiosim/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | int16_t sin_table[256]; 6 | 7 | void generate_sin_table(void) { 8 | for (int i = 0; i < 256; i++) { 9 | double phi = (i / 256.0) * (M_PI / 2.0); 10 | sin_table[i] = (int)(sin(phi) * 32767.0); 11 | } 12 | } 13 | 14 | int16_t lookup_sin(unsigned phase) { 15 | uint8_t idx = (phase & 256) ? (~phase & 255) : (phase & 255); 16 | int16_t val = sin_table[idx]; 17 | return (phase & 512) ? ~val : val; 18 | } 19 | 20 | int main() { 21 | generate_sin_table(); 22 | // for (int i = 0; i < 256; i++) { 23 | // printf("%4d %d\n", i, sin_table[i]); 24 | // } 25 | 26 | double fs = 44100.0; 27 | double fnote = 440.0; 28 | 29 | int freq = 10240; 30 | 31 | int op1_ratio = 16; 32 | int op2_ratio = 32; 33 | 34 | int op1_phase = 0; 35 | int op2_phase = 0; 36 | 37 | int16_t result[44100]; 38 | int idx = 0; 39 | 40 | for (int i = 0; i < 44100; i++) { 41 | int op2_freq = (op2_ratio * freq) / 16; 42 | op2_phase += op2_freq; 43 | int op2_val = lookup_sin(op2_phase >> 10); 44 | 45 | int op1_freq = (op1_ratio * freq) / 16; 46 | op1_phase += op1_freq + (op2_val * 1); 47 | int op1_val = lookup_sin(op1_phase >> 10); 48 | 49 | result[idx++] = op1_val; 50 | } 51 | 52 | FILE *f = fopen("result.bin", "wb"); 53 | fwrite(result, sizeof(result), 1, f); 54 | fclose(f); 55 | 56 | return 0; 57 | } 58 | -------------------------------------------------------------------------------- /misc/bootloader/.gitignore: -------------------------------------------------------------------------------- 1 | out/ 2 | -------------------------------------------------------------------------------- /misc/bootloader/Makefile: -------------------------------------------------------------------------------- 1 | 2 | all: 3 | xa -v -W -B -o out/8kb.bin data6502.a65 4 | cat out/8kb.bin out/8kb.bin > out/16kb.bin 5 | cat out/16kb.bin out/16kb.bin > out/32kb.bin 6 | cat out/32kb.bin out/32kb.bin > out/64kb.bin 7 | -------------------------------------------------------------------------------- /misc/bootloader/bootloader.a65: -------------------------------------------------------------------------------- 1 | ; bootloader.a65 2 | ; 3 | ; Little bootloader for Frank's 6502 test system to upload/download data via serial connection. 4 | 5 | SDATA = $C000 6 | SSTAT = $C001 7 | SCMD = $C002 8 | SCTRL = $C003 9 | 10 | VADDRH = $8000 11 | VADDRM = $8001 12 | VADDRL = $8002 13 | VDATA = $8003 14 | 15 | NMI_HANDLER = $FA 16 | IRQ_HANDLER = $FE 17 | 18 | ADDRL = $10 19 | ADDRH = $11 20 | 21 | ; Read command 22 | ; 01 - read (2 bytes following containing little endian address to read from) 23 | ; 02 - write (3 bytes following containing little endian address and write data) 24 | ; 03 - vread (3 bytes following containing little endian address to read from) 25 | ; 04 - vwrite (4 bytes following containing little endian address and write data) 26 | ; 05 - vwrite2 () 27 | ; 06 - jump (2 bytes following containing little endian address to jump to) 28 | 29 | * = $E000 30 | 31 | RESET_ENTRY 32 | ; Disable IRQs 33 | SEI 34 | ; Clear decimal mode 35 | CLD 36 | 37 | ; Initialize NMI and IRQ vector 38 | LDA #IRQ_DUMMY 42 | STA NMI_HANDLER+1 43 | STA IRQ_HANDLER+1 44 | 45 | ; Initialize ACIA 19200, 8N1, irq disabled 46 | LDA #0 47 | STA SSTAT 48 | STA SCMD 49 | LDA #$1F 50 | STA SCTRL 51 | LDA #$0B 52 | STA SCMD 53 | 54 | MAINLOOP 55 | JSR RXBYTE 56 | CMP #1 57 | BEQ CMD_READ 58 | CMP #2 59 | BEQ CMD_WRITE 60 | CMP #3 61 | BEQ CMD_VREAD 62 | CMP #4 63 | BEQ CMD_VWRITE 64 | CMP #5 65 | BEQ CMD_VWRITE2 66 | CMP #6 67 | BEQ CMD_JUMP 68 | JMP MAINLOOP 69 | 70 | CMD_READ 71 | JSR RXBYTE 72 | STA ADDRL 73 | JSR RXBYTE 74 | STA ADDRH 75 | LDA (ADDRL) 76 | JSR TXBYTE 77 | JMP MAINLOOP 78 | 79 | CMD_WRITE 80 | JSR RXBYTE 81 | STA ADDRL 82 | JSR RXBYTE 83 | STA ADDRH 84 | JSR RXBYTE 85 | STA (ADDRL) 86 | JMP MAINLOOP 87 | 88 | CMD_VREAD 89 | JSR RXBYTE 90 | STA VADDRH 91 | JSR RXBYTE 92 | STA VADDRM 93 | JSR RXBYTE 94 | STA VADDRL 95 | LDA VDATA 96 | JSR TXBYTE 97 | JMP MAINLOOP 98 | 99 | CMD_VWRITE 100 | JSR RXBYTE 101 | STA VADDRH 102 | JSR RXBYTE 103 | STA VADDRM 104 | JSR RXBYTE 105 | STA VADDRL 106 | JSR RXBYTE 107 | STA VDATA 108 | JMP MAINLOOP 109 | 110 | CMD_VWRITE2 111 | JSR RXBYTE 112 | STA VADDRH 113 | JSR RXBYTE 114 | STA VADDRM 115 | JSR RXBYTE 116 | STA VADDRL 117 | JSR RXBYTE 118 | 119 | TAX 120 | VWRITE2_LOOP 121 | JSR RXBYTE 122 | STA VDATA 123 | DEX 124 | BNE VWRITE2_LOOP 125 | 126 | JMP MAINLOOP 127 | 128 | CMD_JUMP 129 | JSR RXBYTE 130 | STA ADDRL 131 | JSR RXBYTE 132 | STA ADDRH 133 | JMP (ADDRL) 134 | 135 | ; Receive byte, result in A 136 | RXBYTE 137 | ; Check for data received 138 | LDA SSTAT 139 | AND #$08 140 | BEQ RXBYTE 141 | 142 | ; Read RX data 143 | LDA SDATA 144 | RTS 145 | 146 | ; Send byte in A 147 | TXBYTE 148 | ; Write TX data 149 | STA SDATA 150 | RTS 151 | 152 | IRQ_DUMMY 153 | RTS 154 | 155 | NMI_ENTRY 156 | JMP (NMI_HANDLER) 157 | 158 | IRQ_ENTRY 159 | JMP (IRQ_HANDLER) 160 | 161 | .dsb $FFFA - *, $ff; 162 | .word NMI_ENTRY 163 | .word RESET_ENTRY 164 | .word IRQ_ENTRY 165 | -------------------------------------------------------------------------------- /misc/c64-char-rom.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/X16Community/vera-module/6e8bea68a5a04687149e27b1b7b3726fb01405f4/misc/c64-char-rom.bin -------------------------------------------------------------------------------- /misc/font8x16.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/X16Community/vera-module/6e8bea68a5a04687149e27b1b7b3726fb01405f4/misc/font8x16.bin -------------------------------------------------------------------------------- /misc/imgconv/.gitignore: -------------------------------------------------------------------------------- 1 | .vscode/ 2 | image.bin 3 | palette.bin 4 | imgconv 5 | -------------------------------------------------------------------------------- /misc/imgconv/Makefile: -------------------------------------------------------------------------------- 1 | all: 2 | gcc -O3 -Wall -Wextra -o imgconv imgconv.c lodepng.c -------------------------------------------------------------------------------- /misc/imgconv/imgconv.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include "lodepng.h" 7 | 8 | uint16_t palette[256]; 9 | int palette_cnt = 0; 10 | 11 | int main() { 12 | uint8_t *pix8 = NULL; 13 | unsigned w, h; 14 | 15 | if (lodepng_decode32_file(&pix8, &w, &h, "../8bitguy.png") != 0) { 16 | exit(0); 17 | } 18 | 19 | printf("w: %u, h: %u\n", w, h); 20 | 21 | int num_pixels = w * h; 22 | 23 | uint8_t result[w * h]; 24 | for (int i = 0; i < num_pixels; i++) { 25 | uint16_t color = 26 | ((pix8[i * 4 + 0] >> 4) << 8) | 27 | ((pix8[i * 4 + 1] >> 4) << 4) | 28 | ((pix8[i * 4 + 2] >> 4) << 0); 29 | 30 | int idx = -1; 31 | for (int j = 0; j < palette_cnt; j++) { 32 | if (palette[j] == color) { 33 | idx = j; 34 | break; 35 | } 36 | } 37 | if (idx < 0) { 38 | if (palette_cnt >= 256) { 39 | printf("Too many colors!\n"); 40 | exit(1); 41 | } 42 | palette[palette_cnt] = color; 43 | idx = palette_cnt; 44 | palette_cnt++; 45 | } 46 | result[i] = idx; 47 | } 48 | 49 | printf("Number of colors: %d\n", palette_cnt); 50 | 51 | FILE *f = fopen("palette.bin", "wb"); 52 | fwrite(palette, 2 * 256, 1, f); 53 | fclose(f); 54 | 55 | f = fopen("image.bin", "wb"); 56 | fwrite(result, w * h, 1, f); 57 | fclose(f); 58 | 59 | return 0; 60 | } 61 | -------------------------------------------------------------------------------- /misc/tests/1bpptest/.gitignore: -------------------------------------------------------------------------------- 1 | obj/ 2 | -------------------------------------------------------------------------------- /misc/tests/1bpptest/1bpptest.s: -------------------------------------------------------------------------------- 1 | ;----------------------------------------------------------------------------- 2 | ; 1bpptest.s 3 | ;----------------------------------------------------------------------------- 4 | 5 | .include "lib.inc" 6 | 7 | ;----------------------------------------------------------------------------- 8 | ; Variables 9 | ;----------------------------------------------------------------------------- 10 | .rodata 11 | image: .incbin "img.raw" 12 | 13 | .zeropage 14 | ptr: .word 0 15 | 16 | ;----------------------------------------------------------------------------- 17 | ; Entry point 18 | ;----------------------------------------------------------------------------- 19 | .code 20 | .global entry 21 | entry: 22 | ; Init palette 23 | stz VERA_ADDR_L 24 | lda #$FA 25 | sta VERA_ADDR_M 26 | lda #$11 27 | sta VERA_ADDR_H 28 | 29 | stz VERA_DATA0 ; Idx 0: black 30 | stz VERA_DATA0 31 | lda #$FF 32 | sta VERA_DATA0 ; Idx 1: white 33 | lda #$0F 34 | sta VERA_DATA0 35 | 36 | ; Layer 0, 1bpp bitmap mode 37 | lda #$04 38 | sta VERA_L0_CONFIG 39 | stz VERA_L0_MAPBASE 40 | lda #$01 41 | sta VERA_L0_TILEBASE 42 | stz VERA_L0_HSCROLL_L 43 | stz VERA_L0_HSCROLL_H 44 | stz VERA_L0_VSCROLL_L 45 | stz VERA_L0_VSCROLL_H 46 | 47 | ; Enable layer 0 + VGA output 48 | lda #$11 49 | sta VERA_DC_VIDEO 50 | 51 | 52 | lda #image 55 | sta ptr+1 56 | 57 | stz VERA_ADDR_L 58 | stz VERA_ADDR_M 59 | lda #$10 60 | sta VERA_ADDR_H 61 | 62 | ldx #0 63 | ldy #150 64 | @again: lda (ptr) 65 | sta VERA_DATA0 66 | inc ptr 67 | bne @noinc 68 | inc ptr+1 69 | @noinc: dex 70 | bne @again 71 | dey 72 | bne @again 73 | 74 | 75 | loop: jmp loop 76 | -------------------------------------------------------------------------------- /misc/tests/1bpptest/Makefile: -------------------------------------------------------------------------------- 1 | OUT = $(OBJ_DIR)/1bpptest.prg 2 | S_SRCS += 1bpptest.s 3 | 4 | include common/Makefile.common 5 | -------------------------------------------------------------------------------- /misc/tests/1bpptest/common: -------------------------------------------------------------------------------- 1 | ../common/ -------------------------------------------------------------------------------- /misc/tests/1bpptest/img.raw: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/X16Community/vera-module/6e8bea68a5a04687149e27b1b7b3726fb01405f4/misc/tests/1bpptest/img.raw -------------------------------------------------------------------------------- /misc/tests/common/Makefile.common: -------------------------------------------------------------------------------- 1 | # 2 | # Common Makefile rules 3 | # 4 | COMMON_DIR := $(patsubst %/,%,$(dir $(lastword $(MAKEFILE_LIST)))) 5 | 6 | S_SRCS += $(COMMON_DIR)/lib.s 7 | 8 | OBJ_DIR ?= obj 9 | S_OBJS := $(addprefix $(OBJ_DIR)/, $(S_SRCS:.s=.o)) 10 | 11 | AS = ca65 12 | LD = ld65 13 | EMU ?= ~/Work/x16/x16-emulator/x16emu 14 | 15 | .PHONY: all run clean 16 | 17 | all: $(OUT) 18 | 19 | $(OUT): $(OBJ_DIR) $(S_OBJS) 20 | @echo Linking $@ 21 | @$(LD) -C $(COMMON_DIR)/x16.cfg -m $(OUT).map -o $(OUT) $(S_OBJS) 22 | 23 | $(OBJ_DIR): 24 | @mkdir -p $(dir $(S_OBJS)) 25 | 26 | $(S_OBJS): $(OBJ_DIR)/%.o: %.s 27 | @echo Assembling $< 28 | @$(AS) --cpu 65C02 -I$(COMMON_DIR) -l $@.lst -o $@ $< 29 | 30 | run: all 31 | $(EMU) $(EMU_PARAMS) -prg $(OUT) -run 32 | 33 | clean: 34 | @echo Cleaning... 35 | @rm -rf $(OUT) $(OBJ_DIR) 36 | -------------------------------------------------------------------------------- /misc/tests/common/lib.s: -------------------------------------------------------------------------------- 1 | ;----------------------------------------------------------------------------- 2 | ; lib.s 3 | ; Copyright (C) 2020 Frank van den Hoef 4 | ;----------------------------------------------------------------------------- 5 | 6 | .include "lib.inc" 7 | .global entry 8 | 9 | ;----------------------------------------------------------------------------- 10 | ; Program header and BASIC code 11 | ;----------------------------------------------------------------------------- 12 | .segment "PRGHDR" 13 | 14 | prghdr: .word @basic 15 | @basic: .word @next, 10 ; Next line pointer and current line number 16 | .byte $9E, " 2062", 0 ; SYS 2062 17 | @next: .word 0 ; End of program 18 | jmp entry 19 | 20 | 21 | .code 22 | 23 | ;----------------------------------------------------------------------------- 24 | ; vera_save 25 | ;----------------------------------------------------------------------------- 26 | .global vera_save 27 | vera_save: 28 | plx 29 | ply 30 | lda VERA_CTRL 31 | pha 32 | stz VERA_CTRL 33 | lda VERA_ADDR_L 34 | pha 35 | lda VERA_ADDR_M 36 | pha 37 | lda VERA_ADDR_H 38 | pha 39 | phy 40 | phx 41 | rts 42 | 43 | ;----------------------------------------------------------------------------- 44 | ; vera_restore 45 | ;----------------------------------------------------------------------------- 46 | .global vera_restore 47 | vera_restore: 48 | plx 49 | ply 50 | pla 51 | sta VERA_ADDR_H 52 | pla 53 | sta VERA_ADDR_M 54 | pla 55 | sta VERA_ADDR_L 56 | pla 57 | sta VERA_CTRL 58 | phy 59 | phx 60 | rts 61 | -------------------------------------------------------------------------------- /misc/tests/common/x16.cfg: -------------------------------------------------------------------------------- 1 | MEMORY { 2 | ZP: start = $0000, size = $80; 3 | RAM: start = $07FF, size = $9701; 4 | } 5 | 6 | SEGMENTS { 7 | ZEROPAGE: load = ZP, type = zp; 8 | PRGHDR: load = RAM, type = ro; 9 | CODE: load = RAM, type = ro; 10 | RODATA: load = RAM, type = ro; 11 | DATA: load = RAM, type = rw; 12 | BSS: load = RAM, type = bss, define = yes; 13 | } 14 | -------------------------------------------------------------------------------- /misc/tests/fos-rom/.gitignore: -------------------------------------------------------------------------------- 1 | obj/ 2 | font/ 3 | jumptable.inc 4 | .vscode/ 5 | -------------------------------------------------------------------------------- /misc/tests/fos-rom/Makefile: -------------------------------------------------------------------------------- 1 | OUT = $(OBJ_DIR)/fos.rom 2 | S_SRCS += main.s 3 | S_SRCS += vera.s 4 | S_SRCS += sdcard.s 5 | S_SRCS += fat32.s 6 | S_SRCS += ps2.s 7 | S_SRCS += text_display.s 8 | S_SRCS += text_input.s 9 | S_SRCS += fat32_util.s 10 | S_SRCS += cli.s 11 | S_SRCS += jumptable.s 12 | 13 | EMU_PARAMS = -sdcard ~/Work/x16/x16-emulator/disk5.img -quality nearest -scale 2 -echo 14 | 15 | COMMON_DIR := common 16 | 17 | S_SRCS += 18 | 19 | OBJ_DIR ?= obj 20 | S_OBJS := $(addprefix $(OBJ_DIR)/, $(S_SRCS:.s=.o)) 21 | 22 | AS = ca65 23 | LD = ld65 24 | EMU ?= ~/Work/x16/x16-emulator/x16emu 25 | 26 | .PHONY: all run clean flash 27 | 28 | all: $(OUT) 29 | 30 | $(OUT): $(OBJ_DIR) $(S_OBJS) 31 | @echo Linking $@ 32 | @$(LD) -C x16-rom.cfg -m $(OUT).map -o $(OUT) $(S_OBJS) 33 | cat $(OUT) $(OUT) $(OUT) $(OUT) $(OUT) $(OUT) $(OUT) $(OUT) > $(OUT).bin 34 | ./jumptable_to_inc.py 35 | 36 | $(OBJ_DIR): 37 | @mkdir -p $(dir $(S_OBJS)) 38 | 39 | $(S_OBJS): $(OBJ_DIR)/%.o: %.s 40 | @echo Assembling $< 41 | @$(AS) --cpu 65C02 -I$(COMMON_DIR) -l $@.lst -o $@ $< 42 | 43 | run: all 44 | $(EMU) $(EMU_PARAMS) -rom $(OUT).bin 45 | 46 | flash: all 47 | minipro -p SST39SF010A -w $(OUT).bin 48 | 49 | clean: 50 | @echo Cleaning... 51 | @rm -rf $(OUT) $(OBJ_DIR) 52 | 53 | .DEFAULT_GOAL := all 54 | -------------------------------------------------------------------------------- /misc/tests/fos-rom/cli.inc: -------------------------------------------------------------------------------- 1 | ;----------------------------------------------------------------------------- 2 | ; cli.inc 3 | ; Copyright (C) 2020 Frank van den Hoef 4 | ;----------------------------------------------------------------------------- 5 | 6 | ;----------------------------------------------------------------------------- 7 | ; Variables 8 | ;----------------------------------------------------------------------------- 9 | 10 | ;----------------------------------------------------------------------------- 11 | ; Functions 12 | ;----------------------------------------------------------------------------- 13 | .global call_cmd 14 | .global cli_start 15 | -------------------------------------------------------------------------------- /misc/tests/fos-rom/common: -------------------------------------------------------------------------------- 1 | ../common/ -------------------------------------------------------------------------------- /misc/tests/fos-rom/fat32.inc: -------------------------------------------------------------------------------- 1 | ;----------------------------------------------------------------------------- 2 | ; fat32.inc 3 | ; Copyright (C) 2020 Frank van den Hoef 4 | ;----------------------------------------------------------------------------- 5 | 6 | .struct dirent 7 | name .res 13 8 | attributes .byte 9 | size .dword 10 | cluster .dword 11 | .endstruct 12 | 13 | ; Maximum number of open files. 14 | FAT32_CONTEXTS = 3 ; Set to 0/1 to disable contexts, max value: 8 15 | 16 | ;----------------------------------------------------------------------------- 17 | ; Functions 18 | ;----------------------------------------------------------------------------- 19 | 20 | ; Global operations 21 | .global fat32_init ; Initialize FAT32 driver and SD card 22 | .global fat32_set_context ; Set current context to idx in A (0..FAT32_CONTEXTS-1) 23 | .global fat32_get_free_space ; Get free space, result in KiB in fat32_size (32-bit) 24 | 25 | ; Directory operations 26 | .global fat32_open_cwd ; Open current working directory 27 | .global fat32_read_dirent ; Read directory entry, result in fat32_dirent 28 | 29 | .global fat32_chdir ; Change to directory with name in fat32_ptr 30 | .global fat32_rename ; Rename file with name in fat32_ptr to fat32_ptr2 31 | .global fat32_delete ; Delete file with name in fat32_ptr 32 | .global fat32_mkdir ; Create new directory with name in fat32_ptr 33 | .global fat32_rmdir ; Delete empty directory with name in fat32_ptr 34 | 35 | ; File operations 36 | .global fat32_open ; Open file with name in fat32_ptr 37 | .global fat32_create ; Create file with name in fat32_ptr (delete existing file) 38 | .global fat32_close ; Close file 39 | .global fat32_read_byte ; Read byte, result in A 40 | .global fat32_read ; Read fat32_size (16-bit) bytes to fat32_ptr 41 | .global fat32_write_byte ; Write byte in A 42 | .global fat32_write ; Write fat32_size (16-bit) bytes from fat32_ptr 43 | 44 | ; TODO: 45 | ; fat32_seek 46 | 47 | ; Low level fast API 48 | .global fat32_next_sector 49 | -------------------------------------------------------------------------------- /misc/tests/fos-rom/fat32_util.inc: -------------------------------------------------------------------------------- 1 | ;----------------------------------------------------------------------------- 2 | ; fat32_util.inc 3 | ; Copyright (C) 2020 Frank van den Hoef 4 | ;----------------------------------------------------------------------------- 5 | 6 | ;----------------------------------------------------------------------------- 7 | ; Variables 8 | ;----------------------------------------------------------------------------- 9 | 10 | ;----------------------------------------------------------------------------- 11 | ; Functions 12 | ;----------------------------------------------------------------------------- 13 | .global print_dirent 14 | -------------------------------------------------------------------------------- /misc/tests/fos-rom/fat32_util.s: -------------------------------------------------------------------------------- 1 | ;----------------------------------------------------------------------------- 2 | ; fat32_util.s 3 | ; Copyright (C) 2020 Frank van den Hoef 4 | ;----------------------------------------------------------------------------- 5 | 6 | .include "fat32_util.inc" 7 | .include "lib.inc" 8 | .include "fat32.inc" 9 | .include "text_display.inc" 10 | .include "text_input.inc" 11 | 12 | ;----------------------------------------------------------------------------- 13 | ; Variables 14 | ;----------------------------------------------------------------------------- 15 | .bss 16 | 17 | .code 18 | 19 | ;----------------------------------------------------------------------------- 20 | ; print_dirent 21 | ;----------------------------------------------------------------------------- 22 | .proc print_dirent 23 | ; Print file name 24 | ldx #0 25 | : lda fat32_dirent + dirent::name, x 26 | beq :+ 27 | jsr to_lower 28 | jsr putchar 29 | inx 30 | bne :- 31 | : 32 | ; Pad spaces 33 | : cpx #13 34 | beq :+ 35 | inx 36 | lda #' ' 37 | jsr putchar 38 | bra :- 39 | : 40 | ; Print attributes 41 | lda fat32_dirent + dirent::attributes 42 | bit #$10 43 | bne dir 44 | 45 | ; Print size 46 | set32 val32, fat32_dirent + dirent::size 47 | lda #' ' 48 | sta padch 49 | jsr print_val32 50 | 51 | bra cluster 52 | 53 | dir: ldy #0 54 | : lda dirstr, y 55 | beq :+ 56 | jsr putchar 57 | iny 58 | bra :- 59 | : 60 | cluster: 61 | .if 0 62 | ; Spacing 63 | lda #' ' 64 | jsr putchar 65 | 66 | ; Print cluster 67 | ; set32 val32, fat32_dirent + dirent::cluster 68 | ; lda #0 69 | ; sta padch 70 | ; jsr print_val32 71 | 72 | ldx #3 73 | : lda fat32_dirent + dirent::cluster, x 74 | jsr puthex 75 | dex 76 | cpx #$FF 77 | bne :- 78 | .endif 79 | 80 | ; New line 81 | lda #10 82 | jsr putchar 83 | 84 | rts 85 | 86 | dirstr: .byte " ", 0 87 | .endproc 88 | -------------------------------------------------------------------------------- /misc/tests/fos-rom/font8x8.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/X16Community/vera-module/6e8bea68a5a04687149e27b1b7b3726fb01405f4/misc/tests/fos-rom/font8x8.bin -------------------------------------------------------------------------------- /misc/tests/fos-rom/jumptable.s: -------------------------------------------------------------------------------- 1 | ;----------------------------------------------------------------------------- 2 | ; jumptable.s 3 | ; Copyright (C) 2020 Frank van den Hoef 4 | ;----------------------------------------------------------------------------- 5 | 6 | .include "cli.inc" 7 | .include "lib.inc" 8 | .include "text_display.inc" 9 | .include "text_input.inc" 10 | .include "sdcard.inc" 11 | .include "fat32.inc" 12 | .include "fat32_util.inc" 13 | .include "ps2.inc" 14 | 15 | .segment "JUMPTABLE" 16 | jumptable: 17 | ; PS/2 functions 18 | jmp ps2_getkey 19 | 20 | ; SD card functions 21 | jmp sdcard_init 22 | jmp sdcard_read_sector 23 | jmp sdcard_write_sector 24 | 25 | ; FAT32 functions 26 | jmp fat32_init 27 | jmp fat32_set_context 28 | jmp fat32_get_free_space 29 | jmp fat32_open_cwd 30 | jmp fat32_read_dirent 31 | jmp fat32_chdir 32 | jmp fat32_rename 33 | jmp fat32_delete 34 | jmp fat32_mkdir 35 | jmp fat32_rmdir 36 | jmp fat32_open 37 | jmp fat32_create 38 | jmp fat32_close 39 | jmp fat32_read_byte 40 | jmp fat32_read 41 | jmp fat32_write_byte 42 | jmp fat32_write 43 | jmp fat32_next_sector 44 | jmp print_dirent 45 | 46 | ; Text display functions 47 | jmp clear_screen 48 | jmp putchar 49 | jmp putstr 50 | jmp puthex 51 | jmp hexdump 52 | jmp print_val32 53 | 54 | ; Text input functions 55 | jmp getchar 56 | jmp to_upper 57 | jmp to_lower 58 | -------------------------------------------------------------------------------- /misc/tests/fos-rom/jumptable_to_inc.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | with open('jumptable.s', 'r') as f: 4 | lines = f.readlines() 5 | 6 | labels = [] 7 | longest_label = 0 8 | 9 | for line in lines: 10 | line = line.strip() 11 | if line.startswith('jmp'): 12 | lbl = line.split()[1] 13 | longest_label = max(longest_label, len(lbl)) 14 | if len(lbl) > longest_label: 15 | longest_label = len(lbl) 16 | labels.append(lbl) 17 | 18 | fmt = '{:' + str(longest_label) + 's} = ${:04X}\n' 19 | 20 | with open('jumptable.inc', 'w') as f: 21 | addr = 0xFF00 22 | 23 | for lbl in labels: 24 | f.write(fmt.format(lbl, addr)) 25 | addr = addr + 3 26 | -------------------------------------------------------------------------------- /misc/tests/fos-rom/main.s: -------------------------------------------------------------------------------- 1 | ;----------------------------------------------------------------------------- 2 | ; main.s 3 | ; Copyright (C) 2020 Frank van den Hoef 4 | ;----------------------------------------------------------------------------- 5 | 6 | .include "lib.inc" 7 | .include "text_display.inc" 8 | .include "fat32.inc" 9 | .include "text_input.inc" 10 | .include "cli.inc" 11 | .include "ps2.inc" 12 | .include "vera.inc" 13 | 14 | ;----------------------------------------------------------------------------- 15 | ; Variables 16 | ;----------------------------------------------------------------------------- 17 | .rodata 18 | .bss 19 | .zeropage 20 | 21 | .segment "VECTORS" 22 | .word nmi_entry 23 | .word reset_entry 24 | .word irq_entry 25 | 26 | .bss 27 | .code 28 | 29 | irq_entry: rti 30 | 31 | ;----------------------------------------------------------------------------- 32 | ; main 33 | ;----------------------------------------------------------------------------- 34 | .proc main 35 | ; Init text display 36 | jsr text_display_init 37 | 38 | ; Print start message 39 | print_str str_message 40 | 41 | ; Start command line interface 42 | jsr cli_start 43 | rts 44 | 45 | str_message: 46 | .byte 10,"** Frank's X16 OS **",10,10, 0 47 | .endproc 48 | 49 | ;----------------------------------------------------------------------------- 50 | ; Entry point 51 | ;----------------------------------------------------------------------------- 52 | .import __BSS_LOAD__ 53 | .import __BSS_SIZE__ 54 | 55 | .proc reset_entry 56 | ; Disable IRQs 57 | sei 58 | stz VIA1_IER 59 | stz VIA2_IER 60 | lda #$FF 61 | sta VIA2_IFR 62 | 63 | ; Clear decimal mode 64 | cld 65 | 66 | ; Clear BSS 67 | set16_val DST_PTR, $200 68 | set16_val SRC_PTR, $800 69 | : lda #0 70 | sta (DST_PTR) 71 | inc16 DST_PTR 72 | cmp16 DST_PTR, SRC_PTR, :- 73 | 74 | ;--------------------------------------------------------------------- 75 | ; Init VIAs 76 | ;--------------------------------------------------------------------- 77 | 78 | ; VIA1 port A: RAM bank 79 | stz VIA1_ORA ; RAM bank to 0 80 | lda $FF ; All output 81 | sta VIA1_DDRA 82 | 83 | ; VIA1 port B: ROM bank (+ IEC port) 84 | stz VIA2_ORB ; ROM bank to 0 85 | lda $07 ; ROM bank bits to output 86 | sta VIA2_DDRB 87 | 88 | ; VIA2 port A: PS/2 (+ NES ports) 89 | stz VIA2_DDRA 90 | 91 | ; VIA2 port B: user port 92 | stz VIA2_DDRB 93 | 94 | ; Configure NMI for PS/2 clock 95 | stz VIA2_PCR 96 | lda #$82 97 | sta VIA2_IER 98 | 99 | 100 | ; Wait for VERA to be ready 101 | vera_wait_ready: 102 | lda #42 103 | sta VERA_ADDR_L 104 | lda VERA_ADDR_L 105 | cmp #42 106 | bne vera_wait_ready 107 | 108 | ; Init display 109 | lda #1 110 | sta vera_output_mode 111 | jsr vera_reset_settings 112 | 113 | ; Call main 114 | jsr main 115 | loop: bra loop 116 | .endproc 117 | -------------------------------------------------------------------------------- /misc/tests/fos-rom/ps2.inc: -------------------------------------------------------------------------------- 1 | ;----------------------------------------------------------------------------- 2 | ; ps2.inc 3 | ; Copyright (C) 2020 Frank van den Hoef 4 | ;----------------------------------------------------------------------------- 5 | 6 | ;----------------------------------------------------------------------------- 7 | ; Variables 8 | ;----------------------------------------------------------------------------- 9 | 10 | ;----------------------------------------------------------------------------- 11 | ; Functions 12 | ;----------------------------------------------------------------------------- 13 | .global nmi_entry 14 | 15 | .global ps2_getkey 16 | -------------------------------------------------------------------------------- /misc/tests/fos-rom/sdcard.inc: -------------------------------------------------------------------------------- 1 | ;----------------------------------------------------------------------------- 2 | ; sdcard.inc 3 | ; Copyright (C) 2020 Frank van den Hoef 4 | ;----------------------------------------------------------------------------- 5 | 6 | ;----------------------------------------------------------------------------- 7 | ; Functions 8 | ;----------------------------------------------------------------------------- 9 | .global sdcard_init 10 | .global sdcard_read_sector 11 | .global sdcard_write_sector 12 | -------------------------------------------------------------------------------- /misc/tests/fos-rom/text_display.inc: -------------------------------------------------------------------------------- 1 | ;----------------------------------------------------------------------------- 2 | ; text_display.inc 3 | ; Copyright (C) 2020 Frank van den Hoef 4 | ;----------------------------------------------------------------------------- 5 | 6 | ;----------------------------------------------------------------------------- 7 | ; Macros 8 | ;----------------------------------------------------------------------------- 9 | 10 | .macro print_str str 11 | .local l1, l2 12 | ldy #0 13 | l1: lda str, y 14 | beq l2 15 | jsr putchar 16 | iny 17 | bra l1 18 | l2: 19 | .endmacro 20 | 21 | ;----------------------------------------------------------------------------- 22 | ; Functions 23 | ;----------------------------------------------------------------------------- 24 | .global text_display_init 25 | .global clear_screen 26 | .global putchar 27 | .global putstr 28 | .global puthex 29 | .global hexdump 30 | .global print_val32 31 | -------------------------------------------------------------------------------- /misc/tests/fos-rom/text_input.inc: -------------------------------------------------------------------------------- 1 | ;----------------------------------------------------------------------------- 2 | ; text_input.inc 3 | ; Copyright (C) 2020 Frank van den Hoef 4 | ;----------------------------------------------------------------------------- 5 | 6 | ;----------------------------------------------------------------------------- 7 | ; Variables 8 | ;----------------------------------------------------------------------------- 9 | MAX_LINE_LEN = 78 10 | 11 | .global line_len 12 | .global line_buf 13 | .global line_start 14 | 15 | ;----------------------------------------------------------------------------- 16 | ; Functions 17 | ;----------------------------------------------------------------------------- 18 | .global getchar 19 | .global getline 20 | .global to_upper 21 | .global to_lower 22 | .global skip_spaces 23 | .global first_word_to_upper 24 | .global terminate_and_skip_to_next_word 25 | -------------------------------------------------------------------------------- /misc/tests/fos-rom/vera.inc: -------------------------------------------------------------------------------- 1 | ;----------------------------------------------------------------------------- 2 | ; vera.inc 3 | ; Copyright (C) 2020 Frank van den Hoef 4 | ;----------------------------------------------------------------------------- 5 | 6 | ;----------------------------------------------------------------------------- 7 | ; Variables 8 | ;----------------------------------------------------------------------------- 9 | .global vera_output_mode 10 | 11 | ;----------------------------------------------------------------------------- 12 | ; Functions 13 | ;----------------------------------------------------------------------------- 14 | .global vera_reset_settings 15 | -------------------------------------------------------------------------------- /misc/tests/fos-rom/x16-rom.cfg: -------------------------------------------------------------------------------- 1 | MEMORY { 2 | ZP: start = $00E0, size = $20; 3 | # RAM: start = $0200, size = $9D00; 4 | RAM: start = $0200, size = $0800; 5 | ROM: start = $C000, size = $4000; 6 | } 7 | 8 | SEGMENTS { 9 | ZEROPAGE: load = ZP, type = zp; 10 | BSS: load = RAM, type = bss, start=$429, define = yes; 11 | CODE: load = ROM, type = ro; 12 | RODATA: load = ROM, type = ro; 13 | JUMPTABLE: load = ROM, type = ro, start = $FF00; 14 | VECTORS: load = ROM, type = ro, start = $FFFA; 15 | } 16 | -------------------------------------------------------------------------------- /misc/tests/fos-test/.gitignore: -------------------------------------------------------------------------------- 1 | obj/ 2 | disk.img 3 | jumptable.inc 4 | -------------------------------------------------------------------------------- /misc/tests/fos-test/Makefile: -------------------------------------------------------------------------------- 1 | OUT = $(OBJ_DIR)/fostest.prg 2 | S_SRCS += main.s 3 | 4 | OBJ_DIR ?= obj 5 | S_OBJS := $(addprefix $(OBJ_DIR)/, $(S_SRCS:.s=.o)) 6 | 7 | AS = ca65 8 | LD = ld65 9 | EMU ?= ~/Work/x16/x16-emulator/x16emu 10 | EMU_PARAMS = -rom ../fos-rom/obj/fos.rom -sdcard disk.img -quality nearest -scale 2 -echo 11 | 12 | .PHONY: all run clean 13 | 14 | all: $(OUT) 15 | 16 | $(OUT): $(OBJ_DIR) $(S_OBJS) 17 | @echo Linking $@ 18 | @$(LD) -C x16.cfg -m $(OUT).map -o $(OUT) $(S_OBJS) 19 | 20 | $(OBJ_DIR): 21 | @mkdir -p $(dir $(S_OBJS)) 22 | 23 | $(S_OBJS): $(OBJ_DIR)/%.o: %.s 24 | @echo Assembling $< 25 | @$(AS) --cpu 65C02 -l $@.lst -o $@ $< 26 | 27 | run: all disk.img 28 | -mdel -i disk.img@@1M $(notdir $(OUT)) 29 | mcopy -i disk.img@@1M $(OUT) :: 30 | $(EMU) $(EMU_PARAMS) 31 | 32 | clean: 33 | @echo Cleaning... 34 | @rm -rf $(OUT) $(OBJ_DIR) 35 | 36 | disk.img: 37 | # Generate empty disk image 38 | dd if=/dev/zero of=diskhdr.img bs=1M count=128 39 | # Partition disk image with one FAT32 partition 40 | echo "o\nn\np\n1\n2048\n\nt\nc\nw" | /sbin/fdisk diskhdr.img 41 | # Copy FAT32 partition to separate file 42 | dd if=diskhdr.img of=diskfs.img bs=1M skip=1 43 | # Truncate to only partition header 44 | truncate -s 1M diskhdr.img 45 | # Format FAT32 partition 46 | /sbin/mkfs.vfat -F 32 diskfs.img 47 | # Concatenate header with partition table 48 | cat diskhdr.img diskfs.img > disk.img 49 | # Remove temporary files 50 | rm -f diskhdr.img diskfs.img 51 | -------------------------------------------------------------------------------- /misc/tests/fos-test/Makefile.common: -------------------------------------------------------------------------------- 1 | # 2 | # Common Makefile rules 3 | # 4 | COMMON_DIR := $(patsubst %/,%,$(dir $(lastword $(MAKEFILE_LIST)))) 5 | 6 | S_SRCS += $(COMMON_DIR)/lib.s 7 | 8 | OBJ_DIR ?= obj 9 | S_OBJS := $(addprefix $(OBJ_DIR)/, $(S_SRCS:.s=.o)) 10 | 11 | AS = ca65 12 | LD = ld65 13 | EMU ?= ~/Work/x16/x16-emulator/x16emu 14 | 15 | .PHONY: all run clean 16 | 17 | all: $(OUT) 18 | 19 | $(OUT): $(OBJ_DIR) $(S_OBJS) 20 | @echo Linking $@ 21 | @$(LD) -C $(COMMON_DIR)/x16.cfg -m $(OUT).map -o $(OUT) $(S_OBJS) 22 | 23 | $(OBJ_DIR): 24 | @mkdir -p $(dir $(S_OBJS)) 25 | 26 | $(S_OBJS): $(OBJ_DIR)/%.o: %.s 27 | @echo Assembling $< 28 | @$(AS) --cpu 65C02 -I$(COMMON_DIR) -l $@.lst -o $@ $< 29 | 30 | run: all 31 | $(EMU) $(EMU_PARAMS) -prg $(OUT) -run 32 | 33 | clean: 34 | @echo Cleaning... 35 | @rm -rf $(OUT) $(OBJ_DIR) 36 | -------------------------------------------------------------------------------- /misc/tests/fos-test/main.s: -------------------------------------------------------------------------------- 1 | ;----------------------------------------------------------------------------- 2 | ; fostest.s 3 | ;----------------------------------------------------------------------------- 4 | 5 | .include "lib.inc" 6 | .include "jumptable.inc" 7 | 8 | ;----------------------------------------------------------------------------- 9 | ; Variables 10 | ;----------------------------------------------------------------------------- 11 | .rodata 12 | .bss 13 | .zeropage 14 | 15 | .segment "HDR" 16 | .byte "EXEs" ; Simple executable 17 | 18 | ;----------------------------------------------------------------------------- 19 | ; Entry point 20 | ;----------------------------------------------------------------------------- 21 | .code 22 | .global entry 23 | entry: 24 | ; jsr clear_screen 25 | ; lda #'!' 26 | ; jsr putchar 27 | 28 | stz VERA_ADDR_L 29 | stz VERA_ADDR_M 30 | lda #$10 31 | sta VERA_ADDR_H 32 | 33 | ldx #0 34 | lda #'A' 35 | 36 | : sta VERA_DATA0 37 | stx VERA_DATA0 38 | inx 39 | cpx #16 40 | bne :- 41 | 42 | 43 | : bra :- 44 | 45 | rts 46 | -------------------------------------------------------------------------------- /misc/tests/fos-test/regs.inc: -------------------------------------------------------------------------------- 1 | ../fos-rom/common/regs.inc -------------------------------------------------------------------------------- /misc/tests/fos-test/x16.cfg: -------------------------------------------------------------------------------- 1 | MEMORY { 2 | ZP: start = $0000, size = $F0; 3 | HDR: start = $07FC, size = $4; 4 | RAM: start = $0800, size = $9D00; 5 | } 6 | 7 | SEGMENTS { 8 | ZEROPAGE: load = ZP, type = zp; 9 | HDR: load = HDR, type = ro; 10 | CODE: load = RAM, type = ro; 11 | RODATA: load = RAM, type = ro; 12 | DATA: load = RAM, type = rw; 13 | BSS: load = RAM, type = bss, define = yes; 14 | } 15 | -------------------------------------------------------------------------------- /misc/tests/fos/.gitignore: -------------------------------------------------------------------------------- 1 | obj/ 2 | font/ 3 | -------------------------------------------------------------------------------- /misc/tests/fos/Makefile: -------------------------------------------------------------------------------- 1 | OUT = $(OBJ_DIR)/fos.prg 2 | S_SRCS += main.s 3 | S_SRCS += sdcard.s 4 | S_SRCS += fat32.s 5 | S_SRCS += text_display.s 6 | S_SRCS += text_input.s 7 | S_SRCS += fat32_util.s 8 | S_SRCS += cli.s 9 | 10 | EMU_PARAMS = -sdcard ~/Work/x16/x16-emulator/disk5.img -quality nearest -scale 2 -echo 11 | 12 | install: all 13 | cp $(OUT) /media/frank/X16/ 14 | sync 15 | umount /media/frank/X16/ 16 | 17 | include common/Makefile.common 18 | 19 | .DEFAULT_GOAL := all 20 | -------------------------------------------------------------------------------- /misc/tests/fos/cli.inc: -------------------------------------------------------------------------------- 1 | ;----------------------------------------------------------------------------- 2 | ; cli.inc 3 | ; Copyright (C) 2020 Frank van den Hoef 4 | ;----------------------------------------------------------------------------- 5 | 6 | ;----------------------------------------------------------------------------- 7 | ; Variables 8 | ;----------------------------------------------------------------------------- 9 | 10 | ;----------------------------------------------------------------------------- 11 | ; Functions 12 | ;----------------------------------------------------------------------------- 13 | .global call_cmd 14 | .global cli_start 15 | -------------------------------------------------------------------------------- /misc/tests/fos/common: -------------------------------------------------------------------------------- 1 | ../common/ -------------------------------------------------------------------------------- /misc/tests/fos/fat32.inc: -------------------------------------------------------------------------------- 1 | ;----------------------------------------------------------------------------- 2 | ; fat32.inc 3 | ; Copyright (C) 2020 Frank van den Hoef 4 | ;----------------------------------------------------------------------------- 5 | 6 | .struct dirent 7 | name .res 13 8 | attributes .byte 9 | size .dword 10 | cluster .dword 11 | .endstruct 12 | 13 | ; Maximum number of open files. 14 | FAT32_CONTEXTS = 3 ; Set to 0/1 to disable contexts, max value: 8 15 | 16 | ;----------------------------------------------------------------------------- 17 | ; Variables 18 | ;----------------------------------------------------------------------------- 19 | .globalzp fat32_ptr ; Buffer pointer for various functions 20 | .globalzp fat32_ptr2 ; Buffer pointer for various functions 21 | .global fat32_size ; 16/32-bit value, used to pass retrieve sizes 22 | .global fat32_dirent ; Directory entry result for fat32_read_dirent (struct dirent) 23 | 24 | ; Low level 25 | .global fat32_cwd_cluster ; Cluster of current working directory (can be used to save and restore working directory by user) 26 | .global sector_buffer ; Current sector buffer (can be used with fat32_next_sector) 27 | 28 | ;----------------------------------------------------------------------------- 29 | ; Functions 30 | ;----------------------------------------------------------------------------- 31 | 32 | ; Global operations 33 | .global fat32_init ; Initialize FAT32 driver and SD card 34 | .global fat32_set_context ; Set current context to idx in A (0..FAT32_CONTEXTS-1) 35 | .global fat32_get_free_space ; Get free space, result in KiB in fat32_size (32-bit) 36 | 37 | ; Directory operations 38 | .global fat32_open_cwd ; Open current working directory 39 | .global fat32_read_dirent ; Read directory entry, result in fat32_dirent 40 | 41 | .global fat32_chdir ; Change to directory with name in fat32_ptr 42 | .global fat32_rename ; Rename file with name in fat32_ptr to fat32_ptr2 43 | .global fat32_delete ; Delete file with name in fat32_ptr 44 | .global fat32_mkdir ; Create new directory with name in fat32_ptr 45 | .global fat32_rmdir ; Delete empty directory with name in fat32_ptr 46 | 47 | ; File operations 48 | .global fat32_open ; Open file with name in fat32_ptr 49 | .global fat32_create ; Create file with name in fat32_ptr (delete existing file) 50 | .global fat32_close ; Close file 51 | .global fat32_read_byte ; Read byte, result in A 52 | .global fat32_read ; Read fat32_size (16-bit) bytes to fat32_ptr 53 | .global fat32_write_byte ; Write byte in A 54 | .global fat32_write ; Write fat32_size (16-bit) bytes from fat32_ptr 55 | 56 | ; TODO: 57 | ; fat32_seek 58 | 59 | ; Low level fast API 60 | .global fat32_next_sector 61 | -------------------------------------------------------------------------------- /misc/tests/fos/fat32_util.inc: -------------------------------------------------------------------------------- 1 | ;----------------------------------------------------------------------------- 2 | ; fat32_util.inc 3 | ; Copyright (C) 2020 Frank van den Hoef 4 | ;----------------------------------------------------------------------------- 5 | 6 | ;----------------------------------------------------------------------------- 7 | ; Variables 8 | ;----------------------------------------------------------------------------- 9 | 10 | ;----------------------------------------------------------------------------- 11 | ; Functions 12 | ;----------------------------------------------------------------------------- 13 | .global print_dirent 14 | -------------------------------------------------------------------------------- /misc/tests/fos/fat32_util.s: -------------------------------------------------------------------------------- 1 | ;----------------------------------------------------------------------------- 2 | ; fat32_util.s 3 | ; Copyright (C) 2020 Frank van den Hoef 4 | ;----------------------------------------------------------------------------- 5 | 6 | .include "fat32_util.inc" 7 | .include "lib.inc" 8 | .include "fat32.inc" 9 | .include "text_display.inc" 10 | .include "text_input.inc" 11 | 12 | ;----------------------------------------------------------------------------- 13 | ; Variables 14 | ;----------------------------------------------------------------------------- 15 | .bss 16 | 17 | .code 18 | 19 | ;----------------------------------------------------------------------------- 20 | ; print_dirent 21 | ;----------------------------------------------------------------------------- 22 | .proc print_dirent 23 | ; Print file name 24 | ldx #0 25 | : lda fat32_dirent + dirent::name, x 26 | beq :+ 27 | jsr to_lower 28 | jsr putchar 29 | inx 30 | bne :- 31 | : 32 | ; Pad spaces 33 | : cpx #13 34 | beq :+ 35 | inx 36 | lda #' ' 37 | jsr putchar 38 | bra :- 39 | : 40 | ; Print attributes 41 | lda fat32_dirent + dirent::attributes 42 | bit #$10 43 | bne dir 44 | 45 | ; Print size 46 | set32 val32, fat32_dirent + dirent::size 47 | lda #' ' 48 | sta padch 49 | jsr print_val32 50 | 51 | bra cluster 52 | 53 | dir: ldy #0 54 | : lda dirstr, y 55 | beq :+ 56 | jsr putchar 57 | iny 58 | bra :- 59 | : 60 | cluster: 61 | .if 0 62 | ; Spacing 63 | lda #' ' 64 | jsr putchar 65 | 66 | ; Print cluster 67 | ; set32 val32, fat32_dirent + dirent::cluster 68 | ; lda #0 69 | ; sta padch 70 | ; jsr print_val32 71 | 72 | ldx #3 73 | : lda fat32_dirent + dirent::cluster, x 74 | jsr puthex 75 | dex 76 | cpx #$FF 77 | bne :- 78 | .endif 79 | 80 | ; New line 81 | lda #10 82 | jsr putchar 83 | 84 | rts 85 | 86 | dirstr: .byte " ", 0 87 | .endproc 88 | -------------------------------------------------------------------------------- /misc/tests/fos/font8x8.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/X16Community/vera-module/6e8bea68a5a04687149e27b1b7b3726fb01405f4/misc/tests/fos/font8x8.bin -------------------------------------------------------------------------------- /misc/tests/fos/main.s: -------------------------------------------------------------------------------- 1 | ;----------------------------------------------------------------------------- 2 | ; main.s 3 | ; Copyright (C) 2020 Frank van den Hoef 4 | ;----------------------------------------------------------------------------- 5 | 6 | .include "lib.inc" 7 | .include "text_display.inc" 8 | .include "fat32.inc" 9 | .include "text_input.inc" 10 | .include "cli.inc" 11 | 12 | ;----------------------------------------------------------------------------- 13 | ; Variables 14 | ;----------------------------------------------------------------------------- 15 | .rodata 16 | .bss 17 | .zeropage 18 | .code 19 | 20 | ;----------------------------------------------------------------------------- 21 | ; main 22 | ;----------------------------------------------------------------------------- 23 | .proc main 24 | ; Init text display 25 | jsr text_display_init 26 | 27 | ; Print start message 28 | print_str str_message 29 | 30 | ; Start command line interface 31 | jsr cli_start 32 | rts 33 | 34 | str_message: 35 | .byte 10,"** Frank's X16 OS **",10,10, 0 36 | .endproc 37 | 38 | ;----------------------------------------------------------------------------- 39 | ; Entry point 40 | ;----------------------------------------------------------------------------- 41 | .import __BSS_LOAD__ 42 | .import __BSS_SIZE__ 43 | 44 | .global entry 45 | .proc entry 46 | ; Switch to ISO mode 47 | lda #15 48 | jsr $FFD2 49 | 50 | ; Disable display 51 | stz VERA_CTRL 52 | lda VERA_DC_VIDEO 53 | and #7 54 | sta VERA_DC_VIDEO 55 | 56 | ; Clear BSS 57 | set16_val DST_PTR, __BSS_LOAD__ 58 | add16_val SRC_PTR, DST_PTR, __BSS_SIZE__ 59 | : lda #0 60 | sta (DST_PTR) 61 | inc16 DST_PTR 62 | cmp16 DST_PTR, SRC_PTR, :- 63 | 64 | ; Call main 65 | jsr main 66 | loop: bra loop 67 | .endproc 68 | -------------------------------------------------------------------------------- /misc/tests/fos/sdcard.inc: -------------------------------------------------------------------------------- 1 | ;----------------------------------------------------------------------------- 2 | ; sdcard.inc 3 | ; Copyright (C) 2020 Frank van den Hoef 4 | ;----------------------------------------------------------------------------- 5 | 6 | ;----------------------------------------------------------------------------- 7 | ; Variables 8 | ;----------------------------------------------------------------------------- 9 | .global sector_buffer ; Sector buffer 10 | .global sector_buffer_end 11 | .global sector_lba ; LBA of sector to read/write 12 | 13 | ;----------------------------------------------------------------------------- 14 | ; Functions 15 | ;----------------------------------------------------------------------------- 16 | .global sdcard_init 17 | .global sdcard_read_sector 18 | .global sdcard_write_sector 19 | -------------------------------------------------------------------------------- /misc/tests/fos/text_display.inc: -------------------------------------------------------------------------------- 1 | ;----------------------------------------------------------------------------- 2 | ; text_display.inc 3 | ; Copyright (C) 2020 Frank van den Hoef 4 | ;----------------------------------------------------------------------------- 5 | 6 | ;----------------------------------------------------------------------------- 7 | ; Variables 8 | ;----------------------------------------------------------------------------- 9 | .global val32 10 | .global padch 11 | 12 | ;----------------------------------------------------------------------------- 13 | ; Macros 14 | ;----------------------------------------------------------------------------- 15 | 16 | .macro print_str str 17 | .local l1, l2 18 | ldy #0 19 | l1: lda str, y 20 | beq l2 21 | jsr putchar 22 | iny 23 | bra l1 24 | l2: 25 | .endmacro 26 | 27 | ;----------------------------------------------------------------------------- 28 | ; Functions 29 | ;----------------------------------------------------------------------------- 30 | .global text_display_init 31 | .global clear_screen 32 | .global putchar 33 | .global putstr 34 | .global puthex 35 | .global hexdump 36 | .global print_val32 37 | -------------------------------------------------------------------------------- /misc/tests/fos/text_input.inc: -------------------------------------------------------------------------------- 1 | ;----------------------------------------------------------------------------- 2 | ; text_input.inc 3 | ; Copyright (C) 2020 Frank van den Hoef 4 | ;----------------------------------------------------------------------------- 5 | 6 | ;----------------------------------------------------------------------------- 7 | ; Variables 8 | ;----------------------------------------------------------------------------- 9 | MAX_LINE_LEN = 78 10 | 11 | .global line_len 12 | .global line_buf 13 | .global line_start 14 | 15 | ;----------------------------------------------------------------------------- 16 | ; Functions 17 | ;----------------------------------------------------------------------------- 18 | .global getchar 19 | .global getline 20 | .global to_upper 21 | .global to_lower 22 | .global skip_spaces 23 | .global first_word_to_upper 24 | .global terminate_and_skip_to_next_word 25 | -------------------------------------------------------------------------------- /misc/tests/pcmtest/.gitignore: -------------------------------------------------------------------------------- 1 | obj/ 2 | -------------------------------------------------------------------------------- /misc/tests/pcmtest/Makefile: -------------------------------------------------------------------------------- 1 | OUT = $(OBJ_DIR)/pcmtest.prg 2 | S_SRCS += pcmtest.s 3 | 4 | include common/Makefile.common 5 | -------------------------------------------------------------------------------- /misc/tests/pcmtest/common: -------------------------------------------------------------------------------- 1 | ../common/ -------------------------------------------------------------------------------- /misc/tests/pcmtest/okay-bye.raw: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/X16Community/vera-module/6e8bea68a5a04687149e27b1b7b3726fb01405f4/misc/tests/pcmtest/okay-bye.raw -------------------------------------------------------------------------------- /misc/tests/pcmtest/pcmtest.s: -------------------------------------------------------------------------------- 1 | ;----------------------------------------------------------------------------- 2 | ; pcmtest.s 3 | ;----------------------------------------------------------------------------- 4 | 5 | .include "lib.inc" 6 | 7 | ;----------------------------------------------------------------------------- 8 | ; Variables 9 | ;----------------------------------------------------------------------------- 10 | .rodata 11 | sample: 12 | .incbin "okay-bye.raw" 13 | sample_end: 14 | 15 | .zeropage 16 | audio_ptr: 17 | .word 0 18 | audio_end: 19 | .word 0 20 | 21 | ;----------------------------------------------------------------------------- 22 | ; Entry point 23 | ;----------------------------------------------------------------------------- 24 | .code 25 | .global entry 26 | entry: 27 | lda #$0F 28 | sta VERA_AUDIO_CTRL 29 | lda #64 30 | sta VERA_AUDIO_RATE 31 | 32 | @play_sample: 33 | lda #sample 36 | sta audio_ptr+1 37 | lda #sample_end 40 | sta audio_end+1 41 | 42 | @sample_loop: 43 | lda audio_ptr 44 | cmp audio_end 45 | bne @not_done 46 | lda audio_ptr+1 47 | cmp audio_end+1 48 | beq @done 49 | @not_done: 50 | 51 | @wait: bit VERA_AUDIO_CTRL 52 | bmi @wait 53 | 54 | lda (audio_ptr) 55 | sta VERA_AUDIO_DATA 56 | 57 | inc audio_ptr 58 | bne @sample_loop 59 | inc audio_ptr+1 60 | bra @sample_loop 61 | 62 | @done: inc VERA_AUDIO_RATE 63 | jmp @play_sample 64 | 65 | loop: jmp loop 66 | -------------------------------------------------------------------------------- /misc/tests/psgtest/.gitignore: -------------------------------------------------------------------------------- 1 | obj/ 2 | -------------------------------------------------------------------------------- /misc/tests/psgtest/Makefile: -------------------------------------------------------------------------------- 1 | OUT = $(OBJ_DIR)/psgtest.prg 2 | S_SRCS += psgtest.s 3 | 4 | include common/Makefile.common 5 | -------------------------------------------------------------------------------- /misc/tests/psgtest/common: -------------------------------------------------------------------------------- 1 | ../common/ -------------------------------------------------------------------------------- /misc/tests/psgtest/music.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/X16Community/vera-module/6e8bea68a5a04687149e27b1b7b3726fb01405f4/misc/tests/psgtest/music.bin -------------------------------------------------------------------------------- /misc/testvera/.gitignore: -------------------------------------------------------------------------------- 1 | testvera 2 | -------------------------------------------------------------------------------- /misc/testvera/.vscode/c_cpp_properties.json: -------------------------------------------------------------------------------- 1 | { 2 | "configurations": [ 3 | { 4 | "name": "Linux", 5 | "includePath": [ 6 | "${workspaceFolder}/**" 7 | ], 8 | "defines": [ 9 | "__USE_GNU" 10 | ], 11 | "compilerPath": "/usr/bin/gcc", 12 | "cStandard": "c11", 13 | "cppStandard": "c++17", 14 | "intelliSenseMode": "gcc-x64" 15 | } 16 | ], 17 | "version": 4 18 | } -------------------------------------------------------------------------------- /misc/testvera/.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "editor.formatOnSave": true 3 | } -------------------------------------------------------------------------------- /misc/testvera/Makefile: -------------------------------------------------------------------------------- 1 | 2 | all: 3 | gcc -Wall -Wextra -std=gnu11 -o testvera testvera.c 4 | -------------------------------------------------------------------------------- /misc/tileconv/.gitignore: -------------------------------------------------------------------------------- 1 | tiles.bin 2 | palette.bin 3 | -------------------------------------------------------------------------------- /misc/tileconv/.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "editor.formatOnSave": true 3 | } -------------------------------------------------------------------------------- /misc/tileconv/Makefile: -------------------------------------------------------------------------------- 1 | all: 2 | gcc -O3 -Wall -Wextra -o tileconv tileconv.c lodepng.c -lm -------------------------------------------------------------------------------- /misc/tileconv/tileconv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/X16Community/vera-module/6e8bea68a5a04687149e27b1b7b3726fb01405f4/misc/tileconv/tileconv -------------------------------------------------------------------------------- /misc/tileconv/tileconv.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include "lodepng.h" 7 | 8 | uint16_t palette[256]; 9 | int palette_cnt = 0; 10 | 11 | int main() { 12 | uint8_t *pix8 = NULL; 13 | unsigned w, h; 14 | 15 | if (lodepng_decode32_file(&pix8, &w, &h, "../tiles.png") != 0) { 16 | exit(0); 17 | } 18 | 19 | printf("w: %u, h: %u\n", w, h); 20 | 21 | int num_pixels = w * h; 22 | 23 | uint8_t result[w * h]; 24 | for (int i = 0; i < num_pixels; i++) { 25 | uint16_t color = 26 | ((pix8[i * 4 + 0] >> 4) << 8) | 27 | ((pix8[i * 4 + 1] >> 4) << 4) | 28 | ((pix8[i * 4 + 2] >> 4) << 0); 29 | 30 | int idx = -1; 31 | for (int j = 0; j < palette_cnt; j++) { 32 | if (palette[j] == color) { 33 | idx = j; 34 | break; 35 | } 36 | } 37 | if (idx < 0) { 38 | if (palette_cnt >= 256) { 39 | printf("Too many colors!\n"); 40 | exit(1); 41 | } 42 | palette[palette_cnt] = color; 43 | idx = palette_cnt; 44 | palette_cnt++; 45 | } 46 | result[i] = idx; 47 | } 48 | 49 | printf("Number of colors: %d\n", palette_cnt); 50 | 51 | FILE *f = fopen("palette.bin", "wb"); 52 | fwrite(palette, 2 * 256, 1, f); 53 | fclose(f); 54 | 55 | f = fopen("tiles.bin", "wb"); 56 | fwrite(result, w * h, 1, f); 57 | fclose(f); 58 | 59 | return 0; 60 | } 61 | -------------------------------------------------------------------------------- /misc/tiles.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/X16Community/vera-module/6e8bea68a5a04687149e27b1b7b3726fb01405f4/misc/tiles.png -------------------------------------------------------------------------------- /misc/x16load/.gitignore: -------------------------------------------------------------------------------- 1 | x16load 2 | .vscode/ 3 | -------------------------------------------------------------------------------- /misc/x16load/Makefile: -------------------------------------------------------------------------------- 1 | 2 | all: 3 | gcc -Wall -Wextra -std=gnu11 -o x16load x16load.c 4 | -------------------------------------------------------------------------------- /pcb/rev0/.gitignore: -------------------------------------------------------------------------------- 1 | eagle.epf 2 | *.b#? 3 | *.s#? 4 | -------------------------------------------------------------------------------- /pcb/rev0/DESCRIPTION: -------------------------------------------------------------------------------- 1 | VERA (Video Embedded Retro Adapter) module 2 | -------------------------------------------------------------------------------- /pcb/rev0/component placement.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/X16Community/vera-module/6e8bea68a5a04687149e27b1b7b3726fb01405f4/pcb/rev0/component placement.pdf -------------------------------------------------------------------------------- /pcb/rev0/gerbers/vera-module gerbers.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/X16Community/vera-module/6e8bea68a5a04687149e27b1b7b3726fb01405f4/pcb/rev0/gerbers/vera-module gerbers.zip -------------------------------------------------------------------------------- /pcb/rev0/gerbers/vera-module.GBS: -------------------------------------------------------------------------------- 1 | G75* 2 | %MOMM*% 3 | %OFA0B0*% 4 | %FSLAX33Y33*% 5 | %IPPOS*% 6 | %LPD*% 7 | %AMOC8* 8 | 5,1,8,0,0,1.08239X$1,22.5* 9 | % 10 | %ADD10C,0.000*% 11 | %ADD11C,1.700*% 12 | %ADD12R,1.700X1.700*% 13 | D10* 14 | X00354Y09244D02* 15 | X21944Y09244D01* 16 | X21944Y14324D01* 17 | X24484Y14324D01* 18 | X24484Y00354D01* 19 | X70204Y00354D01* 20 | X70204Y48614D01* 21 | X24484Y48614D01* 22 | X24484Y34644D01* 23 | X21944Y34644D01* 24 | X21944Y40994D01* 25 | X00354Y40994D01* 26 | X00354Y09244D01* 27 | D11* 28 | X11784Y10514D03* 29 | X14324Y10514D03* 30 | X16864Y10514D03* 31 | X20674Y15594D03* 32 | X20674Y18134D03* 33 | X20674Y20674D03* 34 | X20674Y23214D03* 35 | X20674Y25754D03* 36 | X20674Y28294D03* 37 | X20674Y30834D03* 38 | X25754Y30834D03* 39 | X25754Y28294D03* 40 | X25754Y25754D03* 41 | X25754Y23214D03* 42 | X25754Y20674D03* 43 | X25754Y18134D03* 44 | X25754Y15594D03* 45 | X28294Y01624D03* 46 | X30834Y01624D03* 47 | X33374Y01624D03* 48 | X35914Y01624D03* 49 | X38454Y01624D03* 50 | X40994Y01624D03* 51 | X43534Y01624D03* 52 | X46074Y01624D03* 53 | X48614Y01624D03* 54 | X51154Y01624D03* 55 | X53694Y01624D03* 56 | X56234Y01624D03* 57 | X58774Y01624D03* 58 | X61314Y01624D03* 59 | X63854Y01624D03* 60 | X66394Y01624D03* 61 | X68934Y01624D03* 62 | X16864Y38454D03* 63 | X12654Y39544D03* 64 | X06054Y39544D03* 65 | X04164Y29564D03* 66 | X01624Y29564D03* 67 | X01624Y27024D03* 68 | X04164Y27024D03* 69 | X04164Y24484D03* 70 | X01624Y24484D03* 71 | X04164Y19404D03* 72 | X28294Y47344D03* 73 | X30834Y47344D03* 74 | X33374Y47344D03* 75 | X35914Y47344D03* 76 | X38454Y47344D03* 77 | X40994Y47344D03* 78 | X43534Y47344D03* 79 | X46074Y47344D03* 80 | X48614Y47344D03* 81 | X51154Y47344D03* 82 | X53694Y47344D03* 83 | X56234Y47344D03* 84 | X58774Y47344D03* 85 | X61314Y47344D03* 86 | X63854Y47344D03* 87 | X66394Y47344D03* 88 | X68934Y47344D03* 89 | D12* 90 | X25754Y47344D03* 91 | X19404Y38454D03* 92 | X20674Y33374D03* 93 | X25754Y33374D03* 94 | X01624Y19404D03* 95 | X09244Y10514D03* 96 | X25754Y01624D03* 97 | M02* 98 | -------------------------------------------------------------------------------- /pcb/rev0/gerbers/vera-module.GML: -------------------------------------------------------------------------------- 1 | G75* 2 | %MOMM*% 3 | %OFA0B0*% 4 | %FSLAX33Y33*% 5 | %IPPOS*% 6 | %LPD*% 7 | %AMOC8* 8 | 5,1,8,0,0,1.08239X$1,22.5* 9 | % 10 | %ADD10C,0.000*% 11 | D10* 12 | X00354Y09244D02* 13 | X21944Y09244D01* 14 | X21944Y14324D01* 15 | X24484Y14324D01* 16 | X24484Y00354D01* 17 | X70204Y00354D01* 18 | X70204Y48614D01* 19 | X24484Y48614D01* 20 | X24484Y34644D01* 21 | X21944Y34644D01* 22 | X21944Y40994D01* 23 | X00354Y40994D01* 24 | X00354Y09244D01* 25 | M02* 26 | -------------------------------------------------------------------------------- /pcb/rev0/gerbers/vera-module.dri: -------------------------------------------------------------------------------- 1 | Generated by EAGLE CAM Processor 7.7.0 2 | 3 | Drill Station Info File: C:/Work/Eagle/Commander16_Proto/Gerbers/cmd16.dri 4 | 5 | Date : 21/06/2019 21:37 6 | Drills : generated 7 | Device : Excellon drill station, coordinate format 3.3 mm 8 | 9 | Parameter settings: 10 | 11 | Tolerance Drill + : 0.00 % 12 | Tolerance Drill - : 0.00 % 13 | Rotate : no 14 | Mirror : no 15 | Optimize : yes 16 | Auto fit : yes 17 | OffsetX : 0inch 18 | OffsetY : 0inch 19 | Layers : Drills Holes 20 | 21 | Drill File Info: 22 | 23 | Data Mode : Absolute 24 | Units : 1/1000 MM 25 | 26 | Drills used: 27 | 28 | Code Size used 29 | 30 | T01 0.3000mm 182 31 | T02 1.0000mm 68 32 | 33 | Total number of drills: 250 34 | 35 | Plotfiles: 36 | 37 | C:/Work/Eagle/Commander16_Proto/Gerbers/cmd16.TXT 38 | -------------------------------------------------------------------------------- /pcb/rev0/gerbers/vera-module.gpi: -------------------------------------------------------------------------------- 1 | Generated by EAGLE CAM Processor 7.7.0 2 | 3 | Photoplotter Info File: C:/Work/Eagle/Commander16_Proto/Gerbers/cmd16.gpi 4 | 5 | Date : 21/06/2019 21:37 6 | Plotfile : C:/Work/Eagle/Commander16_Proto/Gerbers/cmd16.GML 7 | Apertures : generated: 8 | Device : Gerber RS-274-X photoplotter, coordinate format 3.3 mm 9 | 10 | Parameter settings: 11 | 12 | Emulate Apertures : no 13 | Tolerance Draw + : 0.00 % 14 | Tolerance Draw - : 0.00 % 15 | Tolerance Flash + : 0.00 % 16 | Tolerance Flash - : 0.00 % 17 | Rotate : no 18 | Mirror : no 19 | Optimize : yes 20 | Auto fit : yes 21 | OffsetX : 0inch 22 | OffsetY : 0inch 23 | 24 | Plotfile Info: 25 | 26 | Coordinate Format : 3.3 27 | Coordinate Units : MM 28 | Data Mode : Absolute 29 | Zero Suppression : None 30 | End Of Block : * 31 | 32 | Apertures used: 33 | 34 | Code Shape Size used 35 | 36 | D10 draw 0.0000mm 12 37 | 38 | -------------------------------------------------------------------------------- /pcb/rev0/vera-module bill of materials.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/X16Community/vera-module/6e8bea68a5a04687149e27b1b7b3726fb01405f4/pcb/rev0/vera-module bill of materials.xlsx -------------------------------------------------------------------------------- /pcb/rev0/vera-module schematics.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/X16Community/vera-module/6e8bea68a5a04687149e27b1b7b3726fb01405f4/pcb/rev0/vera-module schematics.pdf -------------------------------------------------------------------------------- /pcb/rev0/vera-module top.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/X16Community/vera-module/6e8bea68a5a04687149e27b1b7b3726fb01405f4/pcb/rev0/vera-module top.png -------------------------------------------------------------------------------- /pcb/rev1/.gitignore: -------------------------------------------------------------------------------- 1 | eagle.epf 2 | *.b#? 3 | *.s#? 4 | -------------------------------------------------------------------------------- /pcb/rev1/DESCRIPTION: -------------------------------------------------------------------------------- 1 | VERA (Video Embedded Retro Adapter) module 2 | -------------------------------------------------------------------------------- /pcb/rev1/vera-module bom.csv: -------------------------------------------------------------------------------- 1 | Qty;Value;Device;Package;Parts 2 | 4;0;RESISTOR0603;R0603;R33, R36, R50, R52 3 | 2;1;RESISTOR0603;R0603;R28, R37 4 | 4;100;RESISTOR0603;R0603;R53, R54, R55, R56 5 | 15;100n;CAPACITOR0603;C0603;C1, C4, C5, C6, C7, C8, C9, C12, C13, C18, C19, C23, C29, C30, C31 6 | 3;1070;RESISTOR0603;R0603;R8, R12, R20 7 | 3;10k;RESISTOR0603;R0603;R34, R35, R46 8 | 5;10u;CAPACITOR0805;C0805;C2, C25, C26, C69, C70 9 | 2;1k;RESISTOR0603;R0603;R16, R24 10 | 1;1n;CAPACITOR0603;C0603;C3 11 | 2;1u;CAPACITOR0603;C0603;C20, C21 12 | 1;2.2u;CAPACITOR0603;C0603;C27 13 | 2;2.7n;CAPACITOR0603;C0603;C16, C17 14 | 1;2041021-3;2041021-3;2041021-3;J7 15 | 3;2150;RESISTOR0603;R0603;R9, R17, R21 16 | 7;4.7u;CAPACITOR0603;C0603;C10, C11, C14, C15, C22, C24, C28 17 | 3;4300;RESISTOR0603;R0603;R10, R18, R22 18 | 2;470;RESISTOR0603;R0603;R23, R25 19 | 9;47k;RESISTOR0603;R0603;R13, R40, R41, R42, R43, R44, R45, R47, R48 20 | 3;536;RESISTOR0603;R0603;R4, R11, R19 21 | 2;560;RESISTOR0603;R0603;R38, R39 22 | 1;74AHC00PW;74AHC00PW;TSSOP-14;U11 23 | 3;74AHCT1G14SE-7;74AHCT1G14SE-7;TSSOP-5;U9, U12, U13 24 | 1;74LVC4245APW;74LVC4245APW;TSSOP-24;U6 25 | 3;75;RESISTOR0603;R0603;R26, R27, R32 26 | 2;820;RESISTOR0603;R0603;R5, R6 27 | 1;AP3417CKTR-G1;AP3417CKTR-G1;SOT-23-5;U8 28 | 1;AUDIO;35RASMT2BHNTRX;35RASMT2BHNTRX;J6 29 | 1;BUS;HDR2X10;HDR2X10;J5 30 | 9;CAY16-1001F4LF;RES_ARRAY41206;RA4_1206;R1, R2, R3, R7, R14, R15, R29, R30, R31 31 | 2;DNP;RESISTOR0603;R0603;R49, R51 32 | 3;FIDUCIAL;FIDUCIAL;FIDUCIAL;FD1, FD2, FD3 33 | 1;HDR8X1;HDR8X1;HDR8X1;J3 34 | 1;ICD15S13E4GX00LF;ICD15S13E4GX00LF;1-1734344-2;J1 35 | 1;ICE40UP5K-SG48ITR50;ICE40UP5K-SG48ITR50;QFN-48;U1 36 | 1;MD-40S;MD-40S;MD-40S;J4 37 | 1;MIC5504-3.3YM5-TR;MIC5504-3.3YM5-TR;SOT-23-5;U2 38 | 1;NRS4018T2R2MDGJ;INDUCTORNRS4018;NRS4018;L1 39 | 1;RCJ-014;RCJ-014;RCJ-01X;J2 40 | 1;SERIAL;HDR4X1;HDR4X1;J9 41 | 1;SG5032CAN_25.000000M-TJGA3;SG5032CAN_40.000000M-TJGA3;SG5032;U5 42 | 1;SN74CBTD3861PWR;SN74CBTD3861PWR;TSSOP-24;U3 43 | 1;THS7314D;THS7314D;SOIC-8;U7 44 | 1;W25Q16JVSNIQ;QSPI_FLASHSOIC8;SOIC-8;U4 45 | 1;WM8524CGEDT;WM8524CGEDT;TSSOP-16;U10 46 | -------------------------------------------------------------------------------- /pcb/rev1/vera-module bom.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/X16Community/vera-module/6e8bea68a5a04687149e27b1b7b3726fb01405f4/pcb/rev1/vera-module bom.xlsx -------------------------------------------------------------------------------- /pcb/rev1/vera-module_rev1_gerbers.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/X16Community/vera-module/6e8bea68a5a04687149e27b1b7b3726fb01405f4/pcb/rev1/vera-module_rev1_gerbers.zip -------------------------------------------------------------------------------- /pcb/rev2/.gitignore: -------------------------------------------------------------------------------- 1 | *.rpt 2 | *.bak 3 | *.bck 4 | *.xml 5 | *.kicad_pcb-bak 6 | *.sch-bak 7 | _saved_* 8 | fp-info-cache 9 | _autosave-* 10 | -------------------------------------------------------------------------------- /pcb/rev2/fp-lib-table: -------------------------------------------------------------------------------- 1 | (fp_lib_table 2 | (lib (name vera-module)(type KiCad)(uri ${KIPRJMOD}/vera-module.pretty)(options "")(descr "")) 3 | ) 4 | -------------------------------------------------------------------------------- /pcb/rev2/sym-lib-table: -------------------------------------------------------------------------------- 1 | (sym_lib_table 2 | (lib (name vera-module)(type Legacy)(uri ${KIPRJMOD}/vera-module.lib)(options "")(descr "")) 3 | ) 4 | -------------------------------------------------------------------------------- /pcb/rev2/vera-module.pretty/ICD15S13E4GV00LF.kicad_mod: -------------------------------------------------------------------------------- 1 | (module ICD15S13E4GV00LF (layer F.Cu) (tedit 5D8B62C8) 2 | (descr "15-pin HD D-Sub connector") 3 | (fp_text reference REF** (at 0 -17.2) (layer F.SilkS) 4 | (effects (font (size 1 1) (thickness 0.15))) 5 | ) 6 | (fp_text value ICD15S13E4GV00LF (at 0 5) (layer F.Fab) 7 | (effects (font (size 1 1) (thickness 0.15))) 8 | ) 9 | (fp_text user %R (at 0 3) (layer F.Fab) 10 | (effects (font (size 1 1) (thickness 0.15))) 11 | ) 12 | (fp_line (start 15.4 -16) (end 15.4 0) (layer F.SilkS) (width 0.12)) 13 | (fp_line (start -15.4 -16) (end 15.4 -16) (layer F.SilkS) (width 0.12)) 14 | (fp_line (start -15.4 0) (end -15.4 -16) (layer F.SilkS) (width 0.12)) 15 | (fp_line (start 14.5 0) (end 14.5 6) (layer F.Fab) (width 0.1)) 16 | (fp_line (start 10.5 6) (end 14.5 6) (layer F.Fab) (width 0.1)) 17 | (fp_line (start 10.5 0) (end 10.5 6) (layer F.Fab) (width 0.1)) 18 | (fp_line (start -10.5 0) (end -10.5 6) (layer F.Fab) (width 0.1)) 19 | (fp_line (start -14.5 6) (end -10.5 6) (layer F.Fab) (width 0.1)) 20 | (fp_line (start -14.5 0) (end -14.5 6) (layer F.Fab) (width 0.1)) 21 | (fp_line (start 8.15 0) (end 8.15 6) (layer F.Fab) (width 0.1)) 22 | (fp_line (start -8 6) (end 8.15 6) (layer F.Fab) (width 0.1)) 23 | (fp_line (start -8 0) (end -8 6) (layer F.Fab) (width 0.1)) 24 | (fp_line (start 15.4 -16) (end -15.4 -16) (layer F.Fab) (width 0.1)) 25 | (fp_line (start 15.4 0) (end 15.4 -16) (layer F.Fab) (width 0.1)) 26 | (fp_line (start -15.4 0) (end 15.4 0) (layer F.Fab) (width 0.1)) 27 | (fp_line (start -15.4 -16) (end -15.4 0) (layer F.Fab) (width 0.1)) 28 | (pad 0 thru_hole circle (at 12.495 -11.43) (size 4 4) (drill 3.2) (layers *.Cu *.Mask)) 29 | (pad 0 thru_hole circle (at -12.495 -11.43) (size 4 4) (drill 3.2) (layers *.Cu *.Mask)) 30 | (pad 15 thru_hole circle (at -4.845 -8.89) (size 1.6 1.6) (drill 1) (layers *.Cu *.Mask)) 31 | (pad 14 thru_hole circle (at -2.555 -8.89) (size 1.6 1.6) (drill 1) (layers *.Cu *.Mask)) 32 | (pad 13 thru_hole circle (at -0.265 -8.89) (size 1.6 1.6) (drill 1) (layers *.Cu *.Mask)) 33 | (pad 12 thru_hole circle (at 2.025 -8.89) (size 1.6 1.6) (drill 1) (layers *.Cu *.Mask)) 34 | (pad 11 thru_hole circle (at 4.315 -8.89) (size 1.6 1.6) (drill 1) (layers *.Cu *.Mask)) 35 | (pad 10 thru_hole circle (at -3.705 -11.43) (size 1.6 1.6) (drill 1) (layers *.Cu *.Mask)) 36 | (pad 9 thru_hole circle (at -1.415 -11.43) (size 1.6 1.6) (drill 1) (layers *.Cu *.Mask)) 37 | (pad 8 thru_hole circle (at 0.875 -11.43) (size 1.6 1.6) (drill 1) (layers *.Cu *.Mask)) 38 | (pad 7 thru_hole circle (at 3.165 -11.43) (size 1.6 1.6) (drill 1) (layers *.Cu *.Mask)) 39 | (pad 6 thru_hole circle (at 5.455 -11.43) (size 1.6 1.6) (drill 1) (layers *.Cu *.Mask)) 40 | (pad 5 thru_hole circle (at -4.845 -13.97) (size 1.6 1.6) (drill 1) (layers *.Cu *.Mask)) 41 | (pad 4 thru_hole circle (at -2.555 -13.97) (size 1.6 1.6) (drill 1) (layers *.Cu *.Mask)) 42 | (pad 3 thru_hole circle (at -0.265 -13.97) (size 1.6 1.6) (drill 1) (layers *.Cu *.Mask)) 43 | (pad 2 thru_hole circle (at 2.025 -13.97) (size 1.6 1.6) (drill 1) (layers *.Cu *.Mask)) 44 | (pad 1 thru_hole rect (at 4.315 -13.97) (size 1.6 1.6) (drill 1) (layers *.Cu *.Mask)) 45 | (model step/ICD15S13E4GV00LFc.stp 46 | (offset (xyz 0 0.5 0)) 47 | (scale (xyz 1 1 1)) 48 | (rotate (xyz 0 180 0)) 49 | ) 50 | ) 51 | -------------------------------------------------------------------------------- /pcb/rev2/vera-module.pretty/KCDX-5S-N.kicad_mod: -------------------------------------------------------------------------------- 1 | (module KCDX-5S-N (layer F.Cu) (tedit 5D8B550A) 2 | (fp_text reference REF** (at 0 15) (layer F.SilkS) 3 | (effects (font (size 1 1) (thickness 0.15))) 4 | ) 5 | (fp_text value KCDX-5S-N (at 0 16.9) (layer F.Fab) 6 | (effects (font (size 1 1) (thickness 0.15))) 7 | ) 8 | (fp_line (start -9.2 1.7) (end -9.2 13.35) (layer F.SilkS) (width 0.12)) 9 | (fp_line (start 9.2 13.35) (end 9.2 1) (layer F.SilkS) (width 0.12)) 10 | (fp_line (start 10.25 1) (end 10.25 0) (layer F.SilkS) (width 0.12)) 11 | (fp_line (start 10.25 0) (end -9.2 0) (layer F.SilkS) (width 0.12)) 12 | (fp_line (start 10.25 1) (end 9.2 1) (layer F.SilkS) (width 0.12)) 13 | (fp_line (start -9.2 0) (end -9.2 0.95) (layer F.SilkS) (width 0.12)) 14 | (fp_line (start -9.2 0.95) (end -10.25 0.95) (layer F.SilkS) (width 0.12)) 15 | (fp_line (start -10.25 0.95) (end -10.25 1.7) (layer F.SilkS) (width 0.12)) 16 | (fp_line (start -10.25 1.7) (end -9.2 1.7) (layer F.SilkS) (width 0.12)) 17 | (fp_line (start -9.2 13.35) (end -8.8 13.35) (layer F.SilkS) (width 0.12)) 18 | (fp_line (start 9.2 13.35) (end 8.8 13.35) (layer F.SilkS) (width 0.12)) 19 | (fp_line (start -6.2 13.35) (end -1.3 13.35) (layer F.SilkS) (width 0.12)) 20 | (fp_line (start 1.3 13.35) (end 6.2 13.35) (layer F.SilkS) (width 0.12)) 21 | (pad 1 thru_hole circle (at -7.5 12.5) (size 2.5 2.5) (drill 1.4) (layers *.Cu *.Mask)) 22 | (pad 2 thru_hole circle (at 0 12.5) (size 2.5 2.5) (drill 1.4) (layers *.Cu *.Mask)) 23 | (pad 3 thru_hole circle (at 7.5 12.5) (size 2.5 2.5) (drill 1.4) (layers *.Cu *.Mask)) 24 | (pad 5 thru_hole circle (at 5 15) (size 2.5 2.5) (drill 1.4) (layers *.Cu *.Mask)) 25 | (pad 4 thru_hole circle (at -5 15) (size 2.5 2.5) (drill 1.4) (layers *.Cu *.Mask)) 26 | (pad 0 thru_hole circle (at -5 3) (size 2.5 2.5) (drill 1.4) (layers *.Cu *.Mask)) 27 | (pad 0 thru_hole circle (at 5 3) (size 2.5 2.5) (drill 1.4) (layers *.Cu *.Mask)) 28 | (model step/KCDX-5S-N_rA3.STEP 29 | (at (xyz 0 0 0)) 30 | (scale (xyz 1 1 1)) 31 | (rotate (xyz -90 0 180)) 32 | ) 33 | ) 34 | -------------------------------------------------------------------------------- /pcb/rev2/vera-module.pretty/MD-40S.kicad_mod: -------------------------------------------------------------------------------- 1 | (module MD-40S (layer F.Cu) (tedit 5DA85A93) 2 | (fp_text reference REF** (at 0 13.5) (layer F.SilkS) 3 | (effects (font (size 1 1) (thickness 0.15))) 4 | ) 5 | (fp_text value MD-40S (at 0 -0.5) (layer F.Fab) 6 | (effects (font (size 1 1) (thickness 0.15))) 7 | ) 8 | (fp_line (start -7 0) (end -7 12.4) (layer F.SilkS) (width 0.12)) 9 | (fp_line (start -7 12.4) (end 7 12.4) (layer F.SilkS) (width 0.12)) 10 | (fp_line (start 7 12.4) (end 7 0) (layer F.SilkS) (width 0.12)) 11 | (fp_line (start 7 0) (end -7 0) (layer F.SilkS) (width 0.12)) 12 | (fp_line (start -7 1.8) (end 7 1.8) (layer F.SilkS) (width 0.12)) 13 | (pad 0 thru_hole circle (at 0.05 4.7) (size 3 3) (drill 2.2) (layers *.Cu *.Mask)) 14 | (pad 1 thru_hole circle (at -3.4 8.5) (size 1.5 1.5) (drill 0.9) (layers *.Cu *.Mask)) 15 | (pad 2 thru_hole circle (at 3.4 8.5) (size 1.5 1.5) (drill 0.9) (layers *.Cu *.Mask)) 16 | (pad 3 thru_hole circle (at -3.4 11) (size 1.5 1.5) (drill 0.9) (layers *.Cu *.Mask)) 17 | (pad 4 thru_hole circle (at 3.4 11) (size 1.5 1.5) (drill 0.9) (layers *.Cu *.Mask)) 18 | (model step/CUI_MD-40S.step 19 | (offset (xyz 0 0 6.5)) 20 | (scale (xyz 1 1 1)) 21 | (rotate (xyz -90 0 -90)) 22 | ) 23 | ) 24 | -------------------------------------------------------------------------------- /pcb/rev2/vera-module.pretty/RCJ-014.kicad_mod: -------------------------------------------------------------------------------- 1 | (module RCJ-014 (layer F.Cu) (tedit 5D8B6947) 2 | (fp_text reference REF** (at 0 7) (layer F.SilkS) 3 | (effects (font (size 1 1) (thickness 0.15))) 4 | ) 5 | (fp_text value RCJ-014 (at 0 8.5) (layer F.Fab) 6 | (effects (font (size 1 1) (thickness 0.15))) 7 | ) 8 | (fp_line (start -5.3 -0.7) (end -5.3 2) (layer F.SilkS) (width 0.12)) 9 | (fp_line (start 1 5.75) (end 3 5.75) (layer F.SilkS) (width 0.12)) 10 | (fp_line (start 5.3 2) (end 5.3 -0.7) (layer F.SilkS) (width 0.12)) 11 | (fp_line (start 5.3 -0.7) (end -5.3 -0.7) (layer F.SilkS) (width 0.12)) 12 | (fp_line (start -3.15 -0.7) (end -3.15 -8.75) (layer F.Fab) (width 0.12)) 13 | (fp_line (start -3.15 -8.75) (end 3.15 -8.75) (layer F.Fab) (width 0.12)) 14 | (fp_line (start 3.15 -8.75) (end 3.15 -0.7) (layer F.Fab) (width 0.12)) 15 | (fp_line (start -5.3 -0.7) (end 5.3 -0.7) (layer F.Fab) (width 0.12)) 16 | (fp_line (start 5.3 -0.7) (end 5.3 5.75) (layer F.Fab) (width 0.12)) 17 | (fp_line (start 5.3 5.75) (end -5.3 5.75) (layer F.Fab) (width 0.12)) 18 | (fp_line (start -5.3 5.75) (end -5.3 -0.7) (layer F.Fab) (width 0.12)) 19 | (fp_line (start -3 5.75) (end -1 5.75) (layer F.SilkS) (width 0.12)) 20 | (pad 2 thru_hole circle (at 0 0) (size 4 4) (drill 2.6) (layers *.Cu *.Mask)) 21 | (pad 1 thru_hole circle (at 0 4.5) (size 2.5 2.5) (drill 1.7) (layers *.Cu *.Mask)) 22 | (pad 2 thru_hole circle (at 5 4.5) (size 4 4) (drill 2.6) (layers *.Cu *.Mask)) 23 | (pad 2 thru_hole circle (at -5 4.5) (size 4 4) (drill 2.6) (layers *.Cu *.Mask)) 24 | (model step/CUI_RCJ-014.step 25 | (offset (xyz 0 -5.75 6.6)) 26 | (scale (xyz 1 1 1)) 27 | (rotate (xyz -90 0 -90)) 28 | ) 29 | ) 30 | -------------------------------------------------------------------------------- /pcb/rev3/.gitignore: -------------------------------------------------------------------------------- 1 | *.rpt 2 | *.bak 3 | *.bck 4 | *.xml 5 | *.kicad_pcb-bak 6 | *.sch-bak 7 | _saved_* 8 | fp-info-cache 9 | _autosave-* 10 | -------------------------------------------------------------------------------- /pcb/rev3/fp-lib-table: -------------------------------------------------------------------------------- 1 | (fp_lib_table 2 | (lib (name vera-module)(type KiCad)(uri ${KIPRJMOD}/vera-module.pretty)(options "")(descr "")) 3 | ) 4 | -------------------------------------------------------------------------------- /pcb/rev3/sym-lib-table: -------------------------------------------------------------------------------- 1 | (sym_lib_table 2 | (lib (name vera-module)(type Legacy)(uri ${KIPRJMOD}/vera-module.lib)(options "")(descr "")) 3 | ) 4 | -------------------------------------------------------------------------------- /pcb/rev3/vera-module.pretty/ICD15S13E4GV00LF.kicad_mod: -------------------------------------------------------------------------------- 1 | (module ICD15S13E4GV00LF (layer F.Cu) (tedit 5D8B62C8) 2 | (descr "15-pin HD D-Sub connector") 3 | (fp_text reference REF** (at 0 -17.2) (layer F.SilkS) 4 | (effects (font (size 1 1) (thickness 0.15))) 5 | ) 6 | (fp_text value ICD15S13E4GV00LF (at 0 5) (layer F.Fab) 7 | (effects (font (size 1 1) (thickness 0.15))) 8 | ) 9 | (fp_text user %R (at 0 3) (layer F.Fab) 10 | (effects (font (size 1 1) (thickness 0.15))) 11 | ) 12 | (fp_line (start 15.4 -16) (end 15.4 0) (layer F.SilkS) (width 0.12)) 13 | (fp_line (start -15.4 -16) (end 15.4 -16) (layer F.SilkS) (width 0.12)) 14 | (fp_line (start -15.4 0) (end -15.4 -16) (layer F.SilkS) (width 0.12)) 15 | (fp_line (start 14.5 0) (end 14.5 6) (layer F.Fab) (width 0.1)) 16 | (fp_line (start 10.5 6) (end 14.5 6) (layer F.Fab) (width 0.1)) 17 | (fp_line (start 10.5 0) (end 10.5 6) (layer F.Fab) (width 0.1)) 18 | (fp_line (start -10.5 0) (end -10.5 6) (layer F.Fab) (width 0.1)) 19 | (fp_line (start -14.5 6) (end -10.5 6) (layer F.Fab) (width 0.1)) 20 | (fp_line (start -14.5 0) (end -14.5 6) (layer F.Fab) (width 0.1)) 21 | (fp_line (start 8.15 0) (end 8.15 6) (layer F.Fab) (width 0.1)) 22 | (fp_line (start -8 6) (end 8.15 6) (layer F.Fab) (width 0.1)) 23 | (fp_line (start -8 0) (end -8 6) (layer F.Fab) (width 0.1)) 24 | (fp_line (start 15.4 -16) (end -15.4 -16) (layer F.Fab) (width 0.1)) 25 | (fp_line (start 15.4 0) (end 15.4 -16) (layer F.Fab) (width 0.1)) 26 | (fp_line (start -15.4 0) (end 15.4 0) (layer F.Fab) (width 0.1)) 27 | (fp_line (start -15.4 -16) (end -15.4 0) (layer F.Fab) (width 0.1)) 28 | (pad 0 thru_hole circle (at 12.495 -11.43) (size 4 4) (drill 3.2) (layers *.Cu *.Mask)) 29 | (pad 0 thru_hole circle (at -12.495 -11.43) (size 4 4) (drill 3.2) (layers *.Cu *.Mask)) 30 | (pad 15 thru_hole circle (at -4.845 -8.89) (size 1.6 1.6) (drill 1) (layers *.Cu *.Mask)) 31 | (pad 14 thru_hole circle (at -2.555 -8.89) (size 1.6 1.6) (drill 1) (layers *.Cu *.Mask)) 32 | (pad 13 thru_hole circle (at -0.265 -8.89) (size 1.6 1.6) (drill 1) (layers *.Cu *.Mask)) 33 | (pad 12 thru_hole circle (at 2.025 -8.89) (size 1.6 1.6) (drill 1) (layers *.Cu *.Mask)) 34 | (pad 11 thru_hole circle (at 4.315 -8.89) (size 1.6 1.6) (drill 1) (layers *.Cu *.Mask)) 35 | (pad 10 thru_hole circle (at -3.705 -11.43) (size 1.6 1.6) (drill 1) (layers *.Cu *.Mask)) 36 | (pad 9 thru_hole circle (at -1.415 -11.43) (size 1.6 1.6) (drill 1) (layers *.Cu *.Mask)) 37 | (pad 8 thru_hole circle (at 0.875 -11.43) (size 1.6 1.6) (drill 1) (layers *.Cu *.Mask)) 38 | (pad 7 thru_hole circle (at 3.165 -11.43) (size 1.6 1.6) (drill 1) (layers *.Cu *.Mask)) 39 | (pad 6 thru_hole circle (at 5.455 -11.43) (size 1.6 1.6) (drill 1) (layers *.Cu *.Mask)) 40 | (pad 5 thru_hole circle (at -4.845 -13.97) (size 1.6 1.6) (drill 1) (layers *.Cu *.Mask)) 41 | (pad 4 thru_hole circle (at -2.555 -13.97) (size 1.6 1.6) (drill 1) (layers *.Cu *.Mask)) 42 | (pad 3 thru_hole circle (at -0.265 -13.97) (size 1.6 1.6) (drill 1) (layers *.Cu *.Mask)) 43 | (pad 2 thru_hole circle (at 2.025 -13.97) (size 1.6 1.6) (drill 1) (layers *.Cu *.Mask)) 44 | (pad 1 thru_hole rect (at 4.315 -13.97) (size 1.6 1.6) (drill 1) (layers *.Cu *.Mask)) 45 | (model step/ICD15S13E4GV00LFc.stp 46 | (offset (xyz 0 0.5 0)) 47 | (scale (xyz 1 1 1)) 48 | (rotate (xyz 0 180 0)) 49 | ) 50 | ) 51 | -------------------------------------------------------------------------------- /pcb/rev3/vera-module.pretty/KCDX-5S-N.kicad_mod: -------------------------------------------------------------------------------- 1 | (module KCDX-5S-N (layer F.Cu) (tedit 5D8B550A) 2 | (fp_text reference REF** (at 0 15) (layer F.SilkS) 3 | (effects (font (size 1 1) (thickness 0.15))) 4 | ) 5 | (fp_text value KCDX-5S-N (at 0 16.9) (layer F.Fab) 6 | (effects (font (size 1 1) (thickness 0.15))) 7 | ) 8 | (fp_line (start -9.2 1.7) (end -9.2 13.35) (layer F.SilkS) (width 0.12)) 9 | (fp_line (start 9.2 13.35) (end 9.2 1) (layer F.SilkS) (width 0.12)) 10 | (fp_line (start 10.25 1) (end 10.25 0) (layer F.SilkS) (width 0.12)) 11 | (fp_line (start 10.25 0) (end -9.2 0) (layer F.SilkS) (width 0.12)) 12 | (fp_line (start 10.25 1) (end 9.2 1) (layer F.SilkS) (width 0.12)) 13 | (fp_line (start -9.2 0) (end -9.2 0.95) (layer F.SilkS) (width 0.12)) 14 | (fp_line (start -9.2 0.95) (end -10.25 0.95) (layer F.SilkS) (width 0.12)) 15 | (fp_line (start -10.25 0.95) (end -10.25 1.7) (layer F.SilkS) (width 0.12)) 16 | (fp_line (start -10.25 1.7) (end -9.2 1.7) (layer F.SilkS) (width 0.12)) 17 | (fp_line (start -9.2 13.35) (end -8.8 13.35) (layer F.SilkS) (width 0.12)) 18 | (fp_line (start 9.2 13.35) (end 8.8 13.35) (layer F.SilkS) (width 0.12)) 19 | (fp_line (start -6.2 13.35) (end -1.3 13.35) (layer F.SilkS) (width 0.12)) 20 | (fp_line (start 1.3 13.35) (end 6.2 13.35) (layer F.SilkS) (width 0.12)) 21 | (pad 1 thru_hole circle (at -7.5 12.5) (size 2.5 2.5) (drill 1.4) (layers *.Cu *.Mask)) 22 | (pad 2 thru_hole circle (at 0 12.5) (size 2.5 2.5) (drill 1.4) (layers *.Cu *.Mask)) 23 | (pad 3 thru_hole circle (at 7.5 12.5) (size 2.5 2.5) (drill 1.4) (layers *.Cu *.Mask)) 24 | (pad 5 thru_hole circle (at 5 15) (size 2.5 2.5) (drill 1.4) (layers *.Cu *.Mask)) 25 | (pad 4 thru_hole circle (at -5 15) (size 2.5 2.5) (drill 1.4) (layers *.Cu *.Mask)) 26 | (pad 0 thru_hole circle (at -5 3) (size 2.5 2.5) (drill 1.4) (layers *.Cu *.Mask)) 27 | (pad 0 thru_hole circle (at 5 3) (size 2.5 2.5) (drill 1.4) (layers *.Cu *.Mask)) 28 | (model step/KCDX-5S-N_rA3.STEP 29 | (at (xyz 0 0 0)) 30 | (scale (xyz 1 1 1)) 31 | (rotate (xyz -90 0 180)) 32 | ) 33 | ) 34 | -------------------------------------------------------------------------------- /pcb/rev3/vera-module.pretty/MD-40S.kicad_mod: -------------------------------------------------------------------------------- 1 | (module MD-40S (layer F.Cu) (tedit 5DA85A93) 2 | (fp_text reference REF** (at 0 13.5) (layer F.SilkS) 3 | (effects (font (size 1 1) (thickness 0.15))) 4 | ) 5 | (fp_text value MD-40S (at 0 -0.5) (layer F.Fab) 6 | (effects (font (size 1 1) (thickness 0.15))) 7 | ) 8 | (fp_line (start -7 0) (end -7 12.4) (layer F.SilkS) (width 0.12)) 9 | (fp_line (start -7 12.4) (end 7 12.4) (layer F.SilkS) (width 0.12)) 10 | (fp_line (start 7 12.4) (end 7 0) (layer F.SilkS) (width 0.12)) 11 | (fp_line (start 7 0) (end -7 0) (layer F.SilkS) (width 0.12)) 12 | (fp_line (start -7 1.8) (end 7 1.8) (layer F.SilkS) (width 0.12)) 13 | (pad 0 thru_hole circle (at 0.05 4.7) (size 3 3) (drill 2.2) (layers *.Cu *.Mask)) 14 | (pad 1 thru_hole circle (at -3.4 8.5) (size 1.5 1.5) (drill 0.9) (layers *.Cu *.Mask)) 15 | (pad 2 thru_hole circle (at 3.4 8.5) (size 1.5 1.5) (drill 0.9) (layers *.Cu *.Mask)) 16 | (pad 3 thru_hole circle (at -3.4 11) (size 1.5 1.5) (drill 0.9) (layers *.Cu *.Mask)) 17 | (pad 4 thru_hole circle (at 3.4 11) (size 1.5 1.5) (drill 0.9) (layers *.Cu *.Mask)) 18 | (model step/CUI_MD-40S.step 19 | (offset (xyz 0 0 6.5)) 20 | (scale (xyz 1 1 1)) 21 | (rotate (xyz -90 0 -90)) 22 | ) 23 | ) 24 | -------------------------------------------------------------------------------- /pcb/rev3/vera-module.pretty/RCJ-014.kicad_mod: -------------------------------------------------------------------------------- 1 | (module RCJ-014 (layer F.Cu) (tedit 5D8B6947) 2 | (fp_text reference REF** (at 0 7) (layer F.SilkS) 3 | (effects (font (size 1 1) (thickness 0.15))) 4 | ) 5 | (fp_text value RCJ-014 (at 0 8.5) (layer F.Fab) 6 | (effects (font (size 1 1) (thickness 0.15))) 7 | ) 8 | (fp_line (start -5.3 -0.7) (end -5.3 2) (layer F.SilkS) (width 0.12)) 9 | (fp_line (start 1 5.75) (end 3 5.75) (layer F.SilkS) (width 0.12)) 10 | (fp_line (start 5.3 2) (end 5.3 -0.7) (layer F.SilkS) (width 0.12)) 11 | (fp_line (start 5.3 -0.7) (end -5.3 -0.7) (layer F.SilkS) (width 0.12)) 12 | (fp_line (start -3.15 -0.7) (end -3.15 -8.75) (layer F.Fab) (width 0.12)) 13 | (fp_line (start -3.15 -8.75) (end 3.15 -8.75) (layer F.Fab) (width 0.12)) 14 | (fp_line (start 3.15 -8.75) (end 3.15 -0.7) (layer F.Fab) (width 0.12)) 15 | (fp_line (start -5.3 -0.7) (end 5.3 -0.7) (layer F.Fab) (width 0.12)) 16 | (fp_line (start 5.3 -0.7) (end 5.3 5.75) (layer F.Fab) (width 0.12)) 17 | (fp_line (start 5.3 5.75) (end -5.3 5.75) (layer F.Fab) (width 0.12)) 18 | (fp_line (start -5.3 5.75) (end -5.3 -0.7) (layer F.Fab) (width 0.12)) 19 | (fp_line (start -3 5.75) (end -1 5.75) (layer F.SilkS) (width 0.12)) 20 | (pad 2 thru_hole circle (at 0 0) (size 4 4) (drill 2.6) (layers *.Cu *.Mask)) 21 | (pad 1 thru_hole circle (at 0 4.5) (size 2.5 2.5) (drill 1.7) (layers *.Cu *.Mask)) 22 | (pad 2 thru_hole circle (at 5 4.5) (size 4 4) (drill 2.6) (layers *.Cu *.Mask)) 23 | (pad 2 thru_hole circle (at -5 4.5) (size 4 4) (drill 2.6) (layers *.Cu *.Mask)) 24 | (model step/CUI_RCJ-014.step 25 | (offset (xyz 0 -5.75 6.6)) 26 | (scale (xyz 1 1 1)) 27 | (rotate (xyz -90 0 -90)) 28 | ) 29 | ) 30 | -------------------------------------------------------------------------------- /pcb/rev4/.gitignore: -------------------------------------------------------------------------------- 1 | *.rpt 2 | *.bak 3 | *.bck 4 | *.xml 5 | *.kicad_pcb-bak 6 | *.sch-bak 7 | _saved_* 8 | fp-info-cache 9 | _autosave-* 10 | -------------------------------------------------------------------------------- /pcb/rev4/fp-lib-table: -------------------------------------------------------------------------------- 1 | (fp_lib_table 2 | (lib (name vera-module)(type KiCad)(uri ${KIPRJMOD}/vera-module.pretty)(options "")(descr "")) 3 | ) 4 | -------------------------------------------------------------------------------- /pcb/rev4/sym-lib-table: -------------------------------------------------------------------------------- 1 | (sym_lib_table 2 | (lib (name vera-module)(type Legacy)(uri ${KIPRJMOD}/vera-module.lib)(options "")(descr "")) 3 | ) 4 | -------------------------------------------------------------------------------- /pcb/rev4/vera-module.dcm: -------------------------------------------------------------------------------- 1 | EESchema-DOCLIB Version 2.0 2 | # 3 | #End Doc Library 4 | -------------------------------------------------------------------------------- /pcb/rev4/vera-module.pretty/ICD15S13E4GV00LF.kicad_mod: -------------------------------------------------------------------------------- 1 | (module ICD15S13E4GV00LF (layer F.Cu) (tedit 5D8B62C8) 2 | (descr "15-pin HD D-Sub connector") 3 | (fp_text reference REF** (at 0 -17.2) (layer F.SilkS) 4 | (effects (font (size 1 1) (thickness 0.15))) 5 | ) 6 | (fp_text value ICD15S13E4GV00LF (at 0 5) (layer F.Fab) 7 | (effects (font (size 1 1) (thickness 0.15))) 8 | ) 9 | (fp_text user %R (at 0 3) (layer F.Fab) 10 | (effects (font (size 1 1) (thickness 0.15))) 11 | ) 12 | (fp_line (start 15.4 -16) (end 15.4 0) (layer F.SilkS) (width 0.12)) 13 | (fp_line (start -15.4 -16) (end 15.4 -16) (layer F.SilkS) (width 0.12)) 14 | (fp_line (start -15.4 0) (end -15.4 -16) (layer F.SilkS) (width 0.12)) 15 | (fp_line (start 14.5 0) (end 14.5 6) (layer F.Fab) (width 0.1)) 16 | (fp_line (start 10.5 6) (end 14.5 6) (layer F.Fab) (width 0.1)) 17 | (fp_line (start 10.5 0) (end 10.5 6) (layer F.Fab) (width 0.1)) 18 | (fp_line (start -10.5 0) (end -10.5 6) (layer F.Fab) (width 0.1)) 19 | (fp_line (start -14.5 6) (end -10.5 6) (layer F.Fab) (width 0.1)) 20 | (fp_line (start -14.5 0) (end -14.5 6) (layer F.Fab) (width 0.1)) 21 | (fp_line (start 8.15 0) (end 8.15 6) (layer F.Fab) (width 0.1)) 22 | (fp_line (start -8 6) (end 8.15 6) (layer F.Fab) (width 0.1)) 23 | (fp_line (start -8 0) (end -8 6) (layer F.Fab) (width 0.1)) 24 | (fp_line (start 15.4 -16) (end -15.4 -16) (layer F.Fab) (width 0.1)) 25 | (fp_line (start 15.4 0) (end 15.4 -16) (layer F.Fab) (width 0.1)) 26 | (fp_line (start -15.4 0) (end 15.4 0) (layer F.Fab) (width 0.1)) 27 | (fp_line (start -15.4 -16) (end -15.4 0) (layer F.Fab) (width 0.1)) 28 | (pad 0 thru_hole circle (at 12.495 -11.43) (size 4 4) (drill 3.2) (layers *.Cu *.Mask)) 29 | (pad 0 thru_hole circle (at -12.495 -11.43) (size 4 4) (drill 3.2) (layers *.Cu *.Mask)) 30 | (pad 15 thru_hole circle (at -4.845 -8.89) (size 1.6 1.6) (drill 1) (layers *.Cu *.Mask)) 31 | (pad 14 thru_hole circle (at -2.555 -8.89) (size 1.6 1.6) (drill 1) (layers *.Cu *.Mask)) 32 | (pad 13 thru_hole circle (at -0.265 -8.89) (size 1.6 1.6) (drill 1) (layers *.Cu *.Mask)) 33 | (pad 12 thru_hole circle (at 2.025 -8.89) (size 1.6 1.6) (drill 1) (layers *.Cu *.Mask)) 34 | (pad 11 thru_hole circle (at 4.315 -8.89) (size 1.6 1.6) (drill 1) (layers *.Cu *.Mask)) 35 | (pad 10 thru_hole circle (at -3.705 -11.43) (size 1.6 1.6) (drill 1) (layers *.Cu *.Mask)) 36 | (pad 9 thru_hole circle (at -1.415 -11.43) (size 1.6 1.6) (drill 1) (layers *.Cu *.Mask)) 37 | (pad 8 thru_hole circle (at 0.875 -11.43) (size 1.6 1.6) (drill 1) (layers *.Cu *.Mask)) 38 | (pad 7 thru_hole circle (at 3.165 -11.43) (size 1.6 1.6) (drill 1) (layers *.Cu *.Mask)) 39 | (pad 6 thru_hole circle (at 5.455 -11.43) (size 1.6 1.6) (drill 1) (layers *.Cu *.Mask)) 40 | (pad 5 thru_hole circle (at -4.845 -13.97) (size 1.6 1.6) (drill 1) (layers *.Cu *.Mask)) 41 | (pad 4 thru_hole circle (at -2.555 -13.97) (size 1.6 1.6) (drill 1) (layers *.Cu *.Mask)) 42 | (pad 3 thru_hole circle (at -0.265 -13.97) (size 1.6 1.6) (drill 1) (layers *.Cu *.Mask)) 43 | (pad 2 thru_hole circle (at 2.025 -13.97) (size 1.6 1.6) (drill 1) (layers *.Cu *.Mask)) 44 | (pad 1 thru_hole rect (at 4.315 -13.97) (size 1.6 1.6) (drill 1) (layers *.Cu *.Mask)) 45 | (model step/ICD15S13E4GV00LFc.stp 46 | (offset (xyz 0 0.5 0)) 47 | (scale (xyz 1 1 1)) 48 | (rotate (xyz 0 180 0)) 49 | ) 50 | ) 51 | -------------------------------------------------------------------------------- /pcb/rev4/vera-module.pretty/KCDX-5S-N.kicad_mod: -------------------------------------------------------------------------------- 1 | (module KCDX-5S-N (layer F.Cu) (tedit 5D8B550A) 2 | (fp_text reference REF** (at 0 15) (layer F.SilkS) 3 | (effects (font (size 1 1) (thickness 0.15))) 4 | ) 5 | (fp_text value KCDX-5S-N (at 0 16.9) (layer F.Fab) 6 | (effects (font (size 1 1) (thickness 0.15))) 7 | ) 8 | (fp_line (start -9.2 1.7) (end -9.2 13.35) (layer F.SilkS) (width 0.12)) 9 | (fp_line (start 9.2 13.35) (end 9.2 1) (layer F.SilkS) (width 0.12)) 10 | (fp_line (start 10.25 1) (end 10.25 0) (layer F.SilkS) (width 0.12)) 11 | (fp_line (start 10.25 0) (end -9.2 0) (layer F.SilkS) (width 0.12)) 12 | (fp_line (start 10.25 1) (end 9.2 1) (layer F.SilkS) (width 0.12)) 13 | (fp_line (start -9.2 0) (end -9.2 0.95) (layer F.SilkS) (width 0.12)) 14 | (fp_line (start -9.2 0.95) (end -10.25 0.95) (layer F.SilkS) (width 0.12)) 15 | (fp_line (start -10.25 0.95) (end -10.25 1.7) (layer F.SilkS) (width 0.12)) 16 | (fp_line (start -10.25 1.7) (end -9.2 1.7) (layer F.SilkS) (width 0.12)) 17 | (fp_line (start -9.2 13.35) (end -8.8 13.35) (layer F.SilkS) (width 0.12)) 18 | (fp_line (start 9.2 13.35) (end 8.8 13.35) (layer F.SilkS) (width 0.12)) 19 | (fp_line (start -6.2 13.35) (end -1.3 13.35) (layer F.SilkS) (width 0.12)) 20 | (fp_line (start 1.3 13.35) (end 6.2 13.35) (layer F.SilkS) (width 0.12)) 21 | (pad 1 thru_hole circle (at -7.5 12.5) (size 2.5 2.5) (drill 1.4) (layers *.Cu *.Mask)) 22 | (pad 2 thru_hole circle (at 0 12.5) (size 2.5 2.5) (drill 1.4) (layers *.Cu *.Mask)) 23 | (pad 3 thru_hole circle (at 7.5 12.5) (size 2.5 2.5) (drill 1.4) (layers *.Cu *.Mask)) 24 | (pad 5 thru_hole circle (at 5 15) (size 2.5 2.5) (drill 1.4) (layers *.Cu *.Mask)) 25 | (pad 4 thru_hole circle (at -5 15) (size 2.5 2.5) (drill 1.4) (layers *.Cu *.Mask)) 26 | (pad 0 thru_hole circle (at -5 3) (size 2.5 2.5) (drill 1.4) (layers *.Cu *.Mask)) 27 | (pad 0 thru_hole circle (at 5 3) (size 2.5 2.5) (drill 1.4) (layers *.Cu *.Mask)) 28 | (model step/KCDX-5S-N_rA3.STEP 29 | (at (xyz 0 0 0)) 30 | (scale (xyz 1 1 1)) 31 | (rotate (xyz -90 0 180)) 32 | ) 33 | ) 34 | -------------------------------------------------------------------------------- /pcb/rev4/vera-module.pretty/MD-40S.kicad_mod: -------------------------------------------------------------------------------- 1 | (module MD-40S (layer F.Cu) (tedit 5DA85A93) 2 | (fp_text reference REF** (at 0 13.5) (layer F.SilkS) 3 | (effects (font (size 1 1) (thickness 0.15))) 4 | ) 5 | (fp_text value MD-40S (at 0 -0.5) (layer F.Fab) 6 | (effects (font (size 1 1) (thickness 0.15))) 7 | ) 8 | (fp_line (start -7 0) (end -7 12.4) (layer F.SilkS) (width 0.12)) 9 | (fp_line (start -7 12.4) (end 7 12.4) (layer F.SilkS) (width 0.12)) 10 | (fp_line (start 7 12.4) (end 7 0) (layer F.SilkS) (width 0.12)) 11 | (fp_line (start 7 0) (end -7 0) (layer F.SilkS) (width 0.12)) 12 | (fp_line (start -7 1.8) (end 7 1.8) (layer F.SilkS) (width 0.12)) 13 | (pad 0 thru_hole circle (at 0.05 4.7) (size 3 3) (drill 2.2) (layers *.Cu *.Mask)) 14 | (pad 1 thru_hole circle (at -3.4 8.5) (size 1.5 1.5) (drill 0.9) (layers *.Cu *.Mask)) 15 | (pad 2 thru_hole circle (at 3.4 8.5) (size 1.5 1.5) (drill 0.9) (layers *.Cu *.Mask)) 16 | (pad 3 thru_hole circle (at -3.4 11) (size 1.5 1.5) (drill 0.9) (layers *.Cu *.Mask)) 17 | (pad 4 thru_hole circle (at 3.4 11) (size 1.5 1.5) (drill 0.9) (layers *.Cu *.Mask)) 18 | (model step/CUI_MD-40S.step 19 | (offset (xyz 0 0 6.5)) 20 | (scale (xyz 1 1 1)) 21 | (rotate (xyz -90 0 -90)) 22 | ) 23 | ) 24 | -------------------------------------------------------------------------------- /pcb/rev4/vera-module.pretty/RCJ-014.kicad_mod: -------------------------------------------------------------------------------- 1 | (module RCJ-014 (layer F.Cu) (tedit 5D8B6947) 2 | (fp_text reference REF** (at 0 7) (layer F.SilkS) 3 | (effects (font (size 1 1) (thickness 0.15))) 4 | ) 5 | (fp_text value RCJ-014 (at 0 8.5) (layer F.Fab) 6 | (effects (font (size 1 1) (thickness 0.15))) 7 | ) 8 | (fp_line (start -5.3 -0.7) (end -5.3 2) (layer F.SilkS) (width 0.12)) 9 | (fp_line (start 1 5.75) (end 3 5.75) (layer F.SilkS) (width 0.12)) 10 | (fp_line (start 5.3 2) (end 5.3 -0.7) (layer F.SilkS) (width 0.12)) 11 | (fp_line (start 5.3 -0.7) (end -5.3 -0.7) (layer F.SilkS) (width 0.12)) 12 | (fp_line (start -3.15 -0.7) (end -3.15 -8.75) (layer F.Fab) (width 0.12)) 13 | (fp_line (start -3.15 -8.75) (end 3.15 -8.75) (layer F.Fab) (width 0.12)) 14 | (fp_line (start 3.15 -8.75) (end 3.15 -0.7) (layer F.Fab) (width 0.12)) 15 | (fp_line (start -5.3 -0.7) (end 5.3 -0.7) (layer F.Fab) (width 0.12)) 16 | (fp_line (start 5.3 -0.7) (end 5.3 5.75) (layer F.Fab) (width 0.12)) 17 | (fp_line (start 5.3 5.75) (end -5.3 5.75) (layer F.Fab) (width 0.12)) 18 | (fp_line (start -5.3 5.75) (end -5.3 -0.7) (layer F.Fab) (width 0.12)) 19 | (fp_line (start -3 5.75) (end -1 5.75) (layer F.SilkS) (width 0.12)) 20 | (pad 2 thru_hole circle (at 0 0) (size 4 4) (drill 2.6) (layers *.Cu *.Mask)) 21 | (pad 1 thru_hole circle (at 0 4.5) (size 2.5 2.5) (drill 1.7) (layers *.Cu *.Mask)) 22 | (pad 2 thru_hole circle (at 5 4.5) (size 4 4) (drill 2.6) (layers *.Cu *.Mask)) 23 | (pad 2 thru_hole circle (at -5 4.5) (size 4 4) (drill 2.6) (layers *.Cu *.Mask)) 24 | (model step/CUI_RCJ-014.step 25 | (offset (xyz 0 -5.75 6.6)) 26 | (scale (xyz 1 1 1)) 27 | (rotate (xyz -90 0 -90)) 28 | ) 29 | ) 30 | -------------------------------------------------------------------------------- /pcb/vera rev1.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/X16Community/vera-module/6e8bea68a5a04687149e27b1b7b3726fb01405f4/pcb/vera rev1.zip -------------------------------------------------------------------------------- /pcb/vera rev2.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/X16Community/vera-module/6e8bea68a5a04687149e27b1b7b3726fb01405f4/pcb/vera rev2.zip -------------------------------------------------------------------------------- /pcb/vera rev3.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/X16Community/vera-module/6e8bea68a5a04687149e27b1b7b3726fb01405f4/pcb/vera rev3.zip -------------------------------------------------------------------------------- /pcb/vera rev4.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/X16Community/vera-module/6e8bea68a5a04687149e27b1b7b3726fb01405f4/pcb/vera rev4.zip -------------------------------------------------------------------------------- /programmer/programmer_tool/.gitignore: -------------------------------------------------------------------------------- 1 | obj/ 2 | .vscode/ 3 | -------------------------------------------------------------------------------- /programmer/programmer_tool/Makefile: -------------------------------------------------------------------------------- 1 | INC_DIRS += . 2 | SRC_DIRS += . 3 | 4 | CFLAGS += -O0 -g 5 | OUT = $(OBJ_DIR)/programmer_tool 6 | CFLAGS += `pkg-config --cflags libusb-1.0` 7 | LFLAGS += `pkg-config --libs libusb-1.0` -pthread 8 | 9 | CFLAGS += -D_BSD_SOURCE -D_DEFAULT_SOURCE -std=c11 -pedantic 10 | CFLAGS += -Wall -Wextra -Wshadow -Winit-self -Wfloat-conversion -Wdouble-promotion -Wmissing-include-dirs 11 | CFLAGS += -Werror=implicit-function-declaration 12 | OBJ_DIR ?= obj 13 | 14 | CFLAGS += -MD $(addprefix -I,$(INC_DIRS)) 15 | 16 | #----------------------------------------------------------------------------- 17 | # sources 18 | #----------------------------------------------------------------------------- 19 | C_SRCS += $(wildcard $(addsuffix /*.c, $(SRC_DIRS))) 20 | 21 | #----------------------------------------------------------------------------- 22 | # object files 23 | #----------------------------------------------------------------------------- 24 | C_OBJS := $(addprefix $(OBJ_DIR)/, $(C_SRCS:.c=.o)) 25 | OBJS := $(C_OBJS) 26 | DEPS := $(OBJS:.o=.d) 27 | 28 | #----------------------------------------------------------------------------- 29 | # rules 30 | #----------------------------------------------------------------------------- 31 | 32 | .PHONY: all clean run debug 33 | 34 | all: $(OUT) 35 | 36 | $(OUT): $(OBJ_DIR) $(OBJS) 37 | @echo Linking $@ 38 | @$(CC) $(OBJS) $(CFLAGS) $(LFLAGS) -o $@ 39 | 40 | $(C_OBJS): $(OBJ_DIR)/%.o: %.c 41 | @echo Compiling $< 42 | @$(CC) $(CFLAGS) -o $@ -c $< 43 | 44 | $(OBJ_DIR): 45 | @mkdir -p $(dir $(C_OBJS)) 46 | 47 | run: $(OUT) 48 | $(OUT) $(RUN_PARAMS) 49 | 50 | debug: $(OUT) 51 | gdb -ex "b main" -ex "run" -q --tui --args $(OUT) $(RUN_PARAMS) 52 | 53 | clean: 54 | @echo Cleaning... 55 | @rm -f $(OUT) 56 | @rm -rf $(OBJ_DIR) 57 | 58 | .DEFAULT_GOAL = all 59 | 60 | -include $(DEPS) 61 | -------------------------------------------------------------------------------- /programmer/programmer_tool/README.md: -------------------------------------------------------------------------------- 1 | # install 2 | `sudo apt install pkg-config libusb-1.0-0-dev` 3 | -------------------------------------------------------------------------------- /programmer/programmer_tool/flash.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | struct flash_info { 6 | const char *name; 7 | unsigned size; 8 | unsigned sector_size; 9 | unsigned page_size; 10 | // unsigned block_size; 11 | }; 12 | 13 | const struct flash_info *flash_detect(); 14 | void flash_read(unsigned address, void *data, unsigned size); 15 | int flash_compare(unsigned address, const void *data, unsigned size); 16 | void flash_write(const struct flash_info *flash_info, unsigned address, const void *data, unsigned size); 17 | void flash_flush(const struct flash_info *flash_info); 18 | void flash_test(const struct flash_info *flash_info); 19 | -------------------------------------------------------------------------------- /programmer/programmer_tool/lib.c: -------------------------------------------------------------------------------- 1 | #include "lib.h" 2 | 3 | void hexdump(const void *buf, int length) { 4 | int idx = 0; 5 | const uint8_t *p = (const uint8_t *)buf; 6 | 7 | while (length > 0) { 8 | int len = length; 9 | if (len > 16) { 10 | len = 16; 11 | } 12 | 13 | printf("%08x ", idx); 14 | 15 | for (int i = 0; i < 16; i++) { 16 | if (i < len) { 17 | printf("%02x ", p[i]); 18 | } else { 19 | printf(" "); 20 | } 21 | if (i == 7) { 22 | printf(" "); 23 | } 24 | } 25 | printf(" |"); 26 | 27 | for (int i = 0; i < len; i++) { 28 | printf("%c", (p[i] >= 32 && p[i] <= 126) ? p[i] : '.'); 29 | } 30 | printf("|\n"); 31 | 32 | idx += len; 33 | length -= len; 34 | p += len; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /programmer/programmer_tool/lib.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | void hexdump(const void *buf, int length); 14 | -------------------------------------------------------------------------------- /programmer/programmer_tool/usb.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "lib.h" 4 | 5 | enum { 6 | CMD_SPI_MODE_NONE = 0x20, 7 | CMD_SPI_MODE_FPGA_BOOT = 0x21, 8 | CMD_SPI_MODE_FPGA = 0x22, 9 | CMD_SPI_MODE_FLASH = 0x23, 10 | 11 | CMD_GET_CDONE = 0x28, 12 | 13 | CMD_SPI_SHIFT_TX = 0x30, 14 | CMD_SPI_SHIFT_RX = 0x31, 15 | CMD_SPI_SHIFT_TX_RX = 0x32, 16 | 17 | CMD_SPI_CHIP_SELECT = 0x33, 18 | CMD_SPI_CHIP_DESELECT = 0x34, 19 | 20 | CMD_MASS_STORAGE_MODE = 0x40, 21 | CMD_MASS_ERASE = 0xFF, 22 | }; 23 | 24 | void usb_init(void); 25 | 26 | enum spi_mode { 27 | SPI_MODE_NONE, 28 | SPI_MODE_FPGA_BOOT, 29 | SPI_MODE_FPGA, 30 | SPI_MODE_FLASH, 31 | }; 32 | 33 | void spi_set_mode(enum spi_mode mode); 34 | void spi_select(bool on); 35 | void spi_transfer(const void *tx_buf, void *rx_buf, size_t length); 36 | 37 | bool get_cdone(void); 38 | 39 | void start_mass_erase(void); 40 | -------------------------------------------------------------------------------- /programmer/stm32/.gitignore: -------------------------------------------------------------------------------- 1 | obj/ 2 | .vscode/ 3 | -------------------------------------------------------------------------------- /programmer/stm32/flash.c: -------------------------------------------------------------------------------- 1 | #include "lib.h" 2 | #include "flash.h" 3 | 4 | __attribute__((section(".ramcode"))) static bool flash_wait_for_last_operation() { 5 | uint32_t timeout = 0x000B0000; 6 | do { 7 | bool ready = ((FLASH->SR & FLASH_SR_BSY) == 0); // && ((FLASH->SR & (uint32_t)FLASH_SR_WRPERR) == 0) && ((FLASH->SR & (uint32_t)(FLASH_SR_PGERR)) == 0)); 8 | if (ready) { 9 | break; 10 | } 11 | if (--timeout == 0) { 12 | break; 13 | } 14 | } while (true); 15 | return (timeout != 0); 16 | } 17 | 18 | __attribute__((section(".ramcode"))) bool flash_mass_erase(void) { 19 | __disable_irq(); 20 | 21 | FLASH->ACR = 0; 22 | 23 | bool status = flash_wait_for_last_operation(); 24 | if (status) { 25 | if ((FLASH->CR & FLASH_CR_LOCK) != 0) { 26 | FLASH->KEYR = FLASH_KEY1; 27 | FLASH->KEYR = FLASH_KEY2; 28 | } 29 | 30 | FLASH->CR |= FLASH_CR_MER; 31 | FLASH->CR |= FLASH_CR_STRT; 32 | status = flash_wait_for_last_operation(); 33 | FLASH->CR &= ~FLASH_CR_MER; 34 | 35 | FLASH->CR |= FLASH_CR_LOCK; 36 | 37 | FLASH->CR |= FLASH_CR_OBL_LAUNCH; 38 | 39 | NVIC_SystemReset(); 40 | } 41 | return false; 42 | } 43 | -------------------------------------------------------------------------------- /programmer/stm32/flash.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | bool flash_mass_erase(void) __attribute__((section(".ramcode"))); 4 | -------------------------------------------------------------------------------- /programmer/stm32/iopins.h: -------------------------------------------------------------------------------- 1 | #ifndef IO_DEFINE 2 | # define IO_DEFINE(name, bank, io, invert, mode, initial_value, is_open_drain, speed, pull_up_down, function) 3 | #endif 4 | 5 | // clang-format off 6 | IO_DEFINE(IO_USB_DM, IOBANK_A, 11, 0, IOMODE_ALT, 0, 0, IOSPEED_FAST, IOPULL_NONE, 2) 7 | IO_DEFINE(IO_USB_DP, IOBANK_A, 12, 0, IOMODE_ALT, 0, 0, IOSPEED_FAST, IOPULL_NONE, 2) 8 | 9 | IO_DEFINE(IO_FPGA_CDONE, IOBANK_A, 0, 0, IOMODE_IN, 0, 0, IOSPEED_FAST, IOPULL_UP, 0) 10 | IO_DEFINE(IO_FPGA_RESET, IOBANK_A, 1, 1, IOMODE_OUT, 1, 0, IOSPEED_FAST, IOPULL_NONE, 0) 11 | IO_DEFINE(IO_DBG_TXD, IOBANK_A, 2, 0, IOMODE_ALT, 0, 0, IOSPEED_FAST, IOPULL_NONE, 1) // USART2_TX 12 | IO_DEFINE(IO_DBG_RXD, IOBANK_A, 3, 0, IOMODE_ALT, 0, 0, IOSPEED_FAST, IOPULL_NONE, 1) // USART2_RX 13 | IO_DEFINE(IO_FPGA_SSEL, IOBANK_A, 4, 1, IOMODE_OUT, 0, 0, IOSPEED_FAST, IOPULL_NONE, 0) 14 | IO_DEFINE(IO_SPI_SCK, IOBANK_A, 5, 0, IOMODE_ALT, 0, 0, IOSPEED_FAST, IOPULL_NONE, 0) // SPI1_SCK 15 | IO_DEFINE(IO_SPI_MISO, IOBANK_A, 6, 0, IOMODE_ALT, 0, 0, IOSPEED_FAST, IOPULL_NONE, 0) // SPI1_MISO 16 | IO_DEFINE(IO_SPI_MOSI, IOBANK_A, 7, 0, IOMODE_ALT, 0, 0, IOSPEED_FAST, IOPULL_NONE, 0) // SPI1_MOSI 17 | -------------------------------------------------------------------------------- /programmer/stm32/lib/assert.c: -------------------------------------------------------------------------------- 1 | #define MODULE_NAME "ASSERT" 2 | #define MODULE_TYPE ANSI_ERROR 3 | 4 | #include "lib.h" 5 | 6 | /** 7 | * @brief Assert handler used by assert function 8 | * 9 | * @param filename The filename 10 | * @param line The line 11 | * @param function The function 12 | * @param expression The expression 13 | */ 14 | void __assert_func(const char *filename, int line, const char *function, const char *expression) { 15 | __disable_irq(); 16 | DBGF("Assertion (%s) failed in %s (%s:%d)\n", expression, function, filename, line); 17 | while (1) { 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /programmer/stm32/lib/clock.c: -------------------------------------------------------------------------------- 1 | #include "clock.h" 2 | #include "io.h" 3 | 4 | void clock_init(void) { 5 | clock_enable(CLK_PWR); 6 | clock_enable(CLK_SYSCFG); 7 | 8 | // Configure flash (1 waitstate) 9 | FLASH->ACR = FLASH_ACR_PRFTBE | FLASH_ACR_LATENCY; 10 | 11 | // Enable HSE (8MHz crystal) and wait for it to be ready 12 | RCC->CR |= RCC_CR_HSEON; 13 | while ((RCC->CR & RCC_CR_HSERDY) == 0) { 14 | } 15 | 16 | // HCLK = SYSCLK/1, PCLK2 = HCLK/1, PCLK1 = HCLK/1 17 | RCC->CFGR = RCC_CFGR_HPRE_DIV1 | RCC_CFGR_PPRE_DIV1; 18 | 19 | // Configure PLL 20 | RCC->CFGR |= RCC_CFGR_PLLMUL6 | RCC_CFGR_PLLSRC_HSE_PREDIV; 21 | RCC->CFGR2 = RCC_CFGR2_PREDIV_DIV1; 22 | RCC->CR |= RCC_CR_PLLON; 23 | while ((RCC->CR & RCC_CR_PLLRDY) == 0) { 24 | } 25 | 26 | // Select PLL as system clock source 27 | RCC->CFGR = (RCC->CFGR & ~RCC_CFGR_SW) | RCC_CFGR_SW_PLL; 28 | while ((RCC->CFGR & RCC_CFGR_SWS) != RCC_CFGR_SWS_PLL) { 29 | } 30 | } 31 | 32 | void clock_enable(enum clock clk) { 33 | uint32_t bus = clk & 0xF00; 34 | uint32_t bit = 1 << (clk & 0xFF); 35 | switch (bus) { 36 | case CLKBUS_AHB: RCC->AHBENR |= bit; break; 37 | case CLKBUS_APB1: RCC->APB1ENR |= bit; break; 38 | case CLKBUS_APB2: RCC->APB2ENR |= bit; break; 39 | } 40 | } 41 | 42 | void clock_disable(enum clock clk) { 43 | uint32_t bus = clk & 0xF00; 44 | uint32_t bit = 1 << (clk & 0xFF); 45 | switch (bus) { 46 | case CLKBUS_AHB: RCC->AHBENR &= ~bit; break; 47 | case CLKBUS_APB1: RCC->APB1ENR &= ~bit; break; 48 | case CLKBUS_APB2: RCC->APB2ENR &= ~bit; break; 49 | } 50 | } 51 | 52 | uint32_t clock_get_frequency(enum clock clk) { 53 | uint32_t frequency = 0; 54 | 55 | uint32_t cfgr = RCC->CFGR; 56 | 57 | int hpre = (cfgr >> 4) & 0xF; 58 | uint32_t ahb_prescaler = (hpre & 8) ? (2 << (hpre & 7)) : 1; 59 | 60 | uint32_t bus = clk & 0xF00; 61 | bool is_timer = (clk & CLK_IS_TIMER) != 0; 62 | 63 | switch (bus) { 64 | case CLKBUS_AHB: { 65 | frequency = SYSCLK_FREQ / ahb_prescaler; 66 | break; 67 | } 68 | 69 | case CLKBUS_APB1: { 70 | int ppre1 = (cfgr >> 8) & 0x7; 71 | uint32_t apb1_prescaler = (ppre1 & 4) ? (2 << (ppre1 & 3)) : 1; 72 | 73 | frequency = SYSCLK_FREQ / (ahb_prescaler * apb1_prescaler); 74 | 75 | if ((ppre1 & 4) != 0 && is_timer) { 76 | // When APB prescaler == 1, timer clocks are multiplied by 2 77 | frequency *= 2; 78 | } 79 | break; 80 | } 81 | 82 | case CLKBUS_APB2: { 83 | int ppre2 = (cfgr >> 11) & 0x7; 84 | uint32_t apb2_prescaler = (ppre2 & 4) ? (2 << (ppre2 & 3)) : 1; 85 | 86 | frequency = SYSCLK_FREQ / (ahb_prescaler * apb2_prescaler); 87 | 88 | if ((ppre2 & 4) != 0 && is_timer) { 89 | // When APB prescaler == 1, timer clocks are multiplied by 2 90 | frequency *= 2; 91 | } 92 | break; 93 | } 94 | } 95 | return frequency; 96 | } 97 | -------------------------------------------------------------------------------- /programmer/stm32/lib/clock.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "common.h" 4 | 5 | enum clock_bus { 6 | CLKBUS_AHB = 0x100, 7 | CLKBUS_APB1 = 0x200, 8 | CLKBUS_APB2 = 0x300, 9 | }; 10 | 11 | #define CLK_IS_TIMER 0x1000 12 | 13 | enum clock { 14 | CLK_DMA = CLKBUS_AHB | 0, 15 | CLK_SRAM = CLKBUS_AHB | 2, 16 | CLK_FLITF = CLKBUS_AHB | 4, 17 | CLK_CRC = CLKBUS_AHB | 6, 18 | CLK_GPIOA = CLKBUS_AHB | 17, 19 | CLK_GPIOB = CLKBUS_AHB | 18, 20 | CLK_GPIOC = CLKBUS_AHB | 19, 21 | CLK_GPIOD = CLKBUS_AHB | 20, 22 | CLK_GPIOF = CLKBUS_AHB | 22, 23 | 24 | CLK_TIM3 = CLKBUS_APB1 | 1 | CLK_IS_TIMER, 25 | CLK_TIM6 = CLKBUS_APB1 | 4 | CLK_IS_TIMER, 26 | CLK_TIM7 = CLKBUS_APB1 | 5 | CLK_IS_TIMER, 27 | CLK_TIM14 = CLKBUS_APB1 | 8 | CLK_IS_TIMER, 28 | CLK_WWDG = CLKBUS_APB1 | 11, 29 | CLK_SPI2 = CLKBUS_APB1 | 14, 30 | CLK_USART2 = CLKBUS_APB1 | 17, 31 | CLK_USART3 = CLKBUS_APB1 | 18, 32 | CLK_USART4 = CLKBUS_APB1 | 19, 33 | CLK_USART5 = CLKBUS_APB1 | 20, 34 | CLK_I2C1 = CLKBUS_APB1 | 21, 35 | CLK_I2C2 = CLKBUS_APB1 | 22, 36 | CLK_USB = CLKBUS_APB1 | 23, 37 | CLK_PWR = CLKBUS_APB1 | 28, 38 | 39 | CLK_SYSCFG = CLKBUS_APB2 | 0, 40 | CLK_USART6 = CLKBUS_APB2 | 5, 41 | CLK_ADC = CLKBUS_APB2 | 9, 42 | CLK_TIM1 = CLKBUS_APB2 | 11 | CLK_IS_TIMER, 43 | CLK_SPI1 = CLKBUS_APB2 | 12, 44 | CLK_USART1 = CLKBUS_APB2 | 14, 45 | CLK_TIM15 = CLKBUS_APB2 | 16 | CLK_IS_TIMER, 46 | CLK_TIM16 = CLKBUS_APB2 | 17 | CLK_IS_TIMER, 47 | CLK_TIM17 = CLKBUS_APB2 | 18 | CLK_IS_TIMER, 48 | CLK_DBGMCU = CLKBUS_APB2 | 22, 49 | }; 50 | 51 | void clock_init(void); 52 | void clock_enable(enum clock clk); 53 | void clock_disable(enum clock clk); 54 | uint32_t clock_get_frequency(enum clock clk); 55 | -------------------------------------------------------------------------------- /programmer/stm32/lib/common.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | */ 4 | #pragma once 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | #include 12 | #include 13 | #include 14 | #include 15 | 16 | #include "config.h" 17 | #include "mcu.h" 18 | 19 | /** 20 | * @brief OS time type. The time is expressed in system ticks. 21 | * @ingroup os 22 | */ 23 | typedef uint64_t os_time_t; 24 | 25 | /** 26 | * @brief Memory barrier. The compiler will refetch any register-cached 27 | * variables after this. 28 | * @ingroup lib 29 | */ 30 | static inline void __membar(void) { 31 | __asm__ __volatile__("" :: 32 | : "memory"); 33 | } 34 | 35 | /** 36 | * @brief Enter atomic section. Should be closed with ATOMIC_SECTION_LEAVE. 37 | * Interrupts are disabled during the atomic section. Interrupt 38 | * state is restored after closing the atomic section with 39 | * ATOMIC_SECTION_LEAVE. 40 | * @ingroup lib 41 | */ 42 | #define ATOMIC_SECTION_ENTER \ 43 | { \ 44 | __DSB(); \ 45 | uint32_t __atomic; \ 46 | __asm volatile("mrs %0, primask" \ 47 | : "=r"(__atomic)); \ 48 | __asm volatile("cpsid i"); 49 | 50 | /** 51 | * @brief Leave atomic section. Should be preceeded by accompanying with 52 | * ATOMIC_SECTION_ENTER. Interrupt state is restored after closing 53 | * the atomic section to the same state it was before entering the 54 | * atomic section. 55 | * @ingroup lib 56 | */ 57 | #define ATOMIC_SECTION_LEAVE \ 58 | __asm volatile("msr primask, %0" ::"r"(__atomic)); \ 59 | __DSB(); \ 60 | } 61 | 62 | /** 63 | * @brief Get number of elements in array 64 | * @ingroup lib 65 | * 66 | * @param x Array 67 | * 68 | * @return Number of elements in array 69 | */ 70 | #define NUM_ARRAY_ELEMENTS(x) (sizeof((x)) / sizeof((x)[0])) 71 | -------------------------------------------------------------------------------- /programmer/stm32/lib/config.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define STACK_SIZE (1024) 4 | #define RTT_BUFFER_SIZE (512) 5 | -------------------------------------------------------------------------------- /programmer/stm32/lib/core_cmFunc.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************//** 2 | * @file core_cmFunc.h 3 | * @brief CMSIS Cortex-M Core Function Access Header File 4 | * @version V4.30 5 | * @date 20. October 2015 6 | ******************************************************************************/ 7 | /* Copyright (c) 2009 - 2015 ARM LIMITED 8 | 9 | All rights reserved. 10 | Redistribution and use in source and binary forms, with or without 11 | modification, are permitted provided that the following conditions are met: 12 | - Redistributions of source code must retain the above copyright 13 | notice, this list of conditions and the following disclaimer. 14 | - Redistributions in binary form must reproduce the above copyright 15 | notice, this list of conditions and the following disclaimer in the 16 | documentation and/or other materials provided with the distribution. 17 | - Neither the name of ARM nor the names of its contributors may be used 18 | to endorse or promote products derived from this software without 19 | specific prior written permission. 20 | * 21 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 22 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 | ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE 25 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 26 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 27 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 29 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 30 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 31 | POSSIBILITY OF SUCH DAMAGE. 32 | ---------------------------------------------------------------------------*/ 33 | 34 | 35 | #if defined ( __ICCARM__ ) 36 | #pragma system_include /* treat file as system include file for MISRA check */ 37 | #elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) 38 | #pragma clang system_header /* treat file as system include file */ 39 | #endif 40 | 41 | #ifndef __CORE_CMFUNC_H 42 | #define __CORE_CMFUNC_H 43 | 44 | 45 | /* ########################### Core Function Access ########################### */ 46 | /** \ingroup CMSIS_Core_FunctionInterface 47 | \defgroup CMSIS_Core_RegAccFunctions CMSIS Core Register Access Functions 48 | @{ 49 | */ 50 | 51 | /*------------------ RealView Compiler -----------------*/ 52 | #if defined ( __CC_ARM ) 53 | #include "cmsis_armcc.h" 54 | 55 | /*------------------ ARM Compiler V6 -------------------*/ 56 | #elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) 57 | #include "cmsis_armcc_V6.h" 58 | 59 | /*------------------ GNU Compiler ----------------------*/ 60 | #elif defined ( __GNUC__ ) 61 | #include "cmsis_gcc.h" 62 | 63 | /*------------------ ICC Compiler ----------------------*/ 64 | #elif defined ( __ICCARM__ ) 65 | #include 66 | 67 | /*------------------ TI CCS Compiler -------------------*/ 68 | #elif defined ( __TMS470__ ) 69 | #include 70 | 71 | /*------------------ TASKING Compiler ------------------*/ 72 | #elif defined ( __TASKING__ ) 73 | /* 74 | * The CMSIS functions have been implemented as intrinsics in the compiler. 75 | * Please use "carm -?i" to get an up to date list of all intrinsics, 76 | * Including the CMSIS ones. 77 | */ 78 | 79 | /*------------------ COSMIC Compiler -------------------*/ 80 | #elif defined ( __CSMC__ ) 81 | #include 82 | 83 | #endif 84 | 85 | /*@} end of CMSIS_Core_RegAccFunctions */ 86 | 87 | #endif /* __CORE_CMFUNC_H */ 88 | -------------------------------------------------------------------------------- /programmer/stm32/lib/lib.c: -------------------------------------------------------------------------------- 1 | #include "lib.h" 2 | 3 | void hexdump(const void *buf, int length) { 4 | int idx = 0; 5 | const uint8_t *p = (const uint8_t *)buf; 6 | 7 | while (length > 0) { 8 | int len = length; 9 | if (len > 16) { 10 | len = 16; 11 | } 12 | 13 | DBGF("%08x ", idx); 14 | 15 | for (int i = 0; i < 16; i++) { 16 | if (i < len) { 17 | DBGF2("%02x ", p[i]); 18 | } else { 19 | DBGF2(" "); 20 | } 21 | if (i == 7) { 22 | DBGF2(" "); 23 | } 24 | } 25 | DBGF2(" |"); 26 | 27 | for (int i = 0; i < len; i++) { 28 | DBGF2("%c", (p[i] >= 32 && p[i] <= 126) ? p[i] : '.'); 29 | } 30 | DBGF2("|\n"); 31 | 32 | idx += len; 33 | length -= len; 34 | p += len; 35 | 36 | udelay(10000); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /programmer/stm32/lib/lib.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "common.h" 4 | #include "rtt.h" 5 | #include "clock.h" 6 | #include "io.h" 7 | #include "os.h" 8 | #include "buf_reader.h" 9 | 10 | void hexdump(const void *buf, int length); 11 | -------------------------------------------------------------------------------- /programmer/stm32/lib/linkerscript: -------------------------------------------------------------------------------- 1 | MEMORY { 2 | rom (rx) : ORIGIN = 0x08000000, LENGTH = 0x00008000 /* 32k */ 3 | ram (rwx) : ORIGIN = 0x20000000, LENGTH = 0x00001800 /* 6k */ 4 | } 5 | 6 | ENTRY(reset_handler) 7 | 8 | SECTIONS { 9 | /DISCARD/ : { 10 | *(*.data._impure_ptr) 11 | } 12 | 13 | .text : ALIGN(4) { 14 | FILL(0xff) 15 | _stext = .; 16 | KEEP(*(.vectors)) 17 | *(.text*) 18 | *(.rodata) 19 | *(.rodata.*) 20 | . = ALIGN(4); 21 | } > rom 22 | 23 | . = ALIGN(4); 24 | _etext = .; 25 | 26 | .data : ALIGN(4) { 27 | FILL(0xff) 28 | _srelocate = .; 29 | *(vtable) 30 | *(.data*) 31 | 32 | . = ALIGN(4); 33 | *(.ramcode) 34 | 35 | . = ALIGN(4); 36 | _erelocate = .; 37 | } > ram AT > rom 38 | 39 | .bss : ALIGN(4) { 40 | _bss = .; 41 | *(.bss*) 42 | *(COMMON) 43 | . = ALIGN(4); 44 | _ebss = .; 45 | } > ram 46 | 47 | .noinit : ALIGN(4) { 48 | *(.noinit*) 49 | . = ALIGN(4); 50 | } > ram 51 | 52 | .stack (NOLOAD): { 53 | . = ALIGN(8); 54 | _sstack = .; 55 | KEEP(*(.stack_area)) 56 | . = ALIGN(8); 57 | _estack = .; 58 | } > ram 59 | 60 | . = ALIGN(4); 61 | _end = . ; 62 | } 63 | -------------------------------------------------------------------------------- /programmer/stm32/lib/lltimer.c: -------------------------------------------------------------------------------- 1 | #include "lltimer.h" 2 | #include "lib.h" 3 | 4 | static uint32_t upper_bits = 0; 5 | static uint64_t callback_value = -1ULL; 6 | static volatile bool initialized = false; 7 | 8 | #define CALLBACK_MINIMUM_OFFSET (10) 9 | 10 | void lltimer_init(void) { 11 | clock_enable(CLK_TIM14); 12 | uint32_t clkfreq = clock_get_frequency(CLK_TIM14); 13 | 14 | uint32_t prescaler = (clkfreq / TICKS_PER_SECOND); 15 | assert(prescaler < 65536); 16 | 17 | TIM14->CR1 = 0; 18 | TIM14->PSC = prescaler - 1; 19 | TIM14->CNT = 0; 20 | TIM14->ARR = 65535; 21 | TIM14->DIER = TIM_DIER_UIE; 22 | TIM14->CCMR1 = (1 << 4); 23 | TIM14->CCER = 0; 24 | TIM14->EGR = TIM_EGR_UG; // Force update event to ensure prescaler is used 25 | TIM14->CR1 |= TIM_CR1_CEN; 26 | TIM14->SR = 0; 27 | 28 | NVIC_SetPriority(TIM14_IRQn, 3); 29 | NVIC_EnableIRQ(TIM14_IRQn); 30 | 31 | initialized = true; 32 | } 33 | 34 | uint64_t lltimer_get_counter_value(void) { 35 | if (!initialized) { 36 | return 0; 37 | } 38 | 39 | uint64_t total_cnt; 40 | 41 | ATOMIC_SECTION_ENTER { 42 | uint16_t cnt2, sr2; 43 | uint16_t cnt = TIM14->CNT; 44 | uint16_t sr = TIM14->SR; 45 | do { 46 | cnt2 = cnt; 47 | sr2 = sr; 48 | cnt = TIM14->CNT; 49 | sr = TIM14->SR; 50 | } while (cnt != cnt2 || sr != sr2); 51 | 52 | if (sr & TIM_SR_UIF) { 53 | upper_bits++; 54 | TIM14->SR = ~TIM_SR_UIF; 55 | } 56 | 57 | total_cnt = ((uint64_t)upper_bits << 16) | cnt; 58 | } 59 | ATOMIC_SECTION_LEAVE 60 | 61 | return total_cnt; 62 | } 63 | 64 | void lltimer_cancel_counter_callback(void) { 65 | ATOMIC_SECTION_ENTER { 66 | TIM14->DIER &= ~TIM_DIER_CC1IE; 67 | } 68 | ATOMIC_SECTION_LEAVE 69 | } 70 | 71 | static inline void set_compare_value(void) { 72 | TIM14->DIER &= ~TIM_DIER_CC1IE; 73 | 74 | uint64_t current_value = lltimer_get_counter_value(); 75 | uint64_t callback_value2 = callback_value; 76 | 77 | if (callback_value2 < current_value + CALLBACK_MINIMUM_OFFSET) { 78 | // Callback value too soon, push it a bit into the future. 79 | callback_value2 = current_value + CALLBACK_MINIMUM_OFFSET; 80 | } 81 | 82 | uint64_t diff = callback_value2 - current_value; 83 | if (diff < 65536) { 84 | TIM14->CCR1 = callback_value2 & 0xFFFF; 85 | TIM14->SR = ~TIM_SR_CC1IF; 86 | TIM14->DIER |= TIM_DIER_CC1IE; 87 | } 88 | } 89 | 90 | void lltimer_callback_on_counter_value(uint64_t value) { 91 | ATOMIC_SECTION_ENTER { 92 | callback_value = value; 93 | set_compare_value(); 94 | } 95 | ATOMIC_SECTION_LEAVE 96 | } 97 | 98 | void tim14_irq_handler(void) { 99 | bool do_callback = false; 100 | 101 | ATOMIC_SECTION_ENTER { 102 | uint16_t sr = TIM14->SR; 103 | TIM14->SR = 0; 104 | 105 | bool cc_enabled = (TIM14->DIER & TIM_DIER_CC1IE) != 0; 106 | 107 | if (sr & TIM_SR_UIF) { 108 | upper_bits++; 109 | 110 | // Check if it is time to set the compare register to trigger a callback 111 | if (!cc_enabled) { 112 | set_compare_value(); 113 | } 114 | } 115 | if (cc_enabled && (sr & TIM_SR_CC1IF) != 0) { 116 | TIM14->DIER &= ~TIM_DIER_CC1IE; 117 | do_callback = true; 118 | } 119 | } 120 | ATOMIC_SECTION_LEAVE 121 | 122 | if (do_callback) { 123 | lltimer_callback(); 124 | } 125 | } 126 | -------------------------------------------------------------------------------- /programmer/stm32/lib/lltimer.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "common.h" 4 | 5 | #define TICKS_PER_SECOND (10000) 6 | #define MS_TO_TICKS(x) ((x)*10) 7 | 8 | void lltimer_init(void); 9 | uint64_t lltimer_get_counter_value(void); 10 | void lltimer_cancel_counter_callback(void); 11 | void lltimer_callback_on_counter_value(uint64_t value); 12 | 13 | // Implemented by OS 14 | extern void lltimer_callback(void); 15 | -------------------------------------------------------------------------------- /programmer/stm32/lib/mcu.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "stm32f070x6.h" 4 | 5 | #define SYSCLK_FREQ (48000000) 6 | #define NUM_MCU_INTERRUPTS (32) 7 | 8 | static inline void udelay(uint32_t dt) { 9 | uint32_t count = (dt * (SYSCLK_FREQ / 1000000)) / 4; 10 | if (count) { 11 | __asm__ __volatile__("1: sub %0, %0, #1; beq 2f; b 1b; 2:" 12 | : "+r"(count)); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /programmer/stm32/lib/rtt.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | */ 4 | 5 | /** @ingroup lib 6 | * @{ */ 7 | 8 | #pragma once 9 | 10 | #include 11 | #include 12 | 13 | #ifdef MODULE_NAME 14 | # define MODULE_NAME_STR "[" MODULE_NAME "] " 15 | #else 16 | # define MODULE_NAME_STR "" 17 | #endif 18 | 19 | #ifndef MODULE_TYPE 20 | # define MODULE_TYPE "" 21 | #endif 22 | 23 | // clang-format off 24 | #define ANSI_ERROR ANSI_BG_RED ANSI_WHITE 25 | 26 | #define MODULE_TYPE_DRIVER ANSI_GREEN 27 | #define MODULE_TYPE_OS ANSI_YELLOW 28 | #define MODULE_TYPE_RADIO ANSI_MAGENTA 29 | #define MODULE_TYPE_NETWORK ANSI_CYAN 30 | #define MODULE_TYPE_GAPP ANSI_BOLD ANSI_BLUE 31 | 32 | #define DBGF(...) printf(MODULE_TYPE MODULE_NAME_STR __VA_ARGS__) 33 | #define DBGF2(...) printf(__VA_ARGS__) 34 | 35 | #define ANSI_RESET "\033[0m" 36 | #define ANSI_BOLD "\033[1m" 37 | 38 | #define ANSI_CURSOR_HOME "\033[H" 39 | #define ANSI_CLEAR_SCREEN "\033[2J" 40 | #define ANSI_CLEAR_SCROLLBACK "\033[3J" 41 | 42 | #define ANSI_BLACK "\033[30m" 43 | #define ANSI_RED "\033[31m" 44 | #define ANSI_GREEN "\033[32m" 45 | #define ANSI_YELLOW "\033[33m" 46 | #define ANSI_BLUE "\033[34m" 47 | #define ANSI_MAGENTA "\033[35m" 48 | #define ANSI_CYAN "\033[36m" 49 | #define ANSI_WHITE "\033[37m" 50 | 51 | #define ANSI_BG_BLACK "\033[40m" 52 | #define ANSI_BG_RED "\033[41m" 53 | #define ANSI_BG_GREEN "\033[42m" 54 | #define ANSI_BG_YELLOW "\033[43m" 55 | #define ANSI_BG_BLUE "\033[44m" 56 | #define ANSI_BG_MAGENTA "\033[45m" 57 | #define ANSI_BG_CYAN "\033[46m" 58 | #define ANSI_BG_WHITE "\033[47m" 59 | // clang-format on 60 | 61 | /** 62 | * @brief Clear RTT debug output screen 63 | */ 64 | void clear_screen(void); 65 | 66 | /** 67 | * @brief Print formatted string to RTT debug output 68 | * 69 | * @param format Format string 70 | * @param ... Arguments to be formatted 71 | * 72 | * @return Number of characters produced 73 | */ 74 | int printf(const char *format, ...) __attribute__((format(printf, 1, 2))); 75 | 76 | /** 77 | * @brief Print formatted string to RTT debug output 78 | * 79 | * @param format Format string 80 | * @param ap Variable arguments list containing arguments to format 81 | * 82 | * @return Number of characters produced 83 | */ 84 | int vprintf(const char *format, va_list ap); 85 | 86 | /** 87 | * @brief Generic handler of printf style strings. Will call callback handler for produced characters. 88 | * 89 | * @param char_out Callback handler called for each produced character 90 | * @param context User defined pointer passed to callback handler 91 | * @param format Printf format string 92 | * @param ap Variable arguments list containing arguments to format 93 | * 94 | * @return Number of characters produced 95 | */ 96 | int printf_handler(void (*char_out)(void *, char), void *context, const char *format, va_list ap); 97 | 98 | /** 99 | * @brief Read data from host (non-blocking) 100 | * 101 | * @param buf Pointer to buffer to store data 102 | * @param length Maximum bytes to read 103 | * 104 | * @return Bytes read (0 if no bytes available) 105 | */ 106 | size_t rtt_read(void *buf, size_t length); 107 | 108 | /** @} */ 109 | -------------------------------------------------------------------------------- /programmer/stm32/lib/stm32f070x6.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/X16Community/vera-module/6e8bea68a5a04687149e27b1b7b3726fb01405f4/programmer/stm32/lib/stm32f070x6.h -------------------------------------------------------------------------------- /programmer/stm32/os/os.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | */ 4 | 5 | /** 6 | * @defgroup os Operating System 7 | * @brief The simple cooperative multitasking system. 8 | */ 9 | 10 | #pragma once 11 | 12 | #include "common.h" 13 | #include "list_node.h" 14 | #include "task.h" 15 | #include "lltimer.h" 16 | #include "timer.h" 17 | 18 | /** 19 | * @brief Get current OS time. This is the number of system ticks since 20 | * start of the software. 21 | * @ingroup os 22 | * 23 | * @return Current OS time. 24 | */ 25 | static inline os_time_t os_get_time(void) { 26 | return lltimer_get_counter_value(); 27 | } 28 | -------------------------------------------------------------------------------- /programmer/stm32/os/task.c: -------------------------------------------------------------------------------- 1 | #include "task.h" 2 | #include "lib.h" 3 | 4 | LIST_NODE(posted_tasks); 5 | static struct task *current_task; 6 | 7 | void task_init(struct task *task, void (*handler)(void), void *arg) { 8 | task->handler = handler; 9 | task->arg = arg; 10 | task->posted = false; 11 | list_node_init(&task->list_node); 12 | } 13 | 14 | void task_post(struct task *task) { 15 | ATOMIC_SECTION_ENTER { 16 | if (!task->posted) { 17 | task->posted = true; 18 | list_node_remove(&task->list_node); 19 | list_node_insert(&task->list_node, posted_tasks.prev); 20 | } 21 | } 22 | ATOMIC_SECTION_LEAVE 23 | } 24 | 25 | static void suspend_cpu(void) { 26 | // Suspend and wait for interrupt 27 | __WFI(); 28 | } 29 | 30 | void task_run(void) { 31 | while (1) { 32 | // Get next task from posted task list 33 | struct task *task = NULL; 34 | ATOMIC_SECTION_ENTER { 35 | if (!list_node_is_empty(&posted_tasks)) { 36 | task = GET_CONTAINER_OF(posted_tasks.next, struct task, list_node); 37 | list_node_remove(&task->list_node); 38 | task->posted = false; 39 | } 40 | 41 | if (task == NULL) { 42 | // No active task, suspend 43 | suspend_cpu(); 44 | } 45 | } 46 | ATOMIC_SECTION_LEAVE 47 | 48 | // Run task 49 | if (task != NULL) { 50 | current_task = task; 51 | task->handler(); 52 | current_task = NULL; 53 | } 54 | } 55 | } 56 | 57 | struct task *task_get_current(void) { 58 | return current_task; 59 | } 60 | 61 | void *task_get_current_argument(void) { 62 | assert(current_task != NULL); 63 | return current_task->arg; 64 | } 65 | -------------------------------------------------------------------------------- /programmer/stm32/os/task.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | */ 4 | 5 | /** 6 | * @defgroup task OS Task 7 | * @ingroup os 8 | * @brief Allows running multiple tasks on the system 9 | * @{ 10 | */ 11 | #pragma once 12 | 13 | #include "common.h" 14 | #include "list_node.h" 15 | 16 | /** 17 | * @brief Task control structure (don't manipulate directly) 18 | */ 19 | struct task { 20 | void (*handler)(void); ///< Task handler callback 21 | void * arg; ///< User defined argument that can be retrieved by handler function 22 | struct list_node list_node; ///< List node to keep track of tasks 23 | volatile bool posted; ///< True when task is posted 24 | }; 25 | 26 | /** 27 | * @brief Initialize task object 28 | * 29 | * @param task Task object 30 | * @param handler Task handler 31 | * @param arg Argument that can be retrieved by handler 32 | */ 33 | void task_init(struct task *task, void (*handler)(void), void *arg); 34 | 35 | /** 36 | * @brief Post task for execution 37 | * 38 | * @param task Task to be posted 39 | */ 40 | void task_post(struct task *task); 41 | 42 | /** 43 | * @brief Get current task. 44 | * 45 | * @return Current task 46 | */ 47 | struct task *task_get_current(void); 48 | 49 | /** 50 | * @brief Get argument for current task. 51 | * 52 | * @return Argument for current task 53 | */ 54 | void *task_get_current_argument(void); 55 | 56 | /** 57 | * @brief Task loop. Not to be called from user code. 58 | * @details This function never returns. It will loop over the list of posted 59 | * tasks. For each task in the list it will remove the task from the 60 | * list and execute it. When no more tasks are available to run, the 61 | * system will go into low power mode. 62 | */ 63 | void task_run(void); 64 | 65 | /** 66 | * @brief Forward declare static task. 67 | * 68 | * @param name Name of task 69 | */ 70 | #define TASK_DECL(name) \ 71 | static struct task name 72 | 73 | /** 74 | * @brief Forward declare non-static task. 75 | * 76 | * @param name Name of task. 77 | */ 78 | #define TASK_NONSTATIC_DECL(name) \ 79 | extern struct task name 80 | 81 | /** 82 | * @brief Define task handler. This macro will implicitly also define and initialize a static struct task object. 83 | * 84 | * @param name Name of task. 85 | */ 86 | #define TASK(name) \ 87 | static void task_handler_##name(void); \ 88 | static struct task name = {.handler = task_handler_##name, .arg = NULL, .list_node = {.prev = &name.list_node, .next = &name.list_node}, .posted = false}; \ 89 | static void task_handler_##name(void) 90 | 91 | /** 92 | * @brief Define task handler. This macro will implicitly also define and initialize a non-static struct task object. 93 | * 94 | * @param name Name of task. 95 | */ 96 | #define TASK_NONSTATIC(name) \ 97 | static void task_handler_##name(void); \ 98 | struct task name = {.handler = task_handler_##name, .arg = NULL, .list_node = {.prev = &name.list_node, .next = &name.list_node}, .posted = false}; \ 99 | static void task_handler_##name(void) 100 | 101 | /** @} */ 102 | -------------------------------------------------------------------------------- /programmer/stm32/spi.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "common.h" 4 | #include 5 | 6 | enum spi_mode { 7 | SPI_MODE_NONE, 8 | SPI_MODE_FPGA_BOOT, 9 | SPI_MODE_FPGA, 10 | SPI_MODE_FLASH, 11 | }; 12 | 13 | void spi_set_mode(enum spi_mode mode); 14 | void spi_select(bool on); 15 | void spi_transfer(const void *tx_buf, void *rx_buf, size_t length); 16 | -------------------------------------------------------------------------------- /programmer/stm32/usb.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "lib.h" 4 | #include "usbd_core.h" 5 | 6 | #define CMD_EPIN_ADDR (0x83) 7 | #define CMD_EPIN_SIZE (64) 8 | #define CMD_EPOUT_ADDR (0x04) 9 | #define CMD_EPOUT_SIZE (64) 10 | 11 | void usb_init(); 12 | void usb_send_buffer(void *buf, unsigned size); 13 | 14 | extern void usb_handle_cmd_packet(struct buf_reader *br); 15 | 16 | uint8_t programmer_init(struct _USBD_HandleTypeDef *pdev, uint8_t cfgidx); 17 | uint8_t programmer_deinit(struct _USBD_HandleTypeDef *pdev, uint8_t cfgidx); 18 | uint8_t programmer_data_in(struct _USBD_HandleTypeDef *pdev, uint8_t epnum); 19 | uint8_t programmer_data_out(struct _USBD_HandleTypeDef *pdev, uint8_t epnum); 20 | -------------------------------------------------------------------------------- /programmer/stm32/usb/stm32f0xx_hal.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "common.h" 4 | #include "stm32f0xx_hal_pcd.h" 5 | 6 | #define assert_param(...) 7 | -------------------------------------------------------------------------------- /programmer/stm32/usb/stm32f0xx_hal_def.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | typedef enum { 4 | HAL_OK = 0x00U, 5 | HAL_ERROR = 0x01U, 6 | HAL_BUSY = 0x02U, 7 | HAL_TIMEOUT = 0x03U 8 | } HAL_StatusTypeDef; 9 | 10 | typedef enum { 11 | HAL_UNLOCKED = 0x00U, 12 | HAL_LOCKED = 0x01U 13 | } HAL_LockTypeDef; 14 | 15 | #define __HAL_LOCK(__HANDLE__) \ 16 | do { \ 17 | if ((__HANDLE__)->Lock == HAL_LOCKED) { \ 18 | return HAL_BUSY; \ 19 | } else { \ 20 | (__HANDLE__)->Lock = HAL_LOCKED; \ 21 | } \ 22 | } while (0) 23 | 24 | #define __HAL_UNLOCK(__HANDLE__) \ 25 | do { \ 26 | (__HANDLE__)->Lock = HAL_UNLOCKED; \ 27 | } while (0) 28 | 29 | #ifndef __weak 30 | # define __weak __attribute__((weak)) 31 | #endif /* __weak */ 32 | 33 | #define UNUSED(x) ((void)(x)) 34 | -------------------------------------------------------------------------------- /programmer/stm32/usb/usbd_conf.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "common.h" 4 | 5 | /* Common Config */ 6 | #define USBD_MAX_NUM_INTERFACES 3 7 | #define USBD_MAX_NUM_CONFIGURATION 1 8 | #define USBD_MAX_STR_DESC_SIZ 128 9 | #define USBD_SUPPORT_USER_STRING 0 10 | #define USBD_SELF_POWERED 0 11 | 12 | #define USBD_ErrLog(...) 13 | 14 | #define MSC_MEDIA_PACKET 2048 15 | 16 | #define MAX_STATIC_ALLOC_SIZE 2560 17 | 18 | void *USBD_static_malloc(uint32_t size); 19 | void USBD_static_free(void *p); 20 | 21 | #define USBD_malloc (uint32_t *)USBD_static_malloc 22 | #define USBD_free USBD_static_free 23 | -------------------------------------------------------------------------------- /programmer/stm32/usb/usbd_ctlreq.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file usbd_req.h 4 | * @author MCD Application Team 5 | * @version V2.4.2 6 | * @date 11-December-2015 7 | * @brief Header file for the usbd_req.c file 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | *

© COPYRIGHT 2015 STMicroelectronics

12 | * 13 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); 14 | * You may not use this file except in compliance with the License. 15 | * You may obtain a copy of the License at: 16 | * 17 | * http://www.st.com/software_license_agreement_liberty_v2 18 | * 19 | * Unless required by applicable law or agreed to in writing, software 20 | * distributed under the License is distributed on an "AS IS" BASIS, 21 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 22 | * See the License for the specific language governing permissions and 23 | * limitations under the License. 24 | * 25 | ****************************************************************************** 26 | */ 27 | 28 | /* Define to prevent recursive inclusion -------------------------------------*/ 29 | #ifndef __USB_REQUEST_H 30 | # define __USB_REQUEST_H 31 | 32 | # ifdef __cplusplus 33 | extern "C" { 34 | # endif 35 | 36 | /* Includes ------------------------------------------------------------------*/ 37 | # include "usbd_def.h" 38 | 39 | /** @addtogroup STM32_USB_DEVICE_LIBRARY 40 | * @{ 41 | */ 42 | 43 | /** @defgroup USBD_REQ 44 | * @brief header file for the usbd_req.c file 45 | * @{ 46 | */ 47 | 48 | /** @defgroup USBD_REQ_Exported_Defines 49 | * @{ 50 | */ 51 | /** 52 | * @} 53 | */ 54 | 55 | /** @defgroup USBD_REQ_Exported_Types 56 | * @{ 57 | */ 58 | /** 59 | * @} 60 | */ 61 | 62 | /** @defgroup USBD_REQ_Exported_Macros 63 | * @{ 64 | */ 65 | /** 66 | * @} 67 | */ 68 | 69 | /** @defgroup USBD_REQ_Exported_Variables 70 | * @{ 71 | */ 72 | /** 73 | * @} 74 | */ 75 | 76 | /** @defgroup USBD_REQ_Exported_FunctionsPrototype 77 | * @{ 78 | */ 79 | 80 | USBD_StatusTypeDef USBD_StdDevReq(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req); 81 | USBD_StatusTypeDef USBD_StdItfReq(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req); 82 | USBD_StatusTypeDef USBD_StdEPReq(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req); 83 | 84 | void USBD_CtlError(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req); 85 | 86 | void USBD_ParseSetupRequest(USBD_SetupReqTypedef *req, uint8_t *pdata); 87 | 88 | void USBD_GetString(uint8_t *desc, uint8_t *unicode, uint16_t *len); 89 | /** 90 | * @} 91 | */ 92 | 93 | # ifdef __cplusplus 94 | } 95 | # endif 96 | 97 | #endif /* __USB_REQUEST_H */ 98 | 99 | /** 100 | * @} 101 | */ 102 | 103 | /** 104 | * @} 105 | */ 106 | 107 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 108 | -------------------------------------------------------------------------------- /programmer/stm32/usb/usbd_ioreq.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file usbd_ioreq.h 4 | * @author MCD Application Team 5 | * @version V2.4.2 6 | * @date 11-December-2015 7 | * @brief Header file for the usbd_ioreq.c file 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | *

© COPYRIGHT 2015 STMicroelectronics

12 | * 13 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); 14 | * You may not use this file except in compliance with the License. 15 | * You may obtain a copy of the License at: 16 | * 17 | * http://www.st.com/software_license_agreement_liberty_v2 18 | * 19 | * Unless required by applicable law or agreed to in writing, software 20 | * distributed under the License is distributed on an "AS IS" BASIS, 21 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 22 | * See the License for the specific language governing permissions and 23 | * limitations under the License. 24 | * 25 | ****************************************************************************** 26 | */ 27 | 28 | /* Define to prevent recursive inclusion -------------------------------------*/ 29 | #ifndef __USBD_IOREQ_H 30 | # define __USBD_IOREQ_H 31 | 32 | # ifdef __cplusplus 33 | extern "C" { 34 | # endif 35 | 36 | /* Includes ------------------------------------------------------------------*/ 37 | # include "usbd_def.h" 38 | # include "usbd_core.h" 39 | 40 | /** @addtogroup STM32_USB_DEVICE_LIBRARY 41 | * @{ 42 | */ 43 | 44 | /** @defgroup USBD_IOREQ 45 | * @brief header file for the usbd_ioreq.c file 46 | * @{ 47 | */ 48 | 49 | /** @defgroup USBD_IOREQ_Exported_Defines 50 | * @{ 51 | */ 52 | /** 53 | * @} 54 | */ 55 | 56 | /** @defgroup USBD_IOREQ_Exported_Types 57 | * @{ 58 | */ 59 | 60 | /** 61 | * @} 62 | */ 63 | 64 | /** @defgroup USBD_IOREQ_Exported_Macros 65 | * @{ 66 | */ 67 | 68 | /** 69 | * @} 70 | */ 71 | 72 | /** @defgroup USBD_IOREQ_Exported_Variables 73 | * @{ 74 | */ 75 | 76 | /** 77 | * @} 78 | */ 79 | 80 | /** @defgroup USBD_IOREQ_Exported_FunctionsPrototype 81 | * @{ 82 | */ 83 | 84 | USBD_StatusTypeDef USBD_CtlSendData(USBD_HandleTypeDef *pdev, const uint8_t *buf, uint16_t len); 85 | USBD_StatusTypeDef USBD_CtlContinueSendData(USBD_HandleTypeDef *pdev, uint8_t *pbuf, uint16_t len); 86 | USBD_StatusTypeDef USBD_CtlPrepareRx(USBD_HandleTypeDef *pdev, uint8_t *pbuf, uint16_t len); 87 | USBD_StatusTypeDef USBD_CtlContinueRx(USBD_HandleTypeDef *pdev, uint8_t *pbuf, uint16_t len); 88 | USBD_StatusTypeDef USBD_CtlSendStatus(USBD_HandleTypeDef *pdev); 89 | USBD_StatusTypeDef USBD_CtlReceiveStatus(USBD_HandleTypeDef *pdev); 90 | uint16_t USBD_GetRxCount(USBD_HandleTypeDef *pdev, uint8_t epnum); 91 | 92 | /** 93 | * @} 94 | */ 95 | 96 | # ifdef __cplusplus 97 | } 98 | # endif 99 | 100 | #endif /* __USBD_IOREQ_H */ 101 | 102 | /** 103 | * @} 104 | */ 105 | 106 | /** 107 | * @} 108 | */ 109 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 110 | -------------------------------------------------------------------------------- /programmer/stm32/usbd_cdc.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "usbd_ioreq.h" 4 | 5 | #define CDC_IN_EP 0x81 // EP1 for data IN 6 | #define CDC_IN_EP_SIZE 64 7 | 8 | #define CDC_OUT_EP 0x01 // EP1 for data OUT 9 | #define CDC_OUT_EP_SIZE 64 10 | 11 | #define CDC_CMD_EP 0x82 // EP2 for CDC commands 12 | #define CDC_CMD_EP_SIZE 8 13 | 14 | enum { 15 | CDC_SEND_ENCAPSULATED_COMMAND = 0x00, 16 | CDC_GET_ENCAPSULATED_RESPONSE = 0x01, 17 | CDC_SET_COMM_FEATURE = 0x02, 18 | CDC_GET_COMM_FEATURE = 0x03, 19 | CDC_CLEAR_COMM_FEATURE = 0x04, 20 | CDC_SET_LINE_CODING = 0x20, 21 | CDC_GET_LINE_CODING = 0x21, 22 | CDC_SET_CONTROL_LINE_STATE = 0x22, 23 | CDC_SEND_BREAK = 0x23, 24 | }; 25 | 26 | struct cdc_line_coding { 27 | uint32_t bitrate; 28 | uint8_t format; 29 | uint8_t paritytype; 30 | uint8_t datatype; 31 | }; 32 | 33 | struct cdc_interface { 34 | void (*init)(void); 35 | void (*deinit)(void); 36 | void (*control)(uint8_t cmd, uint8_t *buf, uint16_t length); 37 | void (*receive)(uint8_t *buf, uint32_t length); 38 | void (*transmit_done)(void); 39 | }; 40 | 41 | #define CDC_UART_RX_BUFFER_SIZE (2048) 42 | 43 | struct cdc_handle { 44 | uint8_t ep0_data[CDC_IN_EP_SIZE]; 45 | uint8_t cmd_opcode; 46 | uint8_t cmd_length; 47 | uint8_t rx_buffer[CDC_OUT_EP_SIZE]; 48 | __IO bool tx_busy; 49 | 50 | uint8_t uart_rx_buffer[CDC_UART_RX_BUFFER_SIZE]; 51 | }; 52 | 53 | extern const USBD_ClassTypeDef USBD_CDC; 54 | 55 | void cdc_register_interface(USBD_HandleTypeDef *pdev, const struct cdc_interface *fops); 56 | void cdc_receive_packet(USBD_HandleTypeDef *pdev); 57 | bool cdc_transmit_packet(USBD_HandleTypeDef *pdev, uint8_t *buf, uint16_t length); 58 | -------------------------------------------------------------------------------- /programmer/stm32/usbd_cdc_if.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "usbd_cdc.h" 4 | 5 | extern const struct cdc_interface cdc_fops; 6 | --------------------------------------------------------------------------------