Subversion Repositories freemyipod

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
714 user890104 1
//
2
//
3
//    Copyright 2011 TheSeven, user890104
4
//
5
//
6
//    This file is part of emCORE.
7
//
8
//    emCORE is free software: you can redistribute it and/or
9
//    modify it under the terms of the GNU General Public License as
10
//    published by the Free Software Foundation, either version 2 of the
11
//    License, or (at your option) any later version.
12
//
13
//    emCORE is distributed in the hope that it will be useful,
14
//    but WITHOUT ANY WARRANTY; without even the implied warranty of
15
//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16
//    See the GNU General Public License for more details.
17
//
18
//    You should have received a copy of the GNU General Public License along
19
//    with emCORE.  If not, see <http://www.gnu.org/licenses/>.
20
//
21
//
22
 
23
 
24
#include "emcoreapp.h"
25
#include "beep.h"
26
 
27
void singlebeep(unsigned int cycles, unsigned int time)
28
{
29
    /* configure timer for 100 kHz */
30
    TDCMD = (1 << 1);   /* TD_CLR */
31
    TDPRE = 30 - 1;    /* prescaler */
32
    TDCON =
33
            //(1 << 13) | /* TD_INT1_EN */
34
            //(0 << 12) | /* TD_INT0_EN */
35
            //(0 << 11) | /* TD_START */
36
            (2 << 8) |  /* TD_CS = PCLK / 16 */
37
            (1 << 4);   /* TD_MODE_SEL = PWM mode */
38
    TDDATA0 = cycles;   /* set interval period */
39
    TDDATA1 = cycles << 1; /* set interval period */
40
    TDCMD = (1 << 0);   /* TD_EN */
41
    sleep(time);
42
    TDCMD = (1 << 1);   /* TD_CLR */
43
}