3.8 KiB
Template for AVR projects ic C
To jest projekt bazowy, z którego korzystam zaczynając prace nad nowym projektem. Jest w pełnu skonfigorwany tak, aby odrazu zacząć prace nad projektem.
Prerequisites
Before you begin, ensure you have met the following requirements:
- You have installed the latest version of
- testing:
ceedling(requires ruby) - building:
built-essenstial,avr-libc - debuging:
gdb - ide:
Visual Studio Code(extensios:C/C++ for Visual Studio Code,Ceedling Test Expoler)
- testing:
- You have a
Linuxmachine.
New project
To start new project, follow these steps:
mkdir <new_project_name>
cd <new_project_name>
git init
git pull link
Project should be ready to go. The files structure looks like this:
├── .vscode
│ ├── c_cpp_properties.json
│ ├── launch.json
│ ├── settings.json
│ └── tasks.json
├── src
│ ├── i2c
│ │ ├── i2c.c
│ │ └── i2c.h
│ ├── lights
│ │ ├── lights.c
│ │ └── lights.h
│ ├── tempSensor
│ │ ├── tempSensor.c
│ │ └── tempSensor.h
│ └── main.c
├── test
│ ├── support
│ │ ├── HowToUseCeedlingForEmbedded_TDD.pdf
│ │ └── ceedling.txt
│ ├── test_lights.c
│ └── test_tempSensor.c
├── Makefile
├── project.yml
├── .gitignore
└── readme.md
Using templete
#####1. Mikrokontroler i częstotliwość
-
W pliku
c_cpp_properties.jsonw sekcjidefinesnalaży dostosować typ mikrontrolera i jego częstotliwość. Wartość można pobrac z plikuio.h."defines": [ "__AVR_ATmega644PA__", "F_CPU=11059200" ], -
Identycznie należy postąpić w pliku
Makefile(PROCESSORiF_CPU).PROCESSOR := ATmega644PA F_CPU := 11059200ULPrzykładowe wartości:
Makefile c_cpp_properties.json Atmega32 __AVR_ATmega32__ Atmega32U4 __AVR_ATmega32U4__ Atmega644P __AVR_ATmega644P__ Atmega644PA __AVR_ATmega644PA__ Atmega8A __AVR_ATmega8A__ Atmega328P __AVR_ATmega328P__
#####2. Kompilowanie dla AVR
- Tasks in Visual Studio Code
Aby zbudować pliki dla mikrokontrolera można użyć skrótu klawiszowego
Ctrl+Shift+B. Uruchomi to domyślne zadanie (tasks.json). - Command line
Aby otrorzyc terminal użyj skrótu
Ctrl+shift+~.
kompilacja AVR:lubmakemake build
#####3. Uruchamianie testów
Inforamcje jak używać testów znajdziesz w katalogu /test/support
- Z poziomu
Visual Studio CodezakładkaTestlub bezpośrdnio w pliku z testami. - z poziomu lini komend
ceedling
#####4. Debugownaie Nie wymaga opisu.
License
This project uses the following license: MIT.