FlashOS.h 3.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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. {
  41. unsigned long szSector; // Sector Size in Bytes
  42. unsigned long AddrSector; // Address of Sector
  43. };
  44. #define SECTOR_END 0xFFFFFFFF, 0xFFFFFFFF
  45. struct FlashDevice
  46. {
  47. unsigned short Vers; // Version Number and Architecture
  48. char DevName[128]; // Device Name and Description
  49. unsigned short DevType; // Device Type: ONCHIP, EXT8BIT, EXT16BIT, ...
  50. unsigned long DevAdr; // Default Device Start Address
  51. unsigned long szDev; // Total Size of Device
  52. unsigned long szPage; // Programming Page Size
  53. unsigned long Res; // Reserved for future Extension
  54. unsigned char valEmpty; // Content of Erased Memory
  55. unsigned long toProg; // Time Out of Program Page Function
  56. unsigned long toErase; // Time Out of Erase Sector Function
  57. struct FlashSectors sectors[SECTOR_NUM];
  58. };
  59. #define FLASH_DRV_VERS (0x0100+VERS) // Driver Version, do not modify!
  60. // Flash Programming Functions (Called by FlashOS)
  61. extern int Init(unsigned long adr, // Initialize Flash
  62. unsigned long clk,
  63. unsigned long fnc);
  64. extern int UnInit(unsigned long fnc); // De-initialize Flash
  65. extern int BlankCheck(unsigned long adr, // Blank Check
  66. unsigned long sz,
  67. unsigned char pat);
  68. extern int EraseChip(void); // Erase complete Device
  69. extern int EraseSector(unsigned long adr); // Erase Sector Function
  70. extern int ProgramPage(unsigned long adr, // Program Page Function
  71. unsigned long sz,
  72. unsigned char *buf);
  73. extern unsigned long Verify(unsigned long adr, // Verify Function
  74. unsigned long sz,
  75. unsigned char *buf);