basic c and make template for atmega328p and usbasp programmer
This commit is contained in:
commit
6248bc8710
28
.vscode/c_cpp_properties.json
vendored
Normal file
28
.vscode/c_cpp_properties.json
vendored
Normal file
@ -0,0 +1,28 @@
|
||||
{
|
||||
"configurations": [
|
||||
{
|
||||
"name": "Mac",
|
||||
"includePath": [
|
||||
"${workspaceFolder}/**",
|
||||
"usr/local/Cellar/avr-gcc/9.3.0/avr/include/**"
|
||||
],
|
||||
"browse": {
|
||||
"limitSymbolsToIncludedHeaders": true,
|
||||
"path": [
|
||||
"${workspaceFolder}/**",
|
||||
"usr/local/Cellar/avr-gcc/9.3.0/avr/include/**"
|
||||
]
|
||||
},
|
||||
"macFrameworkPath": [],
|
||||
"compilerPath": "/usr/local/bin/avr-gcc",
|
||||
"intelliSenseMode": "clang-x64",
|
||||
"cStandard": "c99",
|
||||
"cppStandard": "c++11",
|
||||
"compilerArgs": [
|
||||
"-mmcu=atmega328p",
|
||||
""
|
||||
]
|
||||
}
|
||||
],
|
||||
"version": 4
|
||||
}
|
||||
16
Makefile
Normal file
16
Makefile
Normal file
@ -0,0 +1,16 @@
|
||||
MCU=atmega328p
|
||||
CC=avr-gcc
|
||||
OBJCOPY=avr-objcopy
|
||||
CFLAGS=-std=c99 -Wall -g -Os -mmcu=${MCU} -I.
|
||||
TARGET=blink
|
||||
SRCS=blink.c
|
||||
|
||||
all:
|
||||
${CC} ${CFLAGS} -o ${TARGET}.bin ${SRCS}
|
||||
${OBJCOPY} -j .text -j .data -O ihex ${TARGET}.bin ${TARGET}.hex
|
||||
|
||||
flash:
|
||||
avrdude -p ${MCU} -c usbasp -U flash:w:${TARGET}.hex:i -F -P usb
|
||||
|
||||
clean:
|
||||
rm -f *.bin *.hex
|
||||
25
blink.c
Normal file
25
blink.c
Normal file
@ -0,0 +1,25 @@
|
||||
/*
|
||||
* File: blink.c
|
||||
* Description: Toggels pin PB0 every 500ms
|
||||
* From: C-Programmierung mit AVR-GCC
|
||||
*/
|
||||
|
||||
#define F_CPU 16000000UL
|
||||
|
||||
#include <avr/io.h>
|
||||
#include <util/delay.h>
|
||||
|
||||
int main(void)
|
||||
{
|
||||
|
||||
DDRB |= (1 << PB0) | (1 << PB1);
|
||||
PORTB |= (1 << PB0) | (1 << PB1);
|
||||
|
||||
while (1)
|
||||
{
|
||||
PORTB ^= (1 << PB0) | (1 << PB1);
|
||||
_delay_ms(500);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
12
blink.hex
Normal file
12
blink.hex
Normal file
@ -0,0 +1,12 @@
|
||||
:100000000C9434000C943E000C943E000C943E0082
|
||||
:100010000C943E000C943E000C943E000C943E0068
|
||||
:100020000C943E000C943E000C943E000C943E0058
|
||||
:100030000C943E000C943E000C943E000C943E0048
|
||||
:100040000C943E000C943E000C943E000C943E0038
|
||||
:100050000C943E000C943E000C943E000C943E0028
|
||||
:100060000C943E000C943E0011241FBECFEFD8E04C
|
||||
:10007000DEBFCDBF0E9440000C9454000C940000E1
|
||||
:1000800084B1836084B985B1836085B993E085B11B
|
||||
:10009000892785B92FEF39E688E12150304080402B
|
||||
:0C00A000E1F700C00000F3CFF894FFCFA0
|
||||
:00000001FF
|
||||
Loading…
Reference in New Issue
Block a user