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 / diskio.h
Created April 7, 2012 04:29
msp430 Petit FatFile System sample
/*-----------------------------------------------------------------------
/ PFF - Low level disk interface modlue include file (C)ChaN, 2009
/-----------------------------------------------------------------------*/
#ifndef _DISKIO
#include "integer.h"
/* Status of Disk Functions */
typedef BYTE DSTATUS;
@RickKimball
RickKimball / main.c
Last active September 4, 2020 00:51
msp430g2553 simple USCI UART print
/*
* main.c - really simple USCI hardware UART code
*/
#include <msp430.h>
#include <stdint.h>
#include <stdio.h>
#if !defined(__MSP430_HAS_USCI__)
#error "This code written for the msp430g2553"
@RickKimball
RickKimball / gpioblnk.ino
Last active July 24, 2019 07:33
c++ template blink using register level gpio access
// more fun with c++ classes and templates
// http://www.stm32duino.com/viewtopic.php?f=18&t=303
class GPIOPort :
public gpio_reg_map {
public:
void high(const uint32_t pin) {
BSRR = 1 << pin;
}
void low(const uint32_t pin) {
BRR = 1 << pin;
@RickKimball
RickKimball / lpc1114.cfg
Last active July 16, 2019 03:48
configuration files for lpc812 using SWD from an stlink-v2 discovery board
#-----------------------------------------
# NXP lpc1114fn23 Cortex-M0 32k flash, 4k ram
set CHIPNAME lpc1114
set CPUTAPID 0x0BB11477
set CPUROMSIZE 0x8000
set CPURAMSIZE 0x1000
# After reset the chip is clocked by the ~12MHz internal RC oscillator.
# When board-specific code (reset-init handler or device firmware)
@RickKimball
RickKimball / deploy.sh
Created March 11, 2019 19:29
compile PRU_gpioToggle and load it into pru using remoteproc
#! /bin/bash
##############################################################################
#
# Copyright (C) 2016 Zubeen Tolani <ZeekHuge - zeekhuge@gmail.com>
#
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
@RickKimball
RickKimball / rt.cpp
Last active February 26, 2019 19:07
raspberry pi 2 toggle using gpiomem
#include <stdio.h>#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <fcntl.h>
#include <sys/mman.h>
#include <errno.h>
#include <stdint.h>
#include <string.h>
#include <unistd.h>
#include <sched.h>
@RickKimball
RickKimball / readme.md
Last active November 26, 2018 09:34
ws281x driver using DMA and MSP430F5529 (tested on ws2811 and ws2812b aka neo pixels)

This code is used to drive a ws281x strip using SPI driven by DMA on an msp430f5529.

#pragma once
struct _HEXZ {
unsigned value;
unsigned len;
_HEXZ(int i, int l = 2): value(i), len(l) {}
};
inline Print &operator <<(Print &obj, const _HEXZ &arg) {
if ( arg.len > 1 && arg.value < 0x10 ) obj.print('0');
/*
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