123 lines
3.8 KiB
Markdown
123 lines
3.8 KiB
Markdown
# Template for AVR projects ic C
|
|
|
|
<!--- These are examples. See https://shields.io for others or to customize this set of shields. You might want to include dependencies, project status and licence info here --->
|
|
<!-- 
|
|

|
|

|
|

|
|
 -->
|
|
|
|
<!-- Project name is a `<utility/tool/feature>` that allows `<insert_target_audience>` to do `<action/task_it_does>`. -->
|
|
|
|
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)`
|
|
* You have a `Linux` machine.
|
|
|
|
## 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:
|
|
```bash
|
|
├── .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.json` w sekcji `defines` nalaży dostosować typ mikrontrolera i jego częstotliwość. Wartość można pobrac z pliku `io.h`.
|
|
|
|
```json
|
|
"defines": [
|
|
"__AVR_ATmega644PA__",
|
|
"F_CPU=11059200"
|
|
],
|
|
```
|
|
|
|
* Identycznie należy postąpić w pliku `Makefile`(`PROCESSOR` i `F_CPU`).
|
|
|
|
```makefile
|
|
PROCESSOR := ATmega644PA
|
|
F_CPU := 11059200UL
|
|
```
|
|
Przykł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+~`.<br>
|
|
**kompilacja AVR:**
|
|
```bash
|
|
make
|
|
```
|
|
lub
|
|
```bash
|
|
make build
|
|
```
|
|
|
|
#####3. Uruchamianie testów
|
|
Inforamcje jak używać testów znajdziesz w katalogu `/test/support`
|
|
* Z poziomu `Visual Studio Code`
|
|
zakładka `Test` lub bezpośrdnio w pliku z testami.
|
|
* z poziomu lini komend
|
|
```bash
|
|
ceedling
|
|
```
|
|
#####4. Debugownaie
|
|
Nie wymaga opisu.
|
|
|
|
|
|
|
|
## License
|
|
<!--- If you're not sure which open license to use see https://choosealicense.com/--->
|
|
|
|
This project uses the following license: [MIT](https://choosealicense.com/licenses/mit/).
|