forked from sensorium/Mozzi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mozzi_utils.h
65 lines (51 loc) · 992 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
53
54
55
56
57
58
59
60
61
62
63
64
65
#ifndef UTILS_H_
#define UTILS_H_
#if ARDUINO >= 100
#include "Arduino.h"
#else
#include "WProgram.h"
#endif
#include "hardware_defines.h"
// macros for setting and clearing register bits
#ifndef cbi
#define cbi(sfr, bit) (_SFR_UINT8_T(sfr) &= ~_BV(bit))
#endif
#ifndef sbi
#define sbi(sfr, bit) (_SFR_UINT8_T(sfr) |= _BV(bit))
#endif
/** @ingroup util
Set digital pin 13 to output for testing timing with an oscilloscope.*/
inline
void setPin13Out()
{
#if IS_AVR()
DDRB |= B00100000;
#else
pinMode(13, OUTPUT);
#endif
}
/** @ingroup util
Set pin 13 high for testing timing with an oscilloscope.*/
inline
void setPin13High()
{
#if IS_AVR()
PORTB |= B00100000;
#else
digitalWrite(13, HIGH);
#endif
}
/** @ingroup util
Set pin 13 low for testing timing with an oscilloscope.*/
inline
void setPin13Low()
{
#if IS_AVR()
PORTB &= B11011111;
#else
digitalWrite(13, LOW);
#endif
}
long trailingZeros(unsigned long v);
unsigned int BPMtoMillis(float bpm);
#endif /* UTILS_H_ */