Skip to content

Timer1c support and per-variant initialization function #2080

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jul 1, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions app/src/processing/app/debug/Compiler.java
Original file line number Diff line number Diff line change
Expand Up @@ -690,6 +690,8 @@ private void compileFilesInFolder(File buildFolder, File srcFolder, List<File> i

// 3. compile the core, outputting .o files to <buildPath> and then
// collecting them into the core.a library file.
// Also compiles the variant (if it supplies actual source files),
// which are included in the link directly (not through core.a)
void compileCore()
throws RunnerException {

Expand All @@ -702,13 +704,9 @@ void compileCore()
if (variantFolder != null)
includeFolders.add(variantFolder);

List<File> objectFiles = compileFiles(buildFolder, coreFolder, true,
includeFolders);
if (variantFolder != null)
objectFiles.addAll(compileFiles(buildFolder, variantFolder, true,
includeFolders));

for (File file : objectFiles) {
List<File> coreObjectFiles = compileFiles(buildFolder, coreFolder, true,
includeFolders);
for (File file : coreObjectFiles) {

PreferencesMap dict = new PreferencesMap(prefs);
dict.put("ide_version", "" + Base.REVISION);
Expand All @@ -724,6 +722,10 @@ void compileCore()
}
execAsynchronously(cmdArray);
}

if (variantFolder != null)
objectFiles.addAll(compileFiles(buildFolder, variantFolder, true,
includeFolders));
}

// 4. link it all together into the .elf file
Expand Down
2 changes: 1 addition & 1 deletion app/src/processing/app/debug/TargetPlatform.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public TargetPlatform(String _name, File _folder, TargetPackage parent)
if (!boardsFile.exists() || !boardsFile.canRead())
throw new TargetPlatformException(
format(_("Could not find boards.txt in {0}. Is it pre-1.5?"),
boardsFile.getAbsolutePath()));
folder.getAbsolutePath()));

// Load boards
try {
Expand Down
30 changes: 16 additions & 14 deletions hardware/arduino/avr/cores/arduino/Arduino.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ typedef uint8_t boolean;
typedef uint8_t byte;

void init(void);
void initVariant(void);

void pinMode(uint8_t, uint8_t);
void digitalWrite(uint8_t, uint8_t);
Expand Down Expand Up @@ -194,20 +195,21 @@ extern const uint8_t PROGMEM digital_pin_to_timer_PGM[];
#define TIMER0B 2
#define TIMER1A 3
#define TIMER1B 4
#define TIMER2 5
#define TIMER2A 6
#define TIMER2B 7

#define TIMER3A 8
#define TIMER3B 9
#define TIMER3C 10
#define TIMER4A 11
#define TIMER4B 12
#define TIMER4C 13
#define TIMER4D 14
#define TIMER5A 15
#define TIMER5B 16
#define TIMER5C 17
#define TIMER1C 5
#define TIMER2 6
#define TIMER2A 7
#define TIMER2B 8

#define TIMER3A 9
#define TIMER3B 10
#define TIMER3C 11
#define TIMER4A 12
#define TIMER4B 13
#define TIMER4C 14
#define TIMER4D 15
#define TIMER5A 16
#define TIMER5B 17
#define TIMER5C 18

#ifdef __cplusplus
} // extern "C"
Expand Down
7 changes: 7 additions & 0 deletions hardware/arduino/avr/cores/arduino/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,17 @@

#include <Arduino.h>

// Weak empty variant initialization function.
// May be redefined by variant files.
void initVariant() __attribute__((weak));
void initVariant() { }

int main(void)
{
init();

initVariant();

#if defined(USBCON)
USBDevice.attach();
#endif
Expand Down
8 changes: 8 additions & 0 deletions hardware/arduino/avr/cores/arduino/wiring_analog.c
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,14 @@ void analogWrite(uint8_t pin, int val)
break;
#endif

#if defined(TCCR1A) && defined(COM1C1)
case TIMER1C:
// connect pwm to pin on timer 1, channel B
sbi(TCCR1A, COM1C1);
OCR1C = val; // set pwm duty
break;
#endif

#if defined(TCCR2) && defined(COM21)
case TIMER2:
// connect pwm to pin on timer 2
Expand Down
3 changes: 3 additions & 0 deletions hardware/arduino/avr/cores/arduino/wiring_digital.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@ static void turnOffPWM(uint8_t timer)
#if defined(TCCR1A) && defined(COM1B1)
case TIMER1B: cbi(TCCR1A, COM1B1); break;
#endif
#if defined(TCCR1A) && defined(COM1C1)
case TIMER1C: cbi(TCCR1A, COM1C1); break;
#endif

#if defined(TCCR2) && defined(COM21)
case TIMER2: cbi(TCCR2, COM21); break;
Expand Down