Skip to content

Instantly share code, notes, and snippets.

View chronopoulos's full-sized avatar

Chris Chronopoulos chronopoulos

View GitHub Profile
@chronopoulos
chronopoulos / readHarp.py
Created June 29, 2021 19:09
read the R_WHO_AM_I register from a Harp device
#!/usr/bin/python3 -u
import serial
import struct
import sys
# set up the serial device
if len(sys.argv) > 1:
deviceFile = sys.argv[1]
@chronopoulos
chronopoulos / tc358743-overlay.dts
Last active December 8, 2023 15:57
tc358743-overlay.dts
/dts-v1/;
/plugin/;
/{
compatible = "rockchip,rockpi","rockchip,rk3399";
fragment@0 {
target = <&i2c4>;
__overlay__ {
@chronopoulos
chronopoulos / i2c_test_stm32l1.c
Created August 2, 2020 00:50
testing I2C on the STM32L1 using libopencm3
#include <stdio.h>
#include <libopencm3/stm32/rcc.h>
#include <libopencm3/stm32/gpio.h>
#include <libopencm3/stm32/usart.h>
#include <libopencm3/stm32/i2c.h>
static void clock_setup(void) {
rcc_clock_setup_hsi(&rcc_clock_config[2]); // 16mhz hsi raw
@chronopoulos
chronopoulos / mikroe-506_working.c
Last active July 3, 2021 08:04
ASoC driver for MikroElektronika 506 (playback and capture work now)
/*
* ASoC driver for MikroElectronika 506 (wm8731 proto board)
* connected to a RockPi 4
*
* Author: Chris Chronopoulos, <chronopoulos.chris@gmail.com>
* Copyright 2020
* Based on rpi-proto.c by Florian Meier
*
* This program is free software; you can redistribute it and/or modify
@chronopoulos
chronopoulos / simple-wm8731-overlay.dts
Created May 31, 2020 23:05
"simple-audio-card"-based overlay for the WM8731 on RockPi 4
// simple-wm8731-overlay.dts
/dts-v1/;
/plugin/;
/ {
compatible = "rockchip,rockpi","rockchip,rk3399";
fragment@0 {
target = <&i2s1>;
@chronopoulos
chronopoulos / mikroe-506.c
Created May 31, 2020 22:30
ASoC driver for MikroElectronika 506 (wm8731 proto board)
/*
* ASoC driver for MikroElectronika 506 (wm8731 proto board)
* connected to a RockPi 4
*
* Author: Chris Chronopoulos, <chronopoulos.chris@gmail.com>
* Copyright 2020
* Based on rpi-proto.c by Florian Meier
*
* This program is free software; you can redistribute it and/or modify
@chronopoulos
chronopoulos / rockpi-mikroe-506-overlay.dts
Created May 31, 2020 21:39
"rpi-proto"-based overlay for the MikroElektronika 506 WM8731 dev board on the RockPi 4
// rockpi-mikroe-506-overlay.dts
/dts-v1/;
/plugin/;
/ {
compatible = "rockchip,rockpi","rockchip,rk3399";
fragment@0 {
target = <&i2s1>;
@chronopoulos
chronopoulos / separate_data_aux.py
Last active August 29, 2015 13:56
Python script to separate the channel data from the auxiliary data in the HDF5 files.
ns = 30000 # number of samples
f = h5py.File('/home/chrono/sng/data/take5.h5')
dset = f['wired-dataset'] # this has length 30000, where each element is a non-rectangular tuple
data = np.zeros((1024,ns), dtype='int16') # 1024 channels at 30 kHz
aux = np.zeros((32,45,ns/15), dtype='int16') # 32 chips, 45 aux values, samples at 2 kHz
for i in range(ns):
data[:,i] = dset[i][3][:1024]