Skip to content

Commit 4014dd6

Browse files
Allow variants to define an initVariant() function that is called at startup.
See #2080 and #2139.
1 parent 4eb6866 commit 4014dd6

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

hardware/arduino/avr/cores/arduino/Arduino.h

+1
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ typedef uint8_t boolean;
118118
typedef uint8_t byte;
119119

120120
void init(void);
121+
void initVariant(void);
121122

122123
void pinMode(uint8_t, uint8_t);
123124
void digitalWrite(uint8_t, uint8_t);

hardware/arduino/avr/cores/arduino/main.cpp

+7
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,17 @@
1919

2020
#include <Arduino.h>
2121

22+
// Weak empty variant initialization function.
23+
// May be redefined by variant files.
24+
void initVariant() __attribute__((weak));
25+
void initVariant() { }
26+
2227
int main(void)
2328
{
2429
init();
2530

31+
initVariant();
32+
2633
#if defined(USBCON)
2734
USBDevice.attach();
2835
#endif

0 commit comments

Comments
 (0)