flash.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /* Copyright 2023 Dual Tachyon
  2. * https://github.com/DualTachyon
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #ifndef DRIVER_FLASH_H
  17. #define DRIVER_FLASH_H
  18. #include "bsp/dp32g030/flash.h"
  19. enum FLASH_READ_MODE {
  20. FLASH_READ_MODE_1_CYCLE = FLASH_CFG_READ_MD_VALUE_1_CYCLE,
  21. FLASH_READ_MODE_2_CYCLE = FLASH_CFG_READ_MD_VALUE_2_CYCLE,
  22. };
  23. typedef enum FLASH_READ_MODE FLASH_READ_MODE;
  24. enum FLASH_MASK_SELECTION {
  25. FLASH_MASK_SELECTION_NONE = FLASH_MASK_SEL_VALUE_NONE,
  26. FLASH_MASK_SELECTION_2KB = FLASH_MASK_SEL_VALUE_2KB,
  27. FLASH_MASK_SELECTION_4KB = FLASH_MASK_SEL_VALUE_4KB,
  28. FLASH_MASK_SELECTION_8KB = FLASH_MASK_SEL_VALUE_8KB,
  29. };
  30. typedef enum FLASH_MASK_SELECTION FLASH_MASK_SELECTION;
  31. enum FLASH_MODE {
  32. FLASH_MODE_READ_AHB = FLASH_CFG_MODE_VALUE_READ_AHB,
  33. FLASH_MODE_PROGRAM = FLASH_CFG_MODE_VALUE_PROGRAM,
  34. FLASH_MODE_ERASE = FLASH_CFG_MODE_VALUE_ERASE,
  35. FLASH_MODE_READ_APB = FLASH_CFG_MODE_VALUE_READ_APB,
  36. };
  37. typedef enum FLASH_MODE FLASH_MODE;
  38. enum FLASH_AREA {
  39. FLASH_AREA_MAIN = FLASH_CFG_NVR_SEL_VALUE_MAIN,
  40. FLASH_AREA_NVR = FLASH_CFG_NVR_SEL_VALUE_NVR,
  41. };
  42. typedef enum FLASH_AREA FLASH_AREA;
  43. void FLASH_Init(FLASH_READ_MODE ReadMode);
  44. void FLASH_ConfigureTrimValues(void);
  45. uint32_t FLASH_ReadNvrWord(uint32_t Address);
  46. #endif