]> git.donarmstrong.com Git - kiibohd-controller.git/blob - avr.cmake
UART0 on Teensy 3.0 now functional
[kiibohd-controller.git] / avr.cmake
1 ###| CMAKE Kiibohd Controller |###
2 #
3 # Jacob Alexander 2011-2013
4 # Due to this file's usefulness:
5 #
6 # Released into the Public Domain
7 #
8 # avr-gcc CMake Build Configuration
9 #
10 ###
11
12
13
14 #| Set the Compilers (must be set first)
15 include( CMakeForceCompiler )
16 cmake_force_c_compiler  ( avr-gcc AVRCCompiler )
17 cmake_force_cxx_compiler( avr-g++ AVRCxxCompiler )
18
19
20 #| Compiler Binaries
21 set( OBJCOPY "avr-objcopy" )
22 set( OBJDUMP "avr-objdump" )
23 set( NM      "avr-nm"      )
24 set( SIZE    "avr-size"    )
25
26
27
28 ###
29 # Atmel Defines and Linker Options
30 #
31
32 #| MCU Name
33 #| You _MUST_ set this to match the board you are using
34 #| type "make clean" after changing this, so all files will be rebuilt
35 #|
36 #| "at90usb162"       # Teensy   1.0
37 #| "atmega32u4"       # Teensy   2.0
38 #| "at90usb646"       # Teensy++ 1.0
39 #| "at90usb1286"      # Teensy++ 2.0
40 #set( MCU "atmega32u4" )
41 set( MCU "at90usb1286" )
42
43 message( STATUS "MCU Selected:" )
44 message( "${MCU}" )
45
46
47 #| Extra Compiler Sources
48 #| Mostly for convenience functions like interrupt handlers
49 set( COMPILER_SRCS
50         # XXX Not needed for avr-gcc
51 )
52
53
54 #| Compiler flag to set the C Standard level.
55 #|     c89   = "ANSI" C
56 #|     gnu89 = c89 plus GCC extensions
57 #|     c99   = ISO C99 standard (not yet fully implemented)
58 #|     gnu99 = c99 plus GCC extensions
59 set( CSTANDARD "-std=gnu99" )
60
61
62 #| Warning Options
63 #|  -Wall...:     warning level
64 set( WARN "-Wall -Wstrict-prototypes" )
65
66
67 #| Tuning Options
68 #|  -f...:        tuning, see GCC manual and avr-libc documentation
69 set( TUNING "-funsigned-char -funsigned-bitfields -ffunction-sections -fpack-struct -fshort-enums" )
70
71
72 #| Optimization level, can be [0, 1, 2, 3, s]. 
73 #|     0 = turn off optimization. s = optimize for size.
74 #|     (Note: 3 is not always the best optimization level. See avr-libc FAQ.)
75 set( OPT "s" )
76
77
78 #| Output Format
79 #| srec, ihex, binary
80 set( FORMAT "ihex" )
81
82
83 #| Processor frequency.
84 #|   Normally the first thing your program should do is set the clock prescaler,
85 #|   so your program will run at the correct speed.  You should also set this
86 #|   variable to same clock speed.  The _delay_ms() macro uses this, and many
87 #|   examples use this variable to calculate timings.  Do not add a "UL" here.
88 set( F_CPU "16000000" )
89
90
91 #| Dependency Files
92 #| Compiler flags to generate dependency files.
93 set( GENDEPFLAGS "-MMD -MP" )
94
95
96 #| Compiler Flags
97 add_definitions( "-mmcu=${MCU} -DF_CPU=${F_CPU} -D_${MCU}_=1 -O${OPT} ${TUNING} ${WARN} ${CSTANDARD} ${GENDEPFLAGS} -I${CMAKE_CURRENT_SOURCE_DIR}" )
98
99
100 #| Linker Flags
101 set( LINKER_FLAGS "-mmcu=${MCU} -Wl,-Map=${TARGET}.map,--cref -Wl,--relax -Wl,--gc-sections" )
102
103
104 #| Hex Flags (XXX, CMake seems to have issues if you quote the arguments for the custom commands...)
105 set( HEX_FLAGS -O ${FORMAT} -R .eeprom -R .fuse -R .lock -R .signature )
106
107
108 #| Eep Flags (XXX, I've removed this target from the builds, but keeping the set line as a note)
109 set( EEP_FLAGS -j .eeprom --set-section-flags=.eeprom="alloc,load" --change-section-lma .eeprom=0 --no-change-warnings -O ${FORMAT} )
110
111
112 #| Lss Flags
113 set( LSS_FLAGS -h -S -z )
114