Skip to content

Instantly share code, notes, and snippets.

@njtbot
njtbot / gist:6c97ca459a7eb9f40fa1
Last active August 29, 2015 14:02
STM32 on OSX Redux

Prerequisites

  • OSX
  • STLink v2

Installation

  • If you don't use homebrew, blindly type this into your terminal -
@njtbot
njtbot / gist:10990105
Created April 17, 2014 15:01
Better git log (usage - git lg)
git config --global alias.lg "log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit"
@njtbot
njtbot / gist:9758296
Created March 25, 2014 09:48
STM32 toolchain for OSX
# gcc-4.8
ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"
brew install openocd
openocd --version # homebrew release of openocd supports most jtag adapters (ie stlink2)
wget "https://launchpad.net/gcc-arm-embedded/4.8/4.8-2013-q4-major/+download/gcc-arm-none-eabi-4_8-2013q4-20131218-mac.tar.bz2"
cd ~/Downloads
tar -xzvf gcc-arm-none-eabi-4_8-2013q4-20131218-mac.tar.bz2
sudo cp -R gcc-arm-none-eabi-4_8-2013q4 /usr/local/
/usr/local/gcc-arm-none-eabi-4_8-2013q4/bin/arm-none-eabi-gcc --version # test
@njtbot
njtbot / roundingScheme.c
Created September 30, 2013 14:56
Basic rounding scheme to avoid sampling/rounding errors. From PIC24 but pseudo-code enough to be ported.
void SampleADC() {
/* Wait till interrupt says samples are ready */
while (!AD1CON1bits.DONE);
/* Assign buffer values to temp variables for processing */
tempPot = ADC1BUF0;
/* Set threshold values to avoid fluctuating rounding errors */
int potThresh = 25;
@njtbot
njtbot / ADAU1701_InterfaceWrite.c
Last active December 24, 2015 07:19
Example interface register write routine for Analog Devices ADAU1701 DSP in C.
/* Volume levels */
const int dspVolume[] = {
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x01,
0x00, 0x00, 0x00, 0x02,
0x00, 0x00, 0x00, 0x03,
0x00, 0x00, 0x00, 0x04,
0x00, 0x00, 0x00, 0x05,
0x00, 0x00, 0x00, 0x06,