ButterflyMP3
|
MultiMedia Card low level Functions. More...
#include <avr/io.h>
#include <avr/pgmspace.h>
#include <avr/interrupt.h>
#include "types.h"
#include "mmc.h"
#include "delay.h"
#include "main.h"
#include "uart.h"
#include "vs1001.h"
Go to the source code of this file.
Defines | |
#define | MMC_C |
Functions | |
void | SpiInit (void) |
Setup Pin configuration of SPI bus for the AVR. | |
uint8 | SpiByte (unsigned char byte) |
Main SPI routine
| |
uint8 | MMCGet (void) |
Retrieve data from then MMC. | |
void | MMCCommand (unsigned char command, uint8 px, uint8 py, uint8 pz) |
Send a control command to the MMC. | |
uint8 | MMC_Reset (void) |
Perform a Hardware then software reset of the MMC. | |
uint8 | MMC_Detect (void) |
Checks if there is a memory card in the slot This requires a pull down resistor on the CS line of about 100K. | |
uint16 | MMC_Check (void) |
Send the get status command to the MMC and returns the result. | |
uint8 | MMC_Read (uint32 lba) |
Grab the Serial number & info from the card. | |
Variables | |
uint8 | mmc_sbuf [512] |
512 byte sector buffer in internal RAM | |
uint8 | mmc_scratch [32] |
32 byte Scratch buffer for CSD/CID/ ops |
MultiMedia Card low level Functions.
This file represents a convergence of a number of code snippets found on the web, some of the Yampp system by Jesper Hansen and the work done by Sylvain.Bissonnette@microsyl.com. The goal is to produce an adaptable library for doing low level MMC activities over the SPI bus. This code was written with the Atmega169V in mind (aka "Butterfly"). http://butterflymp3.sf.net
For details Concerning the MMC spec see www.sandisk.com. I refered to "SanDisk MultiMediaCard and Reduced-Size MultiMediaCard Product Manual" Doc No. 80-36-00320 v1.0 during the writing of this code.
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, MA 02111-1307, USA.
History:
24-26 Sep 2004: Initial write and port of functions collected over last few months
March 2005: Add new improvements based around Circuit cellar article. Updated Comments for Doxygen
Definition in file mmc.c.
uint16 MMC_Check | ( | void | ) |
Send the get status command to the MMC and returns the result.
Definition at line 281 of file mmc.c.
References MMC_CS, MMC_PORT, MMC_SEND_STATUS, MMCCommand(), MMCGet(), SBI, and SpiByte().
Referenced by handle_mmc(), and MMC_tester().
uint8 MMC_Detect | ( | void | ) |
Grab the Serial number & info from the card.
Returns status response from card. if successful CID is in mmc_scratch[1..16]
Definition at line 422 of file mmc.c.
References CBI, MMC_CS, MMC_PORT, MMC_READ_SINGLE_BLOCK, mmc_sbuf, MMC_SEND_STATUS, MMC_STARTBLOCK_READ, MMCCommand(), MMCGet(), SBI, and SpiByte().
Referenced by FAT_tester(), init_HW(), and MMC_tester().
uint8 MMC_Reset | ( | void | ) |
Perform a Hardware then software reset of the MMC.
Definition at line 200 of file mmc.c.
References MMC_CS, MMC_PORT, MMCCommand(), MMCGet(), SBI, and SpiByte().
Referenced by FAT_tester(), handle_mmc(), init_mmc_fat(), MMC_tester(), and streaming().
Send a control command to the MMC.
send one byte of 0xff, then issue command + params + (fake) crc eat up the one command of nothing after the CRC Clears the MMC_CS and BSYNC_PIN lines. MMC must be de-selected outside of this code !!
command | MMC Command to be sent |
px | first byte of command parameters |
py | second byte of command parameters |
pz | third byte of command parameters |
Definition at line 155 of file mmc.c.
References CBI, MMC_CS, MMC_PORT, and SpiByte().
Referenced by MMC_Check(), MMC_Read(), and MMC_Reset().
uint8 MMCGet | ( | void | ) |
Retrieve data from then MMC.
Pings the card until it gets a non-0xff value
Definition at line 130 of file mmc.c.
References SpiByte().
Referenced by MMC_Check(), MMC_Read(), and MMC_Reset().
uint8 SpiByte | ( | unsigned char | byte | ) |
Main SPI routine
byte | Byte to transmit |
Definition at line 105 of file mmc.c.
Referenced by MMC_Check(), MMC_Read(), MMC_Reset(), MMCCommand(), and MMCGet().
void SpiInit | ( | void | ) |
512 byte sector buffer in internal RAM
Definition at line 58 of file mmc.c.
Referenced by FAT_tester(), init_HW(), MMC_Read(), and MMC_tester().
uint8 mmc_scratch[32] |
32 byte Scratch buffer for CSD/CID/ ops
Definition at line 59 of file mmc.c.
Referenced by FAT_tester(), init_HW(), and MMC_tester().