Skip to content

Instantly share code, notes, and snippets.

Jari Tulilahti Jartza

Block or report user

Report or block Jartza

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View avr_common_macros.h
/*
* Common bit handling macros for AVR (avr-gcc)
*
* Examples:
*
* #define LED_DIR BITP(DDRB, PB4) // LED_DIR is "variable" pointing to single bit (PB4) in DDRB
* #define LED_STATE BITP(PORTB, PB4) // LED_STATE points to single bit (PB4) in PORTB
* LED_DIR = DIR_OUT; // Set pin as output
* LED_STATE = LEVEL_HIGH; // Switch LED on
*
View avr_common_macros.h
/*
* Struct to handle bits in registers
*/
typedef struct {
uint8_t b0:1;
uint8_t b1:1;
uint8_t b2:1;
uint8_t b3:1;
uint8_t b4:1;
uint8_t b5:1;
View Makefile
OBJECTS = main.o task.o
DEVICE = attiny85
CLOCK = 8000000
PROGRAMMER = -c usbasp
FUSES = -U lfuse:w:0xe2:m -U hfuse:w:0xDF:m -U efuse:w:0xFF:m -B 12
AVRDUDE = avrdude $(PROGRAMMER) -p $(DEVICE)
COMPILE = avr-gcc -Wall -Os -DF_CPU=$(CLOCK) -mmcu=$(DEVICE)
all: main.hex
@Jartza
Jartza / euler67.js
Created Mar 15, 2015
Euler Problem 67 solver in node :)
View euler67.js
t=require('fs').readFileSync("triangle.txt","utf8").trim().split("\n");for(f in t)i=t[f]=t[f--].split(" ");for(;1+f;)for(s in w=t[f--])i[s]=+w[s]+Math.max(i[s],i[++s]);console.log(i[0])
@Jartza
Jartza / uart.c
Last active Aug 29, 2015
interrupt-driven send-only uart for attiny84
View uart.c
/* Name: uart.c
* Author: Jari Tulilahti
*
* UART TEST
*/
#include <avr/io.h>
#include <avr/interrupt.h>
/* Helpers */
View gist:2977346bc34b7c4d463e
#include <avr/io.h>
start:
sbi _SFR_IO_ADDR(DDRB), 4
blink:
sbi _SFR_IO_ADDR(PINB), 4
ldi ZH, 20
loop:
View gist:9514159
t=require('fs').readFileSync("tree.txt","utf8").split("\n");for(f in t)i=t[f]=t[f--].split(" ");for(;f;)for(s in w=t[f--])i[s]=+w[s]+Math.max(i[s],i[++s]);console.log(i[0])
You can’t perform that action at this time.