source: rtems/c/src/lib/libbsp/arm/nds/libnds/include/nds/arm7/audio.h @ ca11e781

4.104.115
Last change on this file since ca11e781 was ca11e781, checked in by Ralf Corsepius <ralf.corsepius@…>, on 12/07/09 at 07:12:20

Eliminate various warnings.

  • Property mode set to 100644
File size: 5.1 KB
Line 
1/*---------------------------------------------------------------------------------
2        $Id$
3
4        ARM7 audio control
5
6        Copyright (C) 2005
7                Michael Noland (joat)
8                Jason Rogers (dovoto)
9                Dave Murphy (WinterMute)
10
11        This software is provided 'as-is', without any express or implied
12        warranty.  In no event will the authors be held liable for any
13        damages arising from the use of this software.
14
15        Permission is granted to anyone to use this software for any
16        purpose, including commercial applications, and to alter it and
17        redistribute it freely, subject to the following restrictions:
18
19        1.      The origin of this software must not be misrepresented; you
20                must not claim that you wrote the original software. If you use
21                this software in a product, an acknowledgment in the product
22                documentation would be appreciated but is not required.
23        2.      Altered source versions must be plainly marked as such, and
24                must not be misrepresented as being the original software.
25        3.      This notice may not be removed or altered from any source
26                distribution.
27
28---------------------------------------------------------------------------------*/
29
30#ifndef AUDIO_ARM7_INCLUDE
31#define AUDIO_ARM7_INCLUDE
32
33//---------------------------------------------------------------------------------
34// Sound (ARM7 only)
35//---------------------------------------------------------------------------------
36#ifndef ARM7
37#error Audio is only available on the ARM7
38#endif
39
40#ifdef __cplusplus
41extern "C" {
42#endif
43
44#include <nds/arm7/serial.h>
45
46
47#define SOUND_VOL(n)    (n)
48#define SOUND_FREQ(n)   ((-0x1000000 / (n)))
49#define SOUND_ENABLE    BIT(15)
50#define SOUND_REPEAT    BIT(27)
51#define SOUND_ONE_SHOT  BIT(28)
52#define SOUND_FORMAT_16BIT (1<<29)
53#define SOUND_FORMAT_8BIT       (0<<29)
54#define SOUND_FORMAT_PSG    (3<<29)
55#define SOUND_FORMAT_ADPCM  (2<<29)
56#define SOUND_16BIT      (1<<29)
57#define SOUND_8BIT       (0)
58
59#define SOUND_PAN(n)    ((n) << 16)
60
61#define SCHANNEL_ENABLE BIT(31)
62
63//---------------------------------------------------------------------------------
64// registers
65//---------------------------------------------------------------------------------
66#define SCHANNEL_CR(n)                          (*(vuint32*)(0x04000400 + ((n)<<4)))
67#define SCHANNEL_VOL(n)                         (*(vuint8*)(0x04000400 + ((n)<<4)))
68#define SCHANNEL_PAN(n)                         (*(vuint8*)(0x04000402 + ((n)<<4)))
69#define SCHANNEL_SOURCE(n)                      (*(vuint32*)(0x04000404 + ((n)<<4)))
70#define SCHANNEL_TIMER(n)                       (*(vint16*)(0x04000408 + ((n)<<4)))
71#define SCHANNEL_REPEAT_POINT(n)        (*(vuint16*)(0x0400040A + ((n)<<4)))
72#define SCHANNEL_LENGTH(n)                      (*(vuint32*)(0x0400040C + ((n)<<4)))
73
74#define SOUND_CR          (*(vuint16*)0x04000500)
75#define SOUND_MASTER_VOL  (*(vuint8*)0x04000500)
76
77//---------------------------------------------------------------------------------
78// not sure on the following
79//---------------------------------------------------------------------------------
80#define SOUND_BIAS        (*(vuint16*)0x04000504)
81#define SOUND508          (*(vuint16*)0x04000508)
82#define SOUND510          (*(vuint16*)0x04000510)
83#define SOUND514                  (*(vuint16*)0x04000514)
84#define SOUND518          (*(vuint16*)0x04000518)
85#define SOUND51C          (*(vuint16*)0x0400051C)
86
87
88/*---------------------------------------------------------------------------------
89        microphone code based on neimod's microphone example.
90        See: http://neimod.com/dstek/
91        Chris Double (chris.double@double.co.nz)
92        http://www.double.co.nz/nintendo_ds
93---------------------------------------------------------------------------------*/
94
95
96/*---------------------------------------------------------------------------------
97        Read a byte from the microphone
98---------------------------------------------------------------------------------*/
99u8 MIC_ReadData(void);
100
101/*---------------------------------------------------------------------------------
102        Fill the buffer with data from the microphone. The buffer will be
103        signed sound data at 16kHz. Once the length of the buffer is
104        reached, no more data will be stored. Uses ARM7 timer 0.
105---------------------------------------------------------------------------------*/
106void StartRecording(u8* buffer, int length);
107
108/*---------------------------------------------------------------------------------
109        Stop recording data, and return the length of data recorded.
110---------------------------------------------------------------------------------*/
111int StopRecording(void);
112
113/* This must be called during IRQ_TIMER0 */
114void ProcessMicrophoneTimerIRQ(void);
115
116void PM_SetAmp(u8 control);
117
118//---------------------------------------------------------------------------------
119// Turn the microphone on
120//---------------------------------------------------------------------------------
121static inline void MIC_On(void) {
122//---------------------------------------------------------------------------------
123  PM_SetAmp(PM_AMP_ON);
124}
125
126
127//---------------------------------------------------------------------------------
128// Turn the microphone off
129//---------------------------------------------------------------------------------
130static inline void MIC_Off(void) {
131//---------------------------------------------------------------------------------
132  PM_SetAmp(PM_AMP_OFF);
133}
134
135
136#ifdef __cplusplus
137}
138#endif
139
140#endif
141
Note: See TracBrowser for help on using the repository browser.