FlashOS.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. /* -----------------------------------------------------------------------------
  2. * Copyright (c) 2014 ARM Ltd.
  3. *
  4. * This software is provided 'as-is', without any express or implied warranty.
  5. * In no event will the authors be held liable for any damages arising from
  6. * the use of this software. Permission is granted to anyone to use this
  7. * software for any purpose, including commercial applications, and to alter
  8. * it and redistribute it freely, subject to the following restrictions:
  9. *
  10. * 1. The origin of this software must not be misrepresented; you must not
  11. * claim that you wrote the original software. If you use this software in
  12. * a product, an acknowledgment in the product documentation would be
  13. * appreciated but is not required.
  14. *
  15. * 2. Altered source versions must be plainly marked as such, and must not be
  16. * misrepresented as being the original software.
  17. *
  18. * 3. This notice may not be removed or altered from any source distribution.
  19. *
  20. *
  21. * $Date: 14. Jan 2014
  22. * $Revision: V1.00
  23. *
  24. * Project: FlashOS Headerfile for Flash drivers
  25. * --------------------------------------------------------------------------- */
  26. /* History:
  27. * Version 1.00
  28. * Initial release
  29. */
  30. #define VERS 1 // Interface Version 1.01
  31. #define UNKNOWN 0 // Unknown
  32. #define ONCHIP 1 // On-chip Flash Memory
  33. #define EXT8BIT 2 // External Flash Device on 8-bit Bus
  34. #define EXT16BIT 3 // External Flash Device on 16-bit Bus
  35. #define EXT32BIT 4 // External Flash Device on 32-bit Bus
  36. #define EXTSPI 5 // External Flash Device on SPI
  37. #define SECTOR_NUM 512 // Max Number of Sector Items
  38. #define PAGE_MAX 65536 // Max Page Size for Programming
  39. struct FlashSectors {
  40. unsigned long szSector; // Sector Size in Bytes
  41. unsigned long AddrSector; // Address of Sector
  42. };
  43. #define SECTOR_END 0xFFFFFFFF, 0xFFFFFFFF
  44. struct FlashDevice {
  45. unsigned short Vers; // Version Number and Architecture
  46. char DevName[128]; // Device Name and Description
  47. unsigned short DevType; // Device Type: ONCHIP, EXT8BIT, EXT16BIT, ...
  48. unsigned long DevAdr; // Default Device Start Address
  49. unsigned long szDev; // Total Size of Device
  50. unsigned long szPage; // Programming Page Size
  51. unsigned long Res; // Reserved for future Extension
  52. unsigned char valEmpty; // Content of Erased Memory
  53. unsigned long toProg; // Time Out of Program Page Function
  54. unsigned long toErase; // Time Out of Erase Sector Function
  55. struct FlashSectors sectors[SECTOR_NUM];
  56. };
  57. #define FLASH_DRV_VERS (0x0100+VERS) // Driver Version, do not modify!
  58. // Flash Programming Functions (Called by FlashOS)
  59. extern int Init (unsigned long adr, // Initialize Flash
  60. unsigned long clk,
  61. unsigned long fnc);
  62. extern int UnInit (unsigned long fnc); // De-initialize Flash
  63. extern int BlankCheck (unsigned long adr, // Blank Check
  64. unsigned long sz,
  65. unsigned char pat);
  66. extern int EraseChip (void); // Erase complete Device
  67. extern int EraseSector (unsigned long adr); // Erase Sector Function
  68. extern int ProgramPage (unsigned long adr, // Program Page Function
  69. unsigned long sz,
  70. unsigned char *buf);
  71. extern unsigned long Verify (unsigned long adr, // Verify Function
  72. unsigned long sz,
  73. unsigned char *buf);