| Line No. | Rev | Author | Line |
|---|---|---|---|
| 1 | 32 | kaklik | /****************************************************************************** |
| 2 | * |
||
| 3 | * Microchip Memory Disk Drive File System |
||
| 4 | * |
||
| 5 | ****************************************************************************** |
||
| 6 | * FileName: Internal Flash.h |
||
| 7 | * Dependencies: GenericTypeDefs.h |
||
| 8 | * FSconfig.h |
||
| 9 | * FSDefs.h |
||
| 10 | * Processor: PIC18/PIC24/dsPIC30/dsPIC33 |
||
| 11 | * Compiler: C18/C30 |
||
| 12 | * Company: Microchip Technology, Inc. |
||
| 13 | * |
||
| 14 | * Software License Agreement |
||
| 15 | * |
||
| 16 | * The software supplied herewith by Microchip Technology Incorporated |
||
| 17 | * (the Company) for its PICmicro® Microcontroller is intended and |
||
| 18 | * supplied to you, the Companys customer, for use solely and |
||
| 19 | * exclusively on Microchip PICmicro Microcontroller products. The |
||
| 20 | * software is owned by the Company and/or its supplier, and is |
||
| 21 | * protected under applicable copyright laws. All rights are reserved. |
||
| 22 | * Any use in violation of the foregoing restrictions may subject the |
||
| 23 | * user to criminal sanctions under applicable laws, as well as to |
||
| 24 | * civil liability for the breach of the terms and conditions of this |
||
| 25 | * license. |
||
| 26 | * |
||
| 27 | * THIS SOFTWARE IS PROVIDED IN AN AS IS CONDITION. NO WARRANTIES, |
||
| 28 | * WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED |
||
| 29 | * TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A |
||
| 30 | * PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. THE COMPANY SHALL NOT, |
||
| 31 | * IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL OR |
||
| 32 | * CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER. |
||
| 33 | * |
||
| 34 | *****************************************************************************/ |
||
| 35 | |||
| 36 | |||
| 37 | /*************************************************************************/ |
||
| 38 | /* Note: This file is included as a template of a header file for */ |
||
| 39 | /* a new physical layer. It is designed to go with */ |
||
| 40 | /* "FS Phys Interface Template.c" */ |
||
| 41 | /*************************************************************************/ |
||
| 42 | |||
| 43 | //DOM-IGNORE-BEGIN |
||
| 44 | /******************************************************************** |
||
| 45 | Change History: |
||
| 46 | Rev Description |
||
| 47 | ---- ----------------------- |
||
| 48 | 1.2.4 - 1.2.6 No Change |
||
| 49 | ********************************************************************/ |
||
| 50 | //DOM-IGNORE-END |
||
| 51 | |||
| 52 | |||
| 53 | #include "GenericTypeDefs.h" |
||
| 54 | #include "FSconfig.h" |
||
| 55 | #include "MDD File System\FSDefs.h" |
||
| 56 | |||
| 57 | #define FALSE 0 |
||
| 58 | #define TRUE !FALSE |
||
| 59 | |||
| 60 | /****************************************************************/ |
||
| 61 | /* YOUR CODE HERE */ |
||
| 62 | /* Add any defines here */ |
||
| 63 | /****************************************************************/ |
||
| 64 | |||
| 65 | // sample defines |
||
| 66 | #define data_bus PORTB |
||
| 67 | #define data_bus_TRIS_BITS TRISB |
||
| 68 | #define address_bus PORTC |
||
| 69 | #define address_bus_TRIS_BITS TRISC |
||
| 70 | #define READSTROBE LATDbits.LATD4 |
||
| 71 | #define READSTROBE_TRIS_BITS TRISDbits.TRISD4 |
||
| 72 | #define WRITESTROBE LATDbits.LATD5 |
||
| 73 | #define WRITESTROBE_TRIS_BITS TRISDbits.TRISD5 |
||
| 74 | #define WRITEPROTECTPIN PORTDbits.RD6 |
||
| 75 | #define WRITEPROTECTPIN_TRIS TRISDbits.TRISD6 |
||
| 76 | #define DEVICE_DETECT_PIN PORTDbits.RD7 |
||
| 77 | #define DEVICE_DETECT_TRIS TRISDbits.TRISD7 |
||
| 78 | |||
| 79 | |||
| 80 | #define INITIALIZATION_VALUE 0x55 |
||
| 81 | |||
| 82 | BYTE MDD_IntFlash_MediaDetect(void); |
||
| 83 | MEDIA_INFORMATION * MDD_IntFlash_MediaInitialize(void); |
||
| 84 | BYTE MDD_IntFlash_SectorRead(DWORD sector_addr, BYTE* buffer); |
||
| 85 | BYTE MDD_IntFlash_SectorWrite(DWORD sector_addr, BYTE* buffer, BYTE allowWriteToZero); |
||
| 86 | WORD MDD_IntFlash_ReadSectorSize(void); |
||
| 87 | DWORD MDD_IntFlash_ReadCapacity(void); |
||
| 88 | BYTE MDD_IntFlash_WriteProtectState(void); |
||
| 89 | |||
| 90 | #if !defined(MDD_INTERNAL_FLASH_MAX_NUM_FILES_IN_ROOT) |
||
| 91 | #define MDD_INTERNAL_FLASH_MAX_NUM_FILES_IN_ROOT 16 |
||
| 92 | #endif |
||
| 93 | |||
| 94 | //Right now since the number of clusters is limited by the psv window to 32KB, |
||
| 95 | // that means that the maximum number of FAT entries is 32KB/512*1.5 = 96 bytes |
||
| 96 | // This will fit in a single sector of FAT so we will hardcode that value to 1. |
||
| 97 | #define MDD_INTERNAL_FLASH_NUM_FAT_SECTORS 1 |
||
| 98 | #define MDD_INTERNAL_FLASH_NUM_RESERVED_SECTORS 1 |
||
| 99 | #define MDD_INTERNAL_FLASH_NUM_ROOT_DIRECTORY_SECTORS ((MDD_INTERNAL_FLASH_MAX_NUM_FILES_IN_ROOT+15)/16) //+15 because the compiler truncates |
||
| 100 | #define MDD_INTERNAL_FLASH_OVERHEAD_SECTORS (\ |
||
| 101 | MDD_INTERNAL_FLASH_NUM_RESERVED_SECTORS + \ |
||
| 102 | MDD_INTERNAL_FLASH_NUM_ROOT_DIRECTORY_SECTORS + \ |
||
| 103 | MDD_INTERNAL_FLASH_NUM_FAT_SECTORS) |
||
| 104 | #define MDD_INTERNAL_FLASH_TOTAL_DISK_SIZE (\ |
||
| 105 | MDD_INTERNAL_FLASH_OVERHEAD_SECTORS + \ |
||
| 106 | MDD_INTERNAL_FLASH_DRIVE_CAPACITY) |
||
| 107 | |||
| 108 | #if (MDD_INTERNAL_FLASH_TOTAL_DISK_SIZE>=64) |
||
| 109 | #if defined(__C30__) |
||
| 110 | #error "PSV only allows 32KB of memory. The drive options selected result in more than 32KB of data. Please reduce MDD internal flash memory usage." |
||
| 111 | #endif |
||
| 112 | #endif |
||
| 113 | |||
| 114 | #if (MDD_INTERNAL_FLASH_MAX_NUM_FILES_IN_ROOT>64) |
||
| 115 | #if defined(__C30__) |
||
| 116 | #error "PSV only allows 32KB of memory. The drive options selected result in more than 32KB of data. Please reduce the number of root directory entries possible" |
||
| 117 | #endif |
||
| 118 | #endif |
||
| 119 | |||
| 120 | #if (MEDIA_SECTOR_SIZE != 512) |
||
| 121 | #error "The current implementation of internal flash MDD only supports a media sector size of 512. Please modify your selected value in the FSconfig.h file." |
||
| 122 | #endif |
||
| 123 | |||
| 124 | #if (MDD_INTERNAL_FLASH_MAX_NUM_FILES_IN_ROOT != 16) && \ |
||
| 125 | (MDD_INTERNAL_FLASH_MAX_NUM_FILES_IN_ROOT != 32) && \ |
||
| 126 | (MDD_INTERNAL_FLASH_MAX_NUM_FILES_IN_ROOT != 48) && \ |
||
| 127 | (MDD_INTERNAL_FLASH_MAX_NUM_FILES_IN_ROOT != 64) |
||
| 128 | #error "Number of root file entries must be a multiple of 16. Please adjust the definition in the FSconfig.h file." |
||
| 129 | #endif |
||
| 130 |
Powered by WebSVN v2.8.3