Skip to content

Instantly share code, notes, and snippets.

@jcw
jcw / meminfo.cpp
Last active Jul 29, 2021
Show info about the Teensy 4.0/4.1 memory areas
View meminfo.cpp
#define printf Serial.printf
void memInfo () {
constexpr auto RAM_BASE = 0x2020'0000;
constexpr auto RAM_SIZE = 512 << 10;
constexpr auto FLASH_BASE = 0x6000'0000;
#if ARDUINO_TEENSY40
constexpr auto FLASH_SIZE = 2 << 20;
#elif ARDUINO_TEENSY41
constexpr auto FLASH_SIZE = 8 << 20;
@jcw
jcw / jet-mm4.c
Created Dec 4, 2017
JET memory manager
View jet-mm4.c
// Simple chunked memory manager with mark/sweep garbage collection.
// Main code parses text files given as cmdline args as quick test.
// -jcw, 2017-12-01
#include <assert.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@jcw
jcw / mister-rsrc.md
Last active Nov 10, 2017
MiSTer FPGA project resource use
View mister-rsrc.md

MiSTer Resources

Core B-RAM SDRAM DDR3 Video 2nd SD ALMs
a-pacman 29K - - ? no 3K
ao486 270K - 256M 640x480 no 31K
apple-ii 236K - - ? no 5K
c64 106K - - ? no 5K
fpgagen 120K - - ? no 9K
macplus 33K 4096K - 512x342 no 5K
View asm.py
# MCPU assembler, see https://github.com/cpldcpu/MCPU
# python asm.py <test.asm >test.obj
from __future__ import print_function
import sys
def valof(arg):
if arg in syms:
arg = syms[arg]
try:
@jcw
jcw / burn.sh
Created Mar 7, 2017
OpenOCD setup on Raspberry Pi
View burn.sh
#!/bin/sh
# Upload to attached µC via SWD.
case "$2" in
"") echo "need target type (f1x/l0) and name of image to burn as args"
exit 1 ;;
esac
TARGET=$1 IMAGE=$2 /usr/local/bin/openocd
@jcw
jcw / core.cljs
Last active Jan 28, 2017
LCD mockup
View core.cljs
(ns cljs7.core
(:require [reagent.core :as reagent :refer [atom]]))
(defonce app-state (atom {:text "Display viewer"}))
(defn dark? [i]
(even? (bit-xor (quot i 128) (mod i 128))))
(defn hello-world []
[:div
@jcw
jcw / tvsync.fs
Created Sep 8, 2016
TVout test on an ARM µC w/ Forth
View tvsync.fs
\ these routines generate a PAL composite video for display on a TV or monitor
\ timing is not 100% standard, and non-interlaced to avoid single-line flicker
\ requires a 470 Ω resistor on PA2 and a 1 kΩ on PA3, combined at the RCA jack
\ -jcw, 2016-09-04
reset
\ alternate version, this works without system tick interrupts
: us2 ( n -- ) \ microsecond delay using a busy loop, this won't switch tasks
72 * 100 - >r $E000E018 @ begin
@jcw
jcw / spi2vga.v
Created Sep 8, 2016
Some SPI peek tests
View spi2vga.v
//`define LOOPBACK_TEST // loop ucMOSI back to ucMISO
//`define SDPASS_TEST // connect uc* to sd*
//`define DISPLAY_TEST // connect SpiPeek to 7-segment display
`define NUMBER_TEST // connect to 7-seg display via decoder & mux
//`define BRAM_TEST // SpiPeek access to internal BRAM
module spi2fpga (
input clk50,
// act as slave w.r.t microcontroller
input ucSEL_,
@jcw
jcw / vga.v
Last active Aug 1, 2016
VGA 640x480 test pattern generator
View vga.v
// Adapted from: www.TinyVGA.com
module vga(
input clk, // 50 MHz
output [2:0] red,
output [2:0] green,
output [1:0] blue,
output hsync, vsync
);
@jcw
jcw / vga.fs
Created Jul 21, 2016
VGA test with minimal hardware and code
View vga.fs
\ -----------------------------------------------------------------------------
\ VGA signal generator for Nandland Go board
\ GPL3, Matthias Koch, Summer 2016
\ Colourful bitmap demo
\ -----------------------------------------------------------------------------
\ Pin constants
512 constant HSYNC
1024 constant VSYNC