forked from donfroula/rotarydial
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdtmf.h
50 lines (40 loc) · 1.63 KB
/
dtmf.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
//*****************************************************************************
// Title : Pulse to tone (DTMF) converter
// Author : Boris Cherkasskiy
// http://boris0.blogspot.ca/2013/09/rotary-dial-for-digital-age.html
// Created : 2011-10-24
//
// Modified : Arnie Weber 2015-06-22
// https://bitbucket.org/310weber/rotary_dial/
// NOTE: This code is not compatible with Boris's original hardware
// due to changed pin-out (see Eagle files for details)
//
// Modified : Matthew Millman 2018-05-29
// http://tech.mattmillman.com/
// Cleaned up implementation, modified to work more like the
// Rotatone product.
//
// This code is distributed under the GNU Public License
// which can be found at http://www.gnu.org/licenses/gpl.txt
//
// DTMF generator logic is loosely based on the AVR314 app note from Atmel
//
//*****************************************************************************
#ifndef __DTMF_H__
#define __DTMF_H__
#define DIGIT_BEEP -10
#define DIGIT_BEEP_LOW -13
#define DIGIT_TUNE_ASC -11
#define DIGIT_TUNE_DESC -12
#define DIGIT_OFF -1
#define DIGIT_STAR 10
#define DIGIT_POUND 11
#define DTMF_DURATION_MS 100
// PWM frequency = 4Mhz/256 = 15625Hz; overflow cycles per MS = 15
#define T0_OVERFLOW_PER_MS 15
#define PIN_PWM_OUT PB0 // PB0 (OC0A) as PWM output
void dtmf_init(void);
void dtmf_generate_tone(int8_t digit, uint16_t duration_ms);
void sleep_ms(uint16_t msec);
extern volatile uint32_t _g_delay_counter;
#endif /* __DTMF_H__ */