File tree Expand file tree Collapse file tree 1 file changed +16
-3
lines changed Expand file tree Collapse file tree 1 file changed +16
-3
lines changed Original file line number Diff line number Diff line change @@ -72,6 +72,11 @@ void SetBUFFER_IDX(uint8_t idx, volatile uint16_t *V) {
72
72
* This interrupt handler is called every time the ADC finishes a conversion, if
73
73
* the ADC interrupt is enabled. It checks if the trigger condition is
74
74
* fulfilled, and if so copies ADC values into the buffer.
75
+ *
76
+ * @warning
77
+ * If this compilation unit is built with -O0 the ADC1_Interrupt
78
+ * functions won't be inlined. This causes call overhead which
79
+ * significantly reduces the oscilloscope sample rate.
75
80
*/
76
81
void __attribute__((interrupt , no_auto_psv )) _AD1Interrupt (void ) {
77
82
ADC1_InterruptFlagClear ();
@@ -85,9 +90,17 @@ void __attribute__((interrupt, no_auto_psv)) _AD1Interrupt(void) {
85
90
LED_Toggle ();
86
91
87
92
if (TRIGGERED ) {
88
- int i ;
89
- for (i = 0 ; i <= CHANNELS ; i ++ ) {
90
- * (BUFFER_IDX [i ]++ ) = * ADCVALS [i ];
93
+ /* Aweful-looking nested if clause ahead. This turns out to be faster
94
+ * than a for loop or a switch case, so we're stuck with it. */
95
+ * (BUFFER_IDX [0 ]++ ) = * ADCVALS [0 ];
96
+ if (CHANNELS >= 1 ) {
97
+ * (BUFFER_IDX [1 ]++ ) = * ADCVALS [1 ];
98
+ if (CHANNELS >= 2 ) {
99
+ * (BUFFER_IDX [2 ]++ ) = * ADCVALS [2 ];
100
+ if (CHANNELS >= 3 ) {
101
+ * (BUFFER_IDX [3 ]++ ) = * ADCVALS [3 ];
102
+ }
103
+ }
91
104
}
92
105
93
106
if (++ SAMPLES_CAPTURED == SAMPLES_REQUESTED ) {
You can’t perform that action at this time.
0 commit comments