Skip to content

Commit d899ffd

Browse files
author
James Foster
committed
Explore possible fix for Arduino-CI#187.
1 parent f6ca7a7 commit d899ffd

File tree

3 files changed

+20
-1
lines changed

3 files changed

+20
-1
lines changed

SampleProjects/TestSomething/test/defines.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,15 @@ unittest(binary)
88
assertEqual(100, B1100100);
99
}
1010

11+
#define DDRE _SFR_IO8(0x02)
12+
13+
unittest(SFR_IO8)
14+
{
15+
// in normal arduino code, you can do this. in arduino_ci, you might get an
16+
// error like: cannot take the address of an rvalue of type 'int'
17+
//
18+
// this tests that directly
19+
&DDRE;
20+
}
21+
1122
unittest_main()

cpp/arduino/Godmode.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,3 +113,5 @@ SPIClass SPI = SPIClass(&GODMODE()->spi.dataIn, &GODMODE()->spi.dataOut);
113113

114114
// defined in Wire.h
115115
TwoWire Wire = TwoWire();
116+
117+
volatile long long __ARDUINO_CI_SFR_MOCK[1024];

cpp/arduino/avr/io.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,13 @@
9696
#ifndef _AVR_IO_H_
9797
#define _AVR_IO_H_
9898

99-
#define _SFR_IO8(io_addr) (io_addr) // this macro is all we need from the sfr file
99+
// hardware mocks
100+
extern volatile long long __ARDUINO_CI_SFR_MOCK[1024];
101+
#define _SFR_IO8(io_addr) (*(volatile uint8_t *)(__ARDUINO_CI_SFR_MOCK + io_addr)) // this macro is all we need from the sfr file
102+
#define _SFR_IO16(io_addr) (*(volatile uint16_t *)(__ARDUINO_CI_SFR_MOCK + io_addr)) // this macro is all we need from the sfr file
103+
#define _SFR_MEM8(io_addr) (*(volatile uint8_t *)(__ARDUINO_CI_SFR_MOCK + io_addr)) // this macro is all we need from the sfr file
104+
#define _SFR_MEM16(io_addr) (*(volatile uint16_t *)(__ARDUINO_CI_SFR_MOCK + io_addr)) // this macro is all we need from the sfr file
105+
#define _SFR_MEM32(io_addr) (*(volatile uint32_t *)(__ARDUINO_CI_SFR_MOCK + io_addr)) // this macro is all we need from the sfr file
100106

101107
#if defined (__AVR_AT94K__)
102108
# include "ioat94k.h"

0 commit comments

Comments
 (0)