cleanup the setup a bit

This commit is contained in:
Julian Daube 2019-02-08 22:22:28 +01:00 committed by Julian Daube
parent 6a946f09ac
commit abb58843cf
5 changed files with 10 additions and 91 deletions

View File

@ -6,6 +6,7 @@ SET(CMAKE_SYSTEM_PROCESSOR avr)
find_program(AVR_CC avr-gcc) find_program(AVR_CC avr-gcc)
find_program(AVR_CXX avr-g++) find_program(AVR_CXX avr-g++)
find_program(AVR_OBJCOPY avr-objcopy) find_program(AVR_OBJCOPY avr-objcopy)
find_program(AVR_OBJDUMP avr-objdump)
find_program(AVR_SIZE_TOOL avr-size) find_program(AVR_SIZE_TOOL avr-size)
# set compiler (globally) # set compiler (globally)
@ -13,7 +14,7 @@ SET(CMAKE_C_COMPILER ${AVR_CC})
SET(CMAKE_CXX_COMPILER ${AVR_CXX}) SET(CMAKE_CXX_COMPILER ${AVR_CXX})
SET(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS) SET(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS)
add_definitions(-mmcu=${AVR_MCU} -DF_CPU=8000000 --std=c99) add_definitions(-mmcu=${AVR_MCU} -D__${AVR_MCU}__ -DF_CPU=8000000 --std=c99)
function(add_avr_executable EXECUTABLE_NAME) function(add_avr_executable EXECUTABLE_NAME)

View File

@ -1,10 +1,11 @@
cmake_minimum_required(VERSION 3.0.0) cmake_minimum_required(VERSION 3.0.0)
set(AVR_MCU attiny84a) set(AVR_MCU attiny84a)
include(avr-toolchain.cmake) include(${CMAKE_CURRENT_SOURCE_DIR}/../avr-toolchain.cmake)
project(DSPLAB_display_firmware C) project(DSPLAB_display_firmware C)
add_subdirectory(SliderCommunication)
set(CMAKE_C_FLAGS ${CMAKE_C_FLAGS} "-O3") set(CMAKE_C_FLAGS ${CMAKE_C_FLAGS} "-O3")
add_avr_executable(DSPLAB_display_firmware main.c) add_avr_executable(DSPLAB_display_firmware main.c)

View File

@ -1,10 +1,11 @@
cmake_minimum_required(VERSION 3.0.0) cmake_minimum_required(VERSION 3.0.0)
set(AVR_MCU attiny84) set(AVR_MCU attiny84)
include(avr-toolchain.cmake) include(${CMAKE_CURRENT_SOURCE_DIR}/../avr-toolchain.cmake)
project(slider_firmware C) project(slider_firmware C)
add_subdirectory(../../libs/common ${CMAKE_CURRENT_BINARY_DIR}/libs EXCLUDE_FROM_ALL) add_subdirectory(SliderCommunication)
add_avr_executable(slider_firmware main.c) add_avr_executable(slider_firmware main.c)
target_link_libraries(slider_firmware DSPLAB_common) target_link_libraries(slider_firmware DSPLAB_SliderCommunication)

View File

@ -1,85 +0,0 @@
# give info about target
SET(CMAKE_SYSTEM_NAME Generic)
SET(CMAKE_SYSTEM_PROCESSOR avr)
# find tools
find_program(AVR_CC avr-gcc)
find_program(AVR_CXX avr-g++)
find_program(AVR_OBJCOPY avr-objcopy)
find_program(AVR_SIZE_TOOL avr-size)
# set compiler (globally)
SET(CMAKE_C_COMPILER ${AVR_CC})
SET(CMAKE_CXX_COMPILER ${AVR_CXX})
SET(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS)
add_definitions(-mmcu=${AVR_MCU} -DF_CPU=8000000 --std=c99)
function(add_avr_executable EXECUTABLE_NAME)
if(NOT ARGN)
message(FATAL_ERROR "No source files given for ${EXECUTABLE_NAME}.")
endif(NOT ARGN)
# set file names
set(elf_file ${EXECUTABLE_NAME})
set(hex_file ${EXECUTABLE_NAME}.hex)
set(lst_file ${EXECUTABLE_NAME}.lst)
set(map_file ${EXECUTABLE_NAME}.map)
set(eeprom_image ${EXECUTABLE_NAME}_eeprom.hex)
# elf file
add_executable(${elf_file} EXCLUDE_FROM_ALL ${ARGN})
set_target_properties(
${elf_file}
PROPERTIES
COMPILE_FLAGS "-mmcu=${AVR_MCU}"
LINK_FLAGS "-mmcu=${AVR_MCU} -Wl,--gc-sections -mrelax -Wl,-Map,${map_file}"
)
add_custom_command(
OUTPUT ${hex_file}
COMMAND
${AVR_OBJCOPY} -j .text -j .data -O ihex ${elf_file} ${hex_file}
COMMAND
${AVR_SIZE_TOOL} ${AVR_SIZE_ARGS} ${elf_file}
DEPENDS ${elf_file}
)
add_custom_command(
OUTPUT ${lst_file}
COMMAND
${AVR_OBJDUMP} -d ${elf_file} > ${lst_file}
DEPENDS ${elf_file}
)
# eeprom
add_custom_command(
OUTPUT ${eeprom_image}
COMMAND
${AVR_OBJCOPY} -j .eeprom --set-section-flags=.eeprom=alloc,load
--change-section-lma .eeprom=0 --no-change-warnings
-O ihex ${elf_file} ${eeprom_image}
DEPENDS ${elf_file}
)
add_custom_target(
build_${EXECUTABLE_NAME}
ALL
DEPENDS ${hex_file} ${lst_file} ${eeprom_image}
)
set_target_properties(
build_${EXECUTABLE_NAME}
PROPERTIES
OUTPUT_NAME "${elf_file}"
)
# clean
get_directory_property(clean_files ADDITIONAL_MAKE_CLEAN_FILES)
set_directory_properties(
PROPERTIES
ADDITIONAL_MAKE_CLEAN_FILES "${map_file}"
)
endfunction(add_avr_executable)

View File

@ -20,6 +20,7 @@ enum {
ADC_CHANNEL_COUNT ADC_CHANNEL_COUNT
}; };
uint16_t adc_samples[ADC_CHANNEL_COUNT]; uint16_t adc_samples[ADC_CHANNEL_COUNT];
uint8_t adc_current_sample; uint8_t adc_current_sample;
@ -89,7 +90,7 @@ int button_is_pressed() {
#define SLAVE_ENABLE_REG PINA #define SLAVE_ENABLE_REG PINA
#define SLAVE_ENABLE_PIN 1 #define SLAVE_ENABLE_PIN 1
#include <common/interface.h> #include <interface.h>
void comm_write(iface_t * iface, byte_t byte) { void comm_write(iface_t * iface, byte_t byte) {
// disable interrupt // disable interrupt