drv_common.c 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /**************************************************************************//**
  2. *
  3. * @copyright (C) 2020 Nuvoton Technology Corp. All rights reserved.
  4. *
  5. * SPDX-License-Identifier: Apache-2.0
  6. *
  7. * Change Logs:
  8. * Date Author Notes
  9. * 2020-11-11 Wayne First version
  10. *
  11. ******************************************************************************/
  12. #include <rtthread.h>
  13. #include <rthw.h>
  14. #include "board.h"
  15. #include "drv_uart.h"
  16. #include "drv_sys.h"
  17. #if defined(BSP_USING_MMU)
  18. static struct mem_desc hw_mem_desc[] =
  19. {
  20. { 0x00000000, 0xFFFFFFFF, 0x00000000, RW_NCNB }, /* None cached for 4G memory */
  21. { 0x00000000, BOARD_SDRAM_SIZE - 1, 0x00000000, RW_CB }, /* 64M cached DDR memory */
  22. { BIT31, (BIT31 | BOARD_SDRAM_SIZE) - 1, BIT31, RW_NCNB }, /* Shadow DDR Map */
  23. { 0x3C000000, 0x3C004000 - 1, 0x3C000000, RW_NCNB }, /* 16K SRAM memory */
  24. { 0xBC000000, 0xBC004000 - 1, 0xBC000000, RW_NCNB } /* 16K Shadow memory */
  25. };
  26. #endif
  27. /**
  28. * This function will initial M487 board.
  29. */
  30. rt_weak void rt_hw_board_init(void)
  31. {
  32. /* initialize base clock */
  33. nu_clock_base_init();
  34. /* initialize peripheral pin function */
  35. nu_pin_init();
  36. #if defined(BSP_USING_MMU)
  37. /* initialize mmu */
  38. rt_hw_mmu_init(&hw_mem_desc[0], sizeof(hw_mem_desc) / sizeof(hw_mem_desc[0]));
  39. #else
  40. /* disable I/D cache */
  41. mmu_disable_dcache();
  42. mmu_disable_icache();
  43. mmu_disable();
  44. mmu_invalidate_tlb();
  45. #endif
  46. /* initialize hardware interrupt */
  47. rt_hw_interrupt_init();
  48. /* initialize systick */
  49. rt_hw_systick_init();
  50. #ifdef RT_USING_HEAP
  51. /* init memory system */
  52. rt_system_heap_init((void *)BOARD_HEAP_START, (void *)BOARD_HEAP_END);
  53. #endif
  54. /* initialize uart */
  55. rt_hw_uart_init();
  56. #if defined(RT_USING_CONSOLE) && defined(RT_USING_DEVICE)
  57. rt_console_set_device(RT_CONSOLE_DEVICE_NAME);
  58. #endif
  59. #ifdef RT_USING_COMPONENTS_INIT
  60. rt_components_board_init();
  61. #endif
  62. }