|Ondřej Hruška cfdc18d3c4 ADC new APIs and bugfix for 10bit||3 years ago|
|lib||3 years ago|
|.gitignore||3 years ago|
|CMakeLists.txt||3 years ago|
|LICENSE||4 years ago|
|Makefile||3 years ago|
|README.md||4 years ago|
|avr-c-bp.pro||4 years ago|
|main.c||4 years ago|
|style.astylerc||4 years ago|
This is a basic boilerplate for programming AVRs in C.
The project aims to make programming Arduinos in C fun by providing support for basic functionality like GPIO and USART, so you can start developing without having the datasheet open all the time.
It is intended for ATmega328P (the chip in Arduinos), but can be easily adapted to other parts.
Before you can start coding, you need to install a few software packages:
avrdude- the flash tool
avr-libc- libc implementation for AVR
avr-binutils- utils for manipulating AVR binaries
make- to run the Makefile
There's a good chance you already have
make, the rest should be in your
If you're on Arch:
# pacman -S base-devel avr-gcc avr-binutils avr-libc avrdude
If you're on Mac, you should be able to pull the stuff with brew.
main.c is a good starting point - it contains some simple demo code.
You can compile it with
make and flash with
First, check that the
avrdude options in the file are correct for your system - especially
the device and speed.
# AVRDUDE settings PROG_BAUD = 57600 PROG_DEV = /dev/ttyUSB0 PROG_TYPE = arduino # Build the final AVRDUDE arguments PROG_ARGS = -c $(PROG_TYPE) -p $(MCU) -b $(PROG_BAUD) -P $(PROG_DEV)
PROG_DEVto the device your board is connected to. On Linux it's usually
/dev/ttyUSB0, but it can also be
/dev/ttyACM0or something else. On Mac, it'll be
/dev/cu.xxx. On Windows it's some
ls /devto see their devices. Windows users will find this in their Device Manager.
PROG_BAUD). Some boards need
TIP: You can look what the Arduino IDE is using - it's running avrdude too.
.o(object file, created by the compiler before linking) to the
OBJSlist in the Makefile.
printfwith floats), enable the appropriate LD_FLAGS in the Makefile (it's well commented). Code size will - obviously - grow quite a bit.
Double Speed Asynchronous Modefor USART is enabled by default, so if you set your baud rate to 9600, you'd really get 19200.
usart_init()function to keep things consistent and to avoid confusion.