forked from sensorium/Mozzi
-
Notifications
You must be signed in to change notification settings - Fork 1
/
mozzi_utils.h
52 lines (39 loc) · 886 Bytes
/
mozzi_utils.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#ifndef UTILS_H_
#define UTILS_H_
#if ARDUINO >= 100
#include "Arduino.h"
#else
#include "WProgram.h"
#endif
/** @defgroup util Mozzi utility functions
Useful for debugging and profiling high frequency code with an oscilloscope, when serial is too slow.
*/
/** @ingroup util
Set digital pin 13 to output for testing timing with an oscilloscope.*/
inline
void setPin13Out()
{
DDRB |= B00100000;
}
/** @ingroup util
Set pin 13 high for testing timing with an oscilloscope.*/
inline
void setPin13High()
{
PORTB |= B00100000;
}
/** @ingroup util
Set pin 13 low for testing timing with an oscilloscope.*/
inline
void setPin13Low()
{
PORTB &= B11011111;
}
// macros for setting and clearing register bits
#ifndef cbi
#define cbi(sfr, bit) (_SFR_BYTE(sfr) &= ~_BV(bit))
#endif
#ifndef sbi
#define sbi(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit))
#endif
#endif /* UTILS_H_ */