Skip to content

Instantly share code, notes, and snippets.

View opalenic's full-sized avatar

Ondřej Páleníček opalenic

  • Prague, Czech Republic
View GitHub Profile
@opalenic
opalenic / cswitch.c
Last active August 29, 2015 14:11
MourOS task context switching
inline void push_prg_stack(void) __attribute__((always_inline))
{
register int *new_psp asm("r0");
asm("msr psp, r0\n\t"
"sub r0, #32\n\t"
"mov r1, r0\n\t"
"stm r1!, {r4-r7}\n\t"
"mov r4, r8\n\t"
"mov r5, r9\n\t"
@opalenic
opalenic / shrink_apertures.py
Created February 3, 2015 23:21
Gerber file pad shrinker
#!/usr/bin/python
import sys
import re
subtract = float(sys.argv[1]) / 1000
mode = 'IN'
with open(sys.argv[2], "r") as f:
@opalenic
opalenic / PKGBUILD
Last active December 29, 2019 01:06
Arch Linux PKGBUILD for the arm-none-eabi-newlib package. Modified to build newlib without syscall stubs.
# $Id$
# Maintainer: Anatol Pomozov <[email protected]>
# Modified by: Ondrej Palenicek <[email protected]>
_target=arm-none-eabi
pkgname=$_target-newlib
_pkgver=3.1.0
pkgver="$_pkgver"_nostubs
pkgrel=2
_upstream_ver=$_pkgver
@opalenic
opalenic / Makefile
Created September 1, 2015 23:05
Template Makefile project for STM8 SDCC builds
SDCC = sdcc
STM8FLASH = stm8flash
CHIP = STM8S003
CHIP_LCASE = $(shell echo $(CHIP) | tr '[:upper:]' '[:lower:]')
CFLAGS = -lstm8 -mstm8 -L./libsrc/build/ -lstm8s_periph.lib -I./libsrc/inc -D$(CHIP) -DUSE_STDPERIPH_DRIVER
MAIN_SOURCE = launcher
@opalenic
opalenic / lib.rs
Created December 1, 2016 00:41
Rust compiler error
#![no_std]
#![feature(lang_items)]
mod messages;
#[lang = "panic_fmt"]
extern "C" fn panic_fmt() -> ! {
loop {
}
}
@opalenic
opalenic / message_wrapper.rs
Created September 25, 2017 23:16
Message wrapper macro initial
#[macro_export]
macro_rules! derive_message_wrapper {
($type_name:tt<$($lifetime:tt),+>, $msg_id:pat => $parse_func:expr, $alloc_func:expr, $free_func:expr) => (
derive_message_wrapper!($type_name<$($lifetime),+>, [$msg_id => $parse_func], $alloc_func, $free_func);
);
($type_name:tt<$($lifetime:tt),+>, [$($msg_id:pat => $parse_func:expr),+], $alloc_func:expr, $free_func:expr) => (
impl<$($lifetime),+> $crate::bindings::message_dispatcher::TryFrom<*mut $crate::bindings::message_dispatcher::message> for $type_name {
derive_message_wrapper!(@try_from_impl_payload $type_name<$($lifetime),+>, [$($msg_id => $parse_func),+]);
}
@opalenic
opalenic / nodes_wip.rs
Created March 8, 2020 23:47
Rework of node/sensor registry
use std::collections::BTreeMap;
use super::models::SensorTypeEnum;
use super::MeteoError;
mod enviro_phat;
mod serial_node;
pub trait SensorNode {
fn measure(&self, measurement_type: SensorTypeEnum, sensor_id: u32) -> Result<f32, MeteoError>;