EA BaseBoard, playing wav, PC see\'s SD-card through USB port.

Dependencies:   mbed

Committer:
Lerche
Date:
Tue Nov 22 05:45:58 2011 +0000
Revision:
0:fef366d2ed20
Thanks to those who provided EA_WavPlayer and USB_MSC

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Lerche 0:fef366d2ed20 1 /*****************************************************************************\
Lerche 0:fef366d2ed20 2 * efs - General purpose Embedded Filesystem library *
Lerche 0:fef366d2ed20 3 * --------------------- ----------------------------------- *
Lerche 0:fef366d2ed20 4 * *
Lerche 0:fef366d2ed20 5 * Filename : sd.c *
Lerche 0:fef366d2ed20 6 * Revision : Initial developement *
Lerche 0:fef366d2ed20 7 * Description : This file contains the functions needed to use efs for *
Lerche 0:fef366d2ed20 8 * accessing files on an SD-card. *
Lerche 0:fef366d2ed20 9 * *
Lerche 0:fef366d2ed20 10 * This library is free software; you can redistribute it and/or *
Lerche 0:fef366d2ed20 11 * modify it under the terms of the GNU Lesser General Public *
Lerche 0:fef366d2ed20 12 * License as published by the Free Software Foundation; either *
Lerche 0:fef366d2ed20 13 * version 2.1 of the License, or (at your option) any later version. *
Lerche 0:fef366d2ed20 14 * *
Lerche 0:fef366d2ed20 15 * This library is distributed in the hope that it will be useful, *
Lerche 0:fef366d2ed20 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
Lerche 0:fef366d2ed20 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
Lerche 0:fef366d2ed20 18 * Lesser General Public License for more details. *
Lerche 0:fef366d2ed20 19 * *
Lerche 0:fef366d2ed20 20 * (c)2005 Michael De Nil *
Lerche 0:fef366d2ed20 21 * (c)2005 Lennart Yseboodt *
Lerche 0:fef366d2ed20 22 \*****************************************************************************/
Lerche 0:fef366d2ed20 23
Lerche 0:fef366d2ed20 24 /*
Lerche 0:fef366d2ed20 25 2006, Bertrik Sikken, modified for LPCUSB
Lerche 0:fef366d2ed20 26 */
Lerche 0:fef366d2ed20 27 /*
Lerche 0:fef366d2ed20 28 * Modified for mbed NXP LPC1768 & LPCXpresso board
Lerche 0:fef366d2ed20 29 *
Lerche 0:fef366d2ed20 30 * NOT USE efs library
Lerche 0:fef366d2ed20 31 * USE FatFs interface routine
Lerche 0:fef366d2ed20 32 *
Lerche 0:fef366d2ed20 33 * original LPC214x USB stack beta by bertrik
Lerche 0:fef366d2ed20 34 * target-20070727.tar.gr (119.5KB)
Lerche 0:fef366d2ed20 35 * http://sourceforge.net/projects/lpcusb/
Lerche 0:fef366d2ed20 36 * By Kenji Arai / JH1PJL on September 25th, 2010
Lerche 0:fef366d2ed20 37 * October 3rd, 2010
Lerche 0:fef366d2ed20 38 */
Lerche 0:fef366d2ed20 39
Lerche 0:fef366d2ed20 40 //#define DEBUG
Lerche 0:fef366d2ed20 41 #include "dbg.h"
Lerche 0:fef366d2ed20 42 #include "mbed.h"
Lerche 0:fef366d2ed20 43
Lerche 0:fef366d2ed20 44 #include "blockdev.h"
Lerche 0:fef366d2ed20 45 #include "SDFileSystem.h"
Lerche 0:fef366d2ed20 46
Lerche 0:fef366d2ed20 47
Lerche 0:fef366d2ed20 48 extern SDFileSystem sd;
Lerche 0:fef366d2ed20 49
Lerche 0:fef366d2ed20 50 // Get Device media size
Lerche 0:fef366d2ed20 51 uint32_t BlockDevGetSize()
Lerche 0:fef366d2ed20 52 {
Lerche 0:fef366d2ed20 53 DBG("BlockDevGetSize\r\n");
Lerche 0:fef366d2ed20 54 return sd.disk_sectors() * 512;
Lerche 0:fef366d2ed20 55 }
Lerche 0:fef366d2ed20 56
Lerche 0:fef366d2ed20 57 // Initialize
Lerche 0:fef366d2ed20 58 int BlockDevInit(void)
Lerche 0:fef366d2ed20 59 {
Lerche 0:fef366d2ed20 60 DBG("BlockDevInit\r\n");
Lerche 0:fef366d2ed20 61 // return sd.disk_initialize(0); // Drive # = 0
Lerche 0:fef366d2ed20 62 return 0;
Lerche 0:fef366d2ed20 63 }
Lerche 0:fef366d2ed20 64
Lerche 0:fef366d2ed20 65 int BlockDevWrite(uint32_t dwAddress, uint8_t * pbBuf)
Lerche 0:fef366d2ed20 66 {
Lerche 0:fef366d2ed20 67 //( drive #=0, data buffer to write the data, sector's address, Number of Blocks=1 )
Lerche 0:fef366d2ed20 68 return sd.disk_write((char*)pbBuf, dwAddress); // return=0 -> success
Lerche 0:fef366d2ed20 69 }
Lerche 0:fef366d2ed20 70
Lerche 0:fef366d2ed20 71 int BlockDevRead(uint32_t dwAddress, uint8_t * pbBuf)
Lerche 0:fef366d2ed20 72 {
Lerche 0:fef366d2ed20 73 //( drive #=0, data buffer to read the data, sector's address, Number of Blocks=1 )
Lerche 0:fef366d2ed20 74 return sd.disk_read((char*)pbBuf, dwAddress); // return=0 -> success
Lerche 0:fef366d2ed20 75 }