Compare commits
5 Commits
28153db8d1
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| e759db5558 | |||
| 02415e8fd2 | |||
| b3f427e3f4 | |||
| 643ad92917 | |||
| 745caef768 |
10
.vscode/c_cpp_properties.json
vendored
10
.vscode/c_cpp_properties.json
vendored
@@ -4,10 +4,14 @@
|
|||||||
"name": "Linux",
|
"name": "Linux",
|
||||||
"includePath": [
|
"includePath": [
|
||||||
"${workspaceFolder}/**",
|
"${workspaceFolder}/**",
|
||||||
"/var/lib/gems/2.7.0/gems/ceedling-0.30.0/vendor/unity/src/",
|
"/var/lib/gems/2.7.0/gems/ceedling-0.30.0/vendor/unity/src",
|
||||||
"/var/lib/gems/2.7.0/gems/ceedling-0.30.0/vendor/cmock/src"
|
"/var/lib/gems/2.7.0/gems/ceedling-0.30.0/vendor/cmock/src",
|
||||||
|
"/usr/lib/avr/include"
|
||||||
|
],
|
||||||
|
"defines": [
|
||||||
|
"__AVR_ATmega644PA__",
|
||||||
|
"F_CPU=11059200"
|
||||||
],
|
],
|
||||||
"defines": [],
|
|
||||||
"compilerPath": "/usr/bin/gcc",
|
"compilerPath": "/usr/bin/gcc",
|
||||||
"cStandard": "c99",
|
"cStandard": "c99",
|
||||||
"cppStandard": "gnu++14",
|
"cppStandard": "gnu++14",
|
||||||
|
|||||||
125
Makefile
Normal file
125
Makefile
Normal file
@@ -0,0 +1,125 @@
|
|||||||
|
SHELL := /bin/bash
|
||||||
|
# Created by bartool
|
||||||
|
# 15.03.2020
|
||||||
|
# TODO
|
||||||
|
# Create pattern for upload
|
||||||
|
# Create pattern for init (create main.c, src dir, setting.json, c_cpp_properties.json)
|
||||||
|
PROCESSOR := ATmega644PA
|
||||||
|
F_CPU := 11059200UL
|
||||||
|
|
||||||
|
DUDE_PROGRAMMER := ATB-FT232R
|
||||||
|
DUDE_PORT := ft0
|
||||||
|
|
||||||
|
SRC_DIR := src
|
||||||
|
BUILD_DIR := build/$(PROCESSOR)
|
||||||
|
|
||||||
|
OPTIMIZE = Os
|
||||||
|
AVRDUDE_PATH := C:/avr/avrdude
|
||||||
|
CC := avr-gcc
|
||||||
|
OBJCOPY := avr-objcopy
|
||||||
|
OBJDUMP := avr-objdump
|
||||||
|
OBJSIZE := avr-size
|
||||||
|
|
||||||
|
PROJECT_NAME := $(notdir $(CURDIR))
|
||||||
|
ELF := $(BUILD_DIR)/$(PROJECT_NAME).elf
|
||||||
|
LSS := $(BUILD_DIR)/$(PROJECT_NAME).lss
|
||||||
|
MAP := $(BUILD_DIR)/$(PROJECT_NAME).map
|
||||||
|
FLASH_IMAGE := $(BUILD_DIR)/$(PROJECT_NAME).hex
|
||||||
|
EEPROM_IMAGE := $(BUILD_DIR)/$(PROJECT_NAME).eep
|
||||||
|
|
||||||
|
C_FILES := $(wildcard $(SRC_DIR)/*/*.c) $(wildcard $(SRC_DIR)/*.c)
|
||||||
|
OBJ_FILES := $(patsubst src/%.c, $(BUILD_DIR)/%.o, $(C_FILES))
|
||||||
|
DIRS := $(sort $(dir $(OBJ_FILES)))
|
||||||
|
|
||||||
|
# lc = $(subst A,a,$(subst B,b,$(subst C,c,$(subst D,d,$(subst E,e,$(subst F,f,$(subst G,g,$(subst H,h,$(subst I,i,$(subst J,j,$(subst K,k,$(subst L,l,$(subst M,m,$(subst N,n,$(subst O,o,$(subst P,p,$(subst Q,q,$(subst R,r,$(subst S,s,$(subst T,t,$(subst U,u,$(subst V,v,$(subst W,w,$(subst X,x,$(subst Y,y,$(subst Z,z,$1))))))))))))))))))))))))))
|
||||||
|
MCU := $(shell echo $(PROCESSOR) | tr '[:upper:]' '[:lower:]')
|
||||||
|
# MCU = $(call lc,$(PROCESSOR))
|
||||||
|
|
||||||
|
# kratka sa oznaczene opcje wykorzystywane przez eclipse
|
||||||
|
CFLAGS = -mmcu=$(MCU)#
|
||||||
|
CFLAGS += -$(OPTIMIZE)#
|
||||||
|
CFLAGS += -g
|
||||||
|
CFLAGS += -std=gnu99#
|
||||||
|
CFLAGS += -funsigned-char#
|
||||||
|
CFLAGS += -funsigned-bitfields#
|
||||||
|
CFLAGS += -fpack-struct#
|
||||||
|
#CFLAGS += -ffreestanding
|
||||||
|
CFLAGS += -ffunction-sections#
|
||||||
|
CFLAGS += -fdata-sections#
|
||||||
|
CFLAGS += -fshort-enums#
|
||||||
|
CFLAGS += -fverbose-asm
|
||||||
|
CFLAGS += -Wall#
|
||||||
|
#CFLAGS += -Ic:/avr/avr_toolchain/avr/include
|
||||||
|
CFLAGS += -Wstrict-prototypes
|
||||||
|
CFLAGS += -DF_CPU=$(F_CPU)#
|
||||||
|
|
||||||
|
ESC := \033[
|
||||||
|
STOP := $(ESC)0m
|
||||||
|
RESET := $(ESC)$(STOP)
|
||||||
|
DEBUG := $(RESET)$(ESC)36;49;2m
|
||||||
|
FOCUS := $(RESET)$(ESC)35;49;10m
|
||||||
|
PROGRAM := $(RESET)$(ESC)33;49;1m
|
||||||
|
|
||||||
|
all: $(ELF) $(LSS) $(FLASH_IMAGE) $(EEPROM_IMAGE) sizedummy
|
||||||
|
|
||||||
|
build: $(ELF)
|
||||||
|
|
||||||
|
$(DIRS):
|
||||||
|
@echo -e "$(DEBUG)>>> Making a dir: $(FOCUS)$@$(DEBUG) <<<$(STOP)"
|
||||||
|
@mkdir -p $@
|
||||||
|
|
||||||
|
$(ELF): $(OBJ_FILES)
|
||||||
|
@echo -e "$(DEBUG)>>> Building target: $(FOCUS)$@$(DEBUG) <<<$(STOP)"
|
||||||
|
@echo -e "$(DEBUG)>>> Invoking: AVR C Linker <<<$(STOP)"
|
||||||
|
$(CC) -Wl,-Map,$(MAP) -mmcu=$(MCU) -o $(ELF) $(OBJ_FILES)
|
||||||
|
|
||||||
|
$(LSS): $(ELF)
|
||||||
|
@echo -e "$(DEBUG)>>> Invoking: AVR Create Extended Listing $(FOCUS)$@$(DEBUG) <<<$(STOP)"
|
||||||
|
$(OBJDUMP) -h -S $(ELF) > $(LSS)
|
||||||
|
|
||||||
|
$(FLASH_IMAGE): $(ELF)
|
||||||
|
@echo -e "$(DEBUG)>>> Create flash image (ihex format) $(FOCUS)$@$(DEBUG) <<<$(STOP)"
|
||||||
|
$(OBJCOPY) -j .text -j .data -O ihex $(ELF) $(FLASH_IMAGE)
|
||||||
|
|
||||||
|
$(EEPROM_IMAGE): $(ELF)
|
||||||
|
@echo -e "$(DEBUG)>>> Create eeprom image (ihex format) $(FOCUS)$@$(DEBUG) <<<$(STOP)"
|
||||||
|
$(OBJCOPY) -j .eeprom --no-change-warnings --change-section-lma .eeprom=0 -O ihex $(ELF) $(EEPROM_IMAGE)
|
||||||
|
|
||||||
|
sizedummy: $(ELF)
|
||||||
|
@echo -e "$(DEBUG)>>> Invoking: Print size <<<$(STOP)"
|
||||||
|
$(OBJSIZE) --format=avr --mcu=$(MCU) $(ELF)
|
||||||
|
|
||||||
|
clean:
|
||||||
|
@echo -e "$(DEBUG)>>> Cleaning... <<<$(STOP)"
|
||||||
|
rm -rf $(ELF) $(LSS) $(MAP) $(FLASH_IMAGE) $(EEPROM_IMAGE) $(OBJ_FILES)
|
||||||
|
rm -rf $(DIRS)
|
||||||
|
|
||||||
|
info:
|
||||||
|
@echo -e "$(DEBUG)MCU: $(MCU) F_CPU: $(F_CPU)$(STOP)"
|
||||||
|
@echo -e "$(DEBUG)Programer: $(DUDE_PROGRAMMER) Port: $(DUDE_PORT)$(STOP)"
|
||||||
|
@echo -e "$(DEBUG)Source dir: $(SRC_DIR) Build dir: $(BUILD_DIR)$(STOP)"
|
||||||
|
@echo -e "$(DEBUG)Project name: $(PROJECT_NAME)$(STOP)"
|
||||||
|
@echo -e "$(FOCUS)elf: $(ELF) lss: $(LSS) map: $(MAP)$(STOP)"
|
||||||
|
@echo -e "$(DEBUG)hex: $(FLASH_IMAGE) $(ESC)$(STOP)$(FOCUS)eep: $(EEPROM_IMAGE)$(STOP)"
|
||||||
|
@echo -e "$(DEBUG)All dirs: $(DIRS)$(STOP)"
|
||||||
|
@echo -e "$(DEBUG)All c files: $(C_FILES)$(STOP)"
|
||||||
|
@echo -e "$(DEBUG)All o files: $(OBJ_FILES)$(STOP)"
|
||||||
|
@echo -e "$(DEBUG)Cflags: $(CFLAGS)$(STOP)"
|
||||||
|
@echo $(LOWER_VAR)
|
||||||
|
@echo "done"
|
||||||
|
|
||||||
|
# nie testowane! sprawdzic poprawnosc parametrow
|
||||||
|
flash: $(FLASH_IMAGE)
|
||||||
|
@echo -e " $(PROGRAM)>>> Uplod only flash <<<$(STOP)"
|
||||||
|
$(AVRDUDE_PATH)/avrdude -p $(MCU) -P $(DUDE_PORT) -c $(DUDE_PROGRAMMER) -U flash:w:$(FLASH_IMAGE):i
|
||||||
|
|
||||||
|
flash_eeprom:
|
||||||
|
@echo -e " $(PROGRAM)>>> Upload flash and eeprom <<<$(STOP)"
|
||||||
|
avrdude -p $(MCU) -P $(DUDE_PORT) -c $(DUDE_PROGRAMMER) -U flash:w:$(FLASH_IMAGE):i -D -U eeprom:w:$(EEPROM_IMAGE):i
|
||||||
|
|
||||||
|
.SECONDEXPANSION:
|
||||||
|
$(OBJ_FILES): $(BUILD_DIR)/%.o: $(SRC_DIR)/%.c $$(wildcard $$(dir $(SRC_DIR)/%.c)*.h)
|
||||||
|
@if [ ! -d "$(dir $@)" ]; then echo -e "$(DEBUG) >>> Create dir: $(FOCUS)$(dir $@)$(DEBUG) <<<$(STOP)"; mkdir -p $(dir $@); fi
|
||||||
|
@echo -e "$(DEBUG)>>> Building file: $(FOCUS)$<$(DEBUG) --> $(FOCUS)$@$(DEBUG) <<<$(STOP)"
|
||||||
|
$(CC) $(CFLAGS) -c -o $@ $<
|
||||||
|
|
||||||
88
README.md
Normal file
88
README.md
Normal file
@@ -0,0 +1,88 @@
|
|||||||
|
## Ceedling Demo
|
||||||
|
---
|
||||||
|
To jest projekt testowy.
|
||||||
|
|
||||||
|
Kroki do wykonania:
|
||||||
|
1. W katalogu _Projekty_ uruchamiasz komende:
|
||||||
|
```bash
|
||||||
|
ceedling new MyProject
|
||||||
|
```
|
||||||
|
2. Dodajesz **.gitignore** [build/] i **README.md**
|
||||||
|
3. Konfiguracja vscode
|
||||||
|
|
||||||
|
* **c_cpp_properties.json**
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"configurations": [
|
||||||
|
{
|
||||||
|
"name": "Linux",
|
||||||
|
"includePath": [
|
||||||
|
"${workspaceFolder}/**",
|
||||||
|
"/var/lib/gems/2.7.0/gems/ceedling-0.30.0/vendor/unity/src/",
|
||||||
|
"/var/lib/gems/2.7.0/gems/ceedling-0.30.0/vendor/cmock/src"
|
||||||
|
],
|
||||||
|
"defines": [],
|
||||||
|
"compilerPath": "/usr/bin/gcc",
|
||||||
|
"cStandard": "c99",
|
||||||
|
"cppStandard": "gnu++14",
|
||||||
|
"intelliSenseMode": "gcc-x64"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"version": 4
|
||||||
|
}
|
||||||
|
```
|
||||||
|
* **launch.json** [Debuger]
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"version": "0.2.0",
|
||||||
|
"configurations": [
|
||||||
|
{
|
||||||
|
"name": "Ceedling Test Explorer Debug",
|
||||||
|
"type": "cppdbg",
|
||||||
|
"request": "launch",
|
||||||
|
"program": "${workspaceFolder}/build/test/out/${command:ceedlingExplorer.debugTestExecutable}",
|
||||||
|
"args": [],
|
||||||
|
"stopAtEntry": false,
|
||||||
|
"cwd": "${workspaceFolder}",
|
||||||
|
"environment": [],
|
||||||
|
"externalConsole": false,
|
||||||
|
"MIMode": "gdb",
|
||||||
|
"setupCommands": [
|
||||||
|
{
|
||||||
|
"description": "Enable pretty-printing for gdb",
|
||||||
|
"text": "-enable-pretty-printing",
|
||||||
|
"ignoreFailures": true
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"miDebuggerPath": "/usr/bin/gdb"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
```
|
||||||
|
* **settings.json** _tutaj nazwa musi być taka sama jak w launch.json_
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"ceedlingExplorer.debugConfiguration": "Ceedling Test Explorer Debug"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
* **project.yml** [xml_tests_report dodać]
|
||||||
|
```
|
||||||
|
:plugins:
|
||||||
|
:load_paths:
|
||||||
|
- "#{Ceedling.load_path}"
|
||||||
|
:enabled:
|
||||||
|
- stdout_pretty_tests_report
|
||||||
|
- module_generator
|
||||||
|
- xml_tests_report
|
||||||
|
```
|
||||||
|
4. Dodać **Makfile**
|
||||||
|
5. git
|
||||||
|
```bash
|
||||||
|
git add .
|
||||||
|
git commit -m "init commit"
|
||||||
|
git remote add gitea <url>
|
||||||
|
git push gitea master
|
||||||
|
git checkout -b new_feature
|
||||||
|
```
|
||||||
|
|
||||||
|
Powinno być gotowe do pracy
|
||||||
6
src/i2c/i2c.c
Normal file
6
src/i2c/i2c.c
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
#include "i2c.h"
|
||||||
|
|
||||||
|
uint16_t i2c_readRegister(uint8_t registerAddress)
|
||||||
|
{
|
||||||
|
return 0x00;
|
||||||
|
}
|
||||||
33
src/main.c
Normal file
33
src/main.c
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
#include "lights/lights.h"
|
||||||
|
#include <avr/io.h>
|
||||||
|
|
||||||
|
#define _FREQU 680
|
||||||
|
|
||||||
|
void adc_timer_init(void);
|
||||||
|
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
lights_SetHeadlightSwitchOn();
|
||||||
|
lights_SetHeadlightSwitchOff();
|
||||||
|
|
||||||
|
while (1)
|
||||||
|
{
|
||||||
|
PORTB |= (PB3 >> 1);
|
||||||
|
adc_timer_init();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void adc_timer_init(void)
|
||||||
|
{
|
||||||
|
ADMUX |= (1 << REFS1) | (1 << ADLAR);
|
||||||
|
ADCSRA |= (1 << ADEN) | (1 << ADATE) | (1 << ADPS2) | (1 << ADPS0) | (1 << ADIE);
|
||||||
|
//11 059 200/32 = 345 600/13,5 = 25 600
|
||||||
|
ADCSRB |= (1 << ADTS1) | (1 << ADTS0);
|
||||||
|
DIDR0 |= (1 << ADC0D);
|
||||||
|
|
||||||
|
TCCR0A |= (1 << WGM01);
|
||||||
|
// OCR0A = F_CPU/8/19200;
|
||||||
|
OCR0A = F_CPU / 64 / _FREQU;
|
||||||
|
TCCR0B |= (1 << CS01) | (1 << CS00);
|
||||||
|
TIMSK0 |= (1 << OCIE0A);
|
||||||
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
#include "tempSensor.h"
|
#include "tempSensor.h"
|
||||||
#include "i2c.h"
|
#include "../i2c/i2c.h"
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
float tempSensor_getTemperature(void)
|
float tempSensor_getTemperature(void)
|
||||||
Reference in New Issue
Block a user