This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* 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 | |
* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* 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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Name: uart.c | |
* Author: Jari Tulilahti | |
* | |
* UART TEST | |
*/ | |
#include <avr/io.h> | |
#include <avr/interrupt.h> | |
/* Helpers */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <avr/io.h> | |
start: | |
sbi _SFR_IO_ADDR(DDRB), 4 | |
blink: | |
sbi _SFR_IO_ADDR(PINB), 4 | |
ldi ZH, 20 | |
loop: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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]) |