Skip to content

Instantly share code, notes, and snippets.

@szczys
szczys / main.c
Created April 19, 2024 19:59
Golioth Bluetooth Gateway Demo
/* main.c - Application main entry point */
/*
* Copyright (c) 2020 SixOctets Systems
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <stdio.h>
#include <stddef.h>
@szczys
szczys / vcard-split.py
Created December 14, 2011 20:22
Python script for splitting a VCARD file to a user-set number of VCARDs per output file
#split vcf files
working_dir = '/home/mike/compile/'
input_file = 'final.vcf'
output_seed = 'contacts-part-'
vcards_per_file = 75
with open(working_dir + input_file,'r') as f:
count = 0
output_count = 1
@szczys
szczys / conftest.py
Last active April 2, 2024 16:31
Embedded firmware test using pytest
import pytest
import re
import serial
from time import time
# Used to flash binary to nrf52840dk
from pynrfjprog import LowLevel
@pytest.fixture(scope='session')
def anyio_backend():
@szczys
szczys / spi-interrupt-test.ino
Created May 15, 2020 23:44
ESP32 Interrupt Based SPI Slave (receive only)
// Using ESP32 HSPI (SPI2)
// CS is SS -->
// WR is SCK -->
// DATA is MOSI -->
#define SO 12
#define SI 13
#define SCLK 14
#define SS 15
void setup() {
BeanHid.enable();
// Serial port is initialized automatically; we don't have to do anything
}
void loop() {
AccelerationReading accel = Bean.getAcceleration();
int16_t x = accel.xAxis;
int16_t y = accel.yAxis;
int16_t z = accel.zAxis;
// Add a deadzone. If Bean is reasonabally flat, don't move the mouse pointer
@szczys
szczys / stm32f05x-flash-control.diff
Created June 10, 2012 21:08
STM32F05x defines for controlling flash memory
diff --git src/stlink-common.c src/stlink-common.c
index 08bd0bb..1e3c480 100644
--- src/stlink-common.c
+++ src/stlink-common.c
@@ -48,6 +48,38 @@
#define FLASH_CR_STRT 6
#define FLASH_CR_LOCK 7
+/**************************
+ Begin stm32f05x flash controller defines
@szczys
szczys / led-balance.c
Created December 16, 2011 20:34
Balancing LED brightness for Binary Burst Clock
#include <avr/io.h>
#include <avr/interrupt.h>
#define F_CPU 1000000
void init_IO(void) {
DDRD |= (1<<PD0) | (1<<PD1) | (1<<PD2);
PORTD |= (1<<PD0) | (1<<PD1) | (1<<PD2);
}
@szczys
szczys / atmega168-analog-comparator.c
Created December 3, 2011 22:56
ATmega168 Analog Comparator example
/*
AVR ATmega168 Analog Comparator Demonstration
by Mike Szczys
I'm using a voltage divider with a photoresistor on
PC6 and a voltage divider with equal values on PC7
to yield a 2.5V reference signal.
The analog comparator is set to throw an interrupt
whenever there is a zero crossing. I then check the
@szczys
szczys / avr-asm-delay.S
Created July 6, 2011 16:19
AVR assembler delay routine
;Begin delaying
LDI ZH,0xFF ;Set high byte
LDI ZL,0xFF ;Set low byte
DelayLoop:
SBIW ZL,1 ;subtract one from word
BRNE DelayLoop ;Branch back to DelayLoop unless zero flag was set
;Go on with the rest of life
APPLICATION="${0##*/}"
USAGE="$APPLICATION [options]
Wraps enter-chroot to start a Mint session.
By default, it will log into the primary user on the first chroot found.
Options are directly passed to enter-chroot; run enter-chroot to list them."
exec sh -e "`dirname "$0"`/enter-chroot" "$@" startx /bin/bash cinnamon-session-cinnamon