├── .gitignore ├── LICENSE ├── README.md ├── circuit ├── 48_TQFP_7x7 │ ├── atarimovie.brd │ ├── atarimovie.sch │ ├── atarimovie_2023-06-16.zip │ ├── atarimovie_2024-03-05.zip │ ├── atarimovie_2024-05-16.zip │ ├── atarimovie_2024-05-24.zip │ ├── atarimovie_top_bom.csv │ ├── atarimovie_top_cpl.csv │ └── bom2_jlcpcb.csv ├── 48_UQFN_6x6 │ ├── atarimovie.brd │ ├── atarimovie.sch │ ├── atarimovie_2022-12-09.zip │ ├── atarimovie_2024-03-05.zip │ ├── atarimovie_2024-05-16.zip │ ├── atarimovie_2024-05-24.zip │ ├── atarimovie_top_bom.csv │ ├── atarimovie_top_cpl.csv │ └── bom1_jlcpcb.csv ├── 48_UQFN_SIKOR │ ├── atarimovie.brd │ ├── atarimovie.sch │ ├── atarimovie_2025-03-26.zip │ ├── atarimovie_top_bom.csv │ └── atarimovie_top_cpl.csv ├── notes.txt └── utils │ ├── jlcpcb_2_layer_v9.cam │ └── jlcpcb_smta_exporter.ulp ├── docs ├── How_To_Update_Content.txt ├── colorize.jpg ├── colorize_play.jpg ├── inside_cart.jpg ├── instructions1.jpg ├── instructions2.jpg ├── orientation.jpg ├── screenshot.jpg └── screenshot_play.jpg ├── encoder ├── cpu │ ├── .gitignore │ ├── CPlusPlus_Common.h │ ├── ColorizeTOP.cpp │ ├── ColorizeTOP.h │ ├── ColorizeTOP.sln │ ├── ColorizeTOP.vcxproj │ ├── ColorizeTOP.xcodeproj │ │ ├── project.pbxproj │ │ ├── project.xcworkspace │ │ │ ├── contents.xcworkspacedata │ │ │ └── xcshareddata │ │ │ │ └── IDEWorkspaceChecks.plist │ │ └── xcshareddata │ │ │ └── xcschemes │ │ │ └── ColorizeTOP.xcscheme │ ├── Info.plist │ ├── LICENSE │ └── TOP_CPlusPlusBase.h ├── encoder.toe └── palettes │ ├── Atari2600NTSC.chan │ ├── Atari2600PAL.chan │ ├── Atari2600RandomTerrain.chan │ ├── Atari2600SECAM.chan │ ├── BW2.chan │ ├── BW4.chan │ ├── ColecoVision.chan │ ├── RGB.chan │ ├── Rubik.chan │ ├── readme.txt │ └── test.cpp ├── examples ├── 20centryfox_pal.mvc ├── 20centuryfox.mvc ├── cronkite_pal.mvc ├── dancer.mvc ├── lion.mvc ├── numbers.mvc ├── output_cronkite.mvc ├── street.mp4 ├── street.mvc ├── street_tate.mvc ├── testpattern.mvc └── title.mvc ├── firmware ├── .gitignore ├── Makefile ├── TitleScreen.s ├── aivt.c ├── bootloader │ ├── .gitignore │ ├── Makefile │ ├── linkscript.gld │ ├── main.c │ ├── mcc_generated_files │ │ ├── clock.c │ │ ├── clock.h │ │ ├── interrupt_manager.c │ │ ├── interrupt_manager.h │ │ ├── mcc.c │ │ ├── mcc.h │ │ ├── memory │ │ │ ├── flash.h │ │ │ └── flash.s │ │ ├── pin_manager.c │ │ ├── pin_manager.h │ │ ├── reset.c │ │ ├── reset.h │ │ ├── reset_types.h │ │ ├── system.c │ │ ├── system.c.bs_test │ │ ├── system.h │ │ ├── system_types.h │ │ ├── traps.c │ │ ├── traps.h │ │ └── watchdog.h │ ├── moviecart_smd.mc3 │ ├── nbproject │ │ ├── .gitignore │ │ ├── configurations.xml │ │ └── project.xml │ └── payload.s ├── core.c ├── core.h ├── defines.h ├── devices │ ├── p33CK32MC105 │ │ ├── configurations.xml │ │ ├── firmware.production.elf │ │ └── linkscript.gld │ └── p33CK64MC105 │ │ ├── configurations.xml │ │ ├── firmware.production.elf │ │ └── linkscript.gld ├── frame.c ├── frame.h ├── linkscript.gld ├── main.c ├── mcc_generated_files │ ├── clc1.c │ ├── clc1.h │ ├── clock.c │ ├── clock.h │ ├── interrupt_manager.c │ ├── interrupt_manager.h │ ├── mcc.c │ ├── mcc.h │ ├── memory │ │ ├── flash.h │ │ └── flash.s │ ├── pin_manager.c │ ├── pin_manager.h │ ├── reset.c │ ├── reset.h │ ├── reset_types.h │ ├── spi1.c │ ├── spi1.h │ ├── system.c │ ├── system.h │ ├── system_types.h │ ├── traps.c │ ├── traps.h │ └── watchdog.h ├── moviecart_smd.mc3 ├── nbproject │ ├── .gitignore │ ├── configurations.xml │ └── project.xml ├── osd.h ├── patches │ ├── notes.txt │ └── patch2_kernel │ │ ├── README.txt │ │ └── update.frm ├── pff.c ├── pff.h ├── sd_reader.c ├── sd_reader.h ├── update.c ├── update.h └── utils │ ├── code2payload.c │ ├── code2updatefrm.c │ ├── make_tables.c │ ├── pack24.c │ └── testfrm.c ├── kernel ├── Makefile ├── color_chart │ ├── color_chart.asm │ ├── color_chart_ntsc.bin │ ├── color_chart_ntsc.png │ ├── color_chart_pal.bin │ └── color_chart_pal.png ├── core.asm ├── movie_ntsc.bin ├── movie_ntsc.png ├── movie_pal.bin └── movie_pal.png ├── label ├── .gitignore ├── label.toe └── resources │ ├── MUMBSB__.TTF │ ├── atari-eps-vector-logo.png │ └── combat_reference.jpg ├── output ├── colorizer │ ├── OSX │ │ └── ColorizeTOP.plugin │ │ │ └── Contents │ │ │ ├── Info.plist │ │ │ ├── MacOS │ │ │ └── ColorizeTOP │ │ │ └── _CodeSignature │ │ │ └── CodeResources │ └── WIN64 │ │ └── ColorizeTOP.dll └── firmware │ ├── legacy │ ├── beta0 │ │ └── firmware.production.hex │ ├── p33CK32MC105 │ │ └── beta0 │ │ │ └── firmware.production.hex │ ├── rc1.1 │ │ └── firmware.production.hex │ ├── rc1.2 │ │ └── firmware.production.hex │ ├── rc1 │ │ └── firmware.production.hex │ └── rc2.0 │ │ └── firmware.production.hex │ └── p33CK64MC105 │ └── rc2.1 │ └── firmware.production.hex ├── release_notes.txt └── utils ├── expand_bin ├── last_timecode ├── title.mvc └── title_test.c /.gitignore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lodefmode/moviecart/4ae049122e5a2cf368cd9413f8fba21dab926907/.gitignore -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # moviecart 2 | Software and Hardware to create full length color movie + audio cartridges for stock Atari 2600 3 | 4 | [How to watch different files:](docs/How_To_Update_Content.txt) 5 | 6 | [How to encode your own:](https://www.youtube.com/watch?v=WSy6kNrYDSo&list=PLHJZWs7or3edcvVHDeNzGSZABx2JN1WZH) 7 | 8 | Pre-Order Kits at: 9 | 10 | https://www.tindie.com/products/lodefmode/moviecart-atari-2600/ 11 | 12 | September 11 1977 13 | - 14 | 15 | Introducing MovieCart. 16 | 17 | This revolutionary new product will allow for the first time ever, anyone to experience the joy of the silver screen directly from the comfort of their own home, in stunning digital accuracy. 18 | Boasting an impressive 80 x 192 resolution, 7 bit color and 4 bit monaural audio, begin building your full length feature film library today.* 19 | 20 | 21 | Technical Specs: 22 | 23 | Two fields are alternated at 60 frames per second. 24 | Each field consists of a checkerboard pattern of 10 x 262 cells. 25 | Each cell contains one of 128 colours and is 8 pixels wide by 1 pixel deep. 26 | This produces an effective resolution of 80 x 262 @ 30 frames per second, with 10 colors per line. 27 | 28 | Sound is 4 bit mono produced at 15.720 KHz. 29 | 30 | Joystick controls brightness, volume, and shuttle position. 31 | Console switches control b/w, ten second rewind and full rewind. 32 | 33 | Each field requires 2.5K of data. 34 | Each second requires the equivalent of 75.5 Combat cartridges, or over half a million cartridges to produce a full length 2 hour movie. 35 | 36 | 37 | Thanks, 38 | 39 | lodef.mode@gmail.com 40 | 41 | [![Video](docs/screenshot_play.jpg)](https://www.youtube.com/watch?v=PMp-7_ekibU) 42 | 43 | [![Video](docs/colorize_play.jpg)](https://youtu.be/7HMz1SYGolY) 44 | 45 | ![Cart](docs/inside_cart.jpg) 46 | ![Cart](docs/orientation.jpg) 47 | ![Booklet](docs/instructions1.jpg) 48 | ![Booklet](docs/instructions2.jpg) 49 | 50 | *Copyright Disclaimer under Section 107 of the copyright act 1976, allowance is made for fair use for purposes such as criticism, comment, news reporting, scholarship, and research. Fair use is a use permitted by copyright statute that might otherwise be infringing. Non-profit, educational or personal use tips the balance in favour of fair use." 51 | 52 | -------------------------------------------------------------------------------- /circuit/48_TQFP_7x7/atarimovie_2023-06-16.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lodefmode/moviecart/4ae049122e5a2cf368cd9413f8fba21dab926907/circuit/48_TQFP_7x7/atarimovie_2023-06-16.zip -------------------------------------------------------------------------------- /circuit/48_TQFP_7x7/atarimovie_2024-03-05.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lodefmode/moviecart/4ae049122e5a2cf368cd9413f8fba21dab926907/circuit/48_TQFP_7x7/atarimovie_2024-03-05.zip -------------------------------------------------------------------------------- /circuit/48_TQFP_7x7/atarimovie_2024-05-16.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lodefmode/moviecart/4ae049122e5a2cf368cd9413f8fba21dab926907/circuit/48_TQFP_7x7/atarimovie_2024-05-16.zip -------------------------------------------------------------------------------- /circuit/48_TQFP_7x7/atarimovie_2024-05-24.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lodefmode/moviecart/4ae049122e5a2cf368cd9413f8fba21dab926907/circuit/48_TQFP_7x7/atarimovie_2024-05-24.zip -------------------------------------------------------------------------------- /circuit/48_TQFP_7x7/atarimovie_top_bom.csv: -------------------------------------------------------------------------------- 1 | Comment,Designator,Footprint,LCSC Part # 2 | 0.1uF,C3 C4 C5 C6 C7 C8 C9,C0603K, 3 | 10K,R1,R0603, 4 | 10uF,C1 C2,C0603K, 5 | 56.2K,R3 R4 R5 R6 R7,R0603, 6 | 74LVCH245APW 118,U2,SOP65P640X110-20N, 7 | 74LVCH245APW 118,U3,SOP65P640X110-20N, 8 | 180Ω,R2,R0603, 9 | AMS1117-3.3V,IC1,SOT229P700X180-4N, 10 | CARTRIDGE EDGE,J1,MED_TABS_SHORT, 11 | DSPIC33CKXXMC105-X_M4TQFP48_7X7MC_MCH,U1,TQFP48_7X7MC_MCH, 12 | KT-0603R,LED1,LEDC1608X70N, 13 | TF-15X15,J2,TF15X15, 14 | -------------------------------------------------------------------------------- /circuit/48_TQFP_7x7/atarimovie_top_cpl.csv: -------------------------------------------------------------------------------- 1 | Designator,Mid X,Mid Y,Layer,Rotation 2 | C1,22.86,76.20,Top,90.0 3 | C2,21.59,70.48,Top,270.0 4 | C3,48.26,56.52,Top,180.0 5 | C4,37.47,62.87,Top,90.0 6 | C5,36.83,77.72,Top,180.0 7 | C6,54.61,78.49,Top,180.0 8 | C7,16.13,54.10,Top,270.0 9 | C8,65.66,70.61,Top,180.0 10 | C9,47.63,78.11,Top,270.0 11 | IC1,28.58,76.84,Top,0.0 12 | J1,36.83,50.80,Top,0.0 13 | J2, 9.53,65.41,Top,270.0 14 | LED1,63.75,77.34,Top,0.0 15 | R1,44.45,78.11,Top,270.0 16 | R2,67.18,77.34,Top,180.0 17 | R3,10.16,53.98,Top,90.0 18 | R4, 7.49,53.98,Top,90.0 19 | R5,12.45,53.98,Top,90.0 20 | R6, 5.21,53.98,Top,90.0 21 | R7, 2.79,53.98,Top,90.0 22 | U1,48.26,64.14,Top,180.0 23 | U2,27.51,62.23,Top,0.0 24 | U3,65.84,61.59,Top,0.0 25 | -------------------------------------------------------------------------------- /circuit/48_TQFP_7x7/bom2_jlcpcb.csv: -------------------------------------------------------------------------------- 1 | Comment,Designator,Footprint,JLCPCB Part # 2 | 0.1uF,"C3,C4,C5,C6,C7,C8,C9",C0603K,C14663 3 | DSPIC33CKXXMC105-X_M4TQFP48_7X7MC_MCH,U1,TQFP48_7X7MC_MCH,C5226458 4 | 56.2K,"R3,R4,R5,R6,R7",R0603,C209170 5 | KT-0603R,LED1,LEDC1608X70N,C2286 6 | 10K,R1,R0603,C25804 7 | 74LVCH245APW118,"U3,U2",SOP65P640X110-20N,C426764 8 | AMS1117-3.3V,IC1,SOT229P700X180-4N,C173386 9 | TF-15X15,J2,TF15X15,C111196 10 | 180惟,R2,R0603,C22828 11 | 10uF,"C1,C2",C0603K,C19702 12 | -------------------------------------------------------------------------------- /circuit/48_UQFN_6x6/atarimovie_2022-12-09.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lodefmode/moviecart/4ae049122e5a2cf368cd9413f8fba21dab926907/circuit/48_UQFN_6x6/atarimovie_2022-12-09.zip -------------------------------------------------------------------------------- /circuit/48_UQFN_6x6/atarimovie_2024-03-05.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lodefmode/moviecart/4ae049122e5a2cf368cd9413f8fba21dab926907/circuit/48_UQFN_6x6/atarimovie_2024-03-05.zip -------------------------------------------------------------------------------- /circuit/48_UQFN_6x6/atarimovie_2024-05-16.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lodefmode/moviecart/4ae049122e5a2cf368cd9413f8fba21dab926907/circuit/48_UQFN_6x6/atarimovie_2024-05-16.zip -------------------------------------------------------------------------------- /circuit/48_UQFN_6x6/atarimovie_2024-05-24.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lodefmode/moviecart/4ae049122e5a2cf368cd9413f8fba21dab926907/circuit/48_UQFN_6x6/atarimovie_2024-05-24.zip -------------------------------------------------------------------------------- /circuit/48_UQFN_6x6/atarimovie_top_bom.csv: -------------------------------------------------------------------------------- 1 | Comment,Designator,Footprint,LCSC Part # 2 | 0.1uF,C3 C4 C5 C6 C7 C8 C9,C0603K, 3 | 10K,R1,R0603, 4 | 10uF,C1 C2,C0603K, 5 | 56.2K,R3 R4 R5 R6 R7,R0603, 6 | 74LVCH245APW 118,U2,SOP65P640X110-20N, 7 | 74LVCH245APW 118,U3,SOP65P640X110-20N, 8 | 180Ω,R2,R0603, 9 | AMS1117-3.3V,IC1,SOT229P700X180-4N, 10 | CARTRIDGE EDGE,J1,MED_TABS_SHORT, 11 | DSPIC33CKXXMC105-X_M4,U1,UQFN48_6X6MC_MCH, 12 | KT-0603R,LED1,LEDC1608X70N, 13 | TF-15X15,J2,TF15X15, 14 | -------------------------------------------------------------------------------- /circuit/48_UQFN_6x6/atarimovie_top_cpl.csv: -------------------------------------------------------------------------------- 1 | Designator,Mid X,Mid Y,Layer,Rotation 2 | C1,22.86,76.20,Top,90.0 3 | C2,21.59,70.48,Top,270.0 4 | C3,48.26,56.52,Top,180.0 5 | C4,37.47,62.87,Top,90.0 6 | C5,36.83,77.72,Top,180.0 7 | C6,54.61,78.49,Top,180.0 8 | C7,16.13,54.10,Top,270.0 9 | C8,65.66,70.61,Top,180.0 10 | C9,47.63,78.11,Top,270.0 11 | IC1,28.58,76.84,Top,0.0 12 | J1,36.83,50.80,Top,0.0 13 | J2, 9.53,65.41,Top,270.0 14 | LED1,63.75,77.34,Top,0.0 15 | R1,44.45,78.11,Top,270.0 16 | R2,67.18,77.34,Top,180.0 17 | R3,10.16,53.98,Top,90.0 18 | R4, 7.49,53.98,Top,90.0 19 | R5,12.45,53.98,Top,90.0 20 | R6, 5.21,53.98,Top,90.0 21 | R7, 2.79,53.98,Top,90.0 22 | U1,48.26,64.14,Top,180.0 23 | U2,27.51,62.23,Top,0.0 24 | U3,65.84,61.59,Top,0.0 25 | -------------------------------------------------------------------------------- /circuit/48_UQFN_6x6/bom1_jlcpcb.csv: -------------------------------------------------------------------------------- 1 | Comment,Designator,Footprint,JLCPCB Part # 2 | 0.1uF,"C3,C4,C5,C6,C7,C8,C9",C0603K,C14663 3 | 56.2K,"R3,R4,R5,R6,R7",R0603,C209170 4 | KT-0603R,LED1,LEDC1608X70N,C2286 5 | 10K,R1,R0603,C25804 6 | DSPIC33CKXXMC105-X_M4,U1,UQFN48_6X6MC_MCH,C3227359 7 | 74LVCH245APW118,"U2,U3",SOP65P640X110-20N,C426764 8 | AMS1117-3.3V,IC1,SOT229P700X180-4N,C173386 9 | TF-15X15,J2,TF15X15,C111196 10 | 180惟,R2,R0603,C22828 11 | 10uF,"C1,C2",C0603K,C19702 12 | -------------------------------------------------------------------------------- /circuit/48_UQFN_SIKOR/atarimovie_2025-03-26.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lodefmode/moviecart/4ae049122e5a2cf368cd9413f8fba21dab926907/circuit/48_UQFN_SIKOR/atarimovie_2025-03-26.zip -------------------------------------------------------------------------------- /circuit/48_UQFN_SIKOR/atarimovie_top_bom.csv: -------------------------------------------------------------------------------- 1 | Comment,Designator,Footprint,LCSC Part # 2 | 0.1uF,C3 C4 C5 C6 C7 C8 C9,C0603K, 3 | 10K,R1,R0603, 4 | 10uF,C1 C2,C0603K, 5 | 56.2K,R3 R4 R5 R6 R7,R0603, 6 | 74LVCH245APW 118,U2,SOP65P640X110-20N, 7 | 74LVCH245APW 118,U3,SOP65P640X110-20N, 8 | 180Ω,R2,R0603, 9 | AMS1117-3.3V,IC1,SOT229P700X180-4N, 10 | CARTRIDGE EDGE,J1,MED_TABS_SDACCESS, 11 | DSPIC33CKXXMC105-X_M4,U1,UQFN48_6X6MC_MCH, 12 | KT-0603R,LED1,LEDC1608X70N, 13 | RT3301AF260Q,FACTORYRESET,RT3301_EWI, 14 | TF-15X15,J2,TF15X15, 15 | -------------------------------------------------------------------------------- /circuit/48_UQFN_SIKOR/atarimovie_top_cpl.csv: -------------------------------------------------------------------------------- 1 | Designator,Mid X,Mid Y,Layer,Rotation 2 | C1,19.69,73.03,Top,180.0 3 | C2,19.69,70.48,Top,180.0 4 | C3,48.26,56.52,Top,180.0 5 | C4,37.47,62.87,Top,90.0 6 | C5,36.83,77.72,Top,180.0 7 | C6,54.61,79.12,Top,180.0 8 | C7,16.13,54.10,Top,270.0 9 | C8,65.66,70.61,Top,180.0 10 | C9,47.63,78.11,Top,90.0 11 | FACTORYRESET,62.00,85.80,Top,0.0 12 | IC1,28.58,76.84,Top,0.0 13 | J1,36.83,50.80,Top,0.0 14 | J2, 5.08,65.41,Top,270.0 15 | LED1,63.75,77.34,Top,0.0 16 | R1,44.45,78.11,Top,270.0 17 | R2,67.18,77.34,Top,180.0 18 | R3,10.16,53.98,Top,90.0 19 | R4, 7.49,53.98,Top,90.0 20 | R5,12.45,53.98,Top,90.0 21 | R6, 5.21,53.98,Top,90.0 22 | R7, 2.79,53.98,Top,90.0 23 | U1,48.26,64.14,Top,180.0 24 | U2,27.51,62.23,Top,0.0 25 | U3,65.84,61.59,Top,0.0 26 | -------------------------------------------------------------------------------- /circuit/notes.txt: -------------------------------------------------------------------------------- 1 | 2 | Each folder contains a PCB centered around a different package of dsPIC33CK64MC105. 3 | They are otherwise identical. 4 | Note that dsPIC33CK32MC105 is also a suitable drop in replacment at half the program size. 5 | 6 | 48_TQFP_7x7: 7 | DSPIC33CK32MC105-I/PT 8 | 9 | 48_UQFN_6x6: 10 | DSPIC33CK64MC105-I/M4 11 | 12 | 13 | Todo: 14 | 15 | 2.31 16 | Central hole size: 17 | Still too narrow on some production runs, as drill tolerance varies. 18 | Try increasing slightly. 19 | 20 | 17/64" drill bit fits perfectly. 21 | 3.3734375 mm radius? 22 | 23 | currently its: 24 | 3.190mm (was 3.175mm) 25 | 26 | Around 0.18 mm increase each side. 27 | 28 | 2.32/2.42: 29 | hole size increased from 3.19 to 3.373 30 | 31 | ----------------- 32 | 33 | SIKOR version: 34 | 35 | 36 | Missing 'TV/LABEL SIDE' 37 | 38 | special sdcard access version for injection molded offerings: 39 | -consider moving sd card further to edge to increase access on slotted cart. 40 | even widen entire top half left/right to reach edge. 41 | -deepen side tabs toward center to fit 42 | -consider shortening center post hole to match? 43 | -consider a double tab piece that glues through rectangular slots for stability. 44 | 45 | consider: 46 | tactile switch to burn/factory reset firmware updates, instead of grounding programming pins 47 | 48 | LED is way too bright 49 | 50 | 51 | Octob 5 2024: 52 | 53 | 2.42: change name to 2.52 (2.42 is P/T version) 54 | a couple of vias are too close to paths: 55 | top left corner of IC, c6 56 | 57 | 2.52SD 58 | close vias fixed 59 | 2.52 60 | 'TV SIDE' 61 | deeper tabs 62 | SD moved to left edge 63 | tactile switch to factory reset / restore (grounding programming pins still works) 64 | 65 | 2.5SK 66 | 67 | Reshaped for SIKOR carts (5 alignment holes) 68 | 69 | 2.6SK 70 | 71 | RT3301 reverse mounted factory reset button 72 | 73 | -------------------------------------------------------------------------------- /circuit/utils/jlcpcb_smta_exporter.ulp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright 2019 OXullo Intersecans 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 6 | 7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 8 | 9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 10 | 11 | */ 12 | 13 | // Note: the following eagle-bundled ULPs have been used as a guidance: 14 | // * mountsmd.ulp 15 | // * bom.ulp 16 | // * cmd-change-swap-layer.ulp 17 | // * centroid-screamingcircuits-smd.ulp 18 | 19 | 20 | #usage "JLCPCB BOM/CPL files generator\n" 21 | "

" 22 | "Generates BOM and CPL files for JLCPCB SMT assembly service" 23 | "https://jlcpcb.com/smt-assembly" 24 | "

" 25 | "Run the ULP from the board editor" 26 | "

" 27 | "Author: OXullo Intersecans x@brainrapers.org" 28 | 29 | 30 | int layer_id_map[] = { 1, 16 }; 31 | UL_ELEMENT selected_elements[]; 32 | string layer_name_map[] = { "Top", "Bottom" }; 33 | 34 | string replace_commas(string s) 35 | { 36 | while (strstr(s, ",") >= 0) { // convert commas to spaces 37 | string substitution_string = " "; 38 | sprintf(s, "%s%s%s", strsub(s, 0, strstr(s, ",")), substitution_string, strsub(s, strstr(s, ",")+1)); 39 | } 40 | 41 | return s; 42 | } 43 | 44 | if (board) board(B) { 45 | 46 | string txt; 47 | int layer_choice = 0; 48 | 49 | dlgDialog("Layer selection") { 50 | dlgGroup("Export layer") { 51 | dlgRadioButton("&Top", layer_choice); 52 | dlgRadioButton("&Bottom", layer_choice); 53 | } 54 | dlgPushButton("OK") dlgAccept(); 55 | }; 56 | 57 | string output_dir = dlgDirectory("Export files to", filedir(B.name)); 58 | 59 | if (output_dir == "") { 60 | exit(0); 61 | } 62 | 63 | int element_count = 0; 64 | 65 | B.elements(E) if (E.populate) { 66 | E.package.contacts(C) { 67 | if (C.smd && C.smd.layer == layer_id_map[layer_choice]) { 68 | selected_elements[element_count++] = E; 69 | break; 70 | } 71 | } 72 | } 73 | 74 | string base_path = (output_dir + "/" + 75 | strsub(filename(B.name), 0, strlen(filename(B.name)) - 4) + 76 | "_" + strlwr(layer_name_map[layer_choice])); 77 | 78 | string cpl_filename = base_path + "_cpl.csv"; 79 | string bom_filename = base_path + "_bom.csv"; 80 | 81 | output(cpl_filename) { 82 | printf("Designator,Mid X,Mid Y,Layer,Rotation\n"); 83 | 84 | for (int i = 0 ; i < element_count ; ++i) { 85 | UL_ELEMENT E = selected_elements[i]; 86 | int angle = E.angle; 87 | 88 | E.attributes(A) { // manually rotate the part 89 | if (A.name == "JLC_ROTATION" || A.name == "JLC_ROT") { 90 | angle = angle + strtol(A.value); 91 | 92 | while(angle>360){ 93 | angle = angle - 360; 94 | } 95 | } 96 | } 97 | 98 | if (layer_name_map[layer_choice] == "Bottom") { 99 | angle = (360 - angle); 100 | angle = angle + 180; 101 | angle = angle % 360; 102 | } 103 | real ang = angle; 104 | printf("%s,%5.2f,%5.2f,%s,%.1f\n", 105 | E.name, u2mm(E.x), u2mm(E.y), 106 | layer_name_map[layer_choice], 107 | ang); 108 | } 109 | } 110 | 111 | output(bom_filename) { 112 | int i; 113 | int indexes[]; 114 | numeric string values[]; 115 | 116 | for (i=0 ; i < element_count ; ++i) { 117 | indexes[i] = i; 118 | values[i] = selected_elements[i].value; 119 | } 120 | sort(element_count, indexes, values); 121 | printf("Comment,Designator,Footprint,LCSC Part #\n"); 122 | 123 | string current_value = ""; 124 | string current_footprint = ""; 125 | string current_lcscpart = ""; 126 | string designators = ""; 127 | 128 | for (i = 0 ; i < element_count ; ++i) { 129 | UL_ELEMENT E = selected_elements[indexes[i]]; 130 | 131 | if (current_value != "" && (E.value != current_value || E.footprint.name != current_footprint)) { 132 | printf("%s,%s,%s,%s\n", current_value, designators, current_footprint, current_lcscpart); 133 | designators = ""; 134 | } 135 | 136 | if (designators != "") { 137 | designators += " "; 138 | } 139 | designators += E.name; 140 | current_value = replace_commas(E.value); 141 | current_footprint = replace_commas(E.footprint.name); 142 | current_lcscpart = ""; 143 | 144 | E.attributes(A) { 145 | if (A.name == "LCSC_PART" || A.name == "LCSC") { 146 | current_lcscpart = replace_commas(A.value); 147 | } 148 | } 149 | } 150 | if (current_value != "") { 151 | printf("%s,%s,%s,%s\n", current_value, designators, current_footprint, current_lcscpart); 152 | } 153 | } 154 | 155 | dlgMessageBox("BOM and CPL files have been exported to: " + output_dir, "OK"); 156 | 157 | } else { 158 | dlgMessageBox("Run this ULP from a Board", "OK"); 159 | exit (0); 160 | } 161 | -------------------------------------------------------------------------------- /docs/How_To_Update_Content.txt: -------------------------------------------------------------------------------- 1 | 2 | Updating content: 3 | 4 | Your MovieCart should include an sd-card with full length movie on it. 5 | Feel free to put any mvc files on it, including your own. 6 | 7 | 8 | NOTES: 9 | 10 | Best performance is had when the sd-card is freshly formatted before placing the file, 11 | to make forwarding and rewinding smoother. 12 | When formatting an sd-card, it must be FAT32 format. 13 | 14 | MovieCart supports a maximum file size of 4GB. 15 | This translates to around 4 hours of content, so lots of room for most cases. 16 | 17 | Early MovieCarts only play the first regular file it finds on the card, so if you have several videos, 18 | they must all be combined before encoding into a single mvc file, or you can update it with the latest 19 | upgrades, including use of the select button to switch between video files. 20 | 21 | The files below are zipped for easier download, but they must be UNZIPPED before copying to the sd-card. 22 | 23 | # George Romero's classic 1968 thriller, artificially colorized. 24 | https://drive.google.com/file/d/1Dqfl3UvPZDhm9WUWdjGjJoQySyb--Gze 25 | night_dead_nov23.mvc 26 | 27 | # Same as above but encoded for PAL format (50 Hz, Atari PAL color format, 242 lines) 28 | https://drive.google.com/file/d/1VxRiaWOX6W1PFH5AJw6gCAL4KVbaCsg3 29 | night_dead_pal.mvc 30 | 31 | # PAL60 format (60 Hz but Atari PAL color format, similar to PAL-M in use in Brazil) 32 | https://drive.google.com/file/d/19TsIUbs40wUKhLGFbbGpvHSkD-o-Gi09 33 | nightdead_pal60.mvc 34 | 35 | # SECAM format (50 Hz but Atari SECAM color format, very LIMITED color) 36 | https://drive.google.com/file/d/1VsJS2MlWYCcIfghPQl9uj2oBAv7mB7TY 37 | nightdead_secam.mvc 38 | 39 | Cheers, 40 | Lodef Mode. 41 | 42 | 43 | -------------------------------------------------------------------------------- /docs/colorize.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lodefmode/moviecart/4ae049122e5a2cf368cd9413f8fba21dab926907/docs/colorize.jpg -------------------------------------------------------------------------------- /docs/colorize_play.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lodefmode/moviecart/4ae049122e5a2cf368cd9413f8fba21dab926907/docs/colorize_play.jpg -------------------------------------------------------------------------------- /docs/inside_cart.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lodefmode/moviecart/4ae049122e5a2cf368cd9413f8fba21dab926907/docs/inside_cart.jpg -------------------------------------------------------------------------------- /docs/instructions1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lodefmode/moviecart/4ae049122e5a2cf368cd9413f8fba21dab926907/docs/instructions1.jpg -------------------------------------------------------------------------------- /docs/instructions2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lodefmode/moviecart/4ae049122e5a2cf368cd9413f8fba21dab926907/docs/instructions2.jpg -------------------------------------------------------------------------------- /docs/orientation.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lodefmode/moviecart/4ae049122e5a2cf368cd9413f8fba21dab926907/docs/orientation.jpg -------------------------------------------------------------------------------- /docs/screenshot.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lodefmode/moviecart/4ae049122e5a2cf368cd9413f8fba21dab926907/docs/screenshot.jpg -------------------------------------------------------------------------------- /docs/screenshot_play.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lodefmode/moviecart/4ae049122e5a2cf368cd9413f8fba21dab926907/docs/screenshot_play.jpg -------------------------------------------------------------------------------- /encoder/cpu/.gitignore: -------------------------------------------------------------------------------- 1 | .vs/ 2 | ColorizeTOP.vcxproj.user 3 | ColorizeTOP.VC.db 4 | street.mvc 5 | Release/ 6 | Debug/ 7 | Backup 8 | Colorize.* 9 | -------------------------------------------------------------------------------- /encoder/cpu/ColorizeTOP.h: -------------------------------------------------------------------------------- 1 | /* Shared Use License: This file is owned by Derivative Inc. (Derivative) 2 | * and can only be used, and/or modified for use, in conjunction with 3 | * Derivative's TouchDesigner software, and only if you are a licensee who has 4 | * accepted Derivative's TouchDesigner license or assignment agreement 5 | * (which also govern the use of this file). You may share or redistribute 6 | * a modified version of this file provided the following conditions are met: 7 | * 8 | * 1. The shared file or redistribution must retain the information set out 9 | * above and this list of conditions. 10 | * 2. Derivative's name (Derivative Inc.) or its trademarks may not be used 11 | * to endorse or promote products derived from this file without specific 12 | * prior written permission from Derivative. 13 | */ 14 | 15 | #include "TOP_CPlusPlusBase.h" 16 | 17 | using namespace TD; 18 | 19 | 20 | // kd-tree structures 21 | /* Adapted from: https://rosettacode.org/wiki/K-d_tree */ 22 | #define MAX_DIM 3 23 | 24 | struct kd_node_t 25 | { 26 | float val[MAX_DIM]; 27 | int index; 28 | struct kd_node_t *left, *right; 29 | }; 30 | 31 | template 32 | class Array2D 33 | { 34 | public: 35 | 36 | Array2D() 37 | { 38 | width = height = 0; 39 | mem = nullptr; 40 | } 41 | 42 | ~Array2D() 43 | { 44 | setSize(0, 0); 45 | } 46 | 47 | void 48 | setSize(int w, int h) 49 | { 50 | if (w != width || h != height) 51 | { 52 | width = w; 53 | height = h; 54 | 55 | if (mem) 56 | delete [] mem; 57 | 58 | if (w || h) 59 | mem = new T[width * height]; 60 | else 61 | mem = nullptr; 62 | 63 | zero(); 64 | } 65 | } 66 | 67 | void 68 | zero() 69 | { 70 | if (mem) 71 | memset(mem, 0, width*height*sizeof(T)); 72 | } 73 | 74 | T& 75 | operator()(int x, int y) 76 | { 77 | return mem[y*width + x]; 78 | } 79 | 80 | T& 81 | operator()(int x, int y) const 82 | { 83 | return mem[y*width + x]; 84 | } 85 | 86 | T* 87 | getData() 88 | { 89 | return mem; 90 | } 91 | 92 | int 93 | getWidth() const 94 | { 95 | return width; 96 | } 97 | 98 | int 99 | getHeight() const 100 | { 101 | return height; 102 | } 103 | 104 | private: 105 | 106 | T* mem; 107 | int width; 108 | int height; 109 | 110 | }; 111 | 112 | class ColorizeTOP : public TOP_CPlusPlusBase 113 | { 114 | public: 115 | ColorizeTOP(const OP_NodeInfo *info, TOP_Context* context); 116 | virtual ~ColorizeTOP(); 117 | 118 | virtual void getGeneralInfo(TOP_GeneralInfo *, const OP_Inputs*, void*) override; 119 | 120 | virtual void execute(TOP_Output*, 121 | const OP_Inputs*, 122 | void* reserved1) override; 123 | 124 | virtual int32_t getNumInfoCHOPChans(void *reserved1) override; 125 | virtual void getInfoCHOPChan(int32_t index, 126 | OP_InfoCHOPChan *chan, void* reserved1) override; 127 | 128 | virtual bool getInfoDATSize(OP_InfoDATSize *infoSize, void *reserved1) override; 129 | virtual void getInfoDATEntries(int32_t index, 130 | int32_t nEntries, 131 | OP_InfoDATEntries *entries, 132 | void *reserved1) override; 133 | 134 | virtual void setupParameters(OP_ParameterManager *manager, void *reserved1) override; 135 | virtual void pulsePressed(const char *name, void *reserved1) override; 136 | 137 | private: 138 | 139 | TOP_Context* myContext; 140 | 141 | void setupStorage(int outputWidth, int outputHeight, int cellSize); 142 | void storeResults(uint8_t *destPixel, int cellSize); 143 | 144 | Array2D myMem; 145 | Array2D myMemBackup; 146 | Array2D myResultGraph; 147 | Array2D myResultColor; 148 | Array2D myResultBK; 149 | Array2D myFPal; 150 | 151 | unsigned char *myLastPal; 152 | uint8_t myColorLookup[256][256][256]; 153 | void buildColourMap(); 154 | 155 | void ditherLine(int bidx, int y, bool finalB, int width, int height, int cellSize, 156 | float *curY, int palSize, float bleed, int matrix, 157 | bool dither, float *curError, float bestError, 158 | int colorInc); 159 | 160 | // k-d tree data 161 | struct kd_node_t kdtree[256]; 162 | struct kd_node_t* kdtree_root{nullptr}; 163 | void setup_kdtree(Array2D& fpal, int palSize); 164 | 165 | }; 166 | -------------------------------------------------------------------------------- /encoder/cpu/ColorizeTOP.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.30503.244 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ColorizeTOP", "ColorizeTOP.vcxproj", "{3F5BEECD-FA36-459F-91B8-BB481A67EF44}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|x64 = Debug|x64 11 | Release|x64 = Release|x64 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {3F5BEECD-FA36-459F-91B8-BB481A67EF44}.Debug|x64.ActiveCfg = Debug|x64 15 | {3F5BEECD-FA36-459F-91B8-BB481A67EF44}.Debug|x64.Build.0 = Debug|x64 16 | {3F5BEECD-FA36-459F-91B8-BB481A67EF44}.Release|x64.ActiveCfg = Release|x64 17 | {3F5BEECD-FA36-459F-91B8-BB481A67EF44}.Release|x64.Build.0 = Release|x64 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | GlobalSection(ExtensibilityGlobals) = postSolution 23 | SolutionGuid = {9BBFDD9E-842B-449A-9A54-3CAE8DF293BB} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /encoder/cpu/ColorizeTOP.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | x64 7 | 8 | 9 | Release 10 | x64 11 | 12 | 13 | 14 | {3F5BEECD-FA36-459F-91B8-BB481A67EF44} 15 | ColorizeTOP 16 | Win32Proj 17 | 10.0 18 | 19 | 20 | 21 | DynamicLibrary 22 | Unicode 23 | true 24 | v143 25 | 26 | 27 | DynamicLibrary 28 | Unicode 29 | v143 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | <_ProjectFileVersion>10.0.40219.1 43 | $(SolutionDir)$(Configuration)\ 44 | $(Configuration)\ 45 | false 46 | $(SolutionDir)$(Configuration)\ 47 | $(Configuration)\ 48 | false 49 | 50 | 51 | 52 | Disabled 53 | WIN32;_DEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) 54 | EnableFastChecks 55 | MultiThreadedDebugDLL 56 | 57 | 58 | Level3 59 | ProgramDatabase 60 | 61 | 62 | OpenGL32.lib;%(AdditionalDependencies) 63 | true 64 | Windows 65 | 66 | 67 | 68 | 69 | WIN32;NDEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) 70 | MultiThreadedDLL 71 | 72 | 73 | Level3 74 | ProgramDatabase 75 | 76 | 77 | OpenGL32.lib;%(AdditionalDependencies) 78 | true 79 | Windows 80 | true 81 | true 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | -------------------------------------------------------------------------------- /encoder/cpu/ColorizeTOP.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /encoder/cpu/ColorizeTOP.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /encoder/cpu/ColorizeTOP.xcodeproj/xcshareddata/xcschemes/ColorizeTOP.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 43 | 46 | 47 | 48 | 54 | 55 | 61 | 62 | 63 | 64 | 66 | 67 | 70 | 71 | 72 | -------------------------------------------------------------------------------- /encoder/cpu/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | NSHumanReadableCopyright 22 | Copyright © 2022 Derivative. All rights reserved. 23 | NSPrincipalClass 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /encoder/encoder.toe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lodefmode/moviecart/4ae049122e5a2cf368cd9413f8fba21dab926907/encoder/encoder.toe -------------------------------------------------------------------------------- /encoder/palettes/Atari2600NTSC.chan: -------------------------------------------------------------------------------- 1 | 0 0 0 2 | 74 74 74 3 | 111 111 111 4 | 142 142 142 5 | 170 170 170 6 | 192 192 192 7 | 214 214 214 8 | 236 236 236 9 | 72 72 0 10 | 105 105 15 11 | 134 134 29 12 | 162 162 42 13 | 187 187 53 14 | 210 210 64 15 | 232 232 74 16 | 252 252 84 17 | 124 44 0 18 | 144 72 17 19 | 162 98 33 20 | 180 122 48 21 | 195 144 61 22 | 210 164 74 23 | 223 183 85 24 | 236 200 96 25 | 144 28 0 26 | 163 57 21 27 | 181 83 40 28 | 198 108 58 29 | 213 130 74 30 | 227 151 89 31 | 240 170 103 32 | 252 188 116 33 | 148 0 0 34 | 167 26 26 35 | 184 50 50 36 | 200 72 72 37 | 214 92 92 38 | 228 111 111 39 | 240 128 128 40 | 252 144 144 41 | 132 0 100 42 | 151 25 122 43 | 168 48 143 44 | 184 70 162 45 | 198 89 179 46 | 212 108 195 47 | 224 124 210 48 | 236 140 224 49 | 80 0 132 50 | 104 25 154 51 | 125 48 173 52 | 146 70 192 53 | 164 89 208 54 | 181 108 224 55 | 197 124 238 56 | 212 140 252 57 | 20 0 144 58 | 51 26 163 59 | 78 50 181 60 | 104 72 198 61 | 127 92 213 62 | 149 111 227 63 | 169 128 240 64 | 188 144 252 65 | 0 0 148 66 | 24 26 167 67 | 45 50 184 68 | 66 72 200 69 | 84 92 214 70 | 101 111 228 71 | 117 128 240 72 | 132 144 252 73 | 0 28 136 74 | 24 59 157 75 | 45 87 176 76 | 66 114 194 77 | 84 138 210 78 | 101 160 225 79 | 117 181 239 80 | 132 200 252 81 | 0 48 100 82 | 24 80 128 83 | 45 109 152 84 | 66 136 176 85 | 84 160 197 86 | 101 183 217 87 | 117 204 235 88 | 132 224 252 89 | 0 64 48 90 | 24 98 78 91 | 45 129 105 92 | 66 158 130 93 | 84 184 153 94 | 101 209 174 95 | 117 231 194 96 | 132 252 212 97 | 0 68 0 98 | 26 102 26 99 | 50 132 50 100 | 72 160 72 101 | 92 186 92 102 | 111 210 111 103 | 128 232 128 104 | 144 252 144 105 | 20 60 0 106 | 53 95 24 107 | 82 126 45 108 | 110 156 66 109 | 135 183 84 110 | 158 208 101 111 | 180 231 117 112 | 200 252 132 113 | 48 56 0 114 | 80 89 22 115 | 109 118 43 116 | 136 146 62 117 | 160 171 79 118 | 183 194 95 119 | 204 216 110 120 | 224 236 124 121 | 72 44 0 122 | 105 77 20 123 | 134 106 38 124 | 162 134 56 125 | 187 159 71 126 | 210 182 86 127 | 232 204 99 128 | 252 224 112 129 | -------------------------------------------------------------------------------- /encoder/palettes/Atari2600PAL.chan: -------------------------------------------------------------------------------- 1 | 0 0 0 2 | 40 40 40 3 | 80 80 80 4 | 116 116 116 5 | 148 148 148 6 | 180 180 180 7 | 208 208 208 8 | 236 236 236 9 | 0 0 0 10 | 40 40 40 11 | 80 80 80 12 | 116 116 116 13 | 148 148 148 14 | 180 180 180 15 | 208 208 208 16 | 236 236 236 17 | 128 88 0 18 | 148 112 32 19 | 168 132 60 20 | 188 156 88 21 | 204 172 112 22 | 220 192 132 23 | 236 208 156 24 | 252 224 176 25 | 68 92 0 26 | 92 120 32 27 | 116 144 60 28 | 140 172 88 29 | 160 192 112 30 | 176 212 132 31 | 196 232 156 32 | 212 252 176 33 | 112 52 0 34 | 136 80 32 35 | 160 104 60 36 | 180 132 88 37 | 200 152 112 38 | 220 172 132 39 | 236 192 156 40 | 252 212 176 41 | 0 100 20 42 | 32 128 52 43 | 60 152 80 44 | 88 176 108 45 | 112 196 132 46 | 132 216 156 47 | 156 232 180 48 | 176 252 200 49 | 112 0 20 50 | 136 32 52 51 | 160 60 80 52 | 180 88 108 53 | 200 112 132 54 | 220 132 156 55 | 236 156 180 56 | 252 176 200 57 | 0 92 92 58 | 32 116 116 59 | 60 140 140 60 | 88 164 164 61 | 112 184 184 62 | 132 200 200 63 | 156 220 220 64 | 176 236 236 65 | 112 0 92 66 | 132 32 116 67 | 148 60 136 68 | 168 88 156 69 | 180 112 176 70 | 196 132 192 71 | 208 156 208 72 | 224 176 224 73 | 0 60 112 74 | 28 88 136 75 | 56 116 160 76 | 80 140 180 77 | 104 164 200 78 | 124 184 220 79 | 144 204 236 80 | 164 224 252 81 | 88 0 112 82 | 108 32 136 83 | 128 60 160 84 | 148 88 180 85 | 164 112 200 86 | 180 132 220 87 | 196 156 236 88 | 212 176 252 89 | 0 32 112 90 | 28 60 136 91 | 56 88 160 92 | 80 116 180 93 | 104 136 200 94 | 124 160 220 95 | 144 180 236 96 | 164 200 252 97 | 60 0 128 98 | 84 32 148 99 | 108 60 168 100 | 128 88 188 101 | 148 112 204 102 | 168 132 220 103 | 184 156 236 104 | 200 176 252 105 | 0 0 136 106 | 32 32 156 107 | 60 60 176 108 | 88 88 192 109 | 112 112 208 110 | 132 132 224 111 | 156 156 236 112 | 176 176 252 113 | -------------------------------------------------------------------------------- /encoder/palettes/Atari2600RandomTerrain.chan: -------------------------------------------------------------------------------- 1 | 0 0 0 2 | 26 26 26 3 | 57 57 57 4 | 91 91 91 5 | 126 126 126 6 | 162 162 162 7 | 199 199 199 8 | 237 237 237 9 | 25 2 0 10 | 58 31 0 11 | 93 65 0 12 | 130 100 0 13 | 167 136 0 14 | 204 173 0 15 | 242 210 25 16 | 254 250 64 17 | 55 0 0 18 | 94 8 0 19 | 131 39 0 20 | 169 73 0 21 | 207 108 0 22 | 245 143 23 23 | 254 180 56 24 | 254 223 111 25 | 71 0 0 26 | 115 0 0 27 | 152 19 0 28 | 190 50 22 29 | 228 83 53 30 | 254 118 87 31 | 254 156 129 32 | 254 198 187 33 | 68 0 8 34 | 111 0 31 35 | 150 6 64 36 | 187 36 98 37 | 225 69 133 38 | 254 103 170 39 | 254 140 214 40 | 254 183 246 41 | 45 0 74 42 | 87 0 103 43 | 125 5 140 44 | 161 34 177 45 | 199 67 215 46 | 237 101 254 47 | 254 138 246 48 | 254 181 247 49 | 13 0 130 50 | 51 0 162 51 | 85 15 201 52 | 120 45 240 53 | 156 78 254 54 | 195 114 254 55 | 235 152 254 56 | 254 192 249 57 | 0 0 145 58 | 10 5 189 59 | 40 34 228 60 | 72 66 254 61 | 107 100 254 62 | 144 138 254 63 | 183 176 254 64 | 223 216 254 65 | 0 0 114 66 | 0 28 171 67 | 3 60 214 68 | 32 94 253 69 | 64 129 254 70 | 100 166 254 71 | 137 206 254 72 | 176 246 254 73 | 0 16 58 74 | 0 49 110 75 | 0 85 162 76 | 5 121 200 77 | 35 157 238 78 | 68 194 254 79 | 104 233 254 80 | 143 254 254 81 | 0 31 2 82 | 0 67 38 83 | 0 105 87 84 | 0 141 122 85 | 27 177 158 86 | 59 215 195 87 | 93 254 233 88 | 134 254 254 89 | 0 36 3 90 | 0 74 5 91 | 0 112 12 92 | 9 149 43 93 | 40 186 76 94 | 73 224 110 95 | 108 254 146 96 | 151 254 181 97 | 0 33 2 98 | 0 70 4 99 | 8 107 0 100 | 40 144 0 101 | 73 181 9 102 | 107 219 40 103 | 143 254 73 104 | 187 254 105 105 | 0 21 1 106 | 16 54 0 107 | 48 89 0 108 | 83 126 0 109 | 118 163 0 110 | 154 200 0 111 | 191 238 30 112 | 232 254 62 113 | 26 2 0 114 | 59 31 0 115 | 94 65 0 116 | 131 100 0 117 | 168 136 0 118 | 206 173 0 119 | 244 210 24 120 | 254 250 64 121 | 56 0 0 122 | 95 8 0 123 | 132 39 0 124 | 170 73 0 125 | 208 107 0 126 | 246 143 24 127 | 254 180 57 128 | 254 223 112 129 | -------------------------------------------------------------------------------- /encoder/palettes/Atari2600SECAM.chan: -------------------------------------------------------------------------------- 1 | 0 0 0 2 | 33 33 255 3 | 240 60 121 4 | 255 80 255 5 | 127 255 0 6 | 127 255 255 7 | 255 255 63 8 | 255 255 255 9 | -------------------------------------------------------------------------------- /encoder/palettes/BW2.chan: -------------------------------------------------------------------------------- 1 | 0 0 0 2 | 255 255 255 3 | -------------------------------------------------------------------------------- /encoder/palettes/BW4.chan: -------------------------------------------------------------------------------- 1 | 0 0 0 2 | 85 85 85 3 | 170 170 170 4 | 255 255 255 5 | -------------------------------------------------------------------------------- /encoder/palettes/ColecoVision.chan: -------------------------------------------------------------------------------- 1 | 0 0 0 2 | 0 0 0 3 | 10 173 30 4 | 52 200 76 5 | 43 45 227 6 | 81 75 251 7 | 189 41 37 8 | 30 226 239 9 | 251 44 43 10 | 255 95 76 11 | 189 162 43 12 | 215 180 84 13 | 10 140 24 14 | 175 50 154 15 | 178 178 178 16 | 255 255 255 17 | -------------------------------------------------------------------------------- /encoder/palettes/RGB.chan: -------------------------------------------------------------------------------- 1 | 0 0 0 2 | 0 0 255 3 | 0 255 0 4 | 255 0 0 5 | -------------------------------------------------------------------------------- /encoder/palettes/Rubik.chan: -------------------------------------------------------------------------------- 1 | 0 155 72 2 | 255 255 255 3 | 183 18 52 4 | 255 213 0 5 | 0 70 173 6 | 255 88 0 7 | -------------------------------------------------------------------------------- /encoder/palettes/readme.txt: -------------------------------------------------------------------------------- 1 | 2 | Sources: 3 | 4 | Atari2600NTSC.chan stella uInt32 Console::ourNTSCPalette 5 | Atari2600PAL.chan 6 | Atari2600SECAM.chan 7 | Atari2600RandomTerrain.chan https://www.randomterrain.com/atari-2600-memories-tia-color-charts.html 8 | ColecoVision.chan https://en.wikipedia.org/wiki/Texas_Instruments_TMS9918#Colors 9 | 10 | Rubik.chan 11 | BW2.chan 12 | BW4.chan 13 | RGB.chan 14 | -------------------------------------------------------------------------------- /examples/20centryfox_pal.mvc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lodefmode/moviecart/4ae049122e5a2cf368cd9413f8fba21dab926907/examples/20centryfox_pal.mvc -------------------------------------------------------------------------------- /examples/20centuryfox.mvc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lodefmode/moviecart/4ae049122e5a2cf368cd9413f8fba21dab926907/examples/20centuryfox.mvc -------------------------------------------------------------------------------- /examples/cronkite_pal.mvc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lodefmode/moviecart/4ae049122e5a2cf368cd9413f8fba21dab926907/examples/cronkite_pal.mvc -------------------------------------------------------------------------------- /examples/dancer.mvc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lodefmode/moviecart/4ae049122e5a2cf368cd9413f8fba21dab926907/examples/dancer.mvc -------------------------------------------------------------------------------- /examples/lion.mvc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lodefmode/moviecart/4ae049122e5a2cf368cd9413f8fba21dab926907/examples/lion.mvc -------------------------------------------------------------------------------- /examples/numbers.mvc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lodefmode/moviecart/4ae049122e5a2cf368cd9413f8fba21dab926907/examples/numbers.mvc -------------------------------------------------------------------------------- /examples/output_cronkite.mvc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lodefmode/moviecart/4ae049122e5a2cf368cd9413f8fba21dab926907/examples/output_cronkite.mvc -------------------------------------------------------------------------------- /examples/street.mp4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lodefmode/moviecart/4ae049122e5a2cf368cd9413f8fba21dab926907/examples/street.mp4 -------------------------------------------------------------------------------- /examples/street.mvc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lodefmode/moviecart/4ae049122e5a2cf368cd9413f8fba21dab926907/examples/street.mvc -------------------------------------------------------------------------------- /examples/street_tate.mvc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lodefmode/moviecart/4ae049122e5a2cf368cd9413f8fba21dab926907/examples/street_tate.mvc -------------------------------------------------------------------------------- /examples/testpattern.mvc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lodefmode/moviecart/4ae049122e5a2cf368cd9413f8fba21dab926907/examples/testpattern.mvc -------------------------------------------------------------------------------- /examples/title.mvc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lodefmode/moviecart/4ae049122e5a2cf368cd9413f8fba21dab926907/examples/title.mvc -------------------------------------------------------------------------------- /firmware/.gitignore: -------------------------------------------------------------------------------- 1 | build 2 | dist 3 | debug 4 | .generated_files 5 | 6 | -------------------------------------------------------------------------------- /firmware/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # There exist several targets which are by default empty and which can be 3 | # used for execution of your targets. These targets are usually executed 4 | # before and after some main targets. They are: 5 | # 6 | # .build-pre: called before 'build' target 7 | # .build-post: called after 'build' target 8 | # .clean-pre: called before 'clean' target 9 | # .clean-post: called after 'clean' target 10 | # .clobber-pre: called before 'clobber' target 11 | # .clobber-post: called after 'clobber' target 12 | # .all-pre: called before 'all' target 13 | # .all-post: called after 'all' target 14 | # .help-pre: called before 'help' target 15 | # .help-post: called after 'help' target 16 | # 17 | # Targets beginning with '.' are not intended to be called on their own. 18 | # 19 | # Main targets can be executed directly, and they are: 20 | # 21 | # build build a specific configuration 22 | # clean remove built files from a configuration 23 | # clobber remove all built files 24 | # all build all configurations 25 | # help print help mesage 26 | # 27 | # Targets .build-impl, .clean-impl, .clobber-impl, .all-impl, and 28 | # .help-impl are implemented in nbproject/makefile-impl.mk. 29 | # 30 | # Available make variables: 31 | # 32 | # CND_BASEDIR base directory for relative paths 33 | # CND_DISTDIR default top distribution directory (build artifacts) 34 | # CND_BUILDDIR default top build directory (object files, ...) 35 | # CONF name of current configuration 36 | # CND_ARTIFACT_DIR_${CONF} directory of build artifact (current configuration) 37 | # CND_ARTIFACT_NAME_${CONF} name of build artifact (current configuration) 38 | # CND_ARTIFACT_PATH_${CONF} path to build artifact (current configuration) 39 | # CND_PACKAGE_DIR_${CONF} directory of package (current configuration) 40 | # CND_PACKAGE_NAME_${CONF} name of package (current configuration) 41 | # CND_PACKAGE_PATH_${CONF} path to package (current configuration) 42 | # 43 | # NOCDDL 44 | 45 | 46 | # Environment 47 | MKDIR=mkdir 48 | CP=cp 49 | CCADMIN=CCadmin 50 | RANLIB=ranlib 51 | 52 | 53 | # build 54 | build: .build-post 55 | 56 | .build-pre: 57 | # Add your pre 'build' code here... 58 | 59 | .build-post: .build-impl 60 | # Add your post 'build' code here... 61 | 62 | 63 | # clean 64 | clean: .clean-post 65 | 66 | .clean-pre: 67 | # Add your pre 'clean' code here... 68 | # WARNING: the IDE does not call this target since it takes a long time to 69 | # simply run make. Instead, the IDE removes the configuration directories 70 | # under build and dist directly without calling make. 71 | # This target is left here so people can do a clean when running a clean 72 | # outside the IDE. 73 | 74 | .clean-post: .clean-impl 75 | # Add your post 'clean' code here... 76 | 77 | 78 | # clobber 79 | clobber: .clobber-post 80 | 81 | .clobber-pre: 82 | # Add your pre 'clobber' code here... 83 | 84 | .clobber-post: .clobber-impl 85 | # Add your post 'clobber' code here... 86 | 87 | 88 | # all 89 | all: .all-post 90 | 91 | .all-pre: 92 | # Add your pre 'all' code here... 93 | 94 | .all-post: .all-impl 95 | # Add your post 'all' code here... 96 | 97 | 98 | # help 99 | help: .help-post 100 | 101 | .help-pre: 102 | # Add your pre 'help' code here... 103 | 104 | .help-post: .help-impl 105 | # Add your post 'help' code here... 106 | 107 | 108 | 109 | # include project implementation makefile 110 | include nbproject/Makefile-impl.mk 111 | 112 | # include project make variables 113 | include nbproject/Makefile-variables.mk 114 | -------------------------------------------------------------------------------- /firmware/aivt.c: -------------------------------------------------------------------------------- 1 | 2 | 3 | #if 0 4 | #include "mcc_generated_files/system.h" 5 | #include "mcc_generated_files/pin_manager.h" 6 | #include "mcc_generated_files/spi1.h" 7 | #include "mcc_generated_files/memory/flash.h" 8 | #include "mcc_generated_files/interrupt_manager.h" 9 | #endif 10 | 11 | 12 | #include 13 | #include 14 | 15 | extern void flash_led(uint8_t num); 16 | 17 | #if 0 18 | // include in main to use 19 | INTCON2bits.AIVTEN = 1; 20 | PIN_MANAGER_enableInterrupt_On_Change(); 21 | INTERRUPT_GlobalEnable(); 22 | #endif 23 | 24 | void __attribute__((section(".newaivt"), interrupt, no_auto_psv, context, used)) _UserCNCInterrupt(void) 25 | { 26 | // test 27 | while(1) 28 | { 29 | flash_led(5); 30 | flash_led(1); 31 | flash_led(2); 32 | } 33 | 34 | return; 35 | } 36 | 37 | -------------------------------------------------------------------------------- /firmware/bootloader/.gitignore: -------------------------------------------------------------------------------- 1 | build 2 | dist 3 | debug 4 | .generated_files 5 | 6 | -------------------------------------------------------------------------------- /firmware/bootloader/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # There exist several targets which are by default empty and which can be 3 | # used for execution of your targets. These targets are usually executed 4 | # before and after some main targets. They are: 5 | # 6 | # .build-pre: called before 'build' target 7 | # .build-post: called after 'build' target 8 | # .clean-pre: called before 'clean' target 9 | # .clean-post: called after 'clean' target 10 | # .clobber-pre: called before 'clobber' target 11 | # .clobber-post: called after 'clobber' target 12 | # .all-pre: called before 'all' target 13 | # .all-post: called after 'all' target 14 | # .help-pre: called before 'help' target 15 | # .help-post: called after 'help' target 16 | # 17 | # Targets beginning with '.' are not intended to be called on their own. 18 | # 19 | # Main targets can be executed directly, and they are: 20 | # 21 | # build build a specific configuration 22 | # clean remove built files from a configuration 23 | # clobber remove all built files 24 | # all build all configurations 25 | # help print help mesage 26 | # 27 | # Targets .build-impl, .clean-impl, .clobber-impl, .all-impl, and 28 | # .help-impl are implemented in nbproject/makefile-impl.mk. 29 | # 30 | # Available make variables: 31 | # 32 | # CND_BASEDIR base directory for relative paths 33 | # CND_DISTDIR default top distribution directory (build artifacts) 34 | # CND_BUILDDIR default top build directory (object files, ...) 35 | # CONF name of current configuration 36 | # CND_ARTIFACT_DIR_${CONF} directory of build artifact (current configuration) 37 | # CND_ARTIFACT_NAME_${CONF} name of build artifact (current configuration) 38 | # CND_ARTIFACT_PATH_${CONF} path to build artifact (current configuration) 39 | # CND_PACKAGE_DIR_${CONF} directory of package (current configuration) 40 | # CND_PACKAGE_NAME_${CONF} name of package (current configuration) 41 | # CND_PACKAGE_PATH_${CONF} path to package (current configuration) 42 | # 43 | # NOCDDL 44 | 45 | 46 | # Environment 47 | MKDIR=mkdir 48 | CP=cp 49 | CCADMIN=CCadmin 50 | RANLIB=ranlib 51 | 52 | 53 | # build 54 | build: .build-post 55 | 56 | .build-pre: 57 | # Add your pre 'build' code here... 58 | 59 | .build-post: .build-impl 60 | # Add your post 'build' code here... 61 | 62 | 63 | # clean 64 | clean: .clean-post 65 | 66 | .clean-pre: 67 | # Add your pre 'clean' code here... 68 | # WARNING: the IDE does not call this target since it takes a long time to 69 | # simply run make. Instead, the IDE removes the configuration directories 70 | # under build and dist directly without calling make. 71 | # This target is left here so people can do a clean when running a clean 72 | # outside the IDE. 73 | 74 | .clean-post: .clean-impl 75 | # Add your post 'clean' code here... 76 | 77 | 78 | # clobber 79 | clobber: .clobber-post 80 | 81 | .clobber-pre: 82 | # Add your pre 'clobber' code here... 83 | 84 | .clobber-post: .clobber-impl 85 | # Add your post 'clobber' code here... 86 | 87 | 88 | # all 89 | all: .all-post 90 | 91 | .all-pre: 92 | # Add your pre 'all' code here... 93 | 94 | .all-post: .all-impl 95 | # Add your post 'all' code here... 96 | 97 | 98 | # help 99 | help: .help-post 100 | 101 | .help-pre: 102 | # Add your pre 'help' code here... 103 | 104 | .help-post: .help-impl 105 | # Add your post 'help' code here... 106 | 107 | 108 | 109 | # include project implementation makefile 110 | include nbproject/Makefile-impl.mk 111 | 112 | # include project make variables 113 | include nbproject/Makefile-variables.mk 114 | -------------------------------------------------------------------------------- /firmware/bootloader/mcc_generated_files/clock.c: -------------------------------------------------------------------------------- 1 | /** 2 | @Generated PIC24 / dsPIC33 / PIC32MM MCUs Source File 3 | 4 | @Company: 5 | Microchip Technology Inc. 6 | 7 | @File Name: 8 | clock.c 9 | 10 | @Summary: 11 | This is the clock.c file generated using PIC24 / dsPIC33 / PIC32MM MCUs 12 | 13 | @Description: 14 | This header file provides implementations for driver APIs for all modules selected in the GUI. 15 | Generation Information : 16 | Product Revision : PIC24 / dsPIC33 / PIC32MM MCUs - 1.170.0 17 | Device : dsPIC33CK64MC105 18 | The generated drivers are tested against the following: 19 | Compiler : XC16 v1.61 20 | MPLAB : MPLAB X v5.45 21 | */ 22 | 23 | /* 24 | (c) 2020 Microchip Technology Inc. and its subsidiaries. You may use this 25 | software and any derivatives exclusively with Microchip products. 26 | 27 | THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER 28 | EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY IMPLIED 29 | WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS FOR A 30 | PARTICULAR PURPOSE, OR ITS INTERACTION WITH MICROCHIP PRODUCTS, COMBINATION 31 | WITH ANY OTHER PRODUCTS, OR USE IN ANY APPLICATION. 32 | 33 | IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, 34 | INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND 35 | WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS 36 | BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE 37 | FULLEST EXTENT ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN 38 | ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY, 39 | THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE. 40 | 41 | MICROCHIP PROVIDES THIS SOFTWARE CONDITIONALLY UPON YOUR ACCEPTANCE OF THESE 42 | TERMS. 43 | */ 44 | 45 | #include 46 | #include "xc.h" 47 | #include "clock.h" 48 | 49 | void CLOCK_Initialize(void) 50 | { 51 | // FRCDIV FRC/1; PLLPRE 1; DOZE 1:8; DOZEN disabled; ROI disabled; 52 | CLKDIV = 0x3001; 53 | // PLLFBDIV 100; 54 | PLLFBD = 0x64; 55 | // TUN Center frequency; 56 | OSCTUN = 0x00; 57 | // POST1DIV 1:2; VCODIV FVCO/4; POST2DIV 1:1; 58 | PLLDIV = 0x21; 59 | // ROEN disabled; ROSWEN disabled; ROSLP disabled; ROSEL FOSC; ROOUT disabled; ROSIDL disabled; 60 | REFOCONL = 0x00; 61 | // RODIV 0; 62 | REFOCONH = 0x00; 63 | // ROTRIM 0; 64 | REFOTRIMH = 0x00; 65 | // IOLOCK disabled; 66 | RPCON = 0x00; 67 | // PMDLOCK disabled; 68 | PMDCON = 0x00; 69 | // ADC1MD enabled; T1MD enabled; U2MD enabled; U1MD enabled; SPI2MD enabled; SPI1MD enabled; QEIMD enabled; PWMMD enabled; I2C1MD enabled; 70 | PMD1 = 0x00; 71 | // CCP2MD enabled; CCP1MD enabled; CCP4MD enabled; CCP3MD enabled; 72 | PMD2 = 0x00; 73 | // U3MD enabled; CRCMD enabled; 74 | PMD3 = 0x00; 75 | // REFOMD enabled; 76 | PMD4 = 0x00; 77 | // DMA1MD enabled; DMA2MD enabled; DMA3MD enabled; DMA0MD enabled; 78 | PMD6 = 0x00; 79 | // PTGMD enabled; CMP1MD enabled; 80 | PMD7 = 0x00; 81 | // DMTMD enabled; CLC3MD enabled; OPAMPMD enabled; BIASMD enabled; CLC4MD enabled; SENT1MD enabled; CLC1MD enabled; CLC2MD enabled; 82 | PMD8 = 0x00; 83 | // CF no clock failure; NOSC FRCPLL; CLKLOCK unlocked; OSWEN Switch is Complete; 84 | __builtin_write_OSCCONH((uint8_t) (0x01)); 85 | __builtin_write_OSCCONL((uint8_t) (0x01)); 86 | // Wait for Clock switch to occur 87 | while (OSCCONbits.OSWEN != 0); 88 | while (OSCCONbits.LOCK != 1); 89 | } 90 | 91 | -------------------------------------------------------------------------------- /firmware/bootloader/mcc_generated_files/clock.h: -------------------------------------------------------------------------------- 1 | /** 2 | @Generated PIC24 / dsPIC33 / PIC32MM MCUs Source File 3 | 4 | @Company: 5 | Microchip Technology Inc. 6 | 7 | @File Name: 8 | clock.h 9 | 10 | @Summary: 11 | This is the clock.h file generated using PIC24 / dsPIC33 / PIC32MM MCUs 12 | 13 | @Description: 14 | This header file provides implementations for driver APIs for all modules selected in the GUI. 15 | Generation Information : 16 | Product Revision : PIC24 / dsPIC33 / PIC32MM MCUs - 1.170.0 17 | Device : dsPIC33CK64MC105 18 | The generated drivers are tested against the following: 19 | Compiler : XC16 v1.61 20 | MPLAB : MPLAB X v5.45 21 | */ 22 | 23 | /* 24 | (c) 2020 Microchip Technology Inc. and its subsidiaries. You may use this 25 | software and any derivatives exclusively with Microchip products. 26 | 27 | THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER 28 | EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY IMPLIED 29 | WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS FOR A 30 | PARTICULAR PURPOSE, OR ITS INTERACTION WITH MICROCHIP PRODUCTS, COMBINATION 31 | WITH ANY OTHER PRODUCTS, OR USE IN ANY APPLICATION. 32 | 33 | IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, 34 | INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND 35 | WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS 36 | BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE 37 | FULLEST EXTENT ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN 38 | ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY, 39 | THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE. 40 | 41 | MICROCHIP PROVIDES THIS SOFTWARE CONDITIONALLY UPON YOUR ACCEPTANCE OF THESE 42 | TERMS. 43 | */ 44 | 45 | #ifndef CLOCK_H 46 | #define CLOCK_H 47 | 48 | /** 49 | Section: Included Files 50 | */ 51 | 52 | #include 53 | 54 | #ifndef _XTAL_FREQ 55 | #define _XTAL_FREQ 200000000UL 56 | #endif 57 | 58 | #define CLOCK_SystemFrequencyGet() (200000000UL) 59 | 60 | #define CLOCK_PeripheralFrequencyGet() (CLOCK_SystemFrequencyGet() / 2) 61 | 62 | #define CLOCK_InstructionFrequencyGet() (CLOCK_SystemFrequencyGet() / 2) 63 | /** 64 | * @Param 65 | none 66 | * @Returns 67 | none 68 | * @Description 69 | Initializes the oscillator to the default states configured in the 70 | * MCC GUI 71 | * @Example 72 | CLOCK_Initialize(void); 73 | */ 74 | void CLOCK_Initialize(void); 75 | 76 | 77 | #endif /* CLOCK_H */ 78 | /** 79 | End of File 80 | */ -------------------------------------------------------------------------------- /firmware/bootloader/mcc_generated_files/interrupt_manager.c: -------------------------------------------------------------------------------- 1 | /** 2 | System Interrupts Generated Driver File 3 | 4 | @Company: 5 | Microchip Technology Inc. 6 | 7 | @File Name: 8 | interrupt_manager.h 9 | 10 | @Summary: 11 | This is the generated driver implementation file for setting up the 12 | interrupts using PIC24 / dsPIC33 / PIC32MM MCUs 13 | 14 | @Description: 15 | This source file provides implementations for PIC24 / dsPIC33 / PIC32MM MCUs interrupts. 16 | Generation Information : 17 | Product Revision : PIC24 / dsPIC33 / PIC32MM MCUs - 1.170.0 18 | Device : dsPIC33CK64MC105 19 | The generated drivers are tested against the following: 20 | Compiler : XC16 v1.61 21 | MPLAB : MPLAB X v5.45 22 | */ 23 | /* 24 | (c) 2020 Microchip Technology Inc. and its subsidiaries. You may use this 25 | software and any derivatives exclusively with Microchip products. 26 | 27 | THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER 28 | EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY IMPLIED 29 | WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS FOR A 30 | PARTICULAR PURPOSE, OR ITS INTERACTION WITH MICROCHIP PRODUCTS, COMBINATION 31 | WITH ANY OTHER PRODUCTS, OR USE IN ANY APPLICATION. 32 | 33 | IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, 34 | INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND 35 | WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS 36 | BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE 37 | FULLEST EXTENT ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN 38 | ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY, 39 | THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE. 40 | 41 | MICROCHIP PROVIDES THIS SOFTWARE CONDITIONALLY UPON YOUR ACCEPTANCE OF THESE 42 | TERMS. 43 | */ 44 | 45 | /** 46 | Section: Includes 47 | */ 48 | #include 49 | 50 | /** 51 | void INTERRUPT_Initialize (void) 52 | */ 53 | void INTERRUPT_Initialize (void) 54 | { 55 | } 56 | -------------------------------------------------------------------------------- /firmware/bootloader/mcc_generated_files/interrupt_manager.h: -------------------------------------------------------------------------------- 1 | /** 2 | System Interrupts Generated Driver File 3 | 4 | @Company: 5 | Microchip Technology Inc. 6 | 7 | @File Name: 8 | interrupt_manager.h 9 | 10 | @Summary: 11 | This is the generated driver implementation file for setting up the 12 | interrupts using PIC24 / dsPIC33 / PIC32MM MCUs 13 | 14 | @Description: 15 | This source file provides implementations for PIC24 / dsPIC33 / PIC32MM MCUs interrupts. 16 | Generation Information : 17 | Product Revision : PIC24 / dsPIC33 / PIC32MM MCUs - 1.170.0 18 | Device : dsPIC33CK64MC105 19 | The generated drivers are tested against the following: 20 | Compiler : XC16 v1.61 21 | MPLAB : MPLAB X v5.45 22 | */ 23 | /* 24 | (c) 2020 Microchip Technology Inc. and its subsidiaries. You may use this 25 | software and any derivatives exclusively with Microchip products. 26 | 27 | THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER 28 | EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY IMPLIED 29 | WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS FOR A 30 | PARTICULAR PURPOSE, OR ITS INTERACTION WITH MICROCHIP PRODUCTS, COMBINATION 31 | WITH ANY OTHER PRODUCTS, OR USE IN ANY APPLICATION. 32 | 33 | IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, 34 | INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND 35 | WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS 36 | BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE 37 | FULLEST EXTENT ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN 38 | ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY, 39 | THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE. 40 | 41 | MICROCHIP PROVIDES THIS SOFTWARE CONDITIONALLY UPON YOUR ACCEPTANCE OF THESE 42 | TERMS. 43 | */ 44 | 45 | #ifndef _INTERRUPT_MANAGER_H 46 | #define _INTERRUPT_MANAGER_H 47 | 48 | /** 49 | @Summary 50 | Initializes the interrupt priorities of the dsPIC33CK64MC105 51 | 52 | @Description 53 | This routine sets the interrupt priorities of the modules that have been configured 54 | for the dsPIC33CK64MC105 55 | 56 | @Preconditions 57 | None. 58 | 59 | @Returns 60 | None. 61 | 62 | @Param 63 | None. 64 | 65 | @Example 66 | 67 | void SYSTEM_Initialize(void) 68 | { 69 | // Other initializers are called from this function 70 | INTERRUPT_Initialize (); 71 | } 72 | 73 | 74 | */ 75 | void INTERRUPT_Initialize(void); 76 | 77 | /** 78 | @Summary 79 | Enables global interrupts of the dsPIC33CK64MC105 80 | 81 | @Description 82 | This routine enables the global interrupt bit for the dsPIC33CK64MC105 83 | 84 | @Preconditions 85 | None. 86 | 87 | @Returns 88 | None. 89 | 90 | @Param 91 | None. 92 | 93 | @Example 94 | 95 | void SYSTEM_Initialize(void) 96 | { 97 | // Other initializers are called from this function 98 | INTERRUPT_GlobalEnable (); 99 | } 100 | 101 | 102 | */ 103 | inline static void INTERRUPT_GlobalEnable(void) 104 | { 105 | __builtin_enable_interrupts(); 106 | } 107 | 108 | /** 109 | @Summary 110 | Disables global interrupts of the dsPIC33CK64MC105 111 | 112 | @Description 113 | This routine disables the global interrupt bit for the dsPIC33CK64MC105 114 | 115 | @Preconditions 116 | None. 117 | 118 | @Returns 119 | None. 120 | 121 | @Param 122 | None. 123 | 124 | @Example 125 | 126 | void SYSTEM_Initialize(void) 127 | { 128 | // Other initializers are called from this function 129 | INTERRUPT_GlobalDisable (); 130 | } 131 | 132 | 133 | */ 134 | inline static void INTERRUPT_GlobalDisable(void) 135 | { 136 | __builtin_disable_interrupts(); 137 | } 138 | 139 | /** 140 | @Summary 141 | Returns the interrupt vector number of the interrupt which is pending. 142 | 143 | @Description 144 | This routine returns the interrupt vector number of the interrupt which is pending. 145 | 146 | @Preconditions 147 | None. 148 | 149 | @Returns 150 | None. 151 | 152 | @Param 153 | None. 154 | 155 | @Example 156 | 157 | uint16_t ivrNum; 158 | ivrNum = INTERRUPT_VectorNumberGet(); 159 | 160 | 161 | */ 162 | inline static uint16_t INTERRUPT_VectorNumberGet(void) 163 | { 164 | return _VECNUM; 165 | } 166 | 167 | #endif -------------------------------------------------------------------------------- /firmware/bootloader/mcc_generated_files/mcc.c: -------------------------------------------------------------------------------- 1 | /** 2 | @Generated PIC24 / dsPIC33 / PIC32MM MCUs Source File 3 | 4 | @Company: 5 | Microchip Technology Inc. 6 | 7 | @File Name: 8 | mcc.c 9 | 10 | @Summary: 11 | This is the mcc.c file generated using PIC24 / dsPIC33 / PIC32MM MCUs 12 | 13 | @Description: 14 | The configuration contents of this file are moved to system.c and this file will be removed in future MCC releases. 15 | Generation Information : 16 | Product Revision : PIC24 / dsPIC33 / PIC32MM MCUs - 1.170.0 17 | Device : dsPIC33CK64MC105 18 | The generated drivers are tested against the following: 19 | Compiler : XC16 v1.61 20 | MPLAB : MPLAB X v5.45 21 | */ 22 | 23 | /* 24 | (c) 2020 Microchip Technology Inc. and its subsidiaries. You may use this 25 | software and any derivatives exclusively with Microchip products. 26 | 27 | THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER 28 | EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY IMPLIED 29 | WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS FOR A 30 | PARTICULAR PURPOSE, OR ITS INTERACTION WITH MICROCHIP PRODUCTS, COMBINATION 31 | WITH ANY OTHER PRODUCTS, OR USE IN ANY APPLICATION. 32 | 33 | IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, 34 | INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND 35 | WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS 36 | BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE 37 | FULLEST EXTENT ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN 38 | ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY, 39 | THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE. 40 | 41 | MICROCHIP PROVIDES THIS SOFTWARE CONDITIONALLY UPON YOUR ACCEPTANCE OF THESE 42 | TERMS. 43 | */ 44 | 45 | /** 46 | End of File 47 | */ -------------------------------------------------------------------------------- /firmware/bootloader/mcc_generated_files/mcc.h: -------------------------------------------------------------------------------- 1 | /** 2 | @Generated PIC24 / dsPIC33 / PIC32MM MCUs Header File 3 | 4 | @Company: 5 | Microchip Technology Inc. 6 | 7 | @File Name: 8 | mcc.h 9 | 10 | @Summary: 11 | This is the mcc.h file generated using PIC24 / dsPIC33 / PIC32MM MCUs 12 | 13 | @Description: 14 | This file will be removed in future MCC releases. Use system.h instead. 15 | Generation Information : 16 | Product Revision : PIC24 / dsPIC33 / PIC32MM MCUs - 1.170.0 17 | Device : dsPIC33CK64MC105 18 | The generated drivers are tested against the following: 19 | Compiler : XC16 v1.61 20 | MPLAB : MPLAB X v5.45 21 | */ 22 | 23 | /* 24 | (c) 2020 Microchip Technology Inc. and its subsidiaries. You may use this 25 | software and any derivatives exclusively with Microchip products. 26 | 27 | THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER 28 | EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY IMPLIED 29 | WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS FOR A 30 | PARTICULAR PURPOSE, OR ITS INTERACTION WITH MICROCHIP PRODUCTS, COMBINATION 31 | WITH ANY OTHER PRODUCTS, OR USE IN ANY APPLICATION. 32 | 33 | IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, 34 | INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND 35 | WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS 36 | BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE 37 | FULLEST EXTENT ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN 38 | ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY, 39 | THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE. 40 | 41 | MICROCHIP PROVIDES THIS SOFTWARE CONDITIONALLY UPON YOUR ACCEPTANCE OF THESE 42 | TERMS. 43 | */ 44 | 45 | #ifndef MCC_H 46 | #define MCC_H 47 | #include 48 | #include "system.h" 49 | #include "clock.h" 50 | #include "pin_manager.h" 51 | #include 52 | #include 53 | #include "system_types.h" 54 | #include "reset.h" 55 | 56 | #include "reset.h" 57 | #include "interrupt_manager.h" 58 | #include "traps.h" 59 | #include "memory/flash.h" 60 | #include "watchdog.h" 61 | #include "clc1.h" 62 | #include "spi1.h" 63 | 64 | #warning "This file will be removed in future MCC releases. Use system.h instead." 65 | 66 | #endif /* MCC_H */ 67 | /** 68 | End of File 69 | */ -------------------------------------------------------------------------------- /firmware/bootloader/mcc_generated_files/memory/flash.h: -------------------------------------------------------------------------------- 1 | /** 2 | FLASH Generated Driver API Header File 3 | 4 | @Company 5 | Microchip Technology Inc. 6 | 7 | @File Name 8 | flash.h 9 | 10 | @Summary 11 | This is the generated header file for the FLASH driver using PIC24 / dsPIC33 / PIC32MM MCUs 12 | 13 | @Description 14 | This header file provides APIs for driver for FLASH. 15 | Generation Information : 16 | Product Revision : PIC24 / dsPIC33 / PIC32MM MCUs - 1.170.0 17 | Device : dsPIC33CK64MC105 18 | Driver Version : 1.00 19 | The generated drivers are tested against the following: 20 | Compiler : XC16 v1.61 21 | MPLAB : MPLAB X v5.45 22 | */ 23 | 24 | #ifndef FLASH_H 25 | #define FLASH_H 26 | 27 | #include 28 | #include 29 | #include 30 | 31 | #define FLASH_WRITE_ROW_SIZE_IN_INSTRUCTIONS 128U 32 | #define FLASH_ERASE_PAGE_SIZE_IN_INSTRUCTIONS 1024U 33 | 34 | #define FLASH_ERASE_PAGE_SIZE_IN_PC_UNITS (FLASH_ERASE_PAGE_SIZE_IN_INSTRUCTIONS*2U) 35 | #define FLASH_WRITE_ROW_SIZE_IN_PC_UNITS (FLASH_WRITE_ROW_SIZE_IN_INSTRUCTIONS*2U) 36 | #define FLASH_HAS_ECC 1 37 | 38 | #define FLASH_UNLOCK_KEY 0x00AA0055 39 | 40 | #define FLASH_ERASE_PAGE_MASK (~((FLASH_ERASE_PAGE_SIZE_IN_INSTRUCTIONS*2U) - 1U)) 41 | void FLASH_Unlock(uint32_t key); 42 | void FLASH_Lock(void); 43 | 44 | bool FLASH_ErasePage(uint32_t address); 45 | 46 | uint16_t FLASH_ReadWord16(uint32_t address); 47 | uint32_t FLASH_ReadWord24(uint32_t address); 48 | 49 | bool FLASH_WriteDoubleWord16(uint32_t flashAddress, uint16_t Data0, uint16_t Data1); 50 | bool FLASH_WriteDoubleWord24(uint32_t address, uint32_t Data0, uint32_t Data1 ); 51 | 52 | /* Program the flash one row at a time. */ 53 | 54 | /* FLASH_WriteRow24: Writes a single row of data from the location given in *data to 55 | * the flash location in address. Since the flash is only 24 bits wide 56 | * all data in the upper 8 bits of the source will be lost . 57 | * The address in *data must be row aligned. 58 | * returns true if successful */ 59 | 60 | bool FLASH_WriteRow24(uint32_t flashAddress, uint32_t *data); 61 | 62 | /* FLASH_WriteRow16: Writes a single row of data from the location in given in *data to 63 | * to the flash location in address. Each 16 bit source data 64 | * word is stored in the lower 16 bits of each flash entry and the 65 | * upper 8 bits of the flash is not programmed. 66 | * The address in *data must be row aligned. 67 | * returns true if successful */ 68 | bool FLASH_WriteRow16(uint32_t address, uint16_t *data); 69 | 70 | 71 | uint16_t FLASH_GetErasePageOffset(uint32_t address); 72 | uint32_t FLASH_GetErasePageAddress(uint32_t address); 73 | 74 | 75 | 76 | 77 | #endif /* FLASH_H */ 78 | 79 | -------------------------------------------------------------------------------- /firmware/bootloader/mcc_generated_files/pin_manager.c: -------------------------------------------------------------------------------- 1 | /** 2 | PIN MANAGER Generated Driver File 3 | 4 | @Company: 5 | Microchip Technology Inc. 6 | 7 | @File Name: 8 | pin_manager.c 9 | 10 | @Summary: 11 | This is the generated manager file for the PIC24 / dsPIC33 / PIC32MM MCUs device. This manager 12 | configures the pins direction, initial state, analog setting. 13 | The peripheral pin select, PPS, configuration is also handled by this manager. 14 | 15 | @Description: 16 | This source file provides implementations for PIN MANAGER. 17 | Generation Information : 18 | Product Revision : PIC24 / dsPIC33 / PIC32MM MCUs - 1.170.0 19 | Device : dsPIC33CK64MC105 20 | The generated drivers are tested against the following: 21 | Compiler : XC16 v1.61 22 | MPLAB : MPLAB X v5.45 23 | */ 24 | 25 | /* 26 | (c) 2020 Microchip Technology Inc. and its subsidiaries. You may use this 27 | software and any derivatives exclusively with Microchip products. 28 | 29 | THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER 30 | EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY IMPLIED 31 | WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS FOR A 32 | PARTICULAR PURPOSE, OR ITS INTERACTION WITH MICROCHIP PRODUCTS, COMBINATION 33 | WITH ANY OTHER PRODUCTS, OR USE IN ANY APPLICATION. 34 | 35 | IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, 36 | INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND 37 | WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS 38 | BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE 39 | FULLEST EXTENT ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN 40 | ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY, 41 | THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE. 42 | 43 | MICROCHIP PROVIDES THIS SOFTWARE CONDITIONALLY UPON YOUR ACCEPTANCE OF THESE 44 | TERMS. 45 | */ 46 | 47 | 48 | /** 49 | Section: Includes 50 | */ 51 | 52 | #include 53 | #include 54 | #include "pin_manager.h" 55 | 56 | /** 57 | Section: Driver Interface Function Definitions 58 | */ 59 | void PIN_MANAGER_Initialize (void) 60 | { 61 | /**************************************************************************** 62 | * Setting the Output Latch SFR(s) 63 | ***************************************************************************/ 64 | LATA = 0x0000; 65 | LATB = 0x0000; 66 | LATC = 0x0000; 67 | LATD = 0x0000; 68 | 69 | /**************************************************************************** 70 | * Setting the GPIO Direction SFR(s) 71 | ***************************************************************************/ 72 | TRISA = 0x0000; 73 | TRISB = 0xFF00; 74 | TRISC = 0x3FFF; 75 | TRISD = 0x0502; 76 | 77 | /**************************************************************************** 78 | * Setting the Weak Pull Up and Weak Pull Down SFR(s) 79 | ***************************************************************************/ 80 | CNPDA = 0x0000; 81 | CNPDB = 0x0000; 82 | CNPDC = 0x0000; 83 | CNPDD = 0x0000; 84 | CNPUA = 0x0000; 85 | CNPUB = 0xFF00; 86 | CNPUC = 0x2F00; 87 | CNPUD = 0x0000; 88 | 89 | /**************************************************************************** 90 | * Setting the Open Drain SFR(s) 91 | ***************************************************************************/ 92 | ODCA = 0x0000; 93 | ODCB = 0x0000; 94 | ODCC = 0x0000; 95 | ODCD = 0x0000; 96 | 97 | /**************************************************************************** 98 | * Setting the Analog/Digital Configuration SFR(s) 99 | ***************************************************************************/ 100 | ANSELA = 0x0000; 101 | ANSELB = 0x0000; 102 | ANSELC = 0x0000; 103 | ANSELD = 0x0000; 104 | } 105 | 106 | -------------------------------------------------------------------------------- /firmware/bootloader/mcc_generated_files/reset.c: -------------------------------------------------------------------------------- 1 | /** 2 | RESET Generated Driver File 3 | 4 | @Company 5 | Microchip Technology Inc. 6 | 7 | @File Name 8 | reset.c 9 | 10 | @Summary 11 | This is the generated driver implementation file for the RESET driver using PIC24 / dsPIC33 / PIC32MM MCUs 12 | 13 | @Description 14 | This header file provides implementations for driver APIs for RESET. 15 | Generation Information : 16 | Product Revision : PIC24 / dsPIC33 / PIC32MM MCUs - 1.170.0 17 | Device : dsPIC33CK64MC105 18 | The generated drivers are tested against the following: 19 | Compiler : XC16 v1.61 20 | MPLAB : MPLAB X v5.45 21 | */ 22 | 23 | /* 24 | (c) 2020 Microchip Technology Inc. and its subsidiaries. You may use this 25 | software and any derivatives exclusively with Microchip products. 26 | 27 | THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER 28 | EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY IMPLIED 29 | WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS FOR A 30 | PARTICULAR PURPOSE, OR ITS INTERACTION WITH MICROCHIP PRODUCTS, COMBINATION 31 | WITH ANY OTHER PRODUCTS, OR USE IN ANY APPLICATION. 32 | 33 | IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, 34 | INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND 35 | WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS 36 | BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE 37 | FULLEST EXTENT ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN 38 | ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY, 39 | THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE. 40 | 41 | MICROCHIP PROVIDES THIS SOFTWARE CONDITIONALLY UPON YOUR ACCEPTANCE OF THESE 42 | TERMS. 43 | */ 44 | 45 | #include 46 | #include 47 | #include "xc.h" 48 | #include "reset.h" 49 | 50 | /** 51 | Section: Local Variables 52 | */ 53 | 54 | /** 55 | Section: Function prototypes 56 | */ 57 | static bool RESET_CauseFromSoftware(uint16_t resetCause); 58 | static bool RESET_CauseFromWatchdogTimer(uint16_t resetCause); 59 | static bool RESET_CauseFromConfigurationMismatch(uint16_t resetCause); 60 | static bool RESET_CauseFromIllegalOpcode(uint16_t resetCause); 61 | static bool RESET_CauseFromExternal(uint16_t resetCause); 62 | static bool RESET_CauseFromTrap(uint16_t resetCause); 63 | static void RESET_CauseClear(RESET_MASKS resetFlagMask); 64 | 65 | uint16_t RESET_GetCause(void) 66 | { 67 | return RCON; 68 | } 69 | 70 | void __attribute__ ((weak)) RESET_CauseHandler(void) 71 | { 72 | uint16_t resetCause = RESET_GetCause(); 73 | if(RESET_CauseFromTrap(resetCause)) 74 | { 75 | RESET_CauseClear(RESET_MASK_TRAPR); 76 | //Do something 77 | } 78 | if(RESET_CauseFromIllegalOpcode(resetCause)) 79 | { 80 | RESET_CauseClear(RESET_MASK_IOPUWR); 81 | //Do something 82 | } 83 | if(RESET_CauseFromConfigurationMismatch(resetCause)) 84 | { 85 | RESET_CauseClear(RESET_MASK_CM); 86 | //Do something 87 | } 88 | if(RESET_CauseFromExternal(resetCause)) 89 | { 90 | RESET_CauseClear(RESET_MASK_EXTR); 91 | //Do something 92 | } 93 | if(RESET_CauseFromSoftware(resetCause)) 94 | { 95 | RESET_CauseClear(RESET_MASK_SWR); 96 | //Do something 97 | } 98 | if(RESET_CauseFromWatchdogTimer(resetCause)) 99 | { 100 | RESET_CauseClear(RESET_MASK_WDTO); 101 | //Do something 102 | } 103 | } 104 | 105 | static bool RESET_CauseFromTrap(uint16_t resetCause) 106 | { 107 | bool resetStatus = false; 108 | if(resetCause & RESET_MASK_TRAPR) 109 | { 110 | resetStatus = true; 111 | } 112 | return resetStatus; 113 | } 114 | 115 | static bool RESET_CauseFromIllegalOpcode(uint16_t resetCause) 116 | { 117 | bool resetStatus = false; 118 | if(resetCause & RESET_MASK_IOPUWR) 119 | { 120 | resetStatus = true; 121 | } 122 | return resetStatus; 123 | } 124 | 125 | static bool RESET_CauseFromConfigurationMismatch(uint16_t resetCause) 126 | { 127 | bool resetStatus = false; 128 | if(resetCause & RESET_MASK_CM) 129 | { 130 | resetStatus = true; 131 | } 132 | return resetStatus; 133 | } 134 | 135 | static bool RESET_CauseFromExternal(uint16_t resetCause) 136 | { 137 | bool resetStatus = false; 138 | if(resetCause & RESET_MASK_EXTR) 139 | { 140 | resetStatus = true; 141 | } 142 | return resetStatus; 143 | } 144 | 145 | static bool RESET_CauseFromSoftware(uint16_t resetCause) 146 | { 147 | bool resetStatus = false; 148 | if(resetCause & RESET_MASK_SWR) 149 | { 150 | resetStatus = true; 151 | } 152 | return resetStatus; 153 | } 154 | 155 | static bool RESET_CauseFromWatchdogTimer(uint16_t resetCause) 156 | { 157 | bool resetStatus = false; 158 | if(resetCause & RESET_MASK_WDTO) 159 | { 160 | resetStatus = true; 161 | } 162 | return resetStatus; 163 | } 164 | 165 | static void RESET_CauseClear(RESET_MASKS resetFlagMask) 166 | { 167 | RCON = RCON & (~resetFlagMask); 168 | } 169 | 170 | void RESET_CauseClearAll() 171 | { 172 | RCON = 0x00; 173 | } 174 | /** 175 | End of File 176 | */ -------------------------------------------------------------------------------- /firmware/bootloader/mcc_generated_files/reset.h: -------------------------------------------------------------------------------- 1 | /** 2 | RESET Generated Driver File 3 | 4 | @Company 5 | Microchip Technology Inc. 6 | 7 | @File Name 8 | reset.c 9 | 10 | @Summary 11 | This is the generated driver implementation file for the RESET driver using PIC24 / dsPIC33 / PIC32MM MCUs 12 | 13 | @Description 14 | This header file provides implementations for driver APIs for RESET. 15 | Generation Information : 16 | Product Revision : PIC24 / dsPIC33 / PIC32MM MCUs - 1.170.0 17 | Device : dsPIC33CK64MC105 18 | The generated drivers are tested against the following: 19 | Compiler : XC16 v1.61 20 | MPLAB : MPLAB X v5.45 21 | */ 22 | 23 | /* 24 | (c) 2020 Microchip Technology Inc. and its subsidiaries. You may use this 25 | software and any derivatives exclusively with Microchip products. 26 | 27 | THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER 28 | EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY IMPLIED 29 | WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS FOR A 30 | PARTICULAR PURPOSE, OR ITS INTERACTION WITH MICROCHIP PRODUCTS, COMBINATION 31 | WITH ANY OTHER PRODUCTS, OR USE IN ANY APPLICATION. 32 | 33 | IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, 34 | INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND 35 | WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS 36 | BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE 37 | FULLEST EXTENT ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN 38 | ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY, 39 | THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE. 40 | 41 | MICROCHIP PROVIDES THIS SOFTWARE CONDITIONALLY UPON YOUR ACCEPTANCE OF THESE 42 | TERMS. 43 | */ 44 | 45 | #ifndef RESET_H 46 | #define RESET_H 47 | 48 | #include 49 | #include "reset_types.h" 50 | 51 | /** 52 | * Checks reset cause, flashes UI with an error code as a result. 53 | * 54 | * Note: this function should be called before any use of CLRWDT 55 | * since it has a side-effect of clearing the appropriate bits in the 56 | * register showing reset cause (see DS70602B page 8-10) 57 | */ 58 | uint16_t RESET_GetCause(void); 59 | 60 | /** 61 | * It handles the reset cause by clearing the cause register values. 62 | * Its a weak function user can override this function. 63 | * @return None 64 | * @example 65 | * 66 | * RESET_CauseHandler(); 67 | * 68 | */ 69 | void RESET_CauseHandler(void); 70 | 71 | /** 72 | * This function resets the reset cause register. 73 | * @return None 74 | * @example 75 | * 76 | * RESET_CauseClearAll(); 77 | * 78 | */ 79 | void RESET_CauseClearAll(); 80 | 81 | #endif /* RESET_H */ 82 | /** 83 | End of File 84 | */ -------------------------------------------------------------------------------- /firmware/bootloader/mcc_generated_files/reset_types.h: -------------------------------------------------------------------------------- 1 | /** 2 | RESET Generated Driver File 3 | 4 | @Company 5 | Microchip Technology Inc. 6 | 7 | @File Name 8 | reset_types.h 9 | 10 | @Summary 11 | This is the generated driver implementation file for the RESET driver using PIC24 / dsPIC33 / PIC32MM MCUs 12 | 13 | @Description 14 | This header file provides implementations for driver APIs for RESET. 15 | Generation Information : 16 | Product Revision : PIC24 / dsPIC33 / PIC32MM MCUs - 1.170.0 17 | Device : dsPIC33CK64MC105 18 | The generated drivers are tested against the following: 19 | Compiler : XC16 v1.61 20 | MPLAB : MPLAB X v5.45 21 | */ 22 | 23 | /* 24 | (c) 2020 Microchip Technology Inc. and its subsidiaries. You may use this 25 | software and any derivatives exclusively with Microchip products. 26 | 27 | THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER 28 | EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY IMPLIED 29 | WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS FOR A 30 | PARTICULAR PURPOSE, OR ITS INTERACTION WITH MICROCHIP PRODUCTS, COMBINATION 31 | WITH ANY OTHER PRODUCTS, OR USE IN ANY APPLICATION. 32 | 33 | IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, 34 | INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND 35 | WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS 36 | BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE 37 | FULLEST EXTENT ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN 38 | ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY, 39 | THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE. 40 | 41 | MICROCHIP PROVIDES THIS SOFTWARE CONDITIONALLY UPON YOUR ACCEPTANCE OF THESE 42 | TERMS. 43 | */ 44 | 45 | #ifndef RESET_TYPES_H 46 | #define RESET_TYPES_H 47 | 48 | /** 49 | Section: Type defines 50 | */ 51 | 52 | /** 53 | * RCON error type enumerator. Supported types: 54 | * RESET_ERROR_RCON_TRAPR 55 | * RESET_ERROR_RCON_IOPUWR 56 | * RESET_ERROR_RCON_CM 57 | * RESET_ERROR_RCON_WDTO_ISR 58 | */ 59 | typedef enum tagERROR_TYPE 60 | { 61 | RESET_ERROR_RCON_TRAPR = 1, /** A Trap Conflict Reset has occurred **/ 62 | RESET_ERROR_RCON_IOPUWR = 2, /** An illegal opcode detection, an illegal address mode or Uninitialized W register used as an 63 | * Address Pointer caused a Reset **/ 64 | RESET_ERROR_RCON_CM = 3, /** A Configuration Mismatch Reset has occurred **/ 65 | RESET_ERROR_RCON_WDTO_ISR = 4 /** WDT time-out has occurred **/ 66 | }RESET_TYPES; 67 | 68 | /** 69 | * RESET CAUSE Masks. Supported masks: 70 | * RESET_MASK_WDTO 71 | * RESET_MASK_SWR 72 | * RESET_MASK_EXTR 73 | * RESET_MASK_CM 74 | * RESET_MASK_IOPUWR 75 | * RESET_MASK_TRAPR 76 | */ 77 | typedef enum tagRESET_MASKS 78 | { 79 | RESET_MASK_WDTO = 0x0010, 80 | RESET_MASK_SWR = 0x0040, 81 | RESET_MASK_EXTR = 0x0080, 82 | RESET_MASK_CM = 0x0200, 83 | RESET_MASK_IOPUWR = 0x4000, 84 | RESET_MASK_TRAPR = 0x8000, 85 | } RESET_MASKS; 86 | 87 | #endif /* RESET_TYPES_H */ 88 | 89 | 90 | /******************************************************************************* 91 | 92 | !!! Deprecated Definitions and APIs !!! 93 | !!! These will not be supported in future releases !!! 94 | 95 | *******************************************************************************/ 96 | 97 | #define ERR_RCON_TRAPR RESET_ERROR_RCON_TRAPR 98 | #define ERR_RCON_IOPUWR RESET_ERROR_RCON_IOPUWR 99 | #define ERR_RCON_CM RESET_ERROR_RCON_CM 100 | #define ERR_RCON_WDTO_ISR RESET_ERROR_RCON_WDTO_ISR 101 | 102 | /** 103 | End of File 104 | */ -------------------------------------------------------------------------------- /firmware/bootloader/mcc_generated_files/system.h: -------------------------------------------------------------------------------- 1 | /** 2 | @Generated PIC24 / dsPIC33 / PIC32MM MCUs Source File 3 | 4 | @Company: 5 | Microchip Technology Inc. 6 | 7 | @File Name: 8 | system.h 9 | 10 | @Summary: 11 | This is the system.h file generated using PIC24 / dsPIC33 / PIC32MM MCUs 12 | 13 | @Description: 14 | This header file provides implementations for driver APIs for all modules selected in the GUI. 15 | Generation Information : 16 | Product Revision : PIC24 / dsPIC33 / PIC32MM MCUs - 1.170.0 17 | Device : dsPIC33CK64MC105 18 | The generated drivers are tested against the following: 19 | Compiler : XC16 v1.61 20 | MPLAB : MPLAB X v5.45 21 | */ 22 | 23 | /* 24 | (c) 2020 Microchip Technology Inc. and its subsidiaries. You may use this 25 | software and any derivatives exclusively with Microchip products. 26 | 27 | THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER 28 | EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY IMPLIED 29 | WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS FOR A 30 | PARTICULAR PURPOSE, OR ITS INTERACTION WITH MICROCHIP PRODUCTS, COMBINATION 31 | WITH ANY OTHER PRODUCTS, OR USE IN ANY APPLICATION. 32 | 33 | IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, 34 | INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND 35 | WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS 36 | BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE 37 | FULLEST EXTENT ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN 38 | ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY, 39 | THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE. 40 | 41 | MICROCHIP PROVIDES THIS SOFTWARE CONDITIONALLY UPON YOUR ACCEPTANCE OF THESE 42 | TERMS. 43 | */ 44 | 45 | #ifndef _XTAL_FREQ 46 | #define _XTAL_FREQ 200000000UL 47 | #endif 48 | #define WDT_CLR_KEY 0x5743 49 | 50 | #include "xc.h" 51 | #include "stdint.h" 52 | #include "system_types.h" 53 | 54 | #ifndef SYSTEM_H 55 | #define SYSTEM_H 56 | /** 57 | * Initializes the CPU core control register. 58 | * @example 59 | * 60 | * SYSTEM_CORCONInitialize(); 61 | * 62 | */ 63 | inline static void SYSTEM_CORCONInitialize() 64 | { 65 | CORCON = (CORCON & 0x00F2) | CORCON_MODE_PORVALUES; // POR value 66 | } 67 | 68 | /** 69 | * Sets the CPU core control register operating mode to a value that is decided by the 70 | * SYSTEM_CORCON_MODES argument. 71 | * @param modeValue SYSTEM_CORCON_MODES initialization mode specifier 72 | * @example 73 | * 74 | * SYSTEM_CORCONModeOperatingSet(CORCON_MODE_ENABLEALLSATNORMAL_ROUNDUNBIASED); 75 | * 76 | */ 77 | inline static void SYSTEM_CORCONModeOperatingSet(SYSTEM_CORCON_MODES modeValue) 78 | { 79 | CORCON = (CORCON & 0x00F2) | modeValue; 80 | } 81 | 82 | /** 83 | * Sets the value of CPU core control register. 84 | * @param value value that needs to be written to the CPU core control register 85 | * @example 86 | * 87 | * SYSTEM_CORCONRegisterValueSet(0x00E2); 88 | * 89 | */ 90 | inline static void SYSTEM_CORCONRegisterValueSet(uint16_t value) 91 | { 92 | CORCON = value; 93 | } 94 | 95 | /** 96 | * Gets the value of CPU core control register. 97 | * @return value of the CPU core control register 98 | * @example 99 | * 100 | * corconSave = SYSTEM_CORCONRegisterValueGet(); 101 | * 102 | */ 103 | inline static uint16_t SYSTEM_CORCONRegisterValueGet(void) 104 | { 105 | return CORCON; 106 | } 107 | 108 | 109 | /** 110 | * Gets the base address of the DEVID register for the currently selected device 111 | * @return base address of the DEVID register 112 | * @example 113 | * 114 | * uint32_t devIdAddress; 115 | * devIdAddress = SYSTEM_DeviceIdRegisterAddressGet(); 116 | * 117 | */ 118 | inline static uint32_t SYSTEM_DeviceIdRegisterAddressGet(void) 119 | { 120 | return __DEVID_BASE; 121 | } 122 | 123 | /** 124 | * @Param 125 | none 126 | * @Returns 127 | none 128 | * @Description 129 | Initializes the device to the default states configured in the 130 | * MCC GUI 131 | * @Example 132 | SYSTEM_Initialize(void); 133 | */ 134 | void SYSTEM_Initialize(void); 135 | #endif /* SYSTEM_H */ 136 | /** 137 | End of File 138 | */ -------------------------------------------------------------------------------- /firmware/bootloader/mcc_generated_files/traps.c: -------------------------------------------------------------------------------- 1 | /** 2 | System Traps Generated Driver File 3 | 4 | @Company: 5 | Microchip Technology Inc. 6 | 7 | @File Name: 8 | traps.h 9 | 10 | @Summary: 11 | This is the generated driver implementation file for handling traps 12 | using PIC24 / dsPIC33 / PIC32MM MCUs 13 | 14 | @Description: 15 | This source file provides implementations for PIC24 / dsPIC33 / PIC32MM MCUs traps. 16 | Generation Information : 17 | Product Revision : PIC24 / dsPIC33 / PIC32MM MCUs - 1.170.0 18 | Device : dsPIC33CK64MC105 19 | The generated drivers are tested against the following: 20 | Compiler : XC16 v1.61 21 | MPLAB : MPLAB X v5.45 22 | */ 23 | /* 24 | (c) 2020 Microchip Technology Inc. and its subsidiaries. You may use this 25 | software and any derivatives exclusively with Microchip products. 26 | 27 | THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER 28 | EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY IMPLIED 29 | WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS FOR A 30 | PARTICULAR PURPOSE, OR ITS INTERACTION WITH MICROCHIP PRODUCTS, COMBINATION 31 | WITH ANY OTHER PRODUCTS, OR USE IN ANY APPLICATION. 32 | 33 | IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, 34 | INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND 35 | WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS 36 | BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE 37 | FULLEST EXTENT ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN 38 | ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY, 39 | THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE. 40 | 41 | MICROCHIP PROVIDES THIS SOFTWARE CONDITIONALLY UPON YOUR ACCEPTANCE OF THESE 42 | TERMS. 43 | */ 44 | 45 | /** 46 | Section: Includes 47 | */ 48 | #include 49 | #include "traps.h" 50 | 51 | #define ERROR_HANDLER __attribute__((interrupt, no_auto_psv, keep, section("error_handler"))) 52 | #define FAILSAFE_STACK_GUARDSIZE 8 53 | 54 | extern void flash_led(uint8_t num); 55 | 56 | #ifdef __DEBUG 57 | /** 58 | * a private place to store the error code if we run into a severe error 59 | */ 60 | static uint16_t TRAPS_error_code = -1; 61 | #endif 62 | 63 | /** 64 | * Halts 65 | * 66 | * @param code error code 67 | */ 68 | void __attribute__((weak)) TRAPS_halt_on_error(uint16_t code) 69 | { 70 | #ifdef __DEBUG 71 | TRAPS_error_code = code; 72 | #endif 73 | __builtin_software_breakpoint(); 74 | /* If we are in debug mode, cause a software breakpoint in the debugger */ 75 | while(1) 76 | { 77 | flash_led(0); 78 | flash_led(3); 79 | flash_led(code); 80 | } 81 | 82 | } 83 | 84 | // RB - Need the RAM, and this type of error isn't recoverable anyways 85 | #ifdef __DEBUG 86 | /** 87 | * Sets the stack pointer to a backup area of memory, in case we run into 88 | * a stack error (in which case we can't really trust the stack pointer) 89 | */ 90 | inline static void use_failsafe_stack(void) 91 | { 92 | static uint8_t failsafe_stack[32]; 93 | asm volatile ( 94 | " mov %[pstack], W15\n" 95 | : 96 | : [pstack]"r"(failsafe_stack) 97 | ); 98 | /* Controls where the stack pointer limit is, relative to the end of the 99 | * failsafe stack 100 | */ 101 | SPLIM = (uint16_t)(((uint8_t *)failsafe_stack) + sizeof(failsafe_stack) 102 | - FAILSAFE_STACK_GUARDSIZE); 103 | } 104 | #endif 105 | 106 | 107 | /** Oscillator Fail Trap vector**/ 108 | void ERROR_HANDLER _OscillatorFail(void) 109 | { 110 | INTCON1bits.OSCFAIL = 0; //Clear the trap flag 111 | TRAPS_halt_on_error(TRAPS_OSC_FAIL); 112 | } 113 | /** Stack Error Trap Vector**/ 114 | void ERROR_HANDLER _StackError(void) 115 | { 116 | /* We use a failsafe stack: the presence of a stack-pointer error 117 | * means that we cannot trust the stack to operate correctly unless 118 | * we set the stack pointer to a safe place. 119 | */ 120 | #ifdef __DEBUG 121 | use_failsafe_stack(); 122 | #endif 123 | INTCON1bits.STKERR = 0; //Clear the trap flag 124 | TRAPS_halt_on_error(TRAPS_STACK_ERR); 125 | } 126 | /** Address error Trap vector**/ 127 | void ERROR_HANDLER _AddressError(void) 128 | { 129 | INTCON1bits.ADDRERR = 0; //Clear the trap flag 130 | TRAPS_halt_on_error(TRAPS_ADDRESS_ERR); 131 | } 132 | /** Math Error Trap vector**/ 133 | void ERROR_HANDLER _MathError(void) 134 | { 135 | INTCON1bits.MATHERR = 0; //Clear the trap flag 136 | TRAPS_halt_on_error(TRAPS_MATH_ERR); 137 | } 138 | /** Generic Hard Trap vector**/ 139 | void ERROR_HANDLER _HardTrapError(void) 140 | { 141 | INTCON4bits.SGHT = 0; //Clear the trap flag 142 | TRAPS_halt_on_error(TRAPS_HARD_ERR); 143 | } 144 | /** Generic Soft Trap vector**/ 145 | void ERROR_HANDLER _SoftTrapError(void) 146 | { 147 | if(INTCON3bits.NAE) 148 | { 149 | INTCON3bits.NAE = 0; //Clear the trap flag 150 | TRAPS_halt_on_error(TRAPS_NVM_ERR); 151 | } 152 | 153 | #if 0 154 | if(INTCON3bits.DMT) 155 | { 156 | INTCON3bits.DMT = 0; //Clear the trap flag 157 | TRAPS_halt_on_error(TRAPS_DMT_ERR); 158 | } 159 | #endif 160 | 161 | if(INTCON3bits.DOOVR) 162 | { 163 | INTCON3bits.DOOVR = 0; //Clear the trap flag 164 | TRAPS_halt_on_error(TRAPS_DOOVR_ERR); 165 | } 166 | 167 | while(1); 168 | { 169 | flash_led(0); 170 | flash_led(3); 171 | flash_led(4); // unused 172 | } 173 | } 174 | 175 | 176 | -------------------------------------------------------------------------------- /firmware/bootloader/mcc_generated_files/traps.h: -------------------------------------------------------------------------------- 1 | /** 2 | System Traps Generated Driver File 3 | 4 | @Company: 5 | Microchip Technology Inc. 6 | 7 | @File Name: 8 | traps.h 9 | 10 | @Summary: 11 | This is the generated driver implementation file for handling traps 12 | using PIC24 / dsPIC33 / PIC32MM MCUs 13 | 14 | @Description: 15 | This source file provides implementations for PIC24 / dsPIC33 / PIC32MM MCUs traps. 16 | Generation Information : 17 | Product Revision : PIC24 / dsPIC33 / PIC32MM MCUs - 1.170.0 18 | Device : dsPIC33CK64MC105 19 | The generated drivers are tested against the following: 20 | Compiler : XC16 v1.61 21 | MPLAB : MPLAB X v5.45 22 | */ 23 | /* 24 | (c) 2020 Microchip Technology Inc. and its subsidiaries. You may use this 25 | software and any derivatives exclusively with Microchip products. 26 | 27 | THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER 28 | EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY IMPLIED 29 | WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS FOR A 30 | PARTICULAR PURPOSE, OR ITS INTERACTION WITH MICROCHIP PRODUCTS, COMBINATION 31 | WITH ANY OTHER PRODUCTS, OR USE IN ANY APPLICATION. 32 | 33 | IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, 34 | INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND 35 | WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS 36 | BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE 37 | FULLEST EXTENT ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN 38 | ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY, 39 | THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE. 40 | 41 | MICROCHIP PROVIDES THIS SOFTWARE CONDITIONALLY UPON YOUR ACCEPTANCE OF THESE 42 | TERMS. 43 | */ 44 | 45 | #ifndef _TRAPS_H 46 | #define _TRAPS_H 47 | 48 | #include 49 | 50 | /** 51 | * Error codes 52 | */ 53 | typedef enum 54 | { 55 | /* ----- Traps ----- */ 56 | TRAPS_OSC_FAIL = 0, /** Oscillator Fail Trap vector */ 57 | TRAPS_STACK_ERR = 1, /** Stack Error Trap Vector */ 58 | TRAPS_ADDRESS_ERR = 2, /** Address error Trap vector */ 59 | TRAPS_MATH_ERR = 3, /** Math Error Trap vector */ 60 | TRAPS_HARD_ERR = 7, /** Generic Hard Trap vector */ 61 | TRAPS_NVM_ERR = 12, /** Generic Soft Trap vector */ 62 | TRAPS_DMT_ERR = 8, /** Generic Soft Trap vector */ 63 | TRAPS_DOOVR_ERR = 10, /** Generic Soft Trap vector */ 64 | } TRAPS_ERROR_CODE; 65 | /** 66 | @Summary 67 | Default handler for the traps 68 | 69 | @Description 70 | This routine will be called whenever a trap happens. It stores the trap 71 | error code and waits forever. 72 | This routine has a weak attribute and can be over written. 73 | 74 | @Preconditions 75 | None. 76 | 77 | @Returns 78 | None. 79 | 80 | @Param 81 | None. 82 | 83 | @Example 84 | None. 85 | 86 | */ 87 | void TRAPS_halt_on_error(uint16_t code); 88 | 89 | #endif -------------------------------------------------------------------------------- /firmware/bootloader/mcc_generated_files/watchdog.h: -------------------------------------------------------------------------------- 1 | /** 2 | WATCHDOG Generated Driver File 3 | 4 | @Company 5 | Microchip Technology Inc. 6 | 7 | @File Name 8 | watchdog.h 9 | 10 | @Summary 11 | This is the generated driver implementation file for the WATCHDOG driver using PIC24 / dsPIC33 / PIC32MM MCUs 12 | 13 | @Description 14 | This header file provides implementations for driver APIs for WATCHDOG. 15 | Generation Information : 16 | Product Revision : PIC24 / dsPIC33 / PIC32MM MCUs - 1.170.0 17 | Device : dsPIC33CK64MC105 18 | The generated drivers are tested against the following: 19 | Compiler : XC16 v1.61 20 | MPLAB : MPLAB X v5.45 21 | */ 22 | 23 | /* 24 | (c) 2020 Microchip Technology Inc. and its subsidiaries. You may use this 25 | software and any derivatives exclusively with Microchip products. 26 | 27 | THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER 28 | EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY IMPLIED 29 | WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS FOR A 30 | PARTICULAR PURPOSE, OR ITS INTERACTION WITH MICROCHIP PRODUCTS, COMBINATION 31 | WITH ANY OTHER PRODUCTS, OR USE IN ANY APPLICATION. 32 | 33 | IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, 34 | INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND 35 | WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS 36 | BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE 37 | FULLEST EXTENT ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN 38 | ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY, 39 | THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE. 40 | 41 | MICROCHIP PROVIDES THIS SOFTWARE CONDITIONALLY UPON YOUR ACCEPTANCE OF THESE 42 | TERMS. 43 | */ 44 | 45 | #ifndef WATCHDOG_H 46 | #define WATCHDOG_H 47 | 48 | /** 49 | Section: Type defines 50 | */ 51 | #define WATCHDOG_CLR_KEY 0x5743 52 | 53 | /** 54 | * Enables Watch Dog Timer (WDT) using the software bit. 55 | * @example 56 | * 57 | * WATCHDOG_TimerSoftwareEnable(); 58 | * 59 | */ 60 | inline static void WATCHDOG_TimerSoftwareEnable(void) 61 | { 62 | WDTCONLbits.ON = 1; 63 | } 64 | 65 | /** 66 | * Disables Watch Dog Timer (WDT) using the software bit. 67 | * @example 68 | * 69 | * WATCHDOG_TimerSoftwareDisable(); 70 | * 71 | */ 72 | inline static void WATCHDOG_TimerSoftwareDisable(void) 73 | { 74 | WDTCONLbits.ON = 0; 75 | } 76 | 77 | /** 78 | * Clears the Watch Dog Timer (WDT). 79 | * @example 80 | * 81 | * WATCHDOG_TimerClear(); 82 | * 83 | */ 84 | inline static void WATCHDOG_TimerClear(void) 85 | { 86 | WDTCONH = WATCHDOG_CLR_KEY; 87 | } 88 | 89 | #endif /* WATCHDOG_H */ 90 | /** 91 | End of File 92 | */ -------------------------------------------------------------------------------- /firmware/bootloader/nbproject/.gitignore: -------------------------------------------------------------------------------- 1 | Makefile* 2 | Package* 3 | private 4 | -------------------------------------------------------------------------------- /firmware/bootloader/nbproject/project.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | com.microchip.mplab.nbide.embedded.makeproject 4 | 5 | 6 | bootloader 7 | cbcf7f1b-6254-4fbd-8c7a-d6075432c2f1 8 | 0 9 | c 10 | 11 | h 12 | 13 | ISO-8859-1 14 | 15 | 16 | . 17 | 18 | 19 | 20 | default 21 | 2 22 | 23 | 24 | 25 | false 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /firmware/core.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | 4 | Runs an interrupt on address change that feed the buffer to the screen, and updates frameNumber 5 | Main thread needs only maintain the buffer. 6 | 7 | */ 8 | 9 | #ifndef __CORE__ 10 | #define __CORE__ 11 | 12 | #include 13 | #include 14 | 15 | #include "defines.h" 16 | #include "frame.h" 17 | 18 | struct coreInfo 19 | { 20 | // mr_* used by both main + interrupt 21 | 22 | volatile bool mr_endFrame; 23 | volatile bool mr_bufferIndex; 24 | volatile uint_fast8_t mr_swcha; 25 | volatile uint_fast8_t mr_swchb; 26 | volatile uint_fast8_t mr_inpt4; 27 | volatile uint_fast8_t mr_inpt5; // not used 28 | struct frameInfo mr_frameInfo1 , mr_frameInfo2; 29 | 30 | // following only used by interrupt code 31 | 32 | uint_fast8_t peekBus; 33 | volatile uint_fast8_t* storeAddress; 34 | uint_fast8_t breakLoops; 35 | uint_fast8_t lines; 36 | 37 | uint_fast8_t hiAddress; 38 | uint_fast8_t vblankState; 39 | uint_fast8_t vsyncState; 40 | uint_fast8_t endState; 41 | uint_fast8_t nextLineJump; 42 | uint_fast8_t data; 43 | 44 | bool audioPushed; 45 | uint_fast8_t audioVal; 46 | 47 | struct frameInfo frameInfo; 48 | }; 49 | 50 | extern void coreInit(); 51 | 52 | #endif 53 | -------------------------------------------------------------------------------- /firmware/defines.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | 4 | Format description 5 | 6 | */ 7 | 8 | #ifndef __DEFINES__ 9 | #define __DEFINES__ 10 | 11 | #include 12 | #include 13 | 14 | #define FIELD_NUM_BLOCKS 8 15 | #define FIELD_MAX_BLOCKS 6 // pal is 6, but ntsc is only 5, anything larger will require device with more RAM 16 | 17 | // 3K 18 | #define FIELD_SIZE (512*FIELD_MAX_BLOCKS) 19 | 20 | #define TESTA0_LOW IO_RA0_SetLow(); 21 | #define TESTA0_HIGH IO_RA0_SetHigh(); 22 | #define TESTA1_LOW IO_RA1_SetLow(); 23 | #define TESTA1_HIGH IO_RA1_SetHigh(); 24 | #define TESTA2_LOW IO_RA2_SetLow(); 25 | #define TESTA2_HIGH IO_RA2_SetHigh(); 26 | #endif 27 | -------------------------------------------------------------------------------- /firmware/devices/p33CK32MC105/firmware.production.elf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lodefmode/moviecart/4ae049122e5a2cf368cd9413f8fba21dab926907/firmware/devices/p33CK32MC105/firmware.production.elf -------------------------------------------------------------------------------- /firmware/devices/p33CK64MC105/firmware.production.elf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lodefmode/moviecart/4ae049122e5a2cf368cd9413f8fba21dab926907/firmware/devices/p33CK64MC105/firmware.production.elf -------------------------------------------------------------------------------- /firmware/frame.c: -------------------------------------------------------------------------------- 1 | #include "frame.h" 2 | 3 | struct FrameFormat 4 | { 5 | uint8_t version[4]; // ('M', 'V', 'C', 0) 6 | uint8_t format; // ( 1-------) 7 | uint8_t timecode[4]; // (hour, minute, second, fame) 8 | uint8_t vsync; // eg 3 9 | uint8_t vblank; // eg 37 10 | uint8_t overscan; // eg 30 11 | uint8_t visible; // eg 192 12 | uint8_t rate; // eg 60 13 | 14 | // dataStart; 15 | 16 | // sound[vsync+blank+overscan+visible] 17 | // graph[5 * visible] 18 | // color[5 * visible] 19 | // bkcolor[1 * visible] 20 | // timecode[60] 21 | // padding 22 | }; 23 | 24 | void 25 | frameInit(struct frameInfo* fInfo) 26 | { 27 | uint8_t* dst = fInfo->buffer; 28 | struct FrameFormat* ff = (struct FrameFormat* )dst; 29 | uint16_t headerSize; 30 | 31 | 32 | if (ff->format & 0x80) 33 | { 34 | headerSize = sizeof(*ff); 35 | 36 | fInfo->vsyncLines = ff->vsync; 37 | fInfo->blankLines = ff->vblank; 38 | fInfo->overscanLines = ff->overscan; 39 | fInfo->visibleLines = ff->visible; 40 | fInfo->odd = !(ff->timecode[3] & 1); 41 | fInfo->totalLines = fInfo->vsyncLines + fInfo->blankLines + fInfo->overscanLines + fInfo->visibleLines; 42 | 43 | fInfo->audioBuf = dst + headerSize; 44 | fInfo->graphBuf = fInfo->audioBuf + fInfo->totalLines; 45 | fInfo->colorBuf = ((uint8_t*)fInfo->graphBuf) + 5 * fInfo->visibleLines; 46 | fInfo->colorBKBuf = fInfo->colorBuf + 5 * fInfo->visibleLines; 47 | fInfo->timecodeBuf = fInfo->colorBKBuf + 1 * fInfo->visibleLines; 48 | } 49 | else 50 | { 51 | // old format 52 | // 'M', 'V', 'C', 0, f2, f1, f0 53 | headerSize = (4 + 3); 54 | 55 | fInfo->vsyncLines = 3; 56 | fInfo->blankLines = 37; 57 | fInfo->overscanLines = 30; 58 | fInfo->visibleLines = 192; 59 | fInfo->odd = (dst[4 + 3 -1] & 1); 60 | fInfo->totalLines = fInfo->vsyncLines + fInfo->blankLines + fInfo->overscanLines + fInfo->visibleLines; 61 | 62 | fInfo->audioBuf = dst + headerSize; 63 | fInfo->graphBuf = fInfo->audioBuf + fInfo->totalLines; 64 | fInfo->timecodeBuf = ((uint8_t*)fInfo->graphBuf) + 5*fInfo->visibleLines; 65 | fInfo->colorBuf = ((uint8_t*)fInfo->timecodeBuf) + 60; 66 | fInfo->colorBKBuf = fInfo->colorBuf + 5*fInfo->visibleLines; 67 | } 68 | 69 | if (fInfo->odd) 70 | fInfo->colorBKBuf++; 71 | 72 | 73 | // Calculate total blocks needed 74 | 75 | // sound[vsync+blank+overscan+visible] 76 | // graph[5 * visible] 77 | // color[5 * visible] 78 | // bkcolor[1 * visible] 79 | // timecode[60] 80 | // padding 81 | 82 | uint16_t totalSize = fInfo->totalLines + fInfo->visibleLines*(5 + 5 + 1) + (5*12) + headerSize; 83 | 84 | fInfo->numBlocks = (totalSize >> 9); // 512 block chunks 85 | if (totalSize & (512-1)) 86 | fInfo->numBlocks++; 87 | } 88 | 89 | // maximum space between sections since title height adjustable 90 | 91 | void 92 | frameInitTitle(struct frameInfo* fInfo, bool odd) 93 | { 94 | uint8_t* dst = fInfo->buffer; 95 | 96 | int maxVisible = 250; // any larger runs off FIELD_SIZE 97 | 98 | fInfo->vsyncLines = 3; 99 | fInfo->blankLines = 37; 100 | fInfo->overscanLines = 30; 101 | fInfo->odd = odd; 102 | 103 | fInfo->timecodeBuf = dst; // not used 104 | 105 | fInfo->graphBuf = dst; dst += 5*maxVisible; 106 | fInfo->colorBuf = dst; dst += 5*maxVisible; 107 | fInfo->colorBKBuf = dst; dst += 1*maxVisible; 108 | fInfo->audioBuf = dst; //dst += totalLines; 109 | 110 | if (fInfo->odd) 111 | fInfo->colorBKBuf++; 112 | 113 | // default title height 114 | fInfo->visibleLines = 192; 115 | fInfo->totalLines = fInfo->vsyncLines + fInfo->blankLines + fInfo->overscanLines + fInfo->visibleLines; 116 | 117 | fInfo->numBlocks = 0; // not used 118 | } 119 | 120 | -------------------------------------------------------------------------------- /firmware/frame.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | 4 | Frame description 5 | 6 | */ 7 | 8 | #ifndef __FRAME__ 9 | #define __FRAME__ 10 | 11 | #include 12 | #include 13 | 14 | struct frameInfo 15 | { 16 | uint8_t* colorBKBuf; 17 | uint8_t* colorBuf; 18 | uint8_t* graphBuf; 19 | uint8_t* audioBuf; 20 | 21 | uint_fast8_t vsyncLines; 22 | uint_fast8_t blankLines; 23 | uint_fast8_t overscanLines; 24 | uint_fast8_t visibleLines; 25 | 26 | uint8_t* timecodeBuf; // not used by kernel 27 | uint_fast16_t totalLines; // not used by kernel 28 | uint_fast8_t numBlocks; // not used by kernel 29 | 30 | bool odd; 31 | 32 | uint8_t* buffer; 33 | }; 34 | 35 | extern void frameInit(struct frameInfo* fInfo); 36 | extern void frameInitTitle(struct frameInfo* fInfo, bool odd); 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /firmware/mcc_generated_files/clc1.c: -------------------------------------------------------------------------------- 1 | /** 2 | CLC1 Generated Driver File 3 | 4 | @Company 5 | Microchip Technology Inc. 6 | 7 | @File Name 8 | clc1.c 9 | 10 | @Summary 11 | This is the generated driver implementation file for the CLC1 driver using PIC24 / dsPIC33 / PIC32MM MCUs 12 | 13 | @Description 14 | This source file provides implementations for driver APIs for CLC1. 15 | Generation Information : 16 | Product Revision : PIC24 / dsPIC33 / PIC32MM MCUs - 1.170.0 17 | Device : dsPIC33CK64MC105 18 | The generated drivers are tested against the following: 19 | Compiler : XC16 v1.61 20 | MPLAB : MPLAB X v5.45 21 | */ 22 | 23 | /* 24 | (c) 2020 Microchip Technology Inc. and its subsidiaries. You may use this 25 | software and any derivatives exclusively with Microchip products. 26 | 27 | THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER 28 | EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY IMPLIED 29 | WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS FOR A 30 | PARTICULAR PURPOSE, OR ITS INTERACTION WITH MICROCHIP PRODUCTS, COMBINATION 31 | WITH ANY OTHER PRODUCTS, OR USE IN ANY APPLICATION. 32 | 33 | IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, 34 | INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND 35 | WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS 36 | BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE 37 | FULLEST EXTENT ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN 38 | ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY, 39 | THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE. 40 | 41 | MICROCHIP PROVIDES THIS SOFTWARE CONDITIONALLY UPON YOUR ACCEPTANCE OF THESE 42 | TERMS. 43 | */ 44 | 45 | /** 46 | Section: Included Files 47 | */ 48 | 49 | #include "clc1.h" 50 | 51 | /** 52 | Section: CLC1 APIs 53 | */ 54 | 55 | void CLC1_Initialize(void) 56 | { 57 | // Set the CLC1 to the options selected in the User Interface 58 | 59 | CLC1CONL = 0x80A2 & ~(0x8000); 60 | 61 | CLC1CONH = 0x0C; 62 | 63 | CLC1SELL = 0x5000; 64 | 65 | CLC1GLSL = 0x802; 66 | 67 | CLC1GLSH = 0x00; 68 | 69 | 70 | CLC1_Enable(); 71 | } 72 | 73 | void __attribute__ ((weak)) CLC1_PositiveEdge_CallBack(void) 74 | { 75 | // Add your custom callback code here 76 | } 77 | 78 | void __attribute__ ((weak)) CLC1_NegativeEdge_CallBack(void) 79 | { 80 | // Add your custom callback code here 81 | } 82 | 83 | void CLC1_PositiveEdge_Tasks ( void ) 84 | { 85 | if(IFS7bits.CLC1PIF) 86 | { 87 | // CLC1 PositiveEdge callback function 88 | CLC1_PositiveEdge_CallBack(); 89 | 90 | // clear the CLC1 interrupt flag 91 | IFS7bits.CLC1PIF = 0; 92 | } 93 | } 94 | 95 | void CLC1_NegativeEdge_Tasks ( void ) 96 | { 97 | if(IFS11bits.CLC1NIF) 98 | { 99 | // CLC1 NegativeEdge callback function 100 | CLC1_NegativeEdge_CallBack(); 101 | 102 | // clear the CLC1 interrupt flag 103 | IFS11bits.CLC1NIF = 0; 104 | } 105 | } 106 | bool CLC1_OutputStatusGet(void) 107 | { 108 | return(CLC1CONLbits.LCOUT); 109 | 110 | } 111 | /** 112 | End of File 113 | */ 114 | -------------------------------------------------------------------------------- /firmware/mcc_generated_files/clock.c: -------------------------------------------------------------------------------- 1 | /** 2 | @Generated PIC24 / dsPIC33 / PIC32MM MCUs Source File 3 | 4 | @Company: 5 | Microchip Technology Inc. 6 | 7 | @File Name: 8 | clock.c 9 | 10 | @Summary: 11 | This is the clock.c file generated using PIC24 / dsPIC33 / PIC32MM MCUs 12 | 13 | @Description: 14 | This header file provides implementations for driver APIs for all modules selected in the GUI. 15 | Generation Information : 16 | Product Revision : PIC24 / dsPIC33 / PIC32MM MCUs - 1.170.0 17 | Device : dsPIC33CK64MC105 18 | The generated drivers are tested against the following: 19 | Compiler : XC16 v1.61 20 | MPLAB : MPLAB X v5.45 21 | */ 22 | 23 | /* 24 | (c) 2020 Microchip Technology Inc. and its subsidiaries. You may use this 25 | software and any derivatives exclusively with Microchip products. 26 | 27 | THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER 28 | EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY IMPLIED 29 | WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS FOR A 30 | PARTICULAR PURPOSE, OR ITS INTERACTION WITH MICROCHIP PRODUCTS, COMBINATION 31 | WITH ANY OTHER PRODUCTS, OR USE IN ANY APPLICATION. 32 | 33 | IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, 34 | INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND 35 | WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS 36 | BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE 37 | FULLEST EXTENT ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN 38 | ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY, 39 | THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE. 40 | 41 | MICROCHIP PROVIDES THIS SOFTWARE CONDITIONALLY UPON YOUR ACCEPTANCE OF THESE 42 | TERMS. 43 | */ 44 | 45 | #include 46 | #include "xc.h" 47 | #include "clock.h" 48 | 49 | void CLOCK_Initialize(void) 50 | { 51 | // FRCDIV FRC/1; PLLPRE 1; DOZE 1:8; DOZEN disabled; ROI disabled; 52 | CLKDIV = 0x3001; 53 | // PLLFBDIV 100; 54 | PLLFBD = 0x64; 55 | // TUN Center frequency; 56 | OSCTUN = 0x00; 57 | // POST1DIV 1:2; VCODIV FVCO/4; POST2DIV 1:1; 58 | PLLDIV = 0x21; 59 | // ROEN disabled; ROSWEN disabled; ROSLP disabled; ROSEL FOSC; ROOUT disabled; ROSIDL disabled; 60 | REFOCONL = 0x00; 61 | // RODIV 0; 62 | REFOCONH = 0x00; 63 | // ROTRIM 0; 64 | REFOTRIMH = 0x00; 65 | // IOLOCK disabled; 66 | RPCON = 0x00; 67 | // PMDLOCK disabled; 68 | PMDCON = 0x00; 69 | // ADC1MD enabled; T1MD enabled; U2MD enabled; U1MD enabled; SPI2MD enabled; SPI1MD enabled; QEIMD enabled; PWMMD enabled; I2C1MD enabled; 70 | PMD1 = 0x00; 71 | // CCP2MD enabled; CCP1MD enabled; CCP4MD enabled; CCP3MD enabled; 72 | PMD2 = 0x00; 73 | // U3MD enabled; CRCMD enabled; 74 | PMD3 = 0x00; 75 | // REFOMD enabled; 76 | PMD4 = 0x00; 77 | // DMA1MD enabled; DMA2MD enabled; DMA3MD enabled; DMA0MD enabled; 78 | PMD6 = 0x00; 79 | // PTGMD enabled; CMP1MD enabled; 80 | PMD7 = 0x00; 81 | // DMTMD enabled; CLC3MD enabled; OPAMPMD enabled; BIASMD enabled; CLC4MD enabled; SENT1MD enabled; CLC1MD enabled; CLC2MD enabled; 82 | PMD8 = 0x00; 83 | // CF no clock failure; NOSC FRCPLL; CLKLOCK unlocked; OSWEN Switch is Complete; 84 | __builtin_write_OSCCONH((uint8_t) (0x01)); 85 | __builtin_write_OSCCONL((uint8_t) (0x01)); 86 | // Wait for Clock switch to occur 87 | while (OSCCONbits.OSWEN != 0); 88 | while (OSCCONbits.LOCK != 1); 89 | } 90 | 91 | -------------------------------------------------------------------------------- /firmware/mcc_generated_files/clock.h: -------------------------------------------------------------------------------- 1 | /** 2 | @Generated PIC24 / dsPIC33 / PIC32MM MCUs Source File 3 | 4 | @Company: 5 | Microchip Technology Inc. 6 | 7 | @File Name: 8 | clock.h 9 | 10 | @Summary: 11 | This is the clock.h file generated using PIC24 / dsPIC33 / PIC32MM MCUs 12 | 13 | @Description: 14 | This header file provides implementations for driver APIs for all modules selected in the GUI. 15 | Generation Information : 16 | Product Revision : PIC24 / dsPIC33 / PIC32MM MCUs - 1.170.0 17 | Device : dsPIC33CK64MC105 18 | The generated drivers are tested against the following: 19 | Compiler : XC16 v1.61 20 | MPLAB : MPLAB X v5.45 21 | */ 22 | 23 | /* 24 | (c) 2020 Microchip Technology Inc. and its subsidiaries. You may use this 25 | software and any derivatives exclusively with Microchip products. 26 | 27 | THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER 28 | EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY IMPLIED 29 | WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS FOR A 30 | PARTICULAR PURPOSE, OR ITS INTERACTION WITH MICROCHIP PRODUCTS, COMBINATION 31 | WITH ANY OTHER PRODUCTS, OR USE IN ANY APPLICATION. 32 | 33 | IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, 34 | INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND 35 | WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS 36 | BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE 37 | FULLEST EXTENT ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN 38 | ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY, 39 | THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE. 40 | 41 | MICROCHIP PROVIDES THIS SOFTWARE CONDITIONALLY UPON YOUR ACCEPTANCE OF THESE 42 | TERMS. 43 | */ 44 | 45 | #ifndef CLOCK_H 46 | #define CLOCK_H 47 | 48 | /** 49 | Section: Included Files 50 | */ 51 | 52 | #include 53 | 54 | #ifndef _XTAL_FREQ 55 | #define _XTAL_FREQ 200000000UL 56 | #endif 57 | 58 | #define CLOCK_SystemFrequencyGet() (200000000UL) 59 | 60 | #define CLOCK_PeripheralFrequencyGet() (CLOCK_SystemFrequencyGet() / 2) 61 | 62 | #define CLOCK_InstructionFrequencyGet() (CLOCK_SystemFrequencyGet() / 2) 63 | /** 64 | * @Param 65 | none 66 | * @Returns 67 | none 68 | * @Description 69 | Initializes the oscillator to the default states configured in the 70 | * MCC GUI 71 | * @Example 72 | CLOCK_Initialize(void); 73 | */ 74 | void CLOCK_Initialize(void); 75 | 76 | 77 | #endif /* CLOCK_H */ 78 | /** 79 | End of File 80 | */ -------------------------------------------------------------------------------- /firmware/mcc_generated_files/interrupt_manager.c: -------------------------------------------------------------------------------- 1 | /** 2 | System Interrupts Generated Driver File 3 | 4 | @Company: 5 | Microchip Technology Inc. 6 | 7 | @File Name: 8 | interrupt_manager.h 9 | 10 | @Summary: 11 | This is the generated driver implementation file for setting up the 12 | interrupts using PIC24 / dsPIC33 / PIC32MM MCUs 13 | 14 | @Description: 15 | This source file provides implementations for PIC24 / dsPIC33 / PIC32MM MCUs interrupts. 16 | Generation Information : 17 | Product Revision : PIC24 / dsPIC33 / PIC32MM MCUs - 1.170.0 18 | Device : dsPIC33CK64MC105 19 | The generated drivers are tested against the following: 20 | Compiler : XC16 v1.61 21 | MPLAB : MPLAB X v5.45 22 | */ 23 | /* 24 | (c) 2020 Microchip Technology Inc. and its subsidiaries. You may use this 25 | software and any derivatives exclusively with Microchip products. 26 | 27 | THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER 28 | EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY IMPLIED 29 | WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS FOR A 30 | PARTICULAR PURPOSE, OR ITS INTERACTION WITH MICROCHIP PRODUCTS, COMBINATION 31 | WITH ANY OTHER PRODUCTS, OR USE IN ANY APPLICATION. 32 | 33 | IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, 34 | INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND 35 | WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS 36 | BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE 37 | FULLEST EXTENT ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN 38 | ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY, 39 | THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE. 40 | 41 | MICROCHIP PROVIDES THIS SOFTWARE CONDITIONALLY UPON YOUR ACCEPTANCE OF THESE 42 | TERMS. 43 | */ 44 | 45 | /** 46 | Section: Includes 47 | */ 48 | #include 49 | 50 | /** 51 | void INTERRUPT_Initialize (void) 52 | */ 53 | void INTERRUPT_Initialize (void) 54 | { 55 | // CNCI: Change Notification C 56 | // Priority: 7 57 | IPC4bits.CNCIP = 7; 58 | } 59 | -------------------------------------------------------------------------------- /firmware/mcc_generated_files/interrupt_manager.h: -------------------------------------------------------------------------------- 1 | /** 2 | System Interrupts Generated Driver File 3 | 4 | @Company: 5 | Microchip Technology Inc. 6 | 7 | @File Name: 8 | interrupt_manager.h 9 | 10 | @Summary: 11 | This is the generated driver implementation file for setting up the 12 | interrupts using PIC24 / dsPIC33 / PIC32MM MCUs 13 | 14 | @Description: 15 | This source file provides implementations for PIC24 / dsPIC33 / PIC32MM MCUs interrupts. 16 | Generation Information : 17 | Product Revision : PIC24 / dsPIC33 / PIC32MM MCUs - 1.170.0 18 | Device : dsPIC33CK64MC105 19 | The generated drivers are tested against the following: 20 | Compiler : XC16 v1.61 21 | MPLAB : MPLAB X v5.45 22 | */ 23 | /* 24 | (c) 2020 Microchip Technology Inc. and its subsidiaries. You may use this 25 | software and any derivatives exclusively with Microchip products. 26 | 27 | THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER 28 | EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY IMPLIED 29 | WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS FOR A 30 | PARTICULAR PURPOSE, OR ITS INTERACTION WITH MICROCHIP PRODUCTS, COMBINATION 31 | WITH ANY OTHER PRODUCTS, OR USE IN ANY APPLICATION. 32 | 33 | IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, 34 | INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND 35 | WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS 36 | BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE 37 | FULLEST EXTENT ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN 38 | ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY, 39 | THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE. 40 | 41 | MICROCHIP PROVIDES THIS SOFTWARE CONDITIONALLY UPON YOUR ACCEPTANCE OF THESE 42 | TERMS. 43 | */ 44 | 45 | #ifndef _INTERRUPT_MANAGER_H 46 | #define _INTERRUPT_MANAGER_H 47 | 48 | /** 49 | @Summary 50 | Initializes the interrupt priorities of the dsPIC33CK64MC105 51 | 52 | @Description 53 | This routine sets the interrupt priorities of the modules that have been configured 54 | for the dsPIC33CK64MC105 55 | 56 | @Preconditions 57 | None. 58 | 59 | @Returns 60 | None. 61 | 62 | @Param 63 | None. 64 | 65 | @Example 66 | 67 | void SYSTEM_Initialize(void) 68 | { 69 | // Other initializers are called from this function 70 | INTERRUPT_Initialize (); 71 | } 72 | 73 | 74 | */ 75 | void INTERRUPT_Initialize(void); 76 | 77 | /** 78 | @Summary 79 | Enables global interrupts of the dsPIC33CK64MC105 80 | 81 | @Description 82 | This routine enables the global interrupt bit for the dsPIC33CK64MC105 83 | 84 | @Preconditions 85 | None. 86 | 87 | @Returns 88 | None. 89 | 90 | @Param 91 | None. 92 | 93 | @Example 94 | 95 | void SYSTEM_Initialize(void) 96 | { 97 | // Other initializers are called from this function 98 | INTERRUPT_GlobalEnable (); 99 | } 100 | 101 | 102 | */ 103 | inline static void INTERRUPT_GlobalEnable(void) 104 | { 105 | __builtin_enable_interrupts(); 106 | } 107 | 108 | /** 109 | @Summary 110 | Disables global interrupts of the dsPIC33CK64MC105 111 | 112 | @Description 113 | This routine disables the global interrupt bit for the dsPIC33CK64MC105 114 | 115 | @Preconditions 116 | None. 117 | 118 | @Returns 119 | None. 120 | 121 | @Param 122 | None. 123 | 124 | @Example 125 | 126 | void SYSTEM_Initialize(void) 127 | { 128 | // Other initializers are called from this function 129 | INTERRUPT_GlobalDisable (); 130 | } 131 | 132 | 133 | */ 134 | inline static void INTERRUPT_GlobalDisable(void) 135 | { 136 | __builtin_disable_interrupts(); 137 | } 138 | 139 | /** 140 | @Summary 141 | Returns the interrupt vector number of the interrupt which is pending. 142 | 143 | @Description 144 | This routine returns the interrupt vector number of the interrupt which is pending. 145 | 146 | @Preconditions 147 | None. 148 | 149 | @Returns 150 | None. 151 | 152 | @Param 153 | None. 154 | 155 | @Example 156 | 157 | uint16_t ivrNum; 158 | ivrNum = INTERRUPT_VectorNumberGet(); 159 | 160 | 161 | */ 162 | inline static uint16_t INTERRUPT_VectorNumberGet(void) 163 | { 164 | return _VECNUM; 165 | } 166 | 167 | #endif -------------------------------------------------------------------------------- /firmware/mcc_generated_files/mcc.c: -------------------------------------------------------------------------------- 1 | /** 2 | @Generated PIC24 / dsPIC33 / PIC32MM MCUs Source File 3 | 4 | @Company: 5 | Microchip Technology Inc. 6 | 7 | @File Name: 8 | mcc.c 9 | 10 | @Summary: 11 | This is the mcc.c file generated using PIC24 / dsPIC33 / PIC32MM MCUs 12 | 13 | @Description: 14 | The configuration contents of this file are moved to system.c and this file will be removed in future MCC releases. 15 | Generation Information : 16 | Product Revision : PIC24 / dsPIC33 / PIC32MM MCUs - 1.170.0 17 | Device : dsPIC33CK64MC105 18 | The generated drivers are tested against the following: 19 | Compiler : XC16 v1.61 20 | MPLAB : MPLAB X v5.45 21 | */ 22 | 23 | /* 24 | (c) 2020 Microchip Technology Inc. and its subsidiaries. You may use this 25 | software and any derivatives exclusively with Microchip products. 26 | 27 | THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER 28 | EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY IMPLIED 29 | WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS FOR A 30 | PARTICULAR PURPOSE, OR ITS INTERACTION WITH MICROCHIP PRODUCTS, COMBINATION 31 | WITH ANY OTHER PRODUCTS, OR USE IN ANY APPLICATION. 32 | 33 | IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, 34 | INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND 35 | WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS 36 | BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE 37 | FULLEST EXTENT ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN 38 | ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY, 39 | THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE. 40 | 41 | MICROCHIP PROVIDES THIS SOFTWARE CONDITIONALLY UPON YOUR ACCEPTANCE OF THESE 42 | TERMS. 43 | */ 44 | 45 | /** 46 | End of File 47 | */ -------------------------------------------------------------------------------- /firmware/mcc_generated_files/mcc.h: -------------------------------------------------------------------------------- 1 | /** 2 | @Generated PIC24 / dsPIC33 / PIC32MM MCUs Header File 3 | 4 | @Company: 5 | Microchip Technology Inc. 6 | 7 | @File Name: 8 | mcc.h 9 | 10 | @Summary: 11 | This is the mcc.h file generated using PIC24 / dsPIC33 / PIC32MM MCUs 12 | 13 | @Description: 14 | This file will be removed in future MCC releases. Use system.h instead. 15 | Generation Information : 16 | Product Revision : PIC24 / dsPIC33 / PIC32MM MCUs - 1.170.0 17 | Device : dsPIC33CK64MC105 18 | The generated drivers are tested against the following: 19 | Compiler : XC16 v1.61 20 | MPLAB : MPLAB X v5.45 21 | */ 22 | 23 | /* 24 | (c) 2020 Microchip Technology Inc. and its subsidiaries. You may use this 25 | software and any derivatives exclusively with Microchip products. 26 | 27 | THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER 28 | EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY IMPLIED 29 | WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS FOR A 30 | PARTICULAR PURPOSE, OR ITS INTERACTION WITH MICROCHIP PRODUCTS, COMBINATION 31 | WITH ANY OTHER PRODUCTS, OR USE IN ANY APPLICATION. 32 | 33 | IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, 34 | INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND 35 | WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS 36 | BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE 37 | FULLEST EXTENT ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN 38 | ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY, 39 | THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE. 40 | 41 | MICROCHIP PROVIDES THIS SOFTWARE CONDITIONALLY UPON YOUR ACCEPTANCE OF THESE 42 | TERMS. 43 | */ 44 | 45 | #ifndef MCC_H 46 | #define MCC_H 47 | #include 48 | #include "system.h" 49 | #include "clock.h" 50 | #include "pin_manager.h" 51 | #include 52 | #include 53 | #include "system_types.h" 54 | #include "reset.h" 55 | 56 | #include "reset.h" 57 | #include "interrupt_manager.h" 58 | #include "traps.h" 59 | #include "memory/flash.h" 60 | #include "watchdog.h" 61 | #include "clc1.h" 62 | #include "spi1.h" 63 | 64 | #warning "This file will be removed in future MCC releases. Use system.h instead." 65 | 66 | #endif /* MCC_H */ 67 | /** 68 | End of File 69 | */ -------------------------------------------------------------------------------- /firmware/mcc_generated_files/memory/flash.h: -------------------------------------------------------------------------------- 1 | /** 2 | FLASH Generated Driver API Header File 3 | 4 | @Company 5 | Microchip Technology Inc. 6 | 7 | @File Name 8 | flash.h 9 | 10 | @Summary 11 | This is the generated header file for the FLASH driver using PIC24 / dsPIC33 / PIC32MM MCUs 12 | 13 | @Description 14 | This header file provides APIs for driver for FLASH. 15 | Generation Information : 16 | Product Revision : PIC24 / dsPIC33 / PIC32MM MCUs - 1.170.0 17 | Device : dsPIC33CK64MC105 18 | Driver Version : 1.00 19 | The generated drivers are tested against the following: 20 | Compiler : XC16 v1.61 21 | MPLAB : MPLAB X v5.45 22 | */ 23 | 24 | #ifndef FLASH_H 25 | #define FLASH_H 26 | 27 | #include 28 | #include 29 | #include 30 | 31 | #define FLASH_WRITE_ROW_SIZE_IN_INSTRUCTIONS 128U 32 | #define FLASH_ERASE_PAGE_SIZE_IN_INSTRUCTIONS 1024U 33 | 34 | #define FLASH_ERASE_PAGE_SIZE_IN_PC_UNITS (FLASH_ERASE_PAGE_SIZE_IN_INSTRUCTIONS*2U) 35 | #define FLASH_WRITE_ROW_SIZE_IN_PC_UNITS (FLASH_WRITE_ROW_SIZE_IN_INSTRUCTIONS*2U) 36 | #define FLASH_HAS_ECC 1 37 | 38 | #define FLASH_UNLOCK_KEY 0x00AA0055 39 | 40 | #define FLASH_ERASE_PAGE_MASK (~((FLASH_ERASE_PAGE_SIZE_IN_INSTRUCTIONS*2U) - 1U)) 41 | void FLASH_Unlock(uint32_t key); 42 | void FLASH_Lock(void); 43 | 44 | bool FLASH_ErasePage(uint32_t address); 45 | 46 | uint16_t FLASH_ReadWord16(uint32_t address); 47 | uint32_t FLASH_ReadWord24(uint32_t address); 48 | 49 | bool FLASH_WriteDoubleWord16(uint32_t flashAddress, uint16_t Data0, uint16_t Data1); 50 | bool FLASH_WriteDoubleWord24(uint32_t address, uint32_t Data0, uint32_t Data1 ); 51 | 52 | /* Program the flash one row at a time. */ 53 | 54 | /* FLASH_WriteRow24: Writes a single row of data from the location given in *data to 55 | * the flash location in address. Since the flash is only 24 bits wide 56 | * all data in the upper 8 bits of the source will be lost . 57 | * The address in *data must be row aligned. 58 | * returns true if successful */ 59 | 60 | bool FLASH_WriteRow24(uint32_t flashAddress, uint32_t *data); 61 | 62 | /* FLASH_WriteRow16: Writes a single row of data from the location in given in *data to 63 | * to the flash location in address. Each 16 bit source data 64 | * word is stored in the lower 16 bits of each flash entry and the 65 | * upper 8 bits of the flash is not programmed. 66 | * The address in *data must be row aligned. 67 | * returns true if successful */ 68 | bool FLASH_WriteRow16(uint32_t address, uint16_t *data); 69 | 70 | 71 | uint16_t FLASH_GetErasePageOffset(uint32_t address); 72 | uint32_t FLASH_GetErasePageAddress(uint32_t address); 73 | 74 | 75 | 76 | 77 | #endif /* FLASH_H */ 78 | 79 | -------------------------------------------------------------------------------- /firmware/mcc_generated_files/pin_manager.c: -------------------------------------------------------------------------------- 1 | /** 2 | PIN MANAGER Generated Driver File 3 | 4 | @Company: 5 | Microchip Technology Inc. 6 | 7 | @File Name: 8 | pin_manager.c 9 | 10 | @Summary: 11 | This is the generated manager file for the PIC24 / dsPIC33 / PIC32MM MCUs device. This manager 12 | configures the pins direction, initial state, analog setting. 13 | The peripheral pin select, PPS, configuration is also handled by this manager. 14 | 15 | @Description: 16 | This source file provides implementations for PIN MANAGER. 17 | Generation Information : 18 | Product Revision : PIC24 / dsPIC33 / PIC32MM MCUs - 1.170.0 19 | Device : dsPIC33CK64MC105 20 | The generated drivers are tested against the following: 21 | Compiler : XC16 v1.61 22 | MPLAB : MPLAB X v5.45 23 | */ 24 | 25 | /* 26 | (c) 2020 Microchip Technology Inc. and its subsidiaries. You may use this 27 | software and any derivatives exclusively with Microchip products. 28 | 29 | THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER 30 | EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY IMPLIED 31 | WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS FOR A 32 | PARTICULAR PURPOSE, OR ITS INTERACTION WITH MICROCHIP PRODUCTS, COMBINATION 33 | WITH ANY OTHER PRODUCTS, OR USE IN ANY APPLICATION. 34 | 35 | IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, 36 | INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND 37 | WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS 38 | BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE 39 | FULLEST EXTENT ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN 40 | ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY, 41 | THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE. 42 | 43 | MICROCHIP PROVIDES THIS SOFTWARE CONDITIONALLY UPON YOUR ACCEPTANCE OF THESE 44 | TERMS. 45 | */ 46 | 47 | 48 | /** 49 | Section: Includes 50 | */ 51 | 52 | #include 53 | #include 54 | #include "pin_manager.h" 55 | 56 | /** 57 | Section: Driver Interface Function Definitions 58 | */ 59 | void PIN_MANAGER_Initialize (void) 60 | { 61 | /**************************************************************************** 62 | * Setting the Output Latch SFR(s) 63 | ***************************************************************************/ 64 | LATA = 0x0000; 65 | LATB = 0x0000; 66 | LATC = 0x0000; 67 | LATD = 0x0000; 68 | 69 | /**************************************************************************** 70 | * Setting the GPIO Direction SFR(s) 71 | ***************************************************************************/ 72 | TRISA = 0x0000; 73 | TRISB = 0xFF00; 74 | TRISC = 0x3FFF; 75 | TRISD = 0x0500; 76 | 77 | /**************************************************************************** 78 | * Setting the Weak Pull Up and Weak Pull Down SFR(s) 79 | ***************************************************************************/ 80 | CNPDA = 0x0000; 81 | CNPDB = 0x0000; 82 | CNPDC = 0x0000; 83 | CNPDD = 0x0000; 84 | CNPUA = 0x0000; 85 | CNPUB = 0xFF00; 86 | CNPUC = 0x2F00; 87 | CNPUD = 0x0000; 88 | 89 | /**************************************************************************** 90 | * Setting the Open Drain SFR(s) 91 | ***************************************************************************/ 92 | ODCA = 0x0000; 93 | ODCB = 0x0000; 94 | ODCC = 0x0000; 95 | ODCD = 0x0000; 96 | 97 | /**************************************************************************** 98 | * Setting the Analog/Digital Configuration SFR(s) 99 | ***************************************************************************/ 100 | ANSELA = 0x0000; 101 | ANSELB = 0x0000; 102 | ANSELC = 0x0000; 103 | ANSELD = 0x0000; 104 | 105 | /**************************************************************************** 106 | * Set the PPS 107 | ***************************************************************************/ 108 | __builtin_write_RPCON(0x0000); // unlock PPS 109 | 110 | RPINR45bits.CLCINAR = 0x003B; //RC11->CLC1:CLCINA 111 | RPINR46bits.CLCINBR = 0x003C; //RC12->CLC1:CLCINB 112 | RPINR20bits.SCK1R = 0x0048; //RD8->SPI1:SCK1 113 | RPOR15bits.RP72R = 0x0006; //RD8->SPI1:SCK1 114 | RPOR15bits.RP65R = 0x0028; //RD1->CLC1:CLC1OUT 115 | RPOR16bits.RP77R = 0x0005; //RD13->SPI1:SDO1 116 | RPINR20bits.SDI1R = 0x004A; //RD10->SPI1:SDI1 117 | 118 | __builtin_write_RPCON(0x0800); // lock PPS 119 | 120 | /**************************************************************************** 121 | * Interrupt On Change: any 122 | ***************************************************************************/ 123 | 124 | CNEN0C = 0xffff; // interrupt on change 0 125 | CNEN1C = 0xffff; // interrupt on change 1 /* CAUSES NO WAKE FROM SLEEP, and NO ISR */ 126 | CNFC = 0x00; // interrupt on change flag 127 | 128 | /**************************************************************************** 129 | * Interrupt On Change: config 130 | ***************************************************************************/ 131 | CNCONCbits.CNSTYLE = 1; //Config for PORTC 132 | CNCONCbits.ON = 1; //Config for PORTC 133 | } 134 | 135 | 136 | void 137 | PIN_MANAGER_enableInterrupt_On_Change() 138 | { 139 | /**************************************************************************** 140 | * Interrupt On Change: Interrupt Enable 141 | ***************************************************************************/ 142 | IFS1bits.CNCIF = 0; //Clear CNCI interrupt flag 143 | IEC1bits.CNCIE = 1; //Enable CNCI interrupt 144 | 145 | } 146 | 147 | -------------------------------------------------------------------------------- /firmware/mcc_generated_files/reset.c: -------------------------------------------------------------------------------- 1 | /** 2 | RESET Generated Driver File 3 | 4 | @Company 5 | Microchip Technology Inc. 6 | 7 | @File Name 8 | reset.c 9 | 10 | @Summary 11 | This is the generated driver implementation file for the RESET driver using PIC24 / dsPIC33 / PIC32MM MCUs 12 | 13 | @Description 14 | This header file provides implementations for driver APIs for RESET. 15 | Generation Information : 16 | Product Revision : PIC24 / dsPIC33 / PIC32MM MCUs - 1.170.0 17 | Device : dsPIC33CK64MC105 18 | The generated drivers are tested against the following: 19 | Compiler : XC16 v1.61 20 | MPLAB : MPLAB X v5.45 21 | */ 22 | 23 | /* 24 | (c) 2020 Microchip Technology Inc. and its subsidiaries. You may use this 25 | software and any derivatives exclusively with Microchip products. 26 | 27 | THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER 28 | EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY IMPLIED 29 | WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS FOR A 30 | PARTICULAR PURPOSE, OR ITS INTERACTION WITH MICROCHIP PRODUCTS, COMBINATION 31 | WITH ANY OTHER PRODUCTS, OR USE IN ANY APPLICATION. 32 | 33 | IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, 34 | INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND 35 | WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS 36 | BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE 37 | FULLEST EXTENT ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN 38 | ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY, 39 | THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE. 40 | 41 | MICROCHIP PROVIDES THIS SOFTWARE CONDITIONALLY UPON YOUR ACCEPTANCE OF THESE 42 | TERMS. 43 | */ 44 | 45 | #include 46 | #include 47 | #include "xc.h" 48 | #include "reset.h" 49 | 50 | /** 51 | Section: Local Variables 52 | */ 53 | 54 | /** 55 | Section: Function prototypes 56 | */ 57 | static bool RESET_CauseFromSoftware(uint16_t resetCause); 58 | static bool RESET_CauseFromWatchdogTimer(uint16_t resetCause); 59 | static bool RESET_CauseFromConfigurationMismatch(uint16_t resetCause); 60 | static bool RESET_CauseFromIllegalOpcode(uint16_t resetCause); 61 | static bool RESET_CauseFromExternal(uint16_t resetCause); 62 | static bool RESET_CauseFromTrap(uint16_t resetCause); 63 | static void RESET_CauseClear(RESET_MASKS resetFlagMask); 64 | 65 | uint16_t RESET_GetCause(void) 66 | { 67 | return RCON; 68 | } 69 | 70 | void __attribute__ ((weak)) RESET_CauseHandler(void) 71 | { 72 | uint16_t resetCause = RESET_GetCause(); 73 | if(RESET_CauseFromTrap(resetCause)) 74 | { 75 | RESET_CauseClear(RESET_MASK_TRAPR); 76 | //Do something 77 | } 78 | if(RESET_CauseFromIllegalOpcode(resetCause)) 79 | { 80 | RESET_CauseClear(RESET_MASK_IOPUWR); 81 | //Do something 82 | } 83 | if(RESET_CauseFromConfigurationMismatch(resetCause)) 84 | { 85 | RESET_CauseClear(RESET_MASK_CM); 86 | //Do something 87 | } 88 | if(RESET_CauseFromExternal(resetCause)) 89 | { 90 | RESET_CauseClear(RESET_MASK_EXTR); 91 | //Do something 92 | } 93 | if(RESET_CauseFromSoftware(resetCause)) 94 | { 95 | RESET_CauseClear(RESET_MASK_SWR); 96 | //Do something 97 | } 98 | if(RESET_CauseFromWatchdogTimer(resetCause)) 99 | { 100 | RESET_CauseClear(RESET_MASK_WDTO); 101 | //Do something 102 | } 103 | } 104 | 105 | static bool RESET_CauseFromTrap(uint16_t resetCause) 106 | { 107 | bool resetStatus = false; 108 | if(resetCause & RESET_MASK_TRAPR) 109 | { 110 | resetStatus = true; 111 | } 112 | return resetStatus; 113 | } 114 | 115 | static bool RESET_CauseFromIllegalOpcode(uint16_t resetCause) 116 | { 117 | bool resetStatus = false; 118 | if(resetCause & RESET_MASK_IOPUWR) 119 | { 120 | resetStatus = true; 121 | } 122 | return resetStatus; 123 | } 124 | 125 | static bool RESET_CauseFromConfigurationMismatch(uint16_t resetCause) 126 | { 127 | bool resetStatus = false; 128 | if(resetCause & RESET_MASK_CM) 129 | { 130 | resetStatus = true; 131 | } 132 | return resetStatus; 133 | } 134 | 135 | static bool RESET_CauseFromExternal(uint16_t resetCause) 136 | { 137 | bool resetStatus = false; 138 | if(resetCause & RESET_MASK_EXTR) 139 | { 140 | resetStatus = true; 141 | } 142 | return resetStatus; 143 | } 144 | 145 | static bool RESET_CauseFromSoftware(uint16_t resetCause) 146 | { 147 | bool resetStatus = false; 148 | if(resetCause & RESET_MASK_SWR) 149 | { 150 | resetStatus = true; 151 | } 152 | return resetStatus; 153 | } 154 | 155 | static bool RESET_CauseFromWatchdogTimer(uint16_t resetCause) 156 | { 157 | bool resetStatus = false; 158 | if(resetCause & RESET_MASK_WDTO) 159 | { 160 | resetStatus = true; 161 | } 162 | return resetStatus; 163 | } 164 | 165 | static void RESET_CauseClear(RESET_MASKS resetFlagMask) 166 | { 167 | RCON = RCON & (~resetFlagMask); 168 | } 169 | 170 | void RESET_CauseClearAll() 171 | { 172 | RCON = 0x00; 173 | } 174 | /** 175 | End of File 176 | */ -------------------------------------------------------------------------------- /firmware/mcc_generated_files/reset.h: -------------------------------------------------------------------------------- 1 | /** 2 | RESET Generated Driver File 3 | 4 | @Company 5 | Microchip Technology Inc. 6 | 7 | @File Name 8 | reset.c 9 | 10 | @Summary 11 | This is the generated driver implementation file for the RESET driver using PIC24 / dsPIC33 / PIC32MM MCUs 12 | 13 | @Description 14 | This header file provides implementations for driver APIs for RESET. 15 | Generation Information : 16 | Product Revision : PIC24 / dsPIC33 / PIC32MM MCUs - 1.170.0 17 | Device : dsPIC33CK64MC105 18 | The generated drivers are tested against the following: 19 | Compiler : XC16 v1.61 20 | MPLAB : MPLAB X v5.45 21 | */ 22 | 23 | /* 24 | (c) 2020 Microchip Technology Inc. and its subsidiaries. You may use this 25 | software and any derivatives exclusively with Microchip products. 26 | 27 | THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER 28 | EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY IMPLIED 29 | WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS FOR A 30 | PARTICULAR PURPOSE, OR ITS INTERACTION WITH MICROCHIP PRODUCTS, COMBINATION 31 | WITH ANY OTHER PRODUCTS, OR USE IN ANY APPLICATION. 32 | 33 | IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, 34 | INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND 35 | WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS 36 | BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE 37 | FULLEST EXTENT ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN 38 | ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY, 39 | THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE. 40 | 41 | MICROCHIP PROVIDES THIS SOFTWARE CONDITIONALLY UPON YOUR ACCEPTANCE OF THESE 42 | TERMS. 43 | */ 44 | 45 | #ifndef RESET_H 46 | #define RESET_H 47 | 48 | #include 49 | #include "reset_types.h" 50 | 51 | /** 52 | * Checks reset cause, flashes UI with an error code as a result. 53 | * 54 | * Note: this function should be called before any use of CLRWDT 55 | * since it has a side-effect of clearing the appropriate bits in the 56 | * register showing reset cause (see DS70602B page 8-10) 57 | */ 58 | uint16_t RESET_GetCause(void); 59 | 60 | /** 61 | * It handles the reset cause by clearing the cause register values. 62 | * Its a weak function user can override this function. 63 | * @return None 64 | * @example 65 | * 66 | * RESET_CauseHandler(); 67 | * 68 | */ 69 | void RESET_CauseHandler(void); 70 | 71 | /** 72 | * This function resets the reset cause register. 73 | * @return None 74 | * @example 75 | * 76 | * RESET_CauseClearAll(); 77 | * 78 | */ 79 | void RESET_CauseClearAll(); 80 | 81 | #endif /* RESET_H */ 82 | /** 83 | End of File 84 | */ -------------------------------------------------------------------------------- /firmware/mcc_generated_files/reset_types.h: -------------------------------------------------------------------------------- 1 | /** 2 | RESET Generated Driver File 3 | 4 | @Company 5 | Microchip Technology Inc. 6 | 7 | @File Name 8 | reset_types.h 9 | 10 | @Summary 11 | This is the generated driver implementation file for the RESET driver using PIC24 / dsPIC33 / PIC32MM MCUs 12 | 13 | @Description 14 | This header file provides implementations for driver APIs for RESET. 15 | Generation Information : 16 | Product Revision : PIC24 / dsPIC33 / PIC32MM MCUs - 1.170.0 17 | Device : dsPIC33CK64MC105 18 | The generated drivers are tested against the following: 19 | Compiler : XC16 v1.61 20 | MPLAB : MPLAB X v5.45 21 | */ 22 | 23 | /* 24 | (c) 2020 Microchip Technology Inc. and its subsidiaries. You may use this 25 | software and any derivatives exclusively with Microchip products. 26 | 27 | THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER 28 | EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY IMPLIED 29 | WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS FOR A 30 | PARTICULAR PURPOSE, OR ITS INTERACTION WITH MICROCHIP PRODUCTS, COMBINATION 31 | WITH ANY OTHER PRODUCTS, OR USE IN ANY APPLICATION. 32 | 33 | IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, 34 | INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND 35 | WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS 36 | BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE 37 | FULLEST EXTENT ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN 38 | ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY, 39 | THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE. 40 | 41 | MICROCHIP PROVIDES THIS SOFTWARE CONDITIONALLY UPON YOUR ACCEPTANCE OF THESE 42 | TERMS. 43 | */ 44 | 45 | #ifndef RESET_TYPES_H 46 | #define RESET_TYPES_H 47 | 48 | /** 49 | Section: Type defines 50 | */ 51 | 52 | /** 53 | * RCON error type enumerator. Supported types: 54 | * RESET_ERROR_RCON_TRAPR 55 | * RESET_ERROR_RCON_IOPUWR 56 | * RESET_ERROR_RCON_CM 57 | * RESET_ERROR_RCON_WDTO_ISR 58 | */ 59 | typedef enum tagERROR_TYPE 60 | { 61 | RESET_ERROR_RCON_TRAPR = 1, /** A Trap Conflict Reset has occurred **/ 62 | RESET_ERROR_RCON_IOPUWR = 2, /** An illegal opcode detection, an illegal address mode or Uninitialized W register used as an 63 | * Address Pointer caused a Reset **/ 64 | RESET_ERROR_RCON_CM = 3, /** A Configuration Mismatch Reset has occurred **/ 65 | RESET_ERROR_RCON_WDTO_ISR = 4 /** WDT time-out has occurred **/ 66 | }RESET_TYPES; 67 | 68 | /** 69 | * RESET CAUSE Masks. Supported masks: 70 | * RESET_MASK_WDTO 71 | * RESET_MASK_SWR 72 | * RESET_MASK_EXTR 73 | * RESET_MASK_CM 74 | * RESET_MASK_IOPUWR 75 | * RESET_MASK_TRAPR 76 | */ 77 | typedef enum tagRESET_MASKS 78 | { 79 | RESET_MASK_WDTO = 0x0010, 80 | RESET_MASK_SWR = 0x0040, 81 | RESET_MASK_EXTR = 0x0080, 82 | RESET_MASK_CM = 0x0200, 83 | RESET_MASK_IOPUWR = 0x4000, 84 | RESET_MASK_TRAPR = 0x8000, 85 | } RESET_MASKS; 86 | 87 | #endif /* RESET_TYPES_H */ 88 | 89 | 90 | /******************************************************************************* 91 | 92 | !!! Deprecated Definitions and APIs !!! 93 | !!! These will not be supported in future releases !!! 94 | 95 | *******************************************************************************/ 96 | 97 | #define ERR_RCON_TRAPR RESET_ERROR_RCON_TRAPR 98 | #define ERR_RCON_IOPUWR RESET_ERROR_RCON_IOPUWR 99 | #define ERR_RCON_CM RESET_ERROR_RCON_CM 100 | #define ERR_RCON_WDTO_ISR RESET_ERROR_RCON_WDTO_ISR 101 | 102 | /** 103 | End of File 104 | */ -------------------------------------------------------------------------------- /firmware/mcc_generated_files/system.h: -------------------------------------------------------------------------------- 1 | /** 2 | @Generated PIC24 / dsPIC33 / PIC32MM MCUs Source File 3 | 4 | @Company: 5 | Microchip Technology Inc. 6 | 7 | @File Name: 8 | system.h 9 | 10 | @Summary: 11 | This is the system.h file generated using PIC24 / dsPIC33 / PIC32MM MCUs 12 | 13 | @Description: 14 | This header file provides implementations for driver APIs for all modules selected in the GUI. 15 | Generation Information : 16 | Product Revision : PIC24 / dsPIC33 / PIC32MM MCUs - 1.170.0 17 | Device : dsPIC33CK64MC105 18 | The generated drivers are tested against the following: 19 | Compiler : XC16 v1.61 20 | MPLAB : MPLAB X v5.45 21 | */ 22 | 23 | /* 24 | (c) 2020 Microchip Technology Inc. and its subsidiaries. You may use this 25 | software and any derivatives exclusively with Microchip products. 26 | 27 | THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER 28 | EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY IMPLIED 29 | WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS FOR A 30 | PARTICULAR PURPOSE, OR ITS INTERACTION WITH MICROCHIP PRODUCTS, COMBINATION 31 | WITH ANY OTHER PRODUCTS, OR USE IN ANY APPLICATION. 32 | 33 | IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, 34 | INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND 35 | WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS 36 | BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE 37 | FULLEST EXTENT ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN 38 | ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY, 39 | THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE. 40 | 41 | MICROCHIP PROVIDES THIS SOFTWARE CONDITIONALLY UPON YOUR ACCEPTANCE OF THESE 42 | TERMS. 43 | */ 44 | 45 | #ifndef _XTAL_FREQ 46 | #define _XTAL_FREQ 200000000UL 47 | #endif 48 | #define WDT_CLR_KEY 0x5743 49 | 50 | #include "xc.h" 51 | #include "stdint.h" 52 | #include "system_types.h" 53 | 54 | #ifndef SYSTEM_H 55 | #define SYSTEM_H 56 | /** 57 | * Initializes the CPU core control register. 58 | * @example 59 | * 60 | * SYSTEM_CORCONInitialize(); 61 | * 62 | */ 63 | inline static void SYSTEM_CORCONInitialize() 64 | { 65 | CORCON = (CORCON & 0x00F2) | CORCON_MODE_PORVALUES; // POR value 66 | } 67 | 68 | /** 69 | * Sets the CPU core control register operating mode to a value that is decided by the 70 | * SYSTEM_CORCON_MODES argument. 71 | * @param modeValue SYSTEM_CORCON_MODES initialization mode specifier 72 | * @example 73 | * 74 | * SYSTEM_CORCONModeOperatingSet(CORCON_MODE_ENABLEALLSATNORMAL_ROUNDUNBIASED); 75 | * 76 | */ 77 | inline static void SYSTEM_CORCONModeOperatingSet(SYSTEM_CORCON_MODES modeValue) 78 | { 79 | CORCON = (CORCON & 0x00F2) | modeValue; 80 | } 81 | 82 | /** 83 | * Sets the value of CPU core control register. 84 | * @param value value that needs to be written to the CPU core control register 85 | * @example 86 | * 87 | * SYSTEM_CORCONRegisterValueSet(0x00E2); 88 | * 89 | */ 90 | inline static void SYSTEM_CORCONRegisterValueSet(uint16_t value) 91 | { 92 | CORCON = value; 93 | } 94 | 95 | /** 96 | * Gets the value of CPU core control register. 97 | * @return value of the CPU core control register 98 | * @example 99 | * 100 | * corconSave = SYSTEM_CORCONRegisterValueGet(); 101 | * 102 | */ 103 | inline static uint16_t SYSTEM_CORCONRegisterValueGet(void) 104 | { 105 | return CORCON; 106 | } 107 | 108 | 109 | /** 110 | * Gets the base address of the DEVID register for the currently selected device 111 | * @return base address of the DEVID register 112 | * @example 113 | * 114 | * uint32_t devIdAddress; 115 | * devIdAddress = SYSTEM_DeviceIdRegisterAddressGet(); 116 | * 117 | */ 118 | inline static uint32_t SYSTEM_DeviceIdRegisterAddressGet(void) 119 | { 120 | return __DEVID_BASE; 121 | } 122 | 123 | /** 124 | * @Param 125 | none 126 | * @Returns 127 | none 128 | * @Description 129 | Initializes the device to the default states configured in the 130 | * MCC GUI 131 | * @Example 132 | SYSTEM_Initialize(void); 133 | */ 134 | void SYSTEM_Initialize(void); 135 | #endif /* SYSTEM_H */ 136 | /** 137 | End of File 138 | */ -------------------------------------------------------------------------------- /firmware/mcc_generated_files/traps.c: -------------------------------------------------------------------------------- 1 | /** 2 | System Traps Generated Driver File 3 | 4 | @Company: 5 | Microchip Technology Inc. 6 | 7 | @File Name: 8 | traps.h 9 | 10 | @Summary: 11 | This is the generated driver implementation file for handling traps 12 | using PIC24 / dsPIC33 / PIC32MM MCUs 13 | 14 | @Description: 15 | This source file provides implementations for PIC24 / dsPIC33 / PIC32MM MCUs traps. 16 | Generation Information : 17 | Product Revision : PIC24 / dsPIC33 / PIC32MM MCUs - 1.170.0 18 | Device : dsPIC33CK64MC105 19 | The generated drivers are tested against the following: 20 | Compiler : XC16 v1.61 21 | MPLAB : MPLAB X v5.45 22 | */ 23 | /* 24 | (c) 2020 Microchip Technology Inc. and its subsidiaries. You may use this 25 | software and any derivatives exclusively with Microchip products. 26 | 27 | THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER 28 | EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY IMPLIED 29 | WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS FOR A 30 | PARTICULAR PURPOSE, OR ITS INTERACTION WITH MICROCHIP PRODUCTS, COMBINATION 31 | WITH ANY OTHER PRODUCTS, OR USE IN ANY APPLICATION. 32 | 33 | IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, 34 | INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND 35 | WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS 36 | BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE 37 | FULLEST EXTENT ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN 38 | ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY, 39 | THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE. 40 | 41 | MICROCHIP PROVIDES THIS SOFTWARE CONDITIONALLY UPON YOUR ACCEPTANCE OF THESE 42 | TERMS. 43 | */ 44 | 45 | /** 46 | Section: Includes 47 | */ 48 | #include 49 | #include "traps.h" 50 | 51 | #define ERROR_HANDLER __attribute__((interrupt, no_auto_psv, keep, section("error_handler"))) 52 | #define FAILSAFE_STACK_GUARDSIZE 8 53 | 54 | extern void flash_led(uint8_t num); 55 | 56 | #ifdef __DEBUG 57 | /** 58 | * a private place to store the error code if we run into a severe error 59 | */ 60 | static uint16_t TRAPS_error_code = -1; 61 | #endif 62 | 63 | /** 64 | * Halts 65 | * 66 | * @param code error code 67 | */ 68 | void __attribute__((weak)) TRAPS_halt_on_error(uint16_t code) 69 | { 70 | #ifdef __DEBUG 71 | TRAPS_error_code = code; 72 | #endif 73 | __builtin_software_breakpoint(); 74 | /* If we are in debug mode, cause a software breakpoint in the debugger */ 75 | while(1) 76 | { 77 | flash_led(0); 78 | flash_led(3); 79 | flash_led(code); 80 | } 81 | 82 | } 83 | 84 | // RB - Need the RAM, and this type of error isn't recoverable anyways 85 | #ifdef __DEBUG 86 | /** 87 | * Sets the stack pointer to a backup area of memory, in case we run into 88 | * a stack error (in which case we can't really trust the stack pointer) 89 | */ 90 | inline static void use_failsafe_stack(void) 91 | { 92 | static uint8_t failsafe_stack[32]; 93 | asm volatile ( 94 | " mov %[pstack], W15\n" 95 | : 96 | : [pstack]"r"(failsafe_stack) 97 | ); 98 | /* Controls where the stack pointer limit is, relative to the end of the 99 | * failsafe stack 100 | */ 101 | SPLIM = (uint16_t)(((uint8_t *)failsafe_stack) + sizeof(failsafe_stack) 102 | - FAILSAFE_STACK_GUARDSIZE); 103 | } 104 | #endif 105 | 106 | 107 | /** Oscillator Fail Trap vector**/ 108 | void ERROR_HANDLER _OscillatorFail(void) 109 | { 110 | INTCON1bits.OSCFAIL = 0; //Clear the trap flag 111 | TRAPS_halt_on_error(TRAPS_OSC_FAIL); 112 | } 113 | /** Stack Error Trap Vector**/ 114 | void ERROR_HANDLER _StackError(void) 115 | { 116 | /* We use a failsafe stack: the presence of a stack-pointer error 117 | * means that we cannot trust the stack to operate correctly unless 118 | * we set the stack pointer to a safe place. 119 | */ 120 | #ifdef __DEBUG 121 | use_failsafe_stack(); 122 | #endif 123 | INTCON1bits.STKERR = 0; //Clear the trap flag 124 | TRAPS_halt_on_error(TRAPS_STACK_ERR); 125 | } 126 | /** Address error Trap vector**/ 127 | void ERROR_HANDLER _AddressError(void) 128 | { 129 | INTCON1bits.ADDRERR = 0; //Clear the trap flag 130 | TRAPS_halt_on_error(TRAPS_ADDRESS_ERR); 131 | } 132 | /** Math Error Trap vector**/ 133 | void ERROR_HANDLER _MathError(void) 134 | { 135 | INTCON1bits.MATHERR = 0; //Clear the trap flag 136 | TRAPS_halt_on_error(TRAPS_MATH_ERR); 137 | } 138 | /** Generic Hard Trap vector**/ 139 | void ERROR_HANDLER _HardTrapError(void) 140 | { 141 | INTCON4bits.SGHT = 0; //Clear the trap flag 142 | TRAPS_halt_on_error(TRAPS_HARD_ERR); 143 | } 144 | /** Generic Soft Trap vector**/ 145 | void ERROR_HANDLER _SoftTrapError(void) 146 | { 147 | if(INTCON3bits.NAE) 148 | { 149 | INTCON3bits.NAE = 0; //Clear the trap flag 150 | TRAPS_halt_on_error(TRAPS_NVM_ERR); 151 | } 152 | 153 | #if 0 154 | if(INTCON3bits.DMT) 155 | { 156 | INTCON3bits.DMT = 0; //Clear the trap flag 157 | TRAPS_halt_on_error(TRAPS_DMT_ERR); 158 | } 159 | #endif 160 | 161 | if(INTCON3bits.DOOVR) 162 | { 163 | INTCON3bits.DOOVR = 0; //Clear the trap flag 164 | TRAPS_halt_on_error(TRAPS_DOOVR_ERR); 165 | } 166 | 167 | while(1); 168 | { 169 | flash_led(0); 170 | flash_led(3); 171 | flash_led(4); // unused 172 | } 173 | } 174 | 175 | 176 | -------------------------------------------------------------------------------- /firmware/mcc_generated_files/traps.h: -------------------------------------------------------------------------------- 1 | /** 2 | System Traps Generated Driver File 3 | 4 | @Company: 5 | Microchip Technology Inc. 6 | 7 | @File Name: 8 | traps.h 9 | 10 | @Summary: 11 | This is the generated driver implementation file for handling traps 12 | using PIC24 / dsPIC33 / PIC32MM MCUs 13 | 14 | @Description: 15 | This source file provides implementations for PIC24 / dsPIC33 / PIC32MM MCUs traps. 16 | Generation Information : 17 | Product Revision : PIC24 / dsPIC33 / PIC32MM MCUs - 1.170.0 18 | Device : dsPIC33CK64MC105 19 | The generated drivers are tested against the following: 20 | Compiler : XC16 v1.61 21 | MPLAB : MPLAB X v5.45 22 | */ 23 | /* 24 | (c) 2020 Microchip Technology Inc. and its subsidiaries. You may use this 25 | software and any derivatives exclusively with Microchip products. 26 | 27 | THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER 28 | EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY IMPLIED 29 | WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS FOR A 30 | PARTICULAR PURPOSE, OR ITS INTERACTION WITH MICROCHIP PRODUCTS, COMBINATION 31 | WITH ANY OTHER PRODUCTS, OR USE IN ANY APPLICATION. 32 | 33 | IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, 34 | INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND 35 | WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS 36 | BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE 37 | FULLEST EXTENT ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN 38 | ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY, 39 | THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE. 40 | 41 | MICROCHIP PROVIDES THIS SOFTWARE CONDITIONALLY UPON YOUR ACCEPTANCE OF THESE 42 | TERMS. 43 | */ 44 | 45 | #ifndef _TRAPS_H 46 | #define _TRAPS_H 47 | 48 | #include 49 | 50 | /** 51 | * Error codes 52 | */ 53 | typedef enum 54 | { 55 | /* ----- Traps ----- */ 56 | TRAPS_OSC_FAIL = 0, /** Oscillator Fail Trap vector */ 57 | TRAPS_STACK_ERR = 1, /** Stack Error Trap Vector */ 58 | TRAPS_ADDRESS_ERR = 2, /** Address error Trap vector */ 59 | TRAPS_MATH_ERR = 3, /** Math Error Trap vector */ 60 | TRAPS_HARD_ERR = 7, /** Generic Hard Trap vector */ 61 | TRAPS_NVM_ERR = 12, /** Generic Soft Trap vector */ 62 | TRAPS_DMT_ERR = 8, /** Generic Soft Trap vector */ 63 | TRAPS_DOOVR_ERR = 10, /** Generic Soft Trap vector */ 64 | } TRAPS_ERROR_CODE; 65 | /** 66 | @Summary 67 | Default handler for the traps 68 | 69 | @Description 70 | This routine will be called whenever a trap happens. It stores the trap 71 | error code and waits forever. 72 | This routine has a weak attribute and can be over written. 73 | 74 | @Preconditions 75 | None. 76 | 77 | @Returns 78 | None. 79 | 80 | @Param 81 | None. 82 | 83 | @Example 84 | None. 85 | 86 | */ 87 | void TRAPS_halt_on_error(uint16_t code); 88 | 89 | #endif -------------------------------------------------------------------------------- /firmware/mcc_generated_files/watchdog.h: -------------------------------------------------------------------------------- 1 | /** 2 | WATCHDOG Generated Driver File 3 | 4 | @Company 5 | Microchip Technology Inc. 6 | 7 | @File Name 8 | watchdog.h 9 | 10 | @Summary 11 | This is the generated driver implementation file for the WATCHDOG driver using PIC24 / dsPIC33 / PIC32MM MCUs 12 | 13 | @Description 14 | This header file provides implementations for driver APIs for WATCHDOG. 15 | Generation Information : 16 | Product Revision : PIC24 / dsPIC33 / PIC32MM MCUs - 1.170.0 17 | Device : dsPIC33CK64MC105 18 | The generated drivers are tested against the following: 19 | Compiler : XC16 v1.61 20 | MPLAB : MPLAB X v5.45 21 | */ 22 | 23 | /* 24 | (c) 2020 Microchip Technology Inc. and its subsidiaries. You may use this 25 | software and any derivatives exclusively with Microchip products. 26 | 27 | THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER 28 | EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY IMPLIED 29 | WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS FOR A 30 | PARTICULAR PURPOSE, OR ITS INTERACTION WITH MICROCHIP PRODUCTS, COMBINATION 31 | WITH ANY OTHER PRODUCTS, OR USE IN ANY APPLICATION. 32 | 33 | IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, 34 | INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND 35 | WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS 36 | BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE 37 | FULLEST EXTENT ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN 38 | ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY, 39 | THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE. 40 | 41 | MICROCHIP PROVIDES THIS SOFTWARE CONDITIONALLY UPON YOUR ACCEPTANCE OF THESE 42 | TERMS. 43 | */ 44 | 45 | #ifndef WATCHDOG_H 46 | #define WATCHDOG_H 47 | 48 | /** 49 | Section: Type defines 50 | */ 51 | #define WATCHDOG_CLR_KEY 0x5743 52 | 53 | /** 54 | * Enables Watch Dog Timer (WDT) using the software bit. 55 | * @example 56 | * 57 | * WATCHDOG_TimerSoftwareEnable(); 58 | * 59 | */ 60 | inline static void WATCHDOG_TimerSoftwareEnable(void) 61 | { 62 | WDTCONLbits.ON = 1; 63 | } 64 | 65 | /** 66 | * Disables Watch Dog Timer (WDT) using the software bit. 67 | * @example 68 | * 69 | * WATCHDOG_TimerSoftwareDisable(); 70 | * 71 | */ 72 | inline static void WATCHDOG_TimerSoftwareDisable(void) 73 | { 74 | WDTCONLbits.ON = 0; 75 | } 76 | 77 | /** 78 | * Clears the Watch Dog Timer (WDT). 79 | * @example 80 | * 81 | * WATCHDOG_TimerClear(); 82 | * 83 | */ 84 | inline static void WATCHDOG_TimerClear(void) 85 | { 86 | WDTCONH = WATCHDOG_CLR_KEY; 87 | } 88 | 89 | #endif /* WATCHDOG_H */ 90 | /** 91 | End of File 92 | */ -------------------------------------------------------------------------------- /firmware/nbproject/.gitignore: -------------------------------------------------------------------------------- 1 | Makefile* 2 | Package* 3 | private 4 | -------------------------------------------------------------------------------- /firmware/nbproject/project.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | com.microchip.mplab.nbide.embedded.makeproject 4 | 5 | 6 | moviecart_smd 7 | cbcf7f1b-6254-4fbd-8c7a-d6075432c2f1 8 | 0 9 | c 10 | 11 | h 12 | 13 | ISO-8859-1 14 | 15 | 16 | . 17 | 18 | 19 | 20 | default 21 | 2 22 | 23 | 24 | 25 | false 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /firmware/patches/notes.txt: -------------------------------------------------------------------------------- 1 | 2 | ** 3 | ** ONLY DO THIS IF ABSOLUTELY NECESSARY AS YOU RISK BRICKING THE MOVIECART ** 4 | ** 5 | 6 | ----------------------------------- 7 | INSTALLING A NEW PATCH: 8 | ----------------------------------- 9 | 10 | Note: Installing a patch will replace any existing patches, so make sure you have the latest. 11 | Select the update.frm file you require and place it on an sd-card by itself with no other files. 12 | Follow the installation instructions in the associated README.txt file for that patch. 13 | 14 | 15 | ----------------------------------- 16 | FACTORY RESET (Remove patch) : 17 | ----------------------------------- 18 | 19 | * NOTE * Only some patches are removable, some are permanent. 20 | Please read the notes associated with each patch before applying. 21 | 22 | If a patch needs to be removed, use a thin wire with both ends exposed. 23 | A metallic sandwich twist tie, with the paper removed from each end works well. 24 | 25 | Remove any SD cards from the MovieCart PCB. 26 | Insert one end through the hole labelled 'PGD' and the other through the hole labelled 'GND'. 27 | These are holes 2 and 3 of a five hole section in the upper left hand side of the MovieCart PCB. 28 | Verify they are labelled 'PGD' and 'GND'. 29 | Verify the ends of the wire aren't making contact with any other points on the PCB. 30 | 31 | Insert the MovieCart PCB (with the wire in place) into the Atari, and power up the Atari. 32 | After f;ctory reset, the red LED on the moviecart board will flash the sequence 22..22..22.. 33 | (Twice, twice, pause, twice, twice, pause, etc). 34 | 35 | Turn off the Atari and remove the wire. 36 | It should now power up as originally delivered. 37 | 38 | 39 | -------------------------------------------------------------------------------- /firmware/patches/patch2_kernel/README.txt: -------------------------------------------------------------------------------- 1 | 2 | 3 | * WARNING * 4 | 5 | This patch is permanent. 6 | Make sure power is not interrupted while the patch is being applied. 7 | This patch fixes writes to ROM as well as being 7800 PAL startup compatible. 8 | 9 | Intstructions: 10 | 11 | Note: This requires 2 steps: 12 | 13 | Step 1: 14 | With the power off, insert the moviecart with the SD card containing update.frm into the Atari. 15 | Power up the Atari.  If successful the red cart on the Moviecart board will flash 22..22..22.. 16 | (Twice, twice, pause, twice, twice, pause, etc). 17 | It should only take a few seconds. 18 | 19 | Step 2: 20 | Turn off the Atari, and power it back on again. 21 | If successful the LED will now flash 24..24..24.. 22 | (Twice, four times, pause, twice, four times, pause, etc). 23 | It should only take a few seconds. 24 | 25 | 26 | Now turn off the Atari,  and remove the SD card, and put it away. 27 | Any subsequent powerup will be running the new firmware. 28 | 29 | -------------------------------------------------------------------------------- /firmware/patches/patch2_kernel/update.frm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lodefmode/moviecart/4ae049122e5a2cf368cd9413f8fba21dab926907/firmware/patches/patch2_kernel/update.frm -------------------------------------------------------------------------------- /firmware/pff.h: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------------------/ 2 | / Petit FatFs - FAT file system module include file R0.03a 3 | /----------------------------------------------------------------------------/ 4 | / Petit FatFs module is an open source software to implement FAT file system to 5 | / small embedded systems. This is a free software and is opened for education, 6 | / research and commercial developments under license policy of following trems. 7 | / 8 | / Copyright (C) 2019, ChaN, all right reserved. 9 | / 10 | / * The Petit FatFs module is a free software and there is NO WARRANTY. 11 | / * No restriction on use. You can use, modify and redistribute it for 12 | / personal, non-profit or commercial use UNDER YOUR RESPONSIBILITY. 13 | / * Redistributions of source code must retain the above copyright notice. 14 | / 15 | / Adapted from above for MovieCart use 16 | /----------------------------------------------------------------------------*/ 17 | 18 | #ifndef PF_DEFINED 19 | #define PF_DEFINED 20 | 21 | #include 22 | #include 23 | 24 | #define QUEUE_SIZE 128 25 | #define QUEUE_SIZE 128 26 | #define QUEUE_MASK (QUEUE_SIZE-1) 27 | 28 | #define DIR_Name 0 29 | #define DIR_Attr 11 30 | #define DIR_NTres 12 31 | #define DIR_CrtTime 14 32 | #define DIR_CrtDate 16 33 | #define DIR_FstClusHI 20 34 | #define DIR_WrtTime 22 35 | #define DIR_WrtDate 24 36 | #define DIR_FstClusLO 26 37 | #define DIR_FileSize 28 38 | 39 | // File attribute bits for directory entry 40 | 41 | #define AM_RDO 0x01 // Read only 42 | #define AM_HID 0x02 // Hidden 43 | #define AM_SYS 0x04 // System 44 | #define AM_VOL 0x08 // Volume label 45 | #define AM_LFN 0x0F // LFN entry 46 | #define AM_DIR 0x10 // Directory 47 | #define AM_ARC 0x20 // Archive 48 | #define AM_MASK 0x3F // Mask of defined bits 49 | // 50 | struct queueInfo 51 | { 52 | uint32_t block[QUEUE_SIZE]; 53 | uint32_t clust[QUEUE_SIZE]; 54 | uint8_t head; 55 | }; 56 | 57 | bool pf_mount(); /* Mount/Unmount a logical drive */ 58 | bool pf_open_file(uint32_t *numFrames, int num); /* Open first 'num' archived non-deleted file */ 59 | bool pf_seek_block(uint32_t block); /* Move file pointer of the open file */ 60 | void pf_read_block(uint8_t *dst); /* Read full block*/ 61 | 62 | uint32_t ld_dword (const uint8_t* ptr); 63 | uint32_t get_fat (uint32_t clst); // Cluster# to get the link information 64 | 65 | 66 | //----------------------------------------------------------------------- 67 | // Get sector# from cluster# / Get cluster field from directory entry 68 | //----------------------------------------------------------------------- 69 | 70 | #define clust2sect(X) ((((X) - 2) << fsInfo.csize_bits) + fsInfo.database) 71 | 72 | // File system object structure 73 | 74 | struct fileSystemInfo 75 | { 76 | uint8_t name[11]; // 8.3 format 77 | 78 | uint8_t csize; // Number of sectors per cluster N 79 | uint8_t csize_bits; // number of bits 2^N 80 | uint8_t csize_mask; // 2^N-1 81 | 82 | uint16_t n_rootdir; // Number of root directory entries (0 on FAT32) 83 | uint32_t n_fatent; // Number of FAT entries (= number of clusters + 2) 84 | uint32_t fatbase; // FAT start sector 85 | uint32_t dirbase; // Root directory start sector (Cluster# on FAT32) 86 | uint32_t database; // Data start sector 87 | uint32_t fsize; // File size 88 | uint32_t org_clust; // File start cluster 89 | uint32_t curr_clust; // File current cluster 90 | uint32_t block; // Current block, start of cluster 91 | uint32_t file_block; // block index within cluster 92 | 93 | 94 | }; 95 | 96 | #endif /* _PFATFS */ 97 | -------------------------------------------------------------------------------- /firmware/sd_reader.h: -------------------------------------------------------------------------------- 1 | 2 | 3 | bool disk_initialize(); 4 | uint8_t* disk_read_block1 (uint32_t sector); 5 | void disk_read_block2 (uint32_t sector, uint8_t *dst); 6 | 7 | -------------------------------------------------------------------------------- /firmware/update.h: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | #ifndef __UPDATE__ 5 | #define __UPDATE__ 6 | 7 | #include "defines.h" 8 | #include "frame.h" 9 | 10 | #define STATE_PLAYING 0x01 11 | #define STATE_MUTE0 0x02 12 | #define STATE_MUTE1 0x04 13 | 14 | struct stateVars 15 | { 16 | int32_t io_frameNumber; 17 | uint32_t i_numFrames; 18 | 19 | uint8_t i_swcha; 20 | uint8_t i_swchb; 21 | uint8_t i_inpt4; 22 | uint8_t i_inpt5; 23 | 24 | uint8_t io_bits; 25 | }; 26 | 27 | extern void updateTransport(struct stateVars* state); 28 | extern void updateBuffer(struct stateVars* state, struct frameInfo* fInfo); 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /firmware/utils/code2payload.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #if 0 6 | Line Address Opcode Label DisAssy 7 | 8 | input: 9 | 10 | 9,217 4800 B3C010 main2 MOV.B #0x1, W0 11 | 9,218 4802 07E9D7 RCALL flash_led 12 | 9,219 4804 B3C020 MOV.B #0x2, W0 13 | 9,220 4806 07E9D5 RCALL flash_led 14 | 9,221 4808 B3C030 MOV.B #0x3, W0 15 | 9,222 480A 07E9D3 RCALL flash_led 16 | 9,223 480C B3C010 MOV.B #0x1, W0 17 | 9,224 480E 07E9D1 RCALL flash_led 18 | 9,225 4810 B3C020 MOV.B #0x2, W0 19 | 9,226 4812 07E9CF RCALL flash_led 20 | 9,227 4814 B3C030 MOV.B #0x3, W0 21 | 9,228 4816 07E9CD RCALL flash_led 22 | 9,229 4818 37FFF3 BRA main2 23 | 24 | 25 | output: 26 | 27 | /* 28 | format: 29 | crc: 24 bit value // includes version, dest, length + data 30 | version: 24 bit value 31 | dest: 24 bit value 32 | length: 24 bit value // length in (24 bit) values following this section 33 | */ 34 | 35 | .global _payloadData 36 | .section .payload,code 37 | _payloadData: 38 | 39 | .pword 0xDF1C07 /* crc */ 40 | .pword 0x000001 /* version */ 41 | .pword 0x000000 /* dest */ 42 | .pword 320 /* length */ 43 | 44 | .pword 0xc00001, 0x1fd93e, 0x0ff8c1, 0x011ffb, 0xf10000, 0xf0866c, 0x1f07ff, 0x8d3ee7 45 | .pword 0x833ff8, 0xff7ff0, 0xfefce0, 0x0f0eff, 0x37f0d8, 0xbfde77, 0xef077b, 0xe00739 46 | .pword 0xfc0ffe, 0x7eff7f, 0xf1dfc7, 0xf0033f, 0x3ff8c7, 0x03f7f7, 0xffff37, 0xff8c63 47 | .pword 0x9cfaff, 0xffbfe3, 0x6771ff, 0xfcffff, 0xbf7377, 0x73ffff, 0xffff9d, 0x9c9cfa 48 | .pword 0xffff3f, 0xff99cc, 0xdcfaff, 0xff7f98, 0x66ccff, 0xfcffff, 0x7f7767, 0x31ffff 49 | #endif 50 | 51 | void 52 | addToCrc(uint32_t* crc, uint32_t v) 53 | { 54 | // fprintf(stdout, " ADDING 0x%06x to 0x%06x \n", v, *crc); 55 | 56 | *crc ^= v; 57 | for (uint8_t j=0; j<24; j++) 58 | { 59 | if (*crc & 1) 60 | *crc = (*crc >> 1) ^ 0xEDB88320; 61 | else 62 | *crc >>= 1; 63 | } 64 | } 65 | 66 | void 67 | main(int argc, const char* argv[]) 68 | { 69 | if (argc != 3) 70 | { 71 | fprintf(stderr, "Usage: %s input_file output_file\n", argv[0]); 72 | exit(); 73 | } 74 | 75 | FILE* input = fopen(argv[1], "rb"); 76 | if (!input) 77 | { 78 | fprintf(stderr, "Unable to open input %s\n", argv[1]); 79 | exit(); 80 | } 81 | 82 | FILE* output = fopen(argv[2], "wb"); 83 | if (!output) 84 | { 85 | fprintf(stderr, "Unable to open output %s\n", argv[1]); 86 | exit(); 87 | } 88 | 89 | 90 | char linput[500]; 91 | 92 | 93 | uint32_t version = 1; 94 | uint32_t dest = 0x00; 95 | 96 | int len = 0; 97 | int len2 = 0; 98 | 99 | 100 | 101 | uint32_t crc = 0xFFFFFFFF; 102 | 103 | for (int loop=0; loop<3; loop++) 104 | { 105 | if (loop == 1) 106 | { 107 | // do in this order first 108 | addToCrc(&crc, version); 109 | addToCrc(&crc, dest); 110 | addToCrc(&crc, len); 111 | } 112 | 113 | // print crc, etc 114 | if (loop == 2) 115 | { 116 | // fprintf(stdout, "Final CRC 0x%06x\n", crc); 117 | 118 | crc = crc ^ 0xFFFFFFFF; 119 | 120 | // fprintf(stdout, " ^ CRC 0x%06x\n", crc); 121 | 122 | crc &= 0xFFFFFF; // 24 bits 123 | 124 | // fprintf(stdout, " & CRC 0x%06x\n", crc); 125 | 126 | fprintf(output, 127 | "\n" 128 | "/*\n" 129 | " format:\n" 130 | " crc: 24 bit value // includes version, dest, length + data\n" 131 | " version: 24 bit value\n" 132 | " dest: 24 bit value\n" 133 | " length: 24 bit value // length in (24 bit) values following this section\n" 134 | "*/\n" 135 | "\n" 136 | ".global _payloadData\n" 137 | ".section .payload,code\n" 138 | "_payloadData:\n" 139 | ); 140 | 141 | fprintf(output, "\n"); 142 | 143 | fprintf(output, "\t.pword 0x%06x\t/* crc */\n", crc); 144 | fprintf(output, "\t.pword 0x%06x\t/* version */\n", version); 145 | fprintf(output, "\t.pword 0x%06x\t/* dest */\n", dest); 146 | fprintf(output, "\t.pword 0x%06x\t/* length %d */\n", len, len); 147 | 148 | fprintf(output, "\n\n"); 149 | } 150 | 151 | len = 0; 152 | len2 = 0; 153 | 154 | fseek(input, 0, SEEK_SET); 155 | while(!feof(input)) 156 | { 157 | if (!fgets(linput, 500, input)) 158 | break; 159 | 160 | uint32_t v = 0; 161 | 162 | char c = linput[27]; 163 | if (isxdigit(c)) 164 | { 165 | for (int i=27; i<=32; i++) 166 | { 167 | char c = linput[i]; 168 | 169 | v *= 16; 170 | 171 | if (c >= '0' && c <= '9') 172 | v += c - '0'; 173 | else if (c >= 'A' && c <= 'F') 174 | v += c - 'A' + 10; 175 | } 176 | 177 | // calculate crc 178 | if (loop == 1) 179 | addToCrc(&crc, v); 180 | 181 | // print payload 182 | if (loop == 2) 183 | { 184 | if (len2 == 0) 185 | fprintf(output, "\t.pword "); 186 | else 187 | fprintf(output, ","); 188 | 189 | fprintf(output, " 0x%06x", v); 190 | 191 | if (len2 == 7) 192 | fprintf(output, "\n"); 193 | } 194 | 195 | len2++; 196 | len2 %= 8; 197 | 198 | len++; 199 | } 200 | } 201 | } 202 | 203 | fprintf(output, "\n"); 204 | fprintf(output, "\n"); 205 | 206 | fclose(input); 207 | fclose(output); 208 | 209 | } 210 | 211 | -------------------------------------------------------------------------------- /firmware/utils/code2updatefrm.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #if 0 5 | Line Address Opcode Label DisAssy 6 | 9,217 4800 B3C010 main2 MOV.B #0x1, W0 7 | 9,218 4802 07E9D7 RCALL flash_led 8 | 9,219 4804 B3C020 MOV.B #0x2, W0 9 | 9,220 4806 07E9D5 RCALL flash_led 10 | 9,221 4808 B3C030 MOV.B #0x3, W0 11 | 9,222 480A 07E9D3 RCALL flash_led 12 | 9,223 480C B3C010 MOV.B #0x1, W0 13 | 9,224 480E 07E9D1 RCALL flash_led 14 | 9,225 4810 B3C020 MOV.B #0x2, W0 15 | 9,226 4812 07E9CF RCALL flash_led 16 | 9,227 4814 B3C030 MOV.B #0x3, W0 17 | 9,228 4816 07E9CD RCALL flash_led 18 | 9,229 4818 37FFF3 BRA main2 19 | #endif 20 | 21 | void main() 22 | { 23 | FILE* output = fopen("update.frm", "wb"); 24 | 25 | char linput[500]; 26 | while(!feof(stdin)) 27 | { 28 | if (!fgets(linput, 500, stdin)) 29 | break; 30 | 31 | uint32_t v = 0; 32 | 33 | char c = linput[27]; 34 | if (isxdigit(c)) 35 | { 36 | for (int i=27; i<=32; i++) 37 | { 38 | char c = linput[i]; 39 | 40 | v *= 16; 41 | 42 | if (c >= '0' && c <= '9') 43 | v += c - '0'; 44 | else if (c >= 'A' && c <= 'F') 45 | v += c - 'A' + 10; 46 | } 47 | 48 | fwrite(&v, sizeof(v), 1, output); 49 | fprintf(stdout, "%06x\n", v); 50 | } 51 | } 52 | 53 | fclose(output); 54 | 55 | } 56 | 57 | -------------------------------------------------------------------------------- /firmware/utils/make_tables.c: -------------------------------------------------------------------------------- 1 | // 2 | // Create a series of lookup tables for 4 bit audio over a set of volume levels 3 | // Volume changes more pronounced at higher levels. 4 | // 5 | 6 | 7 | #include 8 | #include 9 | 10 | void main() 11 | { 12 | #define MAX_LEVELS 11 13 | #define DEFAULT_LEVEL 6 14 | 15 | float fromA = 0.0f; 16 | float toA = DEFAULT_LEVEL; 17 | 18 | float fromB = 0.0f; 19 | float toB = 1.0f; 20 | 21 | fprintf(stdout, "#define MAX_VOLUME %d\n", MAX_LEVELS); 22 | fprintf(stdout, "#define DEFAULT_VOLUME %d\n", DEFAULT_LEVEL); 23 | 24 | for (int i=0; i DEFAULT_LEVEL) 29 | scale = (scale * scale); 30 | 31 | fprintf(stdout, "const uint8_t scale%d[16] = {", i, scale); 32 | 33 | for (int j=0; j<16; j++) 34 | { 35 | float diff = j - 7.5f; 36 | 37 | int vi = (7.5f + diff*scale + 0.5f); 38 | 39 | if (vi < 0) 40 | vi = 0; 41 | if (vi > 15) 42 | vi = 15; 43 | 44 | if (j) 45 | fprintf(stdout, ","); 46 | fprintf(stdout, "%3d", vi); 47 | } 48 | 49 | fprintf(stdout, "}; /* %0.4f */ \n", scale); 50 | } 51 | 52 | fprintf(stdout, "\n"); 53 | fprintf(stdout, "const uint8_t *scales[%d] = {", MAX_LEVELS); 54 | 55 | for (int i=0; i 3 | #include 4 | 5 | void 6 | main() 7 | { 8 | // 2K instructions * 4 bytes each = 8K 9 | 10 | uint8_t hb = 0xff; 11 | 12 | FILE* output = fopen("update.frm", "wb"); 13 | 14 | for (int i=0; i<2048; i++) 15 | { 16 | uint32_t v = i | (hb << 16); 17 | 18 | #if 1 19 | fprintf(output, "%04x %06x\n", 0x8000 + 2*i, v); 20 | #else 21 | uint8_t a = (v & 0x000000ff) >> 0; 22 | uint8_t b = (v & 0x0000ff00) >> 8; 23 | uint8_t c = (v & 0x00ff0000) >> 16; 24 | uint8_t d = (v & 0xff000000) >> 24; 25 | 26 | fprintf(output, "%c", a); 27 | fprintf(output, "%c", b); 28 | fprintf(output, "%c", c); 29 | fprintf(output, "%c", d); 30 | #endif 31 | 32 | hb--; 33 | } 34 | 35 | fclose(output); 36 | } 37 | 38 | -------------------------------------------------------------------------------- /kernel/Makefile: -------------------------------------------------------------------------------- 1 | 2 | core.bin: core.asm 3 | ./dasm/dasm.exe core.asm -f3 -Idasm/machines/atari2600/ -ocore.bin -lcore.lst -score.sym 4 | "C:/Program Files/Stella/Stella.exe" -debug core.bin & 5 | # ../utils/expand_bin core.bin 6 | 7 | clean: 8 | rm -rf core.bin core.lst core.sym 9 | -------------------------------------------------------------------------------- /kernel/color_chart/color_chart.asm: -------------------------------------------------------------------------------- 1 | 2 | processor 6502 3 | include vcs.h 4 | 5 | ;user memory 128 to 255 6 | DUMMY equ $80 7 | 8 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 9 | 10 | MAC linerow 11 | 12 | ldx #10 13 | .again{1} 14 | sta WSYNC ; 3 15 | 16 | lda #0 17 | sty COLUBK ; 3 18 | sty COLUBK ; 3 19 | sty COLUBK ; 3 20 | sty COLUBK ; 3 21 | sty COLUBK ; 3 22 | sty COLUBK ; 3 23 | sty COLUBK ; 3 24 | 25 | ldy #(${1} + 0x0) 26 | sty COLUBK ; 3 27 | ldy #(${1} + 0x2) 28 | sty COLUBK ; 3 29 | ldy #(${1} + 0x4) 30 | sty COLUBK ; 3 31 | ldy #(${1} + 0x6) 32 | sty COLUBK ; 3 33 | ldy #(${1} + 0x8) 34 | sty COLUBK ; 3 35 | ldy #(${1} + 0xA) 36 | sty COLUBK ; 3 37 | ldy #(${1} + 0xC) 38 | sty COLUBK ; 3 39 | ldy #(${1} + 0xE) 40 | sty COLUBK ; 3 41 | 42 | ; black 43 | ldy #$00 44 | sty COLUBK ; 3 45 | 46 | dex 47 | bne .again{1} 48 | 49 | sta WSYNC 50 | 51 | ENDM 52 | 53 | 54 | seg 55 | 56 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 57 | org $F000 58 | 59 | main_start 60 | 61 | sei 62 | cld 63 | ldx #$FF 64 | txs 65 | 66 | ;zero memory 67 | lda #0 68 | ClearMem 69 | sta 0,X 70 | dex 71 | bne ClearMem 72 | 73 | jmp line_start 74 | 75 | 76 | ; page align to avoid longer branches 77 | ;; 78 | org $F100 79 | line_start 80 | line0 81 | linerow 00 82 | jmp line1 83 | ;; 84 | org $F180 85 | line1 86 | linerow 10 87 | jmp line2 88 | ;; 89 | org $F200 90 | line2 91 | linerow 20 92 | jmp line3 93 | ;; 94 | org $F280 95 | line3 96 | linerow 30 97 | jmp line4 98 | ;; 99 | org $F300 100 | line4 101 | linerow 40 102 | jmp line5 103 | ;; 104 | org $F380 105 | line5 106 | linerow 50 107 | jmp line6 108 | ;; 109 | org $F400 110 | line6 111 | linerow 60 112 | jmp line7 113 | ;; 114 | org $F480 115 | line7 116 | linerow 70 117 | jmp line8 118 | ;; 119 | org $F500 120 | line8 121 | linerow 80 122 | jmp line9 123 | ;; 124 | org $F580 125 | line9 126 | linerow 90 127 | jmp lineA 128 | ;; 129 | org $F600 130 | lineA 131 | linerow A0 132 | jmp lineB 133 | ;; 134 | org $F680 135 | lineB 136 | linerow B0 137 | jmp lineC 138 | ;; 139 | org $F700 140 | lineC 141 | linerow C0 142 | jmp lineD 143 | ;; 144 | org $F780 145 | lineD 146 | linerow D0 147 | jmp lineE 148 | ;; 149 | org $F800 150 | lineE 151 | linerow E0 152 | jmp lineF 153 | ;; 154 | org $F880 155 | lineF 156 | linerow F0 157 | 158 | 159 | end_lines 160 | 161 | ; overscan 162 | #if 1 ; NTSC 163 | ldx #(262 - 216) 164 | #else ; PAL 165 | ldx #(312 - 216) 166 | #endif 167 | 168 | jsr wait_lines 169 | 170 | ; vsync 3 171 | lda #2 172 | sta VSYNC 173 | ldx #3 174 | jsr wait_lines 175 | lda #0 176 | sta VSYNC 177 | 178 | ; vblank 37 179 | lda #2 180 | sta VBLANK 181 | ldx #37 182 | jsr wait_lines 183 | lda #0 184 | sta VBLANK 185 | 186 | 187 | jmp line_start 188 | 189 | wait_lines 190 | sta WSYNC 191 | dex 192 | bne wait_lines 193 | rts 194 | 195 | org $FFFA 196 | reset_loop 197 | .word main_start ;NMI 198 | .word main_start ;RESET 199 | .word main_start ;IRQ/BRK 200 | 201 | 202 | -------------------------------------------------------------------------------- /kernel/color_chart/color_chart_ntsc.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lodefmode/moviecart/4ae049122e5a2cf368cd9413f8fba21dab926907/kernel/color_chart/color_chart_ntsc.bin -------------------------------------------------------------------------------- /kernel/color_chart/color_chart_ntsc.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lodefmode/moviecart/4ae049122e5a2cf368cd9413f8fba21dab926907/kernel/color_chart/color_chart_ntsc.png -------------------------------------------------------------------------------- /kernel/color_chart/color_chart_pal.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lodefmode/moviecart/4ae049122e5a2cf368cd9413f8fba21dab926907/kernel/color_chart/color_chart_pal.bin -------------------------------------------------------------------------------- /kernel/color_chart/color_chart_pal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lodefmode/moviecart/4ae049122e5a2cf368cd9413f8fba21dab926907/kernel/color_chart/color_chart_pal.png -------------------------------------------------------------------------------- /kernel/core.asm: -------------------------------------------------------------------------------- 1 | 2 | processor 6502 3 | include vcs.h 4 | 5 | ;user memory 128 to 255 6 | DUMMY equ $80 7 | FIELD equ $81 8 | 9 | GAUDIO equ #0 10 | NUM_LINES equ 8 11 | PREROLL equ 50 12 | 13 | #if 1 ; NTSC 14 | VISIBLE_LINES equ (192 - NUM_LINES*2 - PREROLL + 1) 15 | GCOL0 equ $42 ;red 16 | GCOL5 equ $36 ;orange 17 | GCOL1 equ $EC ;yellow 18 | GCOL6 equ $D8 ;light green 19 | GCOL2 equ $72 ;blue 20 | GCOL7 equ $64 ;purple 21 | GCOL3 equ $B8 ;cyan 22 | GCOL8 equ $6C ;light purple 23 | GCOL4 equ $06 ;dark grey 24 | GCOL9 equ $0A ;light grey 25 | GBKCOLOR equ $02 ;dark grey 26 | 27 | #else ; PAl 28 | 29 | VISIBLE_LINES equ (242 - NUM_LINES*2 - PREROLL + 1) 30 | GCOL0 equ $44 ;red 31 | GCOL5 equ $46 ;orange 32 | GCOL1 equ $2C ;yellow 33 | GCOL6 equ $36 ;green 34 | GCOL2 equ $B2 ;blue 35 | GCOL7 equ $C4 ;purple 36 | 37 | GCOL3 equ $9A ;cyan 38 | GCOL8 equ $AC ;light purple 39 | 40 | GCOL4 equ $F8 ;dark grey 41 | GCOL9 equ $FC ;light grey 42 | GBKCOLOR equ $04 ;dark grey 43 | #endif 44 | 45 | 46 | seg 47 | 48 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 49 | 50 | MAC kernel 51 | 52 | ; right_line 53 | 54 | 55 | lda #{4} ; 2 56 | sta GRP1 ; 3 VDELed 57 | sta HMOVE ; 3 @03 +8 pixel 58 | lda #GAUDIO ; 2 59 | ldx #{10} ; 2 60 | sta AUDV0 ; 3 @10 61 | ldy #GCOL9 ; 2 62 | lda #GCOL6 ; 2 63 | sta COLUP1 ; 3 64 | lda #{2} ; 2 65 | sta GRP0 ; 3 66 | lda #GCOL5 ; 2 67 | sta COLUP0 ; 3 68 | lda #{8} ; 2 69 | sta GRP1 ; 3 VDELed 70 | lda #GBKCOLOR ; 2 71 | sta COLUBK ; 3 background color 72 | lda #GCOL7 ; 2 73 | sta COLUP0 ; 3 @42! end of GRP0a display 74 | lda #{6} ; 2 75 | sta GRP0 ; 3 @47! end of GRP1a display 76 | lda #GCOL8 ; 2 77 | sta COLUP1 ; 3 @52 78 | stx GRP0 ; 3 @55 79 | sty COLUP0 ; 3 @58<=@60 80 | lda #$00 ; 2 turn off background color 81 | sta COLUBK ; 3 background color 82 | sta HMCLR ; 3 83 | 84 | 85 | ; left_line 86 | 87 | lda #$00 ; 2 dummy 88 | lda #{3} ; 2 89 | sta HMOVE ;back 8, late hmove ;needs to be on cycle 71 90 | sta GRP1 ; 3 VDELed 91 | lda #GCOL1 ; 2 92 | sta COLUP1 ; 3 93 | lda #GAUDIO ; 2 94 | sta AUDV0 ; 3 @10 95 | ldx #{9} ; 2 96 | ldy #GCOL4 ; 2 97 | lda #{1} ; 2 98 | sta GRP0 ; 3 99 | lda #GCOL0 ; 2 100 | sta COLUP0 ; 3 101 | lda #{7} ; 2 102 | sta GRP1 ; 3 VDELed 103 | lda #GBKCOLOR ; 2 playfield color 104 | sta COLUPF ; 3 playfield color 105 | lda #GCOL2 ; 2 106 | sta COLUP0 ; 3 @39! end of GRP0a display 107 | lda #{5} ; 2 108 | sta GRP0 ; 3 @44! end of GRP1a display 109 | lda #GCOL3 ; 2 110 | sta COLUP1 ; 3 @49 111 | stx GRP0 ; 3 @52 112 | sty COLUP0 ; 3 @55<=@57 113 | lda #$00 ; 2 turn off playfield 114 | sta COLUPF ; 3 115 | lda #$80 ; 2 116 | sta HMP0 ; 3 117 | sta HMP1 ; 3 @63 118 | 119 | jmp .lineX 120 | .lineX 121 | 122 | ENDM 123 | 124 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 125 | 126 | org $FC00 127 | 128 | main_start 129 | 130 | sei 131 | cld 132 | ldx #$FF 133 | txs 134 | 135 | ;zero memory 136 | lda #0 137 | ClearMem 138 | sta 0,X 139 | dex 140 | bne ClearMem 141 | 142 | lda #1 143 | sta VDELP1 144 | 145 | lda #$CF 146 | sta PF0 147 | lda #$33 148 | sta PF1 149 | lda #$CC 150 | sta PF2 151 | 152 | ldx #$30 ; going into HMP0 later 153 | sta RESP0 154 | nop 155 | sta RESP1 156 | lda #$06 ;3 copies medium 157 | sta NUSIZ0 158 | lda #$02 ;2 copies medium 159 | sta NUSIZ1 160 | 161 | stx HMP0 162 | 163 | lda #$20 164 | sta HMP1 165 | 166 | ; HMOVE needs to be after WSYNC here 167 | sta WSYNC 168 | sta HMOVE 169 | 170 | ldx #12 171 | wait_cnt 172 | dex 173 | bne wait_cnt 174 | 175 | sta HMCLR 176 | nop 177 | nop 178 | 179 | line0 180 | 181 | kernel %01111100, %00110000, %01111100, %01111100, %00011100, %11111110, %01111100, %11111110, %01111100, %01111100 182 | kernel %10000110, %01010000, %10000010, %10000010, %00100100, %10000000, %10000010, %00000010, %10000010, %10000010 183 | kernel %10001010, %10010000, %00000100, %00000100, %01000100, %10000000, %10000000, %00000100, %10000010, %10000001 184 | kernel %10010010, %00010000, %00011000, %00111000, %10000100, %01111100, %11111100, %00001000, %01111100, %10000011 185 | kernel %10100010, %00010000, %01100000, %00000100, %11111110, %00000010, %10000010, %00010000, %10000010, %01111101 186 | kernel %11000010, %00010000, %11000000, %10000010, %00000100, %10000010, %10000010, %00100000, %10000010, %00000001 187 | kernel %01111100, %11111110, %11111110, %01111100, %00000100, %01111100, %01111100, %01000000, %01111100, %11111110 188 | 189 | end_lines 190 | 191 | ;clear 192 | lda #0 193 | sta GRP0 194 | sta GRP1 195 | sta GRP0 196 | 197 | ldx #VISIBLE_LINES 198 | jsr wait_lines 199 | 200 | 201 | inc FIELD 202 | lda FIELD 203 | lsr 204 | bcc .start_odd 205 | 206 | .start_even 207 | 208 | ldx #29 ; overscan 209 | ldy #PREROLL 210 | jmp .start3 211 | 212 | .start_odd 213 | 214 | ldx #30 ; overscan 215 | ldy #(PREROLL+1) 216 | 217 | .start3 218 | 219 | jsr wait_lines 220 | 221 | ; vsync 3 222 | lda #2 223 | sta VSYNC 224 | ldx #3 225 | jsr wait_lines 226 | lda #0 227 | sta VSYNC 228 | 229 | ; vblank 37 230 | lda #2 231 | sta VBLANK 232 | ldx #37 233 | jsr wait_lines 234 | lda #0 235 | sta VBLANK 236 | 237 | ; preroll 238 | tya 239 | tax 240 | jsr wait_lines 241 | 242 | 243 | ;; wait... 244 | 245 | lda #0 246 | sta DUMMY 247 | sta DUMMY 248 | sta DUMMY 249 | sta DUMMY 250 | 251 | ldx #7 252 | busy_wait 253 | dex 254 | bne busy_wait 255 | 256 | sta DUMMY 257 | sta DUMMY 258 | nop 259 | 260 | jmp line0 261 | 262 | wait_lines 263 | sta WSYNC 264 | dex 265 | bne wait_lines 266 | rts 267 | 268 | 269 | org $FFFA 270 | reset_loop 271 | .word main_start ;NMI 272 | .word main_start ;RESET 273 | .word main_start ;IRQ/BRK 274 | 275 | 276 | -------------------------------------------------------------------------------- /kernel/movie_ntsc.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lodefmode/moviecart/4ae049122e5a2cf368cd9413f8fba21dab926907/kernel/movie_ntsc.bin -------------------------------------------------------------------------------- /kernel/movie_ntsc.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lodefmode/moviecart/4ae049122e5a2cf368cd9413f8fba21dab926907/kernel/movie_ntsc.png -------------------------------------------------------------------------------- /kernel/movie_pal.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lodefmode/moviecart/4ae049122e5a2cf368cd9413f8fba21dab926907/kernel/movie_pal.bin -------------------------------------------------------------------------------- /kernel/movie_pal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lodefmode/moviecart/4ae049122e5a2cf368cd9413f8fba21dab926907/kernel/movie_pal.png -------------------------------------------------------------------------------- /label/.gitignore: -------------------------------------------------------------------------------- 1 | Backup 2 | label.* 3 | -------------------------------------------------------------------------------- /label/label.toe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lodefmode/moviecart/4ae049122e5a2cf368cd9413f8fba21dab926907/label/label.toe -------------------------------------------------------------------------------- /label/resources/MUMBSB__.TTF: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lodefmode/moviecart/4ae049122e5a2cf368cd9413f8fba21dab926907/label/resources/MUMBSB__.TTF -------------------------------------------------------------------------------- /label/resources/atari-eps-vector-logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lodefmode/moviecart/4ae049122e5a2cf368cd9413f8fba21dab926907/label/resources/atari-eps-vector-logo.png -------------------------------------------------------------------------------- /label/resources/combat_reference.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lodefmode/moviecart/4ae049122e5a2cf368cd9413f8fba21dab926907/label/resources/combat_reference.jpg -------------------------------------------------------------------------------- /output/colorizer/OSX/ColorizeTOP.plugin/Contents/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | BuildMachineOSBuild 6 | 22G91 7 | CFBundleDevelopmentRegion 8 | en 9 | CFBundleExecutable 10 | ColorizeTOP 11 | CFBundleIdentifier 12 | ca.derivative.cpp.ColorizeTOP 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | ColorizeTOP 17 | CFBundlePackageType 18 | BNDL 19 | CFBundleShortVersionString 20 | 1.0 21 | CFBundleSupportedPlatforms 22 | 23 | MacOSX 24 | 25 | CFBundleVersion 26 | 1 27 | DTCompiler 28 | com.apple.compilers.llvm.clang.1_0 29 | DTPlatformBuild 30 | 14B47b 31 | DTPlatformName 32 | macosx 33 | DTPlatformVersion 34 | 13.0 35 | DTSDKBuild 36 | 22A372 37 | DTSDKName 38 | macosx13.0 39 | DTXcode 40 | 1410 41 | DTXcodeBuild 42 | 14B47b 43 | LSMinimumSystemVersion 44 | 10.13 45 | NSHumanReadableCopyright 46 | Copyright © 2022 Derivative. All rights reserved. 47 | 48 | 49 | -------------------------------------------------------------------------------- /output/colorizer/OSX/ColorizeTOP.plugin/Contents/MacOS/ColorizeTOP: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lodefmode/moviecart/4ae049122e5a2cf368cd9413f8fba21dab926907/output/colorizer/OSX/ColorizeTOP.plugin/Contents/MacOS/ColorizeTOP -------------------------------------------------------------------------------- /output/colorizer/OSX/ColorizeTOP.plugin/Contents/_CodeSignature/CodeResources: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | files 6 | 7 | files2 8 | 9 | rules 10 | 11 | ^Resources/ 12 | 13 | ^Resources/.*\.lproj/ 14 | 15 | optional 16 | 17 | weight 18 | 1000 19 | 20 | ^Resources/.*\.lproj/locversion.plist$ 21 | 22 | omit 23 | 24 | weight 25 | 1100 26 | 27 | ^Resources/Base\.lproj/ 28 | 29 | weight 30 | 1010 31 | 32 | ^version.plist$ 33 | 34 | 35 | rules2 36 | 37 | .*\.dSYM($|/) 38 | 39 | weight 40 | 11 41 | 42 | ^(.*/)?\.DS_Store$ 43 | 44 | omit 45 | 46 | weight 47 | 2000 48 | 49 | ^(Frameworks|SharedFrameworks|PlugIns|Plug-ins|XPCServices|Helpers|MacOS|Library/(Automator|Spotlight|LoginItems))/ 50 | 51 | nested 52 | 53 | weight 54 | 10 55 | 56 | ^.* 57 | 58 | ^Info\.plist$ 59 | 60 | omit 61 | 62 | weight 63 | 20 64 | 65 | ^PkgInfo$ 66 | 67 | omit 68 | 69 | weight 70 | 20 71 | 72 | ^Resources/ 73 | 74 | weight 75 | 20 76 | 77 | ^Resources/.*\.lproj/ 78 | 79 | optional 80 | 81 | weight 82 | 1000 83 | 84 | ^Resources/.*\.lproj/locversion.plist$ 85 | 86 | omit 87 | 88 | weight 89 | 1100 90 | 91 | ^Resources/Base\.lproj/ 92 | 93 | weight 94 | 1010 95 | 96 | ^[^/]+$ 97 | 98 | nested 99 | 100 | weight 101 | 10 102 | 103 | ^embedded\.provisionprofile$ 104 | 105 | weight 106 | 20 107 | 108 | ^version\.plist$ 109 | 110 | weight 111 | 20 112 | 113 | 114 | 115 | 116 | -------------------------------------------------------------------------------- /output/colorizer/WIN64/ColorizeTOP.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lodefmode/moviecart/4ae049122e5a2cf368cd9413f8fba21dab926907/output/colorizer/WIN64/ColorizeTOP.dll -------------------------------------------------------------------------------- /release_notes.txt: -------------------------------------------------------------------------------- 1 | # 2 | # MovieCart Version 2 3 | # 4 | # Rob Bairos 5 | # 6 | 7 | Main improvements: 8 | 9 | - Replaced bulky expensive obsolete through-hole IC's with modern SMD components 10 | which can be fully created by PCB assembly houses. 11 | 12 | - Drop in compatible with Combat cartridges. No cutting / drilling / gluing required. 13 | 14 | - Micro SD Card uses standard FAT file format, so standard copy / drag-n-drop of files works. 15 | No longer requires separate utility to prepare card and playback no longer experiences 16 | random noise. 17 | 18 | - Supports both NTSC and PAL formats. 19 | 20 | - Enhanced video quality utilizing TIA background and playfield colors. 21 | 22 | - Enhanced audio encoding that utilizes error diffusion which introduces constant hiss, but 23 | eliminates random drop outs and distortion during low volume. 24 | 25 | - Encoding utility redesigned with more features including re-takes. 26 | 27 | - Encoding utility GPU accelerated. Speed increase of 2x to 20x depending on video card from previous encoder. 28 | 2 hour movie can be encoded in 30 minutes to 1 hour, instead of a full day. 29 | 30 | - Reliable startup, as boot time is now 0.58 msec from powerup. 31 | (Flashback 2 starts reading from the cart in 1.52 msec, while Atari 2600 around 25 msec). 32 | 33 | 34 | # 35 | # Acknowledgements 36 | # 37 | 38 | Many thanks to the members of AtariAge for expert advise in kernel development, hardware considerations, user interface and general knowledge. 39 | 40 | Andrew Davie 41 | ZackAttack 42 | JetSetIlly 43 | Thomas Jentzch 44 | Shawn 45 | DirtyHairy 46 | Marco J 47 | ZeroPage Homebrew 48 | -^CrossBow^- 49 | swlovinist 50 | TPR 51 | SuperZapperRecharge 52 | Omegamatrix 53 | SpiceWare 54 | 55 | 56 | and many more. 57 | 58 | 59 | Night of the Living Dead 60 | Directed by 61 | George A. Romero 62 | Screenplay by 63 | John Russo 64 | George A. Romero 65 | Produced by 66 | Russell W. Streiner 67 | Karl Hardman 68 | Starring 69 | Judith O'Dea 70 | Duane Jones 71 | Marilyn Eastman 72 | Karl Hardman 73 | Judith Ridley 74 | Keith Wayne 75 | Distributed by Contential Distributing 76 | Released October 1 1968 (Pittburgh, Pennsylvania) 77 | 78 | 79 | Colorized with De-Oldify python library: 80 | MIT License 81 | Copyright (c) 2018 Jason Antic 82 | 83 | 84 | Busy Street Demo: 85 | colorize/test/street.mp4 86 | https://www.pexels.com/video/people-walking-by-on-a-sidewalk-854100/ 87 | 88 | 89 | -------------------------------------------------------------------------------- /utils/expand_bin: -------------------------------------------------------------------------------- 1 | #!/bin/tcsh 2 | 3 | # Convert input to c-style unsigned character array 4 | 5 | set output = "$1:r_data.h" 6 | 7 | rm -rf $output 8 | 9 | echo "//Automatically generated from executing: csh " $0 >> $output 10 | echo >> $output 11 | echo "const unsigned char "$1:r"_data[] = {" >> $output 12 | 13 | foreach f ($1) 14 | echo Converting $f 15 | hexdump -v -e '16/1 "%d, " "\n"' $f >> $output 16 | end 17 | 18 | #trailing null 19 | echo "};" >> $output 20 | -------------------------------------------------------------------------------- /utils/last_timecode: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # last 4k 4 | # last 4 bytes of first characters 5 | 6 | # last_timecode street.mvc 7 | # hh mm ss ff 8 | 9 | tail -c 4096 $1 | head -c 9 | tail -c 4 | hexdump -C | cut -d ' ' -f 2-6 | head -1 10 | 11 | -------------------------------------------------------------------------------- /utils/title.mvc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lodefmode/moviecart/4ae049122e5a2cf368cd9413f8fba21dab926907/utils/title.mvc --------------------------------------------------------------------------------