Skip to content

Instantly share code, notes, and snippets.

View JayKickliter's full-sized avatar
💭
Cache Rules Everything Around Me

Jay Kickliter JayKickliter

💭
Cache Rules Everything Around Me
View GitHub Profile
@JayKickliter
JayKickliter / tickless.c
Created January 16, 2020 22:53
FreeRTOS tickless idle with STM32 LPTIM
#include <assert.h>
#include <stdbool.h>
#include <stdint.h>
#include "system_config_lptim.h"
#include "system_config_power.h"
#include "system_config_irq.h"
#include "FreeRTOS.h"
#include "FreeRTOSConfig.h"
@JayKickliter
JayKickliter / bitacc.rs
Last active November 22, 2019 22:18
Bit accumulator in Rust
#![feature(const_generics)]
use num::{PrimInt, Zero};
#[derive(Default)]
struct BitAcc<T: Default, const N: u8> {
acc: T,
n: u8,
}
@JayKickliter
JayKickliter / interlaced_ntsc.v
Last active December 2, 2023 13:32
NTSC in Verilog
module interlaced_ntsc (
input wire clk,
input wire [2:0] pixel_data, // 0 ( black )..5 (bright white)
output wire h_sync_out, // single clock tick indicating pixel_y will incrememt on next clock ( for debugging )
output wire v_sync_out, // single clock tick indicating pixel_y will reset to 0 or 1 on next clock, depending on the field ( for debugging )
output wire [9:0] pixel_y, // which line
output wire [9:0] pixel_x,
output wire pixel_is_visible,
output reg [2:0] ntsc_out
@JayKickliter
JayKickliter / building-ti-opencl-from-source.md
Last active January 12, 2019 01:04
Compiling TI OpenCL and dependencies from source

Compiling TI OpenCL and dependencies from source

In the following instructions, keep in mind that I'm using an install prefix of ~/ti as a placeholder while I attempt to bring on OpenCL by hand. That, and some other paths will be replaced with Buildroot-specific install directories later on.

Install host binaries

C66x DSP compiler

@JayKickliter
JayKickliter / hdb.rs
Last active April 14, 2020 20:24
Parse from hex, decimal, or binary
trait FromHexDecBin: Sized {
type Error;
fn from_hex_dec_bin(s: &str) -> Result<Self, Self::Error>;
}
macro_rules! impl_from_hex_dec_bin {
($T:tt, $E:ty) => {
impl FromHexDecBin for $T {
type Error = $E;
fn from_hex_dec_bin(s: &str) -> Result<$T, Self::Error> {
@JayKickliter
JayKickliter / main.rs
Last active June 19, 2018 00:20
Runtime debugging Tock apps
pub unsafe fn reset_handler() {
// Lots of stuff
for (proc_num, proc_) in PROCESSES.as_ref().iter().enumerate() {
match proc_ {
Some(p) => {
load_process_hook(proc_num as u32, p.package_name, p.flash_non_protected_start() as u32)
},
None => (),
}
}
@JayKickliter
JayKickliter / fosphor_cmdline_client_ci16.diff
Created May 14, 2018 19:17
fosphor command-line app to read complex i16 samples from stdin
diff --git a/lib/fosphor/Makefile b/lib/fosphor/Makefile
index a8fb3bb..07af0e6 100644
--- a/lib/fosphor/Makefile
+++ b/lib/fosphor/Makefile
@@ -1,6 +1,6 @@
UNAME=$(shell uname)
CC=gcc
-CFLAGS=-Wall -Werror -O2 `pkg-config freetype2 glfw3 --cflags` -g
+CFLAGS=-Wall -O2 `pkg-config freetype2 glfw3 --cflags` -g
LDLIBS=`pkg-config freetype2 glfw3 --libs` -lm
# $(CURRENT_DIR) contains the location of this makefile
CURRENT_DIR := $(shell dirname $(abspath $(lastword $(MAKEFILE_LIST))))
@JayKickliter
JayKickliter / compdb.mk
Created February 28, 2018 21:26
Generate 'compile_commands.json' in Makefile
%.compdb_entry: %.c
@echo " {" > $@
@echo " \"command\": \"cc $(CFLAGS) $(CPPFLAGS) -c $<\"," >> $@
@echo " \"directory\": \"$(CURDIR)\"," >> $@
@echo " \"file\": \"$<\"" >> $@
@echo " }," >> $@
COMPDB_ENTRIES = $(addsuffix .compdb_entry, $(basename $(SOURCES)))
compile_commands.json: $(COMPDB_ENTRIES)
@JayKickliter
JayKickliter / tock_ffi_example.md
Last active September 13, 2017 18:27
Generating Tock userland header from rust source

Common rust source for both rust driver and userland code.

use core::intrinsics::transmute;

#[repr(C)]
#[derive(Debug, Clone, Copy)]
pub enum Partnum {
    CC1121,
    CC1120,