Changes to allow hardware camera trigger
Fork of GPS_Incremental by
FatFileSystem/diskio.cpp@10:078891935385, 2013-04-18 (annotated)
- Committer:
- dannyman939
- Date:
- Thu Apr 18 00:59:49 2013 +0000
- Revision:
- 10:078891935385
- Parent:
- 0:c746ee34feae
Hardware trigger camera using the DigitalOut of Pin 2
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
dannyman939 | 0:c746ee34feae | 1 | /*-----------------------------------------------------------------------*/ |
dannyman939 | 0:c746ee34feae | 2 | /* Low level disk I/O module skeleton for FatFs (C)ChaN, 2007 */ |
dannyman939 | 0:c746ee34feae | 3 | /*-----------------------------------------------------------------------*/ |
dannyman939 | 0:c746ee34feae | 4 | /* This is a stub disk I/O module that acts as front end of the existing */ |
dannyman939 | 0:c746ee34feae | 5 | /* disk I/O modules and attach it to FatFs module with common interface. */ |
dannyman939 | 0:c746ee34feae | 6 | /*-----------------------------------------------------------------------*/ |
dannyman939 | 0:c746ee34feae | 7 | |
dannyman939 | 0:c746ee34feae | 8 | #include "diskio.h" |
dannyman939 | 0:c746ee34feae | 9 | #include <stdio.h> |
dannyman939 | 0:c746ee34feae | 10 | #include <string.h> |
dannyman939 | 0:c746ee34feae | 11 | #include "FATFileSystem.h" |
dannyman939 | 0:c746ee34feae | 12 | |
dannyman939 | 0:c746ee34feae | 13 | #include "mbed.h" |
dannyman939 | 0:c746ee34feae | 14 | |
dannyman939 | 0:c746ee34feae | 15 | DSTATUS disk_initialize ( |
dannyman939 | 0:c746ee34feae | 16 | BYTE drv /* Physical drive nmuber (0..) */ |
dannyman939 | 0:c746ee34feae | 17 | ) |
dannyman939 | 0:c746ee34feae | 18 | { |
dannyman939 | 0:c746ee34feae | 19 | FFSDEBUG("disk_initialize on drv [%d]\n", drv); |
dannyman939 | 0:c746ee34feae | 20 | return (DSTATUS)FATFileSystem::_ffs[drv]->disk_initialize(); |
dannyman939 | 0:c746ee34feae | 21 | } |
dannyman939 | 0:c746ee34feae | 22 | |
dannyman939 | 0:c746ee34feae | 23 | DSTATUS disk_status ( |
dannyman939 | 0:c746ee34feae | 24 | BYTE drv /* Physical drive nmuber (0..) */ |
dannyman939 | 0:c746ee34feae | 25 | ) |
dannyman939 | 0:c746ee34feae | 26 | { |
dannyman939 | 0:c746ee34feae | 27 | FFSDEBUG("disk_status on drv [%d]\n", drv); |
dannyman939 | 0:c746ee34feae | 28 | return (DSTATUS)FATFileSystem::_ffs[drv]->disk_status(); |
dannyman939 | 0:c746ee34feae | 29 | } |
dannyman939 | 0:c746ee34feae | 30 | |
dannyman939 | 0:c746ee34feae | 31 | DRESULT disk_read ( |
dannyman939 | 0:c746ee34feae | 32 | BYTE drv, /* Physical drive nmuber (0..) */ |
dannyman939 | 0:c746ee34feae | 33 | BYTE *buff, /* Data buffer to store read data */ |
dannyman939 | 0:c746ee34feae | 34 | DWORD sector, /* Sector address (LBA) */ |
dannyman939 | 0:c746ee34feae | 35 | BYTE count /* Number of sectors to read (1..255) */ |
dannyman939 | 0:c746ee34feae | 36 | ) |
dannyman939 | 0:c746ee34feae | 37 | { |
dannyman939 | 0:c746ee34feae | 38 | FFSDEBUG("disk_read(sector %d, count %d) on drv [%d]\n", sector, count, drv); |
dannyman939 | 0:c746ee34feae | 39 | for(DWORD s=sector; s<sector+count; s++) { |
dannyman939 | 0:c746ee34feae | 40 | FFSDEBUG(" disk_read(sector %d)\n", s); |
dannyman939 | 0:c746ee34feae | 41 | int res = FATFileSystem::_ffs[drv]->disk_read((char*)buff, s); |
dannyman939 | 0:c746ee34feae | 42 | if(res) { |
dannyman939 | 0:c746ee34feae | 43 | return RES_PARERR; |
dannyman939 | 0:c746ee34feae | 44 | } |
dannyman939 | 0:c746ee34feae | 45 | buff += 512; |
dannyman939 | 0:c746ee34feae | 46 | } |
dannyman939 | 0:c746ee34feae | 47 | return RES_OK; |
dannyman939 | 0:c746ee34feae | 48 | } |
dannyman939 | 0:c746ee34feae | 49 | |
dannyman939 | 0:c746ee34feae | 50 | #if _READONLY == 0 |
dannyman939 | 0:c746ee34feae | 51 | DRESULT disk_write ( |
dannyman939 | 0:c746ee34feae | 52 | BYTE drv, /* Physical drive nmuber (0..) */ |
dannyman939 | 0:c746ee34feae | 53 | const BYTE *buff, /* Data to be written */ |
dannyman939 | 0:c746ee34feae | 54 | DWORD sector, /* Sector address (LBA) */ |
dannyman939 | 0:c746ee34feae | 55 | BYTE count /* Number of sectors to write (1..255) */ |
dannyman939 | 0:c746ee34feae | 56 | ) |
dannyman939 | 0:c746ee34feae | 57 | { |
dannyman939 | 0:c746ee34feae | 58 | FFSDEBUG("disk_write(sector %d, count %d) on drv [%d]\n", sector, count, drv); |
dannyman939 | 0:c746ee34feae | 59 | for(DWORD s=sector; s<sector+count; s++) { |
dannyman939 | 0:c746ee34feae | 60 | FFSDEBUG(" disk_write(sector %d)\n", s); |
dannyman939 | 0:c746ee34feae | 61 | int res = FATFileSystem::_ffs[drv]->disk_write((char*)buff, s); |
dannyman939 | 0:c746ee34feae | 62 | if(res) { |
dannyman939 | 0:c746ee34feae | 63 | return RES_PARERR; |
dannyman939 | 0:c746ee34feae | 64 | } |
dannyman939 | 0:c746ee34feae | 65 | buff += 512; |
dannyman939 | 0:c746ee34feae | 66 | } |
dannyman939 | 0:c746ee34feae | 67 | return RES_OK; |
dannyman939 | 0:c746ee34feae | 68 | } |
dannyman939 | 0:c746ee34feae | 69 | #endif /* _READONLY */ |
dannyman939 | 0:c746ee34feae | 70 | |
dannyman939 | 0:c746ee34feae | 71 | DRESULT disk_ioctl ( |
dannyman939 | 0:c746ee34feae | 72 | BYTE drv, /* Physical drive nmuber (0..) */ |
dannyman939 | 0:c746ee34feae | 73 | BYTE ctrl, /* Control code */ |
dannyman939 | 0:c746ee34feae | 74 | void *buff /* Buffer to send/receive control data */ |
dannyman939 | 0:c746ee34feae | 75 | ) |
dannyman939 | 0:c746ee34feae | 76 | { |
dannyman939 | 0:c746ee34feae | 77 | FFSDEBUG("disk_ioctl(%d)\n", ctrl); |
dannyman939 | 0:c746ee34feae | 78 | switch(ctrl) { |
dannyman939 | 0:c746ee34feae | 79 | case CTRL_SYNC: |
dannyman939 | 0:c746ee34feae | 80 | if(FATFileSystem::_ffs[drv] == NULL) { |
dannyman939 | 0:c746ee34feae | 81 | return RES_NOTRDY; |
dannyman939 | 0:c746ee34feae | 82 | } else if(FATFileSystem::_ffs[drv]->disk_sync()) { |
dannyman939 | 0:c746ee34feae | 83 | return RES_ERROR; |
dannyman939 | 0:c746ee34feae | 84 | } |
dannyman939 | 0:c746ee34feae | 85 | return RES_OK; |
dannyman939 | 0:c746ee34feae | 86 | case GET_SECTOR_COUNT: |
dannyman939 | 0:c746ee34feae | 87 | if(FATFileSystem::_ffs[drv] == NULL) { |
dannyman939 | 0:c746ee34feae | 88 | return RES_NOTRDY; |
dannyman939 | 0:c746ee34feae | 89 | } else { |
dannyman939 | 0:c746ee34feae | 90 | int res = FATFileSystem::_ffs[drv]->disk_sectors(); |
dannyman939 | 0:c746ee34feae | 91 | if(res > 0) { |
dannyman939 | 0:c746ee34feae | 92 | *((DWORD*)buff) = res; // minimum allowed |
dannyman939 | 0:c746ee34feae | 93 | return RES_OK; |
dannyman939 | 0:c746ee34feae | 94 | } else { |
dannyman939 | 0:c746ee34feae | 95 | return RES_ERROR; |
dannyman939 | 0:c746ee34feae | 96 | } |
dannyman939 | 0:c746ee34feae | 97 | } |
dannyman939 | 0:c746ee34feae | 98 | case GET_BLOCK_SIZE: |
dannyman939 | 0:c746ee34feae | 99 | *((DWORD*)buff) = 1; // default when not known |
dannyman939 | 0:c746ee34feae | 100 | return RES_OK; |
dannyman939 | 0:c746ee34feae | 101 | |
dannyman939 | 0:c746ee34feae | 102 | } |
dannyman939 | 0:c746ee34feae | 103 | return RES_PARERR; |
dannyman939 | 0:c746ee34feae | 104 | } |
dannyman939 | 0:c746ee34feae | 105 |