Created
December 18, 2017 06:13
-
-
Save joeltg/f60dc36ed0f09db1b01c66f4c10b88aa to your computer and use it in GitHub Desktop.
Secrets
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> | |
#include <util/delay.h> | |
#define output(directions,pin) (directions |= pin) | |
#define set(port,pin) (port |= pin) | |
#define clear(port,pin) (port &= (~pin)) | |
#define pin_test(pins,pin) (pins & pin) | |
#define bit_test(byte,bit) (byte & (1 << bit)) | |
#define led_delay() _delay_ms(500) | |
#define led_port PORTC | |
#define led_direction DDRC | |
#define led_pin (1 << PC7) | |
int main(void) { | |
CLKPR = (1 << CLKPCE); | |
CLKPR = (0 << CLKPS3) | (0 << CLKPS2) | (0 << CLKPS1) | (0 << CLKPS0); | |
clear(led_port, led_pin); | |
output(led_direction, led_pin); | |
while(1) { | |
set(led_port, led_pin); | |
led_delay(); | |
clear(led_port, led_pin); | |
led_delay(); | |
} | |
return 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
PROJECT=secrets | |
SOURCES=$(PROJECT).c | |
MMCU=atmega32u4 | |
F_CPU = 8000000 | |
CFLAGS=-mmcu=$(MMCU) -Wall -Os -DF_CPU=$(F_CPU) | |
$(PROJECT).hex: $(PROJECT).out | |
avr-objcopy -O ihex $(PROJECT).out $(PROJECT).c.hex;\ | |
avr-size --mcu=$(MMCU) --format=avr $(PROJECT).out | |
$(PROJECT).out: $(SOURCES) | |
avr-gcc $(CFLAGS) -I./ -o $(PROJECT).out $(SOURCES) | |
program-ice: $(PROJECT).hex | |
avrdude -p m32u4 -P usb -c atmelice_isp -U flash:w:$(PROJECT).c.hex | |
program-fuses: | |
avrdude -p m32u4 -c atmelice_isp -P usb -U lfuse:w:0x5e:m -U hfuse:w:0x99:m -U efuse:w:0xf3:m |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment