Nut/OS  4.10.3
API Reference
vs1001k.h
Go to the documentation of this file.
00001 #ifndef _VS1001K_H_
00002 #define _VS1001K_H_
00003 /*
00004  * Copyright (C) 2001-2003 by egnite Software GmbH. All rights reserved.
00005  *
00006  * Redistribution and use in source and binary forms, with or without
00007  * modification, are permitted provided that the following conditions
00008  * are met:
00009  *
00010  * 1. Redistributions of source code must retain the above copyright
00011  *    notice, this list of conditions and the following disclaimer.
00012  * 2. Redistributions in binary form must reproduce the above copyright
00013  *    notice, this list of conditions and the following disclaimer in the
00014  *    documentation and/or other materials provided with the distribution.
00015  * 3. Neither the name of the copyright holders nor the names of
00016  *    contributors may be used to endorse or promote products derived
00017  *    from this software without specific prior written permission.
00018  *
00019  * THIS SOFTWARE IS PROVIDED BY EGNITE SOFTWARE GMBH AND CONTRIBUTORS
00020  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00021  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00022  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL EGNITE
00023  * SOFTWARE GMBH OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00024  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
00025  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
00026  * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
00027  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
00028  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
00029  * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
00030  * SUCH DAMAGE.
00031  *
00032  * For additional information see http://www.ethernut.de/
00033  *
00034  * -
00035  * Portions Copyright (C) 2001 Jesper Hansen <jesperh@telia.com>.
00036  * 
00037  * This file is part of the yampp system.
00038  * 
00039  * This program is free software; you can redistribute it and/or
00040  * modify it under the terms of the GNU General Public License
00041  * as published by the Free Software Foundation; either version 2
00042  * of the License, or (at your option) any later version.
00043  * 
00044  * This program is distributed in the hope that it will be useful,
00045  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00046  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00047  * GNU General Public License for more details.
00048  *
00049  * You should have received a copy of the GNU General Public License
00050  * along with this program; if not, write to the Free Software Foundation,
00051  * Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00052  */
00053 
00054 /*
00055  * $Log$
00056  * Revision 1.5  2008/08/11 06:59:59  haraldkipp
00057  * BSD types replaced by stdint types (feature request #1282721).
00058  *
00059  * Revision 1.4  2006/05/15 11:46:00  haraldkipp
00060  * Bug corrected, which stopped player on flush. Now flushing plays
00061  * the remaining bytes in the buffer.
00062  * VS1001 ports are now fully configurable.
00063  * Several changes had been added to adapt the code to newer
00064  * Nut/OS style, like replacing outp with outb and using API
00065  * routines for interrupt control.
00066  *
00067  * Revision 1.3  2004/03/16 16:48:28  haraldkipp
00068  * Added Jan Dubiec's H8/300 port.
00069  *
00070  * Revision 1.2  2003/07/13 19:37:39  haraldkipp
00071  * Enable application to control decoder interrupts.
00072  *
00073  * Revision 1.1.1.1  2003/05/09 14:41:10  haraldkipp
00074  * Initial using 3.2.1
00075  *
00076  * Revision 1.9  2003/05/06 18:44:58  harald
00077  * Cleanup
00078  *
00079  * Revision 1.8  2003/04/21 16:46:53  harald
00080  * New functions
00081  *
00082  * Revision 1.7  2003/04/07 20:08:09  harald
00083  * Redesigned by Pavel Chromy
00084  *
00085  * Revision 1.5  2003/02/04 18:00:37  harald
00086  * Version 3 released
00087  *
00088  * Revision 1.4  2002/10/29 15:40:49  harald
00089  * *** empty log message ***
00090  *
00091  * Revision 1.3  2002/08/16 17:51:19  harald
00092  * First public release
00093  *
00094  * Revision 1.2  2002/06/26 17:29:15  harald
00095  * First pre-release with 2.4 stack
00096  *
00097  */
00098 
00099 #include <sys/types.h>
00100 #include <stdint.h>
00101 
00111 
00112 
00113 
00114 /*
00115  * Instruction opcodes.
00116  */
00117 #define VS_OPCODE_READ  3
00118 #define VS_OPCODE_WRITE 2
00119 
00120 /*
00121  * Decoder registers.
00122  */
00123 #define VS_MODE_REG         0
00124 #define VS_STATUS_REG       1
00125 #define VS_INT_FCTLH_REG    2
00126 #define VS_CLOCKF_REG       3
00127 #define VS_DECODE_TIME_REG  4
00128 #define VS_AUDATA_REG       5
00129 #define VS_WRAM_REG         6
00130 #define VS_WRAMADDR_REG     7
00131 #define VS_HDAT0_REG        8
00132 #define VS_HDAT1_REG        9
00133 #define VS_A1ADDR_REG      10
00134 #define VS_VOL_REG         11
00135 #define VS_A1CTRL_REG      13
00136 
00137 
00138 /*
00139  * Mode register bits.
00140  */
00141 #define VS_SM_DIFF      0x0001
00142 #define VS_SM_FFWD      0x0002
00143 #define VS_SM_RESET     0x0004
00144 #define VS_SM_MP12      0x0008
00145 #define VS_SM_PDOWN     0x0010
00146 #define VS_SM_DAC       0x0020
00147 #define VS_SM_DACMONO   0x0040
00148 #define VS_SM_BASS      0x0080
00149 #define VS_SM_DACT      0x0100
00150 #define VS_SM_BYTEORD   0x0200
00151 #define VS_SM_IBMODE    0x0400
00152 #define VS_SM_IBCLK     0x0800
00153 
00154 
00155 /*
00156  * Clock register bits.
00157  */
00158 #define VS_CF_DOUBLER   0x8000
00159 
00160 
00161 /*
00162  * Bytes needed to flush internal VS buffer (size of VS interbal buffer)
00163  */
00164 #define VS_FLUSH_BYTES 2048
00165 
00166 
00167 /*
00168  * Status of the decoder
00169  */
00170 #define VS_STATUS_STOPPED 0
00171 #define VS_STATUS_RUNNING 1
00172 #define VS_STATUS_EOF     2
00173 #define VS_STATUS_EMPTY   4
00174 
00175 /*
00176  * Header info filled by VsGetHeaderInfo.
00177  */
00178 #ifdef __GNUC__
00179 typedef struct {
00180     uint16_t vshi_no_crc:1;
00181     uint16_t vshi_layer:2;
00182     uint16_t vshi_id:2;
00183     uint16_t vshi_syncword:11;
00184 
00185     uint16_t vshi_emphasis:2;
00186     uint16_t vshi_original:1;
00187     uint16_t vshi_copyright:1;
00188     uint16_t vshi_extension:2;
00189     uint16_t vshi_mode:2;
00190     uint16_t vshi_private_bit:1;
00191     uint16_t vshi_pad_bit:1;
00192     uint16_t vshi_sample_rate:2;
00193     uint16_t vshi_bitrate:4;
00194 } VS_HEADERINFO;
00195 #endif
00196 
00197 __BEGIN_DECLS
00198 /* Function prototypes */
00199 
00200 extern int VsPlayerInit(void);
00201 extern int VsPlayerReset(uint16_t mode);
00202 extern int VsPlayerSetMode(uint16_t mode);
00203 extern int VsPlayerKick(void);
00204 extern int VsPlayerStop(void);
00205 extern int VsPlayerFlush(void);
00206 extern uint8_t VsPlayerInterrupts(uint8_t enable);
00207 
00208 extern uint8_t *VsBufferInit(uint16_t size);
00209 extern uint8_t *VsBufferReset(void);
00210 extern uint8_t *VsBufferRequest(uint16_t *sizep);
00211 extern uint8_t *VsBufferAcknowledge(uint16_t nbytes);
00212 
00213 extern uint16_t VsBufferAvailable(void);
00214 extern uint16_t VsPlayTime(void);
00215 extern uint8_t VsGetStatus(void);
00216 #ifdef __GNUC__
00217 extern int VsGetHeaderInfo(VS_HEADERINFO *vshi);
00218 #endif
00219 extern uint16_t VsMemoryTest(void);
00220 
00221 extern int VsSetVolume(uint8_t left, uint8_t right);
00222 extern int VsBeep(uint8_t fsin, uint8_t ms);
00223 
00226 __END_DECLS
00227 /* End of prototypes */
00228 
00229 #endif