fal_flash_port.c 1.2 KB

1234567891011121314151617181920212223242526272829303132333435
  1. /*
  2. * Copyright (C) 2012-2019 UCloud. All Rights Reserved.
  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. * A copy of the License is located at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * or in the "license" file accompanying this file. This file is distributed
  11. * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
  12. * express or implied. See the License for the specific language governing
  13. * permissions and limitations under the License.
  14. */
  15. #include <fal.h>
  16. #include <stm32f7xx.h>
  17. static int fal_flash_read(long offset, rt_uint8_t *buf, size_t size)
  18. {
  19. return stm32_flash_read(stm32_onchip_flash.addr + offset, buf, size);
  20. }
  21. static int fal_flash_write(long offset, const rt_uint8_t *buf, size_t size)
  22. {
  23. return stm32_flash_write(stm32_onchip_flash.addr + offset, buf, size);
  24. }
  25. static int fal_flash_erase(long offset, size_t size)
  26. {
  27. return stm32_flash_erase(stm32_onchip_flash.addr + offset, size);
  28. }
  29. const struct fal_flash_dev stm32_onchip_flash = { "onchip_flash", STM32_FLASH_START_ADRESS, STM32_FLASH_SIZE, (512 * 1024), {NULL, fal_flash_read, fal_flash_write, fal_flash_erase} };