FlashOS.h 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /**************************************************************************//**
  2. * @file FlashOS.h
  3. * @brief Data structures and entries Functions
  4. * @version V1.0.0
  5. * @date 10. January 2018
  6. ******************************************************************************/
  7. /*
  8. * Copyright (c) 2010-2018 Arm Limited. All rights reserved.
  9. *
  10. * SPDX-License-Identifier: Apache-2.0
  11. *
  12. * Licensed under the Apache License, Version 2.0 (the License); you may
  13. * not use this file except in compliance with the License.
  14. * You may obtain a copy of the License at
  15. *
  16. * www.apache.org/licenses/LICENSE-2.0
  17. *
  18. * Unless required by applicable law or agreed to in writing, software
  19. * distributed under the License is distributed on an AS IS BASIS, WITHOUT
  20. * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  21. * See the License for the specific language governing permissions and
  22. * limitations under the License.
  23. */
  24. #define VERS 1 // Interface Version 1.01
  25. #define UNKNOWN 0 // Unknown
  26. #define ONCHIP 1 // On-chip Flash Memory
  27. #define EXT8BIT 2 // External Flash Device on 8-bit Bus
  28. #define EXT16BIT 3 // External Flash Device on 16-bit Bus
  29. #define EXT32BIT 4 // External Flash Device on 32-bit Bus
  30. #define EXTSPI 5 // External Flash Device on SPI
  31. #define SECTOR_NUM 512 // Max Number of Sector Items
  32. #define PAGE_MAX 65536 // Max Page Size for Programming
  33. struct FlashSectors {
  34. unsigned long szSector; // Sector Size in Bytes
  35. unsigned long AddrSector; // Address of Sector
  36. };
  37. #define SECTOR_END 0xFFFFFFFF, 0xFFFFFFFF
  38. struct FlashDevice {
  39. unsigned short Vers; // Version Number and Architecture
  40. char DevName[128]; // Device Name and Description
  41. unsigned short DevType; // Device Type: ONCHIP, EXT8BIT, EXT16BIT, ...
  42. unsigned long DevAdr; // Default Device Start Address
  43. unsigned long szDev; // Total Size of Device
  44. unsigned long szPage; // Programming Page Size
  45. unsigned long Res; // Reserved for future Extension
  46. unsigned char valEmpty; // Content of Erased Memory
  47. unsigned long toProg; // Time Out of Program Page Function
  48. unsigned long toErase; // Time Out of Erase Sector Function
  49. struct FlashSectors sectors[SECTOR_NUM];
  50. };
  51. #define FLASH_DRV_VERS (0x0100+VERS) // Driver Version, do not modify!
  52. // Flash Programming Functions (Called by FlashOS)
  53. extern int Init (unsigned long adr, // Initialize Flash
  54. unsigned long clk,
  55. unsigned long fnc);
  56. extern int UnInit (unsigned long fnc); // De-initialize Flash
  57. extern int BlankCheck (unsigned long adr, // Blank Check
  58. unsigned long sz,
  59. unsigned char pat);
  60. extern int EraseChip (void); // Erase complete Device
  61. extern int EraseSector (unsigned long adr); // Erase Sector Function
  62. extern int ProgramPage (unsigned long adr, // Program Page Function
  63. unsigned long sz,
  64. unsigned char *buf);
  65. extern unsigned long Verify (unsigned long adr, // Verify Function
  66. unsigned long sz,
  67. unsigned char *buf);