Skip to content

Instantly share code, notes, and snippets.

View mvduin's full-sized avatar

Matthijs van Duin mvduin

View GitHub Profile
(STILL BEING REVISED, and beware that not all uarts behave the same)
Table showing whether a particular byte triggers a break condition when
receiver uart is configured at a higher baudrate than the transmitter uart and
both are 8N1.
always = byte always triggers break regardless of preceding data
init = byte triggers break at least if preceded by line idle state
*** = not sure, dependent on subtle details of uart behaviour
@mvduin
mvduin / die.h
Last active September 9, 2019 09:33
sysfs gpio event example
#pragma once
#include <stdio.h>
#include <stdarg.h>
#include <stdlib.h>
[[ noreturn ]]
inline void die( char const *fmt, ... )
{
va_list ap;
va_start( ap, fmt );
@mvduin
mvduin / sgx-init.service
Created September 25, 2017 04:47
sgx init
# /etc/systemd/system/sgx-init.service
[Unit]
Description=Initialize SGX
BindsTo=dev-dri-sgx.device
After=dev-dri-sgx.device
RefuseManualStop=true
DefaultDependencies=no
[Service]
struct __attribute__((packed,aligned(4))) Ratios11 {
u32 d0r0 : 11;
u32 d0r1 : 11;
u32 d1r0 : 11;
u32 d1r1 : 11;
u32 d2r0 : 11;
u32 d2r1 : 11;
u32 d3r0 : 11;
u32 d3r1 : 11;
};
@mvduin
mvduin / wsegl.h
Created July 20, 2017 13:59
wsegl v4, cleaned up
/*************************************************************************/ /*!
@Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved
@License Dual MIT/GPLv2
The contents of this file are subject to the MIT license as set out below.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
#pragma once
#include "die.h"
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
struct Gpio {
int fd = -1;
char *path = NULL;
@mvduin
mvduin / demo.asm
Created March 21, 2017 04:18
clpru code output
; boilerplate and compiler spam removed for readability
.global ||_Z6istruei||
||_Z6istruei||:
LDI r0.b0, 0x00
QBEQ ||$C$L4||, r14, 0x00
LDI r0.b0, 0x01
||$C$L4||:
MOV r14.b0, r0.b0
JMP r3.w2
@mvduin
mvduin / 1 - empty.c
Created March 21, 2017 04:02
empty PRU program with clpru
int main() {
return 0;
}
#!/bin/bash
set -e
shopt -s lastpipe extglob
if [[ $# != 1 ]]; then
echo "Usage: ${BASH_SOURCE} <device or image file>" >&2
false
fi
#pragma once
#include "die.h"
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
class Gpio {
int fd = -1;
char *path = NULL;