Add a led blinking code and a build script
This commit is contained in:
parent
7058070132
commit
cc4321ae40
4
build.sh
Normal file
4
build.sh
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
avr-gcc -Os -DF_CPU=16000000UL -Wall -Wextra -Wpedantic -Wformat -pedantic-errors -Werror -Wfatal-errors -mmcu=atmega2560 -c -o src/main.o src/main.c
|
||||||
|
avr-gcc -mmcu=atmega2560 src/main.o -o bin/atmega2560-user-code.elf
|
||||||
|
avr-objcopy -O ihex -R .eeprom bin/atmega2560-user-code.elf bin/atmega2560-user-code.ihx
|
||||||
|
avrdude -v -F -V -c stk500v2 -p m2560 -P /dev/ttyACM0 -b 115200 -U flash:w:bin/atmega2560-user-code.ihx
|
18
src/main.c
18
src/main.c
@ -0,0 +1,18 @@
|
|||||||
|
#include <avr/io.h>
|
||||||
|
#include <util/delay.h>
|
||||||
|
|
||||||
|
#define BLINK_DELAY_MS 1000
|
||||||
|
|
||||||
|
int main (void)
|
||||||
|
{
|
||||||
|
/* set pin 25 of PORTB for output*/
|
||||||
|
DDRA |= _BV(DDA3);
|
||||||
|
while(1) {
|
||||||
|
/* set pin 25 high to turn led on */
|
||||||
|
PORTA |= _BV(PORTA3);
|
||||||
|
_delay_ms(BLINK_DELAY_MS);
|
||||||
|
/* set pin 25 low to turn led off */
|
||||||
|
PORTA &= ~_BV(PORTA3);
|
||||||
|
_delay_ms(BLINK_DELAY_MS);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user