FlashPrg.c 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. /**************************************************************************//**
  2. * @file FlashPrg.c
  3. * @brief Flash Programming Functions adapted for New Device Flash
  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. #include "FlashOS.h" // FlashOS Structures
  25. /*
  26. Mandatory Flash Programming Functions (Called by FlashOS):
  27. int Init (unsigned long adr, // Initialize Flash
  28. unsigned long clk,
  29. unsigned long fnc);
  30. int UnInit (unsigned long fnc); // De-initialize Flash
  31. int EraseSector (unsigned long adr); // Erase Sector Function
  32. int ProgramPage (unsigned long adr, // Program Page Function
  33. unsigned long sz,
  34. unsigned char *buf);
  35. Optional Flash Programming Functions (Called by FlashOS):
  36. int BlankCheck (unsigned long adr, // Blank Check
  37. unsigned long sz,
  38. unsigned char pat);
  39. int EraseChip (void); // Erase complete Device
  40. unsigned long Verify (unsigned long adr, // Verify Function
  41. unsigned long sz,
  42. unsigned char *buf);
  43. - BlanckCheck is necessary if Flash space is not mapped into CPU memory space
  44. - Verify is necessary if Flash space is not mapped into CPU memory space
  45. - if EraseChip is not provided than EraseSector for all sectors is called
  46. */
  47. /*
  48. * Initialize Flash Programming Functions
  49. * Parameter: adr: Device Base Address
  50. * clk: Clock Frequency (Hz)
  51. * fnc: Function Code (1 - Erase, 2 - Program, 3 - Verify)
  52. * Return Value: 0 - OK, 1 - Failed
  53. */
  54. int Init (unsigned long adr, unsigned long clk, unsigned long fnc) {
  55. /* Add your Code */
  56. return (0); // Finished without Errors
  57. }
  58. /*
  59. * De-Initialize Flash Programming Functions
  60. * Parameter: fnc: Function Code (1 - Erase, 2 - Program, 3 - Verify)
  61. * Return Value: 0 - OK, 1 - Failed
  62. */
  63. int UnInit (unsigned long fnc) {
  64. /* Add your Code */
  65. return (0); // Finished without Errors
  66. }
  67. /*
  68. * Erase complete Flash Memory
  69. * Return Value: 0 - OK, 1 - Failed
  70. */
  71. int EraseChip (void) {
  72. /* Add your Code */
  73. return (0); // Finished without Errors
  74. }
  75. /*
  76. * Erase Sector in Flash Memory
  77. * Parameter: adr: Sector Address
  78. * Return Value: 0 - OK, 1 - Failed
  79. */
  80. int EraseSector (unsigned long adr) {
  81. /* Add your Code */
  82. return (0); // Finished without Errors
  83. }
  84. /*
  85. * Program Page in Flash Memory
  86. * Parameter: adr: Page Start Address
  87. * sz: Page Size
  88. * buf: Page Data
  89. * Return Value: 0 - OK, 1 - Failed
  90. */
  91. int ProgramPage (unsigned long adr, unsigned long sz, unsigned char *buf) {
  92. /* Add your Code */
  93. return (0); // Finished without Errors
  94. }