Skip to content

Instantly share code, notes, and snippets.

View andresv's full-sized avatar

Andres Vahter andresv

View GitHub Profile
@andresv
andresv / ax25_crc16.c
Last active March 16, 2024 11:12
AX25 CRC16 implementation
uint16_t ax25crc16(unsigned char *data_p, uint16_t length) {
uint16_t crc = 0xFFFF;
uint32_t data;
uint16_t crc16_table[] = {
0x0000, 0x1081, 0x2102, 0x3183,
0x4204, 0x5285, 0x6306, 0x7387,
0x8408, 0x9489, 0xa50a, 0xb58b,
0xc60c, 0xd68d, 0xe70e, 0xf78f
};
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <time.h>
uint32_t d_shift_register = 0;
uint32_t d_taps[32];
uint32_t d_tap_count;
@andresv
andresv / satellitetracker.py
Last active March 14, 2023 23:37
Pyephem satellite tracker
import sys
import time
import datetime
from math import *
import ephem
# taken from: http://celestrak.com/NORAD/elements/cubesat.txt
ec1_tle = { "name": "ESTCUBE 1", \
@andresv
andresv / sys_bios_uart_example.c
Last active March 14, 2022 15:11
Demonstration how to use UART with SYS/BIOS.
/*
* uartSample_main.c
*
* This file contains the test / demo code to demonstrate the UART driver
* functionality on SYS/BIOS 6
*
* Copyright (C) 2009 Texas Instruments Incorporated - http://www.ti.com/
*
*
* Redistribution and use in source and binary forms, with or without
@andresv
andresv / memcpyexample.c
Created August 9, 2012 09:55
memcpy example
#include <stdio.h>
#include <string.h>
#include <stdint.h> //uint8_t and friends
int main(void){
uint8_t settings[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x01}; // preamble, stx and other stuff must be defined here
char text[] = "hello world";
@andresv
andresv / monotonic.rs
Created October 7, 2021 19:57
rtic 0.6 monotonic timer for stm32L0
#![no_main]
#![no_std]
use rtic::rtic_monotonic::{embedded_time, Clock, Fraction, Instant, Monotonic};
use stm32l0xx_hal::pac::TIM21;
use stm32l0xx_hal::timer::Timer;
/// Extended TIM21/16 to 64 bits
pub struct ExtendedMonotonicTimer<TIM> {
_tim: Timer<TIM>,
@andresv
andresv / ingress_manager.rs
Created November 10, 2021 08:35
atat ingress_manager
fn cpin_partial_response() {
static mut RES_Q: BBBuffer<TEST_RES_CAPACITY> = BBBuffer::new();
let (res_p, mut res_c) = unsafe { RES_Q.try_split_framed().unwrap() };
static mut URC_Q: BBBuffer<TEST_URC_CAPACITY> = BBBuffer::new();
let (urc_p, _urc_c) = unsafe { URC_Q.try_split_framed().unwrap() };
static mut COM_Q: queues::ComQueue = Queue::new();
let (_com_p, com_c) = unsafe { COM_Q.split() };
@andresv
andresv / stm32_rtfm_monotonic.rs
Last active October 27, 2020 16:37
stm32g0 rtfm::Monotonic
//! Using STM32G0 TIM2 as monotonic timer
use core::u32;
use core::{
cmp::Ordering,
convert::{Infallible, TryInto},
ops,
};
use defmt::Format;
use hal::stm32;
@andresv
andresv / adc.rs
Created September 18, 2020 12:55
stm32g0 adc using dma
use cortex_m::asm;
use hal::stm32;
use hal::prelude::*;
use hal::analog::adc::{Precision, SampleTime};
use hal::timer::Timer;
use hal::time::Hertz;
pub type AdcBuf = [u16; 4];
pub fn init(adc_dma_buf: &AdcBuf) {
@andresv
andresv / keybase.md
Created October 12, 2016 06:16
keybase

Keybase proof

I hereby claim:

  • I am andresv on github.
  • I am andresv (https://keybase.io/andresv) on keybase.
  • I have a public key whose fingerprint is 63CE D109 DA53 0973 CD04 5180 30A6 572C 6CA8 65C9

To claim this, I am signing this object: