inital commit
This commit is contained in:
commit
42adc515cf
35 changed files with 9957 additions and 0 deletions
54
fandevicefw/CMakeLists.txt
Normal file
54
fandevicefw/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
# CMake version
|
||||
cmake_minimum_required(VERSION 3.10)
|
||||
|
||||
project(fanddevice C CXX ASM)
|
||||
|
||||
set(MCU "attiny3226")
|
||||
set(CPU_SPEED "16500000")
|
||||
message(STATUS "${CPU_SPEED}")
|
||||
|
||||
set(SRC_FILES
|
||||
main.cpp
|
||||
usbdrv/usbdrvasm.S
|
||||
usbdrv/usbdrv.c
|
||||
usbdrv/oddebug.c
|
||||
)
|
||||
|
||||
set(CMAKE_C_COMPILER /usr/bin/avr-gcc)
|
||||
set(CMAKE_CXX_COMPILER /usr/bin/avr-g++)
|
||||
set(CMAKE_ASM_COMPILER /usr/bin/avr-gcc)
|
||||
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)
|
||||
|
||||
add_definitions(-mmcu=${MCU} -DF_CPU=${CPU_SPEED} -c -g -Os -flto -ffunction-sections -fdata-sections)
|
||||
set(CMAKE_CXX_FLAGS "-std=c++17 -fno-exceptions -fno-strict-aliasing -fno-rtti")
|
||||
set(CMAKE_C_FLAGS "")
|
||||
|
||||
set(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "") # remove -rdynamic for C
|
||||
set(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "") # remove -rdynamic for CXX
|
||||
set(CMAKE_SHARED_LIBRARY_LINK_ASM_FLAGS "") # remove -rdynamic for ASM
|
||||
set(CMAKE_EXE_LINKER_FLAGS "-s -Os -Wl,--gc-sections -mmcu=${MCU}")
|
||||
|
||||
add_executable(${PROJECT_NAME} ${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(export
|
||||
COMMAND ${CMAKE_OBJCOPY} -j .text -j .data -O ihex ${PROJECT_NAME} ${PROJECT_NAME}.hex
|
||||
COMMAND ${AR_AVRSIZE} -C ${PROJECT_NAME}
|
||||
DEPENDS ${PROJECT_NAME}
|
||||
)
|
||||
|
||||
add_custom_target(download
|
||||
COMMAND ${AR_AVRDUDE} -c serialupdi -P /dev/ttyUSB0 -p t3226 -B 1 -U flash:w:${PROJECT_NAME}.hex
|
||||
DEPENDS export
|
||||
)
|
||||
|
||||
add_custom_target(fuses
|
||||
COMMAND ${AR_AVRDUDE} -c serialupdi -P /dev/ttyUSB0 -p t3226 -B 1 -U osccfg:w:0x01:m -U syscfg0:w:0xF7:m
|
||||
)
|
||||
|
||||
target_include_directories(${PROJECT_NAME} PRIVATE ./usbdrv)
|
||||
Loading…
Add table
Add a link
Reference in a new issue