| 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 long trailingZeros(unsigned long v);
63 unsigned int BPMtoMillis(float bpm);
64
65 #endif /* UTILS_H_ */
setPin13Out
void setPin13Out()
Set digital pin 13 to output for testing timing with an oscilloscope.
Definition: mozzi_utils.h:26
trailingZeros
long trailingZeros(unsigned long v)
Given a power of 2, work out the number to shift right by to do a divide by the number, or shift left to multiply.
Definition: mozzi_utils.cpp:8
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