Skip to content
Prev Previous commit
Next Next commit
separate ADC definition into separate files and add a test
  • Loading branch information
PRosenb committed Feb 6, 2019
commit 16655d5c7c8b1431fb98f0ebc30a87383225772f
10 changes: 10 additions & 0 deletions SampleProjects/TestSomething/test/adc.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#include <ArduinoUnitTests.h>
#include <Arduino.h>

unittest(check_ADCSRA_read_write) {
ADCSRA = 123;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where is ADCSRA defined?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added explanations into this file


assertEqual(123, ADCSRA);
}

unittest_main()
1 change: 1 addition & 0 deletions SampleProjects/TestSomething/test/isr_declaration.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include <ArduinoUnitTests.h>
#include <Arduino.h>

// just check if declaration compiles
ISR (WDT_vect) {
Copy link
Collaborator

@ianfixes ianfixes Feb 6, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please move this to interrupts.cpp, and add a comment with some explanation of WDT_vect.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

}

Expand Down
1 change: 1 addition & 0 deletions cpp/arduino/Arduino.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ typedef uint8_t byte;
// Math and Trig
#include "AvrMath.h"

#include "AvrAdc.h"
#include <avr/interrupt.h>

#include "Godmode.h"
Expand Down
4 changes: 4 additions & 0 deletions cpp/arduino/AvrAdc.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#include "AvrAdc.h"

// mock storage to allow access to ADCSRA
unsigned char sfr_store;
8 changes: 8 additions & 0 deletions cpp/arduino/AvrAdc.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#ifndef _AVR_ADC_H_
#define _AVR_ADC_H_

// mock storage to allow access to ADCSRA
extern unsigned char sfr_store;
#define _SFR_MEM8(mem_addr) sfr_store

#endif // _AVR_ADC_H_
4 changes: 0 additions & 4 deletions cpp/arduino/avr/sleep.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,4 @@ void sleep_mode() {
sleep_disable();
}

// mock storage to allow access to ADCSRA
unsigned char sfr_store;
#define _SFR_MEM8(mem_addr) sfr_store

#endif /* _AVR_SLEEP_H_ */