Mozzi
version v1.1.0
sound synthesis library for Arduino
mozzi_utils.h
1
2
#
ifndef
UTILS_H_
3
#
define
UTILS_H_
4
5
6
#
if
ARDUINO
>=
100
7
#
include
"Arduino.h"
8
#
else
9
#
include
"WProgram.h"
10
#
endif
11
12
#
include
"hardware_defines.h"
13
14
// macros for setting and clearing register bits
15
#
ifndef
cbi
16
#
define
cbi
(
sfr
,
bit
)
(
_SFR_UINT8_T
(
sfr
)
&=
~
_BV
(
bit
)
)
17
#
endif
18
#
ifndef
sbi
19
#
define
sbi
(
sfr
,
bit
)
(
_SFR_UINT8_T
(
sfr
)
|=
_BV
(
bit
)
)
20
#
endif
21
22
23
/** @ingroup util
24
Set digital pin 13 to output for testing timing with an oscilloscope.*/
25
inline
26
void
setPin13Out
()
27
{
28
#
if
IS_AVR
(
)
29
DDRB |= B00100000;
30
#
else
31
pinMode(13, OUTPUT);
32
#
endif
33
}
34
35
36
/** @ingroup util
37
Set pin 13 high for testing timing with an oscilloscope.*/
38
inline
39
void
setPin13High
()
40
{
41
#
if
IS_AVR
(
)
42
PORTB |= B00100000;
43
#
else
44
digitalWrite(13, HIGH);
45
#
endif
46
}
47
48
49
/** @ingroup util
50
Set pin 13 low for testing timing with an oscilloscope.*/
51
inline
52
void
setPin13Low
()
53
{
54
#
if
IS_AVR
(
)
55
PORTB &= B11011111;
56
#
else
57
digitalWrite(13, LOW);
58
#
endif
59
}
60
61
62
constexpr uint8_t trailingZerosConst(
unsigned
long
v) {
return
((v % 2) ? 0 : 1+trailingZerosConst(v >> 1)); }
63
//uint8_t trailingZeros(uint16_t v);
64
unsigned
int
BPMtoMillis(
float
bpm);
65
66
#
endif
/* UTILS_H_ */
setPin13Out
void setPin13Out()
Set digital pin 13 to output for testing timing with an oscilloscope.
Definition:
mozzi_utils.h:26
setPin13High
void setPin13High()
Set pin 13 high for testing timing with an oscilloscope.
Definition:
mozzi_utils.h:39
IS_AVR
#define IS_AVR()
Definition:
hardware_defines.h:15
setPin13Low
void setPin13Low()
Set pin 13 low for testing timing with an oscilloscope.
Definition:
mozzi_utils.h:52
mozzi_utils.h
Generated on Thu Mar 16 2023 14:01:35 for Mozzi by
1.8.14