From d08ae5b8b2db62962c2f4f8523a42d16eca25db7 Mon Sep 17 00:00:00 2001 From: uvos Date: Mon, 10 Jan 2022 22:51:48 +0100 Subject: [PATCH] add missing files --- CMakeLists.txt | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++ bitrep.h | 9 ++++++++ commands | 8 +++++++ trains | 4 ++++ 4 files changed, 80 insertions(+) create mode 100644 CMakeLists.txt create mode 100644 bitrep.h create mode 100644 commands create mode 100644 trains diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..f94530c --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,59 @@ +## A simple CMake file to compile an Arduino project. +## Adjust the settings according to your board. +## The settings here work for the Arduino Uno, Rev. 3. + +# Project name +project(marklincontroller) + +# CMake version +cmake_minimum_required(VERSION 2.6) + +# Options +# Adjust to your board +set(MCU "atmega328p" CACHE STRING "Processor Type") +set(CPU_SPEED "16000000" CACHE STRING "Speed of the CPU") +set(PORT "/dev/ttyUSB3" CACHE STRING "USB Port") +set(PORT_SPEED "57600" CACHE STRING "Serial Port Speed") +set(PROGRAMMER "stk500v1" CACHE STRING "Programmer Type") +set(COMPILE_FLAGS "" CACHE STRING "Additional Compiler Flags") + +# Set own source files +# Simply list all your C / C++ source (not header!) files here +set(SRC_FILES main.cpp serial.cpp train.cpp) + +# Compiler suite specification +set(CMAKE_C_COMPILER /usr/bin/avr-gcc) +set(CMAKE_CXX_COMPILER /usr/bin/avr-g++) +set(CMAKE_OBJCOPY /usr/bin/avr-objcopy) +set(CMAKE_OBJDUMP /usr/bin/avr-objdump) +set(CMAKE_RANLIB /usr/bin/avr-ranlib) +set(CMAKE_LINKER /usr/bin/avr-ld) + +# Compiler flags +add_definitions(-mmcu=${MCU} -DF_CPU=${CPU_SPEED}) +add_definitions(-s -c -g -Os -Wall -std=c++11 ) +add_definitions(-fno-exceptions -ffunction-sections -fdata-sections) + +# Linker flags +set(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "-Os") # remove -rdynamic for C +set(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "-Os") # remove -rdynamic for CXX +set(CMAKE_EXE_LINKER_FLAGS "-Os -Wl,--gc-sections -mmcu=${MCU}") + +add_executable(${PROJECT_NAME} ${ARDUINO_CORE_SRC} ${SRC_FILES}) + +find_program(AR_AVRDUDE NAMES avrdude PATHS /usr/bin NO_DEFAULT_PATH) + +find_program(AR_AVRSIZE NAMES avr-size PATHS /usr/bin NO_DEFAULT_PATH) + +add_custom_target(download + COMMAND ${CMAKE_OBJCOPY} -j .text -j .data -O ihex ${PROJECT_NAME} ${PROJECT_NAME}.hex + COMMAND ${AR_AVRSIZE} -C ${PROJECT_NAME} + COMMAND ${AR_AVRDUDE} -v -p ${MCU} -c ${PROGRAMMER} -P /dev/ttyUSB0 -b 57600 -D -U flash:w:${PROJECT_NAME}.hex + DEPENDS ${PROJECT_NAME} + ) + +add_custom_target(export +COMMAND ${CMAKE_OBJCOPY} -j .text -j .data -O ihex ${PROJECT_NAME} ${PROJECT_NAME}.hex +COMMAND ${AR_AVRSIZE} -C ${PROJECT_NAME} +DEPENDS ${PROJECT_NAME} +) diff --git a/bitrep.h b/bitrep.h new file mode 100644 index 0000000..8cf1d25 --- /dev/null +++ b/bitrep.h @@ -0,0 +1,9 @@ +#pragma once + +const char *bit_rep[16] = +{ + [ 0] = "0000", [ 1] = "0001", [ 2] = "0010", [ 3] = "0011", + [ 4] = "0100", [ 5] = "0101", [ 6] = "0110", [ 7] = "0111", + [ 8] = "1000", [ 9] = "1001", [10] = "1010", [11] = "1011", + [12] = "1100", [13] = "1101", [14] = "1110", [15] = "1111", +}; diff --git a/commands b/commands new file mode 100644 index 0000000..3aec079 --- /dev/null +++ b/commands @@ -0,0 +1,8 @@ +Lights: + +TRYING: 3 //works 0000000011 + +TELEX: + +TRYING: 280 //works front telex 0b1010000000 +TRYING: 2A0 //works rear telex 0b1010100000 diff --git a/trains b/trains new file mode 100644 index 0000000..1690d55 --- /dev/null +++ b/trains @@ -0,0 +1,4 @@ +NUMBER: 0 ID: 01010100 CURRENT SPD: 0 +NUMBER: 1 ID: 01010000 CURRENT SPD: 0 +NUMBER: 2 ID: 01000100 CURRENT SPD: 0 +NUMBER: 3 ID: 00010100 CURRENT SPD: 0