Driver_Flash.c 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. /*
  2. * Copyright (c) 2013-2020 Arm Limited. All rights reserved.
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Licensed under the Apache License, Version 2.0 (the License); you may
  7. * not use this file except in compliance with the License.
  8. * You may obtain a copy of the License at
  9. *
  10. * www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing, software
  13. * distributed under the License is distributed on an AS IS BASIS, WITHOUT
  14. * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. * See the License for the specific language governing permissions and
  16. * limitations under the License.
  17. */
  18. #include "Driver_Flash.h"
  19. #define ARM_FLASH_DRV_VERSION ARM_DRIVER_VERSION_MAJOR_MINOR(1, 0) /* driver version */
  20. /* Sector Information */
  21. #ifdef FLASH_SECTORS
  22. static ARM_FLASH_SECTOR FLASH_SECTOR_INFO[FLASH_SECTOR_COUNT] = {
  23. FLASH_SECTORS
  24. };
  25. #else
  26. #define FLASH_SECTOR_INFO NULL
  27. #endif
  28. /* Flash Information */
  29. static ARM_FLASH_INFO FlashInfo = {
  30. 0, /* FLASH_SECTOR_INFO */
  31. 0, /* FLASH_SECTOR_COUNT */
  32. 0, /* FLASH_SECTOR_SIZE */
  33. 0, /* FLASH_PAGE_SIZE */
  34. 0, /* FLASH_PROGRAM_UNIT */
  35. 0, /* FLASH_ERASED_VALUE */
  36. { 0, 0, 0 } /* Reserved (must be zero) */
  37. };
  38. /* Flash Status */
  39. static ARM_FLASH_STATUS FlashStatus;
  40. /* Driver Version */
  41. static const ARM_DRIVER_VERSION DriverVersion = {
  42. ARM_FLASH_API_VERSION,
  43. ARM_FLASH_DRV_VERSION
  44. };
  45. /* Driver Capabilities */
  46. static const ARM_FLASH_CAPABILITIES DriverCapabilities = {
  47. 0, /* event_ready */
  48. 0, /* data_width = 0:8-bit, 1:16-bit, 2:32-bit */
  49. 0, /* erase_chip */
  50. 0 /* reserved (must be zero) */
  51. };
  52. //
  53. // Functions
  54. //
  55. static ARM_DRIVER_VERSION ARM_Flash_GetVersion(void)
  56. {
  57. return DriverVersion;
  58. }
  59. static ARM_FLASH_CAPABILITIES ARM_Flash_GetCapabilities(void)
  60. {
  61. return DriverCapabilities;
  62. }
  63. static int32_t ARM_Flash_Initialize(ARM_Flash_SignalEvent_t cb_event)
  64. {
  65. }
  66. static int32_t ARM_Flash_Uninitialize(void)
  67. {
  68. }
  69. static int32_t ARM_Flash_PowerControl(ARM_POWER_STATE state)
  70. {
  71. switch (state)
  72. {
  73. case ARM_POWER_OFF:
  74. break;
  75. case ARM_POWER_LOW:
  76. break;
  77. case ARM_POWER_FULL:
  78. break;
  79. }
  80. return ARM_DRIVER_OK;
  81. }
  82. static int32_t ARM_Flash_ReadData(uint32_t addr, void *data, uint32_t cnt)
  83. {
  84. }
  85. static int32_t ARM_Flash_ProgramData(uint32_t addr, const void *data, uint32_t cnt)
  86. {
  87. }
  88. static int32_t ARM_Flash_EraseSector(uint32_t addr)
  89. {
  90. }
  91. static int32_t ARM_Flash_EraseChip(void)
  92. {
  93. }
  94. static ARM_FLASH_STATUS ARM_Flash_GetStatus(void)
  95. {
  96. return FlashStatus;
  97. }
  98. static ARM_FLASH_INFO * ARM_Flash_GetInfo(void)
  99. {
  100. return &FlashInfo;
  101. }
  102. static void ARM_Flash_SignalEvent(uint32_t event)
  103. {
  104. }
  105. // End Flash Interface
  106. extern \
  107. ARM_DRIVER_FLASH Driver_Flash0;
  108. ARM_DRIVER_FLASH Driver_Flash0 = {
  109. ARM_Flash_GetVersion,
  110. ARM_Flash_GetCapabilities,
  111. ARM_Flash_Initialize,
  112. ARM_Flash_Uninitialize,
  113. ARM_Flash_PowerControl,
  114. ARM_Flash_ReadData,
  115. ARM_Flash_ProgramData,
  116. ARM_Flash_EraseSector,
  117. ARM_Flash_EraseChip,
  118. ARM_Flash_GetStatus,
  119. ARM_Flash_GetInfo
  120. };