Skip to content

Commit

Permalink
make MCU, PARTNO and F_CPU configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
gdamjan authored and sw17ch committed Oct 18, 2011
1 parent 3a19d2b commit 617adde
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions Rakefile
@@ -1,6 +1,9 @@
require 'rake/clean'
require 'fileutils'

MCU = ENV['MCU'] || 'atmega328p'
PARTNO = ENV['PARTNO'] || MCU
F_CPU = ENV['F_CPU'] || '16000000UL'
SERIAL_PORT = ENV['SERIAL_PORT']
PROG = 'scaffold'
SRCDIR = 'src'
Expand All @@ -23,16 +26,16 @@ TARGET = {
:compiler => 'avr-gcc',
:compiler_args => [
'-DTARGET',
'-DF_CPU=16000000UL',
'-mmcu=atmega328p',
"-DF_CPU=#{F_CPU}",
"-mmcu=#{MCU}",
'-Iinclude/',
'-Wall',
'-Os',
'-c'
],
:linker => 'avr-gcc',
:linker_args => [
'-mmcu=atmega328p'
"-mmcu=#{MCU}"
],
:objcopy => 'avr-objcopy'
}
Expand Down Expand Up @@ -90,11 +93,11 @@ namespace :target do

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

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

0 comments on commit 617adde

Please sign in to comment.