-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathADDAC_VCO.h
executable file
·61 lines (47 loc) · 1.52 KB
/
ADDAC_VCO.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
/*
* Interrupt and PWM utilities for 16 bit Timer3 on ATmega168/328
* Original code by Jesse Tane for http://labs.ideo.com August 2008
* Modified March 2009 by Jérôme Despatis and Jesse Tane for ATmega328 support
* Modified June 2009 by Michael Polli and Jesse Tane to fix a bug in setPeriod() which caused the timer to stop
*
* This is free software. You can redistribute it and/or modify it under
* the terms of Creative Commons Attribution 3.0 United States License.
* To view a copy of this license, visit http://creativecommons.org/licenses/by/3.0/us/
* or send a letter to Creative Commons, 171 Second Street, Suite 300, San Francisco, California, 94105, USA.
*
*/
#if defined(ARDUINO) && ARDUINO >= 100
#include "Arduino.h"
#else
#include <WProgram.h>
#endif
#include <avr/io.h>
#include <avr/interrupt.h>
#define RESOLUTION 65536 // Timer3 is 16 bit
class ADDAC_VCO
{
public:
// properties
unsigned int pwmPeriod;
unsigned char clockSelectBits;
int channel, offset;
float vol,volOffset;
bool UP;
int mode;
// methods
void initialize();
void update(float _Notes05v, float _vol);
void start();
void stop();
void restart();
void pwm(char pin, int duty, long microseconds=-1);
void disablePwm(char pin);
void startup(void (*isr)(), long microseconds=-1);
void detachInterrupt();
void setPeriod(long microseconds);
void setPwmDuty(char pin, int duty);
void (*isrCallback)();
private:
float Period(float _Notes05v);
};
extern ADDAC_VCO VCO;