-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
122 lines (104 loc) · 4.3 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
cmake_minimum_required(VERSION 3.9)
set(AVR_UPLOADTOOL avrdude)
set(AVR_PROGRAMMER usbtiny)
set(AVR_UPLOADTOOL_PORT usb)
set(AVR_UPLOADTOOL_OPTIONS -C ${CMAKE_CURRENT_SOURCE_DIR}/avrdude.conf)
set(AVR_MCU attiny167)
set(AVR_E_FUSE 0xfe)
set(AVR_H_FUSE 0xdd)
set(AVR_L_FUSE 0xdf)
project(Keyboard C CXX ASM)
include(gcc-avr-util.cmake)
##########################################################################
# needs to be defined for AVR toolchain
##########################################################################
set(MCU_SPEED "16000000UL")
##########################################################################
# some cmake cross-compile necessities
##########################################################################
if(DEFINED ENV{AVR_FIND_ROOT_PATH})
set(CMAKE_FIND_ROOT_PATH $ENV{AVR_FIND_ROOT_PATH})
else(DEFINED ENV{AVR_FIND_ROOT_PATH})
if(EXISTS "/opt/local/avr")
set(CMAKE_FIND_ROOT_PATH "/opt/local/avr")
elseif(EXISTS "/usr/avr")
set(CMAKE_FIND_ROOT_PATH "/usr/avr")
elseif(EXISTS "/usr/lib/avr")
set(CMAKE_FIND_ROOT_PATH "/usr/lib/avr")
elseif(EXISTS "/usr/local/CrossPack-AVR")
set(CMAKE_FIND_ROOT_PATH "/usr/local/CrossPack-AVR")
else(EXISTS "/opt/local/avr")
message(FATAL_ERROR "Please set AVR_FIND_ROOT_PATH in your environment.")
endif(EXISTS "/opt/local/avr")
endif(DEFINED ENV{AVR_FIND_ROOT_PATH})
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
# not added automatically, since CMAKE_SYSTEM_NAME is "generic"
set(CMAKE_SYSTEM_INCLUDE_PATH "${CMAKE_FIND_ROOT_PATH}/include")
set(CMAKE_SYSTEM_LIBRARY_PATH "${CMAKE_FIND_ROOT_PATH}/lib")
##########################################################################
# set compiler options for build types
##########################################################################
if(CMAKE_BUILD_TYPE MATCHES Release)
set(CMAKE_C_FLAGS_RELEASE "-Os")
set(CMAKE_CXX_FLAGS_RELEASE "-Os")
endif(CMAKE_BUILD_TYPE MATCHES Release)
if(CMAKE_BUILD_TYPE MATCHES RelWithDebInfo)
set(CMAKE_C_FLAGS_RELWITHDEBINFO "-Os -save-temps -g -gdwarf-3 -gstrict-dwarf")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-Os -save-temps -g -gdwarf-3 -gstrict-dwarf")
endif(CMAKE_BUILD_TYPE MATCHES RelWithDebInfo)
if(CMAKE_BUILD_TYPE MATCHES Debug)
set(CMAKE_C_FLAGS_DEBUG "-O0 -save-temps -g -gdwarf-3 -gstrict-dwarf")
set(CMAKE_CXX_FLAGS_DEBUG "-O0 -save-temps -g -gdwarf-3 -gstrict-dwarf")
endif(CMAKE_BUILD_TYPE MATCHES Debug)
##########################################################################
# compiler options for all build types
##########################################################################
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Werror -pedantic -pedantic-errors")
set(USB_CFG_IOPORTNAME "B")
set(USB_CFG_DMINUS_BIT "3")
set(USB_CFG_DPLUS_BIT "6")
set(USB_CFG_HAVE_INTRIN_ENDPOINT ON)
set(USB_CFG_INTR_POLL_INTERVAL 1)
set(USB_CFG_MAX_BUS_POWER "200")
set(USB_CFG_HID_REPORT_DESCRIPTOR_LENGTH 119)
set(USB_CFG_IMPLEMENT_FN_WRITE ON)
set(USB_COUNT_SOF ON)
set(USB_CFG_VENDOR_ID "0xc0, 0x16")
set(USB_CFG_VENDOR_NAME "schwanfurt.de")
set(USB_CFG_DEVICE_ID "0xdb, 0x27")
set(USB_CFG_DEVICE_NAME "Sun Type5 USB")
set(USB_CFG_DEVICE_CLASS 0)
set(USB_CFG_INTERFACE_CLASS 3)
set(USB_CFG_INTERFACE_SUBCLASS 1)
set(USB_CFG_INTERFACE_PROTOCOL 1)
# Use PCINT11 (B3, D-) instead of INT0
set(USB_CFG_MCU_DESC [[#define USB_INTR_CFG PCMSK1
#define USB_INTR_CFG_SET (1 << PCINT11)
#define USB_INTR_CFG_CLR (~(1 << PCINT11))
#define USB_INTR_ENABLE PCICR
#define USB_INTR_ENABLE_BIT PCIE1
#define USB_INTR_PENDING PCIFR
#define USB_INTR_PENDING_BIT PCIF1
#define USB_INTR_VECTOR PCINT1_vect]])
file(COPY lib/vusb_cmake/CMakeLists.txt lib/vusb_cmake/usbconfig.h.in DESTINATION lib/v-usb/usbdrv)
add_subdirectory(lib/v-usb/usbdrv)
add_avr_executable(keyboard
keyboard.cpp
stack.c
usb/descriptor_kbd.cpp
usb/report.h
usb/descriptor.h
usb/descriptor_kbd.h
keyboard/keymap.cpp
keyboard/keymap.h
keyboard/Keyboard.h
keyboard/Keyboard.cpp
keyboard/uart.h
keyboard/uart.cpp
)
target_link_libraries(keyboard PRIVATE vusb)
target_include_directories(keyboard PRIVATE "${CMAKE_CURRENT_LIST_DIR}")
#target_compile_options(keyboard PRIVATE -fstack-usage)
set_target_properties(keyboard PROPERTIES CXX_STANDARD 14)