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