Skip to content

Commit

Permalink
use avr-gcc for compilation
Browse files Browse the repository at this point in the history
  • Loading branch information
kelvinabrokwa committed Sep 21, 2017
1 parent 51475a8 commit ad1a969
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 26 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
*.elf
*.o
*.hex
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
FROM ubuntu
MAINTAINER Kelvin Abrokwa ([email protected])
RUN apt-get update
RUN apt-get install -y --force-yes build-essential arduino arduino-core
RUN apt-get install -y --force-yes gcc-avr binutils-avr avr-libc
RUN mkdir /build
ADD ./ /build
WORKDIR /build
Expand Down
7 changes: 6 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
all:
arduino blink.uno
avr-gcc -g -Os -mmcu=atmega32 -c blink.c
avr-gcc -g -mmcu=atmega32 -o blink.elf blink.o
avr-objcopy -j .text -j .data -O ihex blink.elf blink.hex

docker-build:
docker build -t firmware-builder .
docker run -it firmware-builder

clean:
rm -f *.o *.elf *.hex
21 changes: 21 additions & 0 deletions blink.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#ifndef F_CPU
#define F_CPU 16000000UL // or whatever may be your frequency
#endif

#include <avr/io.h>
#include <util/delay.h> // for _delay_ms()

int main(void)
{
DDRC = 0x01; // initialize port C
while(1)
{
// LED on
PORTC = 0b00000001; // PC0 = High = Vcc
_delay_ms(500); // wait 500 milliseconds

//LED off
PORTC = 0b00000000; // PC0 = Low = 0v
_delay_ms(500); // wait 500 milliseconds
}
}
24 changes: 0 additions & 24 deletions blink/blink.ino

This file was deleted.

0 comments on commit ad1a969

Please sign in to comment.