Skip to content

Instantly share code, notes, and snippets.

@RickKimball
RickKimball / nco.cpp
Last active March 11, 2024 14:01
NCO c++ template
// vim: set ts=2 sw=2 expandtab list
/*
* File: nco.cpp
* Description: NCO c++ template and testdriver
*
* Author: rick kimball
*
* g++ -DDEBUG -Wall -Os -g nco.cpp -o nco
*/
@RickKimball
RickKimball / print_64t.ino
Last active October 17, 2017 00:38
arduino int64_t streaming serial print example
// sketch_oct16a
// printll provides printing for int64_t uint64_t types using Streaming..
// Rick Kimball
#include "Streaming.h"
char * _print_base(char *buf, uint64_t n, int base) {
char *str = &buf[(64+1) - 1]; // handle printing bits
*str = '\0'; // work from least significant digit to most
@RickKimball
RickKimball / Makefile
Last active January 28, 2018 22:07
stm32duino Makefile for adding custom boards.
# STM32F1/Makefile - provide a way to use a custom boards.txt
#
#
.phony: all checkout clean
all: boards.txt
checkout:
git checkout boards.txt
boards.txt:
#!/bin/bash
# read the w1-temp values
# put each line1 and 2 into variables
# parse and see if it is ready
# if so read the raw value and round it to 2 decimals
read_sensor()
{
SENSOR_FILE=$1
local __celsius_raw=$2
@RickKimball
RickKimball / 60Hz.cpp
Last active November 28, 2016 19:19
msp430fr5969 - 60Hz Sine Wave using PWM
/*
* 60Hz.c - generate a 60Hz PWM sine wave msp430frxxxx
*
* This code written for msp430-elf-gcc
*
* Note: make sure to compile with -ffixed-R6 -ffixed-R7.
*/
#include <msp430.h>
#include <inttypes.h>
#include "ringbuffer_e.h"
#include "streaming.h"
uint8_t buffer[32];
ring_buffer message_buffer = { buffer, 0, 0, sizeof(buffer) };
void queue_message(const char *str) {
while (*str) {
GPIOC_BASE->BRR = (1 << 13); // time function using gpio toggle
#include "libmaple/ring_buffer.h"
#include "streaming.h"
uint8_t buffer[32];
ring_buffer message_buffer = { buffer, 0, 0, 32 - 1 };
void queue_message(const char *str) {
while (*str) {
GPIOC_BASE->BRR = (1 << 13); // time function using gpio toggle
/*
ringbuffer.h - fabooh version of the ringbuffer_t c++ template
Desc: A c++ template class implementing a lock free fixed sized ringbuffer
with arbitrary types. The push and pop methods implement adding and
removing items. The size and capacity methods return the unread
and max number of items in the buffer.
This version has been optimized for embedded single core 32 bit
mcus. It doesn't disable or enable any interrupts. It is safe
This file has been truncated, but you can view the full file.
@RickKimball
RickKimball / Makefile
Last active March 22, 2016 20:22
tiny preemptive msp430 tasker from Tony Philipsson ported to msp430-gcc
#--------------------------------------------------------------------
# Makefile - for tiny msp430 preemptive kernel
TARGET = tinyos.elf
# point this to where your CCS is installed
CCS_PATH =? $(HOME)/ti/ccsv6
#ARCH ?= msp430-elf-
ARCH ?= msp430-