OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [freertos-6.1.1/] [Demo/] [CORTEX_AT91SAM3U256_IAR/] [AT91Lib/] [peripherals/] [ac97c/] [ac97c.h] - Blame information for rev 580

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 580 jeremybenn
/* ----------------------------------------------------------------------------
2
 *         ATMEL Microcontroller Software Support
3
 * ----------------------------------------------------------------------------
4
 * Copyright (c) 2008, Atmel Corporation
5
 *
6
 * All rights reserved.
7
 *
8
 * Redistribution and use in source and binary forms, with or without
9
 * modification, are permitted provided that the following conditions are met:
10
 *
11
 * - Redistributions of source code must retain the above copyright notice,
12
 * this list of conditions and the disclaimer below.
13
 *
14
 * Atmel's name may not be used to endorse or promote products derived from
15
 * this software without specific prior written permission.
16
 *
17
 * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
18
 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
19
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
20
 * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
21
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
23
 * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
24
 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
25
 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
26
 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
 * ----------------------------------------------------------------------------
28
 */
29
 
30
//------------------------------------------------------------------------------
31
/// \unit
32
///
33
/// !!!Purpose
34
/// 
35
/// This module provides definitions and functions for using the AC'97
36
/// controller (AC97C).
37
/// 
38
/// !!!Usage
39
/// 
40
/// -# Enable the AC'97 interface pins (see pio & board.h).
41
/// -# Configure the AC'97 controller using AC97C_Configure
42
/// -# Assign the input and output slots to channels, and the data size used to
43
///    transfer AC97 data stream.
44
///    - Three functions can be used:
45
///       - AC97C_AssignInputSlots: set slots for AC'97 data in, recording.
46
///       - AC97C_AssignOutputSlots: set slots for AC'97 data out, playing.
47
///       - AC97C_SetChannelSize: set data sizes in bits for AC'97 data stream.
48
///    - Three different channels can be configured:
49
///       - AC97C_CHANNEL_CODEC: AC'97 register access channel, its size is
50
///         fixed and #must not# change by AC97C_SetChannelSize
51
///       - AC97C_CHANNEL_A: AC'97 stream channel, with PDC support.
52
///       - AC97C_CHANNEL_B: AC'97 data channel, without PDC support.
53
/// -# Configure the used AC97 channel with AC97C_ConfigureChannel, to enable
54
///    the channel.
55
/// -# Then you can operate the connected AC'97 codec:
56
///    - AC97C_ReadCodec / AC97C_WriteCodec: Read / Write codec register.
57
///    - AC97C_Transfer: Transfer through AC97C channels to setup codec register
58
///     or transfer %audio data stream.
59
///       - AC97C_CODEC_TRANSFER: access the codec register.
60
///       - AC97C_CHANNEL_A_RECEIVE, AC97C_CHANNEL_B_RECEIVE: start reading.
61
///       - AC97C_CHANNEL_A_TRANSMIT, AC97C_CHANNEL_B_TRANSMIT: start writing.
62
///    Normally you can initialize a set of AC'97 codec registers to initialize
63
///    the codec for %audio playing and recording.
64
/// -# Example code for playing & recording:
65
///    - General process:
66
///       -# Configure the codec registers for the %audio settings and formats;
67
///       -# Setup the channel size if necessery;
68
///       -# Start %audio stream transfer.
69
///    - Audio playing sample:
70
/// \code
71
///    // Configure sample rate of codec
72
///    AC97C_WriteCodec(AD1981B_PMC_DAC, expectedSampleRate);
73
///    // Set channel size
74
///    AC97C_SetChannelSize(AC97C_CHANNEL_A, bitsPerSample);
75
///    // Start channel A transfer
76
///    AC97C_Transfer(AC97C_CHANNEL_A_TRANSMIT, 
77
///                   (unsigned char *) (pointerToAudioDataBuffer),
78
///                   numberOfSamplesToSend,
79
///                   (Ac97Callback) PlayingFinished, 
80
///                   0);
81
/// \endcode
82
///    - Audio recording sample:
83
/// \code
84
///    // Enable recording
85
///    AC97C_WriteCodec(AD1981B_REC_SEL, 0);
86
///    // Set sample rate
87
///    AC97C_WriteCodec(AD1981B_PMC_ADC, 7000);
88
///    // Always use 16-bits recording
89
///    AC97C_SetChannelSize(AC97C_CHANNEL_A, 16);
90
///    // Start recording
91
///    AC97C_Transfer(AC97C_CHANNEL_A_RECEIVE, 
92
///                   (unsigned char *) RECORD_ADDRESS,
93
///                   MAX_RECORD_SIZE,
94
///                   (Ac97Callback) RecordFinished,
95
///                   0);
96
/// \endcode
97
//------------------------------------------------------------------------------
98
 
99
#ifndef AC97C_H
100
#define AC97C_H
101
 
102
//------------------------------------------------------------------------------
103
//         Constants
104
//------------------------------------------------------------------------------
105
 
106
/// The channel is already busy with a transfer.
107
#define AC97C_ERROR_BUSY            1
108
/// The transfer has been stopped by the user.
109
#define AC97C_ERROR_STOPPED         2
110
 
111
/// Codec channel index.
112
#define AC97C_CHANNEL_CODEC         0
113
/// Channel A index.
114
#define AC97C_CHANNEL_A             1
115
/// Channel B index.
116
#define AC97C_CHANNEL_B             2
117
 
118
/// Codec transmit/receive transfer index.
119
#define AC97C_CODEC_TRANSFER        0
120
/// Channel A receive transfer index.
121
#define AC97C_CHANNEL_A_RECEIVE     1
122
/// Channel A transmit transfer index.
123
#define AC97C_CHANNEL_A_TRANSMIT    2
124
/// Channel B receive transfer index.
125
#define AC97C_CHANNEL_B_RECEIVE     3
126
/// Channel B transmit transfer index.
127
#define AC97C_CHANNEL_B_TRANSMIT    4
128
 
129
//------------------------------------------------------------------------------
130
//         Types
131
//------------------------------------------------------------------------------
132
 
133
/// AC97C transfer callback function.
134
typedef void (*Ac97Callback)(void *pArg,
135
                             unsigned char status,
136
                             unsigned int remaining);
137
 
138
//------------------------------------------------------------------------------
139
//         Exported functions
140
//------------------------------------------------------------------------------
141
 
142
extern void AC97C_Configure();
143
 
144
extern void AC97C_ConfigureChannel(unsigned char channel, unsigned int cfg);
145
 
146
extern void AC97C_AssignInputSlots(unsigned char channel, unsigned int slots);
147
 
148
extern void AC97C_AssignOutputSlots(unsigned char channel, unsigned int slots);
149
 
150
extern unsigned char AC97C_Transfer(
151
                unsigned char channel,
152
                unsigned char *pBuffer,
153
                unsigned int numSamples,
154
                Ac97Callback callback,
155
                void *pArg);
156
 
157
extern unsigned char AC97C_IsFinished(unsigned char channel);
158
 
159
extern void AC97C_WriteCodec(unsigned char address, unsigned short data);
160
 
161
extern unsigned short AC97C_ReadCodec(unsigned char address);
162
 
163
extern void AC97C_SetChannelSize(unsigned char channel, unsigned char size);
164
 
165
extern void AC97C_CancelTransfer(unsigned char channel);
166
 
167
#endif //#ifndef AC97C_H
168
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.