Skip to content

Commit 617adde

Browse files
gdamjansw17ch
authored andcommitted
make MCU, PARTNO and F_CPU configurable
1 parent 3a19d2b commit 617adde

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

Rakefile

+8-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
require 'rake/clean'
22
require 'fileutils'
33

4+
MCU = ENV['MCU'] || 'atmega328p'
5+
PARTNO = ENV['PARTNO'] || MCU
6+
F_CPU = ENV['F_CPU'] || '16000000UL'
47
SERIAL_PORT = ENV['SERIAL_PORT']
58
PROG = 'scaffold'
69
SRCDIR = 'src'
@@ -23,16 +26,16 @@ TARGET = {
2326
:compiler => 'avr-gcc',
2427
:compiler_args => [
2528
'-DTARGET',
26-
'-DF_CPU=16000000UL',
27-
'-mmcu=atmega328p',
29+
"-DF_CPU=#{F_CPU}",
30+
"-mmcu=#{MCU}",
2831
'-Iinclude/',
2932
'-Wall',
3033
'-Os',
3134
'-c'
3235
],
3336
:linker => 'avr-gcc',
3437
:linker_args => [
35-
'-mmcu=atmega328p'
38+
"-mmcu=#{MCU}"
3639
],
3740
:objcopy => 'avr-objcopy'
3841
}
@@ -90,11 +93,11 @@ namespace :target do
9093

9194
desc "Program the Arduino over the serial port."
9295
task :program => [:convert, :serial_port] do
93-
sh "avrdude -F -V -c arduino -p ATMEGA328P -P #{SERIAL_PORT} -b 115200 -U flash:w:#{PROG}.hex"
96+
sh "avrdude -F -V -c arduino -p #{PARTNO} -P #{SERIAL_PORT} -b 115200 -U flash:w:#{PROG}.hex"
9497
end
9598

9699
desc "Make a backup hex image of the flash contents."
97100
task :backup, [:backup_name] => :serial_port do |t, args|
98-
sh "avrdude -F -V -c arduino -p ATMEGA328P -P #{SERIAL_PORT} -b 115200 -U flash:r:#{args.backup_name}:i"
101+
sh "avrdude -F -V -c arduino -p #{PARTNO} -P #{SERIAL_PORT} -b 115200 -U flash:r:#{args.backup_name}:i"
99102
end
100103
end

0 commit comments

Comments
 (0)