Skip to content

Instantly share code, notes, and snippets.

@hansfbaier
hansfbaier / get_top200_pico8_games.sh
Last active June 4, 2024 01:32
Automatically download the TOP 200 Pico8 game cartridges
#!/bin/bash
wget https://nerdyteachers.com/PICO-8/Games/Top200/?d=list -O top200.html
grep bbs top200.html | grep pid | fgrep '/a' | cut -d\" -f6 > urls.txt
grep bbs top200.html | grep pid | fgrep '/a' | cut -d\> -f2 | cut -d\< -f1 > titles.txt
tr -d "\!.':" < titles.txt | tr " " "_" | sed 's/$/.html/' > fnames.txt
exec 6<"fnames.txt"
exec 7<"urls.txt"
while read -r url <&7
do
@hansfbaier
hansfbaier / adv7513-status.py
Last active February 23, 2024 23:44
ADV7513 status display tool in python
#!/usr/bin/env python
from smbus import SMBus
def byte(addr):
return bus.read_byte_data(0x39, addr)
def bit(addr, n):
d = bus.read_byte_data(0x39, addr)
return (d >> n) & 0x1
@hansfbaier
hansfbaier / syscalls.c
Created August 12, 2022 21:00
How to compile CH56x applications without the vendor toolchain, using a stock embedded riscv toolchain
/****************************************************************************
* Copyright (c) 2009 by Michael Fischer. All rights reserved.
* Copyright (c) 2022 by Hans Baier
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
@hansfbaier
hansfbaier / xc7k420t_constraints.xdc
Last active May 14, 2022 14:08
XC7K420T DDR constraint file
#NET "clk" LOC = U24;
#NET "clk" IOSTANDARD = LVCMOS25;
#set_property SLEW FAST [get_ports {clk}]
set_property IOSTANDARD LVCMOS25 [get_ports clk]
set_property PACKAGE_PIN U24 [get_ports clk]
#NET "led" LOC = A27;
#NET "led" IOSTANDARD = LVCMOS15;
@hansfbaier
hansfbaier / gist:b75252a5d73a9789478a7b2ae1066516
Created April 5, 2022 20:49
Attempt to put CH569 into debug mode
#!/usr/bin/env python3
import sys
import usb.core
import usb.util
from time import sleep
# find our device
dev = usb.core.find(idVendor=0x4348, idProduct=0x55e0)
if not dev:
print("Could not find device!")
@hansfbaier
hansfbaier / pll-calc.py
Last active July 8, 2021 05:15
Using constraint solver for calculating optimal PLL parameters
#!/usr/bin/env python3
# from the python-constraint package
import constraint
from pprint import pprint
# All frequencies in MHz
platform = 'xilinx-mmcm'
fin = 50
fout = 12.288