Skip to content

Commit 8180efb

Browse files
committed
Fix definition of SFR macro to prevent linker errors about duplicate symbol
1 parent 334b7aa commit 8180efb

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

cpp/arduino/Arduino.h

+9-2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,15 @@ Mock Arduino.h library.
55
Where possible, variable names from the Arduino library are used to avoid conflicts
66
77
*/
8+
9+
// hardware mocks
10+
volatile long long __ARDUINO_CI_SFR_MOCK[1024];
11+
#define _SFR_IO8(io_addr) (*(volatile uint8_t *)(__ARDUINO_CI_SFR_MOCK + io_addr)) // this macro is all we need from the sfr file
12+
#define _SFR_IO16(io_addr) (*(volatile uint16_t *)(__ARDUINO_CI_SFR_MOCK + io_addr)) // this macro is all we need from the sfr file
13+
#define _SFR_MEM8(io_addr) (*(volatile uint8_t *)(__ARDUINO_CI_SFR_MOCK + io_addr)) // this macro is all we need from the sfr file
14+
#define _SFR_MEM16(io_addr) (*(volatile uint16_t *)(__ARDUINO_CI_SFR_MOCK + io_addr)) // this macro is all we need from the sfr file
15+
#define _SFR_MEM32(io_addr) (*(volatile uint32_t *)(__ARDUINO_CI_SFR_MOCK + io_addr)) // this macro is all we need from the sfr file
16+
817
// Chars and strings
918

1019
#include "ArduinoDefines.h"
@@ -71,5 +80,3 @@ inline unsigned int makeWord(unsigned int w) { return w; }
7180
inline unsigned int makeWord(unsigned char h, unsigned char l) { return (h << 8) | l; }
7281

7382
#define word(...) makeWord(__VA_ARGS__)
74-
75-

cpp/arduino/avr/io.h

-2
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,6 @@
9696
#ifndef _AVR_IO_H_
9797
#define _AVR_IO_H_
9898

99-
#define _SFR_IO8(io_addr) (*(volatile uint8_t *)(io_addr)) // this macro is all we need from the sfr file
100-
10199
#if defined (__AVR_AT94K__)
102100
# include "ioat94k.h"
103101
#elif defined (__AVR_AT43USB320__)

0 commit comments

Comments
 (0)