board.c 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /*
  2. * Copyright (c) 2006-2021, RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2011-01-13 weety first version
  9. * 2015-05-02 ArdaFu Port from AT91SAM9260 BSP
  10. */
  11. #include <rtthread.h>
  12. #include <rthw.h>
  13. #include <timer0.h>
  14. #include "board.h"
  15. #include <mmu.h>
  16. #include "interrupt.h"
  17. extern void rt_hw_interrupt_init(void);
  18. extern void rt_hw_clock_init(void);
  19. extern void rt_hw_uart_init(void);
  20. static struct mem_desc hw_mem_desc[] =
  21. {
  22. { 0x00000000, 0xFFFFFFFF, 0x00000000, RW_NCNB },/* None cached for 4G memory */
  23. // visual start, visual end, phy start , props
  24. { 0x00000000, 0x000FFFFF, 0x20000000, RW_CB }, /* ISR Vector table */
  25. { 0x00200000, 0x00001FFF, 0x40000000, RW_CB }, /* 8K cached SRAM 0/1 */
  26. { 0x20000000, 0x21FFFFFF, 0x20000000, RW_CB }, /* 32M cached SDRAM */
  27. { 0x90000000, 0x90001FFF, 0x40000000, RW_NCNB },/* 4K SRAM0 + 4k SRAM1 */
  28. { 0xA0000000, 0xA1FFFFFF, 0x20000000, RW_NCNB },/* 32M none-cached SDRAM */
  29. };
  30. /**
  31. * This function will handle rtos timer
  32. */
  33. static void rt_systick_handler(int vector, void *param)
  34. {
  35. uint32_t ir = inl(HW_TIMER0_IR);
  36. if (ir & 1UL)
  37. rt_tick_increase();
  38. outl(ir, REG_SET(HW_TIMER0_IR));
  39. }
  40. /**
  41. * This function will init pit for system ticks
  42. */
  43. static void rt_hw_timer_init()
  44. {
  45. hw_timer0_init();
  46. /* install interrupt handler */
  47. rt_hw_interrupt_install(INT_TIMER0, rt_systick_handler, RT_NULL, "SysTick");
  48. rt_hw_interrupt_umask(INT_TIMER0);
  49. }
  50. /**
  51. * This function will init at91sam9260 board
  52. */
  53. void rt_hw_board_init(void)
  54. {
  55. /* initialize mmu */
  56. rt_hw_mmu_init(hw_mem_desc, sizeof(hw_mem_desc)/sizeof(hw_mem_desc[0]));
  57. /* initialize hardware interrupt */
  58. rt_hw_interrupt_init();
  59. /* initialize the system clock */
  60. //rt_hw_clock_init(); //set each pll etc.
  61. /* initialize uart */
  62. rt_hw_uart_init();
  63. rt_console_set_device(RT_CONSOLE_DEVICE_NAME);
  64. /* initialize timer0 */
  65. rt_hw_timer_init();
  66. }