Skip to content

Instantly share code, notes, and snippets.

@lsalmon
lsalmon / OpenAMP linux ping example with 2 echos
Last active May 12, 2025 21:09
OpenAMP linux legacy expanding ping example to 2 remoteproc instances with a vdev each (2 echos)
Title
@lsalmon
lsalmon / i2c_dev_wiinunchuck.c
Created July 17, 2022 23:29
Get sensor data from knockoff wii nunchuck with i2c-dev on linux (compile with -li2c)
#include <linux/i2c-dev.h>
#include <i2c/smbus.h>
#include <sys/ioctl.h>
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <unistd.h>
#include <errno.h>
#include <stdbool.h>
@lsalmon
lsalmon / pointers_global.c
Created May 31, 2022 17:47
Random pointer stuff
#include <stdio.h>
#include <stdlib.h>
typedef struct b {
int mb1[5];
} b;
typedef struct a {
int ma1;
b ma2;
@lsalmon
lsalmon / i2c_stub_sensors.sh
Created May 27, 2022 01:28
Simulate I2C temperature sensors for lm-sensors
#!/bin/sh
# Insert driver simulating an i2c bus,
# with two devices at addresses 0x48 and 0x49
# (see datasheets for the LM75 and LM77 temp sensors)
modprobe i2c-stub chip_addr=0x48,0x49
# Extract i2c-stub bus number from i2cdetect
bus_number=$(i2cdetect -l | grep -i stub | awk -F' ' '{print $1;}' - | cut -d"-" -f2)