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
# Compile for attiny85 - optimize for size | |
compile: | |
avr-gcc -Wall -Os -mmcu=attiny85 src/main.c | |
# Get the assembly | |
assembly: | |
avr-gcc -S -Os -mmcu=attiny85 src/main.c -o assembly.asm | |
# Dump hex from out file | |
dump: compile |
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
... | |
// Add the SREG register | |
#define SREG REG(0x3F) | |
... | |
int main() | |
{ | |
... | |
// Write 1 to bit 7 (I-bit) for Global Interrupt Enable | |
SREG |= BV_MASK(7); |
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
// When addressing I/O Registers as data space using LD and ST | |
// instrucrutions, 0x20 must be added to these addresses. | |
#define OFFSET 0x20 | |
// Macro helper for registers | |
#define REG(addr) *((volatile unsigned char*)(addr+OFFSET)) | |
// Port B Data Direction Register | |
#define DDRB REG(0x17) |
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
while (1) { | |
for (unsigned int i = 0; i < 50000; i++) { PORTB |= (1 << 0); } | |
for (unsigned int i = 0; i < 50000; i++) { PORTB = 0x0; } | |
} |
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
// Port B data direction register 0x17 (+ 0x20 for the special func register offset) | |
#define DDRB *((volatile unsigned char*)0x37) | |
// Port B data register 0x18 (+ 0x20 for the special func register offset) | |
#define PORTB *((volatile unsigned char*)0x38) | |
int main() | |
{ | |
// Set data direction for Port B bit 0 (PB0 - pin 5) | |
DDRB |= (1 << 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
int main() | |
{ | |
// Set data direction for Port B bit 0 (PB0 - pin 5) to 1 for output | |
DDRB |= (1 << 0); | |
// Set data for Port B bit 0 (PB0 - pin 5) to 1 to turn on LED | |
PORTB |= (1 << 0); | |
while (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
// Port B data direction register | |
#define DDRB *((volatile unsigned char*)0x17) | |
// Port B data register | |
#define PORTB *((volatile unsigned char*)0x18) | |
int main() {} |
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
package cache | |
import ( | |
"container/list" | |
) | |
type lru struct { | |
cap int // max number of items the cache can hold before needing to evict. | |
ll *list.List // a doubly linked list. | |
items map[interface{}]*list.Element // map of keys -> doubly linked list elements |
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
package cache | |
import ( | |
"container/list" | |
"errors" | |
"sync" | |
) | |
// ErrMinCacheSize is returned when a caller tries to create a new LRU cache with a capacity of less than one | |
var ErrMinCacheSize = errors.New("please provide an LRU cache capacity greater than or equal to 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
package dora | |
import ( | |
"errors" | |
"fmt" | |
"strconv" | |
"github.com/bradford-hamilton/dora/pkg/ast" | |
) |
NewerOlder