summaryrefslogtreecommitdiff
path: root/vendor
diff options
context:
space:
mode:
authorhathach <[email protected]>2013-09-25 11:23:53 +0700
committerhathach <[email protected]>2013-09-25 11:23:53 +0700
commitcf65f859be27d71fb64c1c0bca07585f4df37f75 (patch)
tree128bc4d10b4234ead466047780f9ae6216bf2f90 /vendor
parentf820fc5b86d93847560d04f45bbb53b6a29665d3 (diff)
working on fatfs integration
fix retarget input for lpcxpresso
Diffstat (limited to 'vendor')
-rw-r--r--vendor/fatfs/diskio.c116
-rw-r--r--vendor/fatfs/diskio.h29
-rw-r--r--vendor/fatfs/ffconf.h2
-rw-r--r--vendor/fatfs/integer.h3
4 files changed, 137 insertions, 13 deletions
diff --git a/vendor/fatfs/diskio.c b/vendor/fatfs/diskio.c
new file mode 100644
index 000000000..85862e47a
--- /dev/null
+++ b/vendor/fatfs/diskio.c
@@ -0,0 +1,116 @@
+/**************************************************************************/
+/*!
+ @file diskio.c
+ @author hathach (tinyusb.org)
+
+ @section LICENSE
+
+ Software License Agreement (BSD License)
+
+ Copyright (c) 2013, hathach (tinyusb.org)
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+ 1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+ 3. Neither the name of the copyright holders nor the
+ names of its contributors may be used to endorse or promote products
+ derived from this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
+ EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+ This file is part of the tinyusb stack.
+*/
+/**************************************************************************/
+
+#include "boards/board.h"
+#include "tusb.h"
+
+#include "diskio.h"
+
+//--------------------------------------------------------------------+
+// INCLUDE
+//--------------------------------------------------------------------+
+
+//--------------------------------------------------------------------+
+// MACRO CONSTANT TYPEDEF
+//--------------------------------------------------------------------+
+static volatile DSTATUS disk_state = STA_NOINIT;
+
+//--------------------------------------------------------------------+
+// INTERNAL OBJECT & FUNCTION DECLARATION
+//--------------------------------------------------------------------+
+
+//--------------------------------------------------------------------+
+// IMPLEMENTATION
+//--------------------------------------------------------------------+
+
+//pdrv Specifies the physical drive number.
+DSTATUS disk_initialize ( BYTE pdrv )
+{
+ return disk_state;
+}
+
+DSTATUS disk_status (BYTE pdrv)
+{
+ return disk_state;
+}
+
+//pdrv
+// Specifies the physical drive number.
+//buff
+// Pointer to the byte array to store the read data. The size of buffer must be in sector size * sector count.
+//sector
+// Specifies the start sector number in logical block address (LBA).
+//count
+// Specifies number of sectors to read. The value can be 1 to 128. Generally, a multiple sector transfer request
+// must not be split into single sector transactions to the device, or you may not get good read performance.
+DRESULT disk_read (BYTE pdrv, BYTE*buff, DWORD sector, BYTE count)
+{
+
+}
+
+
+DRESULT disk_write (BYTE pdrv, const BYTE* buff, DWORD sector, BYTE count)
+{
+
+}
+
+DRESULT disk_ioctl (BYTE pdrv, BYTE cmd, void* buff)
+{
+
+}
+
+//DWORD get_fattime (void)
+//{
+// union {
+// struct {
+// DWORD second : 5;
+// DWORD minute : 6;
+// DWORD hour : 5;
+// DWORD day_in_month : 5;
+// DWORD month : 4;
+// DWORD year : 7;
+// };
+//
+// DWORD value
+// } timestamp =
+// {
+// .year = (2013-1980),
+// .month = 10,
+// .day_in_month = 21,
+// };
+//}
diff --git a/vendor/fatfs/diskio.h b/vendor/fatfs/diskio.h
index 580fbf747..5a69f69d6 100644
--- a/vendor/fatfs/diskio.h
+++ b/vendor/fatfs/diskio.h
@@ -13,7 +13,7 @@ extern "C" {
#define _USE_IOCTL 1 /* 1: Enable disk_ioctl fucntion */
#include "integer.h"
-
+#include <stdbool.h>
/* Status of Disk Functions */
typedef BYTE DSTATUS;
@@ -28,17 +28,6 @@ typedef enum {
} DRESULT;
-/*---------------------------------------*/
-/* Prototypes for disk control functions */
-
-
-DSTATUS disk_initialize (BYTE pdrv);
-DSTATUS disk_status (BYTE pdrv);
-DRESULT disk_read (BYTE pdrv, BYTE*buff, DWORD sector, BYTE count);
-DRESULT disk_write (BYTE pdrv, const BYTE* buff, DWORD sector, BYTE count);
-DRESULT disk_ioctl (BYTE pdrv, BYTE cmd, void* buff);
-
-
/* Disk Status Bits (DSTATUS) */
#define STA_NOINIT 0x01 /* Drive not initialized */
#define STA_NODISK 0x02 /* No medium in the drive */
@@ -80,6 +69,22 @@ DRESULT disk_ioctl (BYTE pdrv, BYTE cmd, void* buff);
#define CT_SDC (CT_SD1|CT_SD2) /* SD */
#define CT_BLOCK 0x08 /* Block addressing */
+/*---------------------------------------*/
+/* Prototypes for disk control functions */
+
+
+DSTATUS disk_initialize (BYTE pdrv);
+DSTATUS disk_status (BYTE pdrv);
+DRESULT disk_read (BYTE pdrv, BYTE*buff, DWORD sector, BYTE count);
+DRESULT disk_write (BYTE pdrv, const BYTE* buff, DWORD sector, BYTE count);
+DRESULT disk_ioctl (BYTE pdrv, BYTE cmd, void* buff);
+
+static inline bool disk_is_ready(BYTE pdrv);
+static inline bool disk_is_ready(BYTE pdrv)
+{
+ return (disk_status(pdrv) & (STA_NOINIT | STA_NODISK)) == 0;
+}
+
#ifdef __cplusplus
}
diff --git a/vendor/fatfs/ffconf.h b/vendor/fatfs/ffconf.h
index c5cbfa88f..87af580a9 100644
--- a/vendor/fatfs/ffconf.h
+++ b/vendor/fatfs/ffconf.h
@@ -20,7 +20,7 @@
/ data transfer. This reduces memory consumption 512 bytes each file object. */
-#define _FS_READONLY 0 /* 0:Read/Write or 1:Read only */
+#define _FS_READONLY 1 /* 0:Read/Write or 1:Read only */
/* Setting _FS_READONLY to 1 defines read only configuration. This removes
/ writing functions, f_write, f_sync, f_unlink, f_mkdir, f_chmod, f_rename,
/ f_truncate and useless f_getfree. */
diff --git a/vendor/fatfs/integer.h b/vendor/fatfs/integer.h
index 16ad40823..37cda0e07 100644
--- a/vendor/fatfs/integer.h
+++ b/vendor/fatfs/integer.h
@@ -17,7 +17,10 @@ typedef int INT;
typedef unsigned int UINT;
/* These types must be 8-bit integer */
+#ifndef LPC_TYPES_H // avoid typedef redefinition in lpc_types.h
typedef char CHAR;
+#endif
+
typedef unsigned char UCHAR;
typedef unsigned char BYTE;