Skip to content

Instantly share code, notes, and snippets.

@peisenhower
peisenhower / COUNTOF.h
Created October 29, 2013 17:27
COUNTOF
#define COUNTOF(x) (sizeof(x)/sizeof(x[0]))
@peisenhower
peisenhower / xxd.py
Last active August 29, 2015 14:10
xxd written in python for windows. Need to install IntelHex first.
#!/usr/bin/env python
from argparse import ArgumentParser
from intelhex import IntelHex
import os
def xxd(in_path, out_path, offset=0):
"""convert binary to hex"""
@peisenhower
peisenhower / source-template.c
Last active August 18, 2022 16:54
C source file template. Code groupings and doxygen header.
/**
* @file [file name].c
* @copyright [copy write holder]
*
* @brief [description]
*/
/*******************************************************************************
* Includes
*******************************************************************************/
@peisenhower
peisenhower / header-template.h
Created January 21, 2015 19:07
C header template with doxygen
/**
* @file [file name].h
* @authors [Author]
* @copyright [Copyright holder]
*
* @brief [description]
*/
#pragma once
@peisenhower
peisenhower / coding-standard.md
Last active July 30, 2018 18:31
My personal short coding standard for embedded c code

Coding Standard

General

  • lower underscore function names
    • void my_function_name(void)
  • Lower camel case variables
    • int myVariable = 10
  • Lower case underscore structs and enums custom types ending in _t
@peisenhower
peisenhower / gist:70b23be1bada54f1c1b1
Created May 1, 2015 18:47
Generate a hex file of sequential bytes
from intelhex import IntelHex
import struct
h = IntelHex()
for x in range(16535):
h.puts(x, struct.pack("B", x & 0xFF))
h.tofile("sequence.hex", "hex")
#!/usr/bin/env python
# python 3
from serial import Serial
import time
import argparse
import re
from threading import Thread
@peisenhower
peisenhower / plumbus-heat-step.py
Created April 11, 2017 21:12
Plumbus Heat Step
#!/usr/bin/env python
# python 3
from serial import Serial
import time
import argparse
from threading import Thread
class Command():
@peisenhower
peisenhower / view.py
Created April 19, 2017 20:42
Matplotlib plotter for json files generated by jack
import matplotlib.pyplot as plt
from numpy import loadtxt
import numpy as np
import pprint
import argparse
import json
from collections import namedtuple
pp = pprint.PrettyPrinter(indent=4)
@peisenhower
peisenhower / calibration.py
Last active May 1, 2017 13:50
Three9 Calibration Code in Python
import matplotlib.pyplot as plt
import numpy as np
import scipy.io as sio
import scipy.signal as ssi
import peakutils
import pprint as pp
import itertools
import argparse