main.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. /*!
  2. \file main.h
  3. \brief the header file of main
  4. */
  5. /*
  6. Copyright (C) 2017 GigaDevice
  7. 2017-06-06, V1.0.0, firmware for GD32F3x0
  8. */
  9. #ifndef MAIN_H
  10. #define MAIN_H
  11. /* bit num chosen for this example */
  12. #define WP_PAGES_BIT_1 (8U)
  13. #define WP_PAGES_BIT_2 (9U)
  14. #define WP_PAGES_BIT_3 (10U)
  15. #define WP_ALL_PAGES_BITMAP (0xFFFFU)
  16. /* construct the bitmap which pages need to be configured the write protection */
  17. #define WRITE_PROTECT_PAGES(bit_num) (BIT(bit_num))
  18. /* every bit in OB_WP indicates 4 pages if they are in write protection */
  19. #define PAGE_NUM_PER_WP_BIT (4U)
  20. /* address and data for fmc operation */
  21. #define ERASE_PAGE (WP_PAGES_BIT_1 * PAGE_NUM_PER_WP_BIT)
  22. #define ERASE_PAGE_START_ADDR (0x08000000U + 0x400U * ERASE_PAGE)
  23. #define PROGRAM_ADDRESS ERASE_PAGE_START_ADDR
  24. #define PROGRAM_DATA (0x12345678U)
  25. /* enable some pages' write protection function by configuring option byte */
  26. void fmc_ob_write_protection_enable(uint16_t wp_pages_bitmap);
  27. /* disable some pages' write protection function by configuring option byte */
  28. void fmc_ob_write_protection_disable(uint16_t wp_pages_bitmap);
  29. /* erase and program flash, meanwhile check the operation result */
  30. void fmc_erase_and_program(void);
  31. #endif