⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 vs1001.h

📁 用ATmega8 做的MP3播放器
💻 H
字号:
/*
 * Copyright (c) 2003-2004 K. John '2B|!2B' Crispin
 * Copyright (c) 2005      Stephan Dobretsberger
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA02111-1307USA
 *
 * Feedback, Bugs, ... mail stephan.dobretsberger@gmx.at
 *
 */

#include <avr/io.h>
#include <avr/signal.h>
#include <avr/interrupt.h>

#include "types.h"

#define VS_CS_LO      cbi(VS1001_PORT, PIN_VS1001_CS)
#define VS_CS_HI      sbi(VS1001_PORT, PIN_VS1001_CS)

#define VS_BSYNC_LO   cbi(VS1001_PORT, PIN_VS1001_BSYNC)
#define VS_BSYNC_HI   sbi(VS1001_PORT, PIN_VS1001_BSYNC)

#define VS_RESET_LO   cbi(VS1001_PORT, PIN_VS1001_RESET)
#define VS_RESET_HI   sbi(VS1001_PORT, PIN_VS1001_RESET)

#define VS1001_READ   spi_io(0x03)
#define VS1001_WRITE  spi_io(0x02)

#define VS1001_NEEDS_DATA           bit_is_set(VS1001_PIN, PIN_VS1001_DREQ)
#define VS1001_NEEDS_NO_DATA        bit_is_clear(VS1001_PIN, PIN_VS1001_DREQ)
#define VS1001_WHILE_NEEDS_NO_DATA  while((inp(VS1001_PIN) & (0x01 << PIN_VS1001_DREQ))== 0x00){}

#define REG_MODE        0x0
#define REG_STATUS      0x1
#define REG_INT_FCTLH   0x2
#define REG_CLOCKF      0x3
#define REG_DECODETIME  0x4
#define REG_AUDATA      0x5
#define REG_WRAM        0x6
#define REG_WRAMADDR    0x7
#define REG_HDAT0       0x8
#define REG_HDAT1       0x9
#define REG_A1ADDR      0xa
#define REG_VOL         0xb
#define REG_A1CTRL0     0xc
#define REG_A1CTRL1     0xd
#define REG_A1CTRL2     0xe


// used to identify the device currently using the spi bus
#define SPI_FREE  0
#define SPI_SCI   1
#define SPI_SDI   2
#define SPI_MMC   3


void VS1001_send_SCI(u08 reg, u16 data);
u16  VS1001_read_SCI(u08 reg);
void VS1001_send_SDI(u08 data);
void VS1001_send_SDI_32(u08* data);
void VS1001_send_zeros(u08 count);
void VS1001_SW_reset(void);
void VS1001_HW_reset(void);
void VS1001_init(void);

void VS1001_sine(BOOL state, u08 freq);
void VS1001_volume(u08 left, u08 right);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -