ThrowTheSwitch/arduino_c_scaffold — Issue #2: make MCU, PARTNO and F_CPU configurable
Author: gdamjan
Created: 2011-10-18 17:09:44+00:00
State: open

Here's a patch:

```
From a6cce5b42a531d08a8120a8451376911737c0d95 Mon Sep 17 00:00:00 2001
From: Damjan Georgievski
Date: Mon, 17 Oct 2011 06:15:52 +0200
Subject: [PATCH 1/4] make MCU, PARTNO and F_CPU configurable

---
Rakefile | 13 ++++++++-----
1 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/Rakefile b/Rakefile
index 62f4106..b30b133 100644
--- a/Rakefile
+++ b/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'
@@ -23,8 +26,8 @@ TARGET = {
:compiler => 'avr-gcc',
:compiler_args => [
'-DTARGET',
- '-DF_CPU=16000000UL',
- '-mmcu=atmega328p',
+ "-DF_CPU=#{F_CPU}",
+ "-mmcu=#{MCU}",
'-Iinclude/',
'-Wall',
'-Os',
@@ -32,7 +35,7 @@ TARGET = {
],
:linker => 'avr-gcc',
:linker_args => [
- '-mmcu=atmega328p'
+ "-mmcu=#{MCU}"
],
:objcopy => 'avr-objcopy'
}
@@ -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
--
1.7.7
```