board.c 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. /*
  2. * File : board.c
  3. * This file is part of RT-Thread RTOS
  4. * COPYRIGHT (C) 2006 - 2009 RT-Thread Develop Team
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License along
  17. * with this program; if not, write to the Free Software Foundation, Inc.,
  18. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  19. *
  20. * Change Logs:
  21. * Date Author Notes
  22. * 2011-01-13 weety first version
  23. * 2015-05-02 ArdaFu Port from AT91SAM9260 BSP
  24. */
  25. #include <rtthread.h>
  26. #include <rthw.h>
  27. #include <timer0.h>
  28. #include "board.h"
  29. #include <mmu.h>
  30. #include "interrupt.h"
  31. extern void rt_hw_interrupt_init(void);
  32. extern void rt_hw_clock_init(void);
  33. extern void rt_hw_uart_init(void);
  34. static struct mem_desc hw_mem_desc[] =
  35. {
  36. { 0x00000000, 0xFFFFFFFF, 0x00000000, RW_NCNB },/* None cached for 4G memory */
  37. // visual start, visual end, phy start , props
  38. { 0x00000000, 0x000FFFFF, 0x20000000, RW_CB }, /* ISR Vector table */
  39. { 0x00200000, 0x00001FFF, 0x40000000, RW_CB }, /* 8K cached SRAM 0/1 */
  40. { 0x20000000, 0x21FFFFFF, 0x20000000, RW_CB }, /* 32M cached SDRAM */
  41. { 0x90000000, 0x90001FFF, 0x40000000, RW_NCNB },/* 4K SRAM0 + 4k SRAM1 */
  42. { 0xA0000000, 0xA1FFFFFF, 0x20000000, RW_NCNB },/* 32M none-cached SDRAM */
  43. };
  44. /**
  45. * This function will handle rtos timer
  46. */
  47. static void rt_systick_handler(int vector, void *param)
  48. {
  49. uint32_t ir = inl(HW_TIMER0_IR);
  50. if (ir & 1UL)
  51. rt_tick_increase();
  52. outl(ir, REG_SET(HW_TIMER0_IR));
  53. }
  54. /**
  55. * This function will init pit for system ticks
  56. */
  57. static void rt_hw_timer_init()
  58. {
  59. hw_timer0_init();
  60. /* install interrupt handler */
  61. rt_hw_interrupt_install(INT_TIMER0, rt_systick_handler, RT_NULL, "SysTick");
  62. rt_hw_interrupt_umask(INT_TIMER0);
  63. }
  64. /**
  65. * This function will init at91sam9260 board
  66. */
  67. void rt_hw_board_init(void)
  68. {
  69. /* initialize mmu */
  70. rt_hw_mmu_init(hw_mem_desc, sizeof(hw_mem_desc)/sizeof(hw_mem_desc[0]));
  71. /* initialize hardware interrupt */
  72. rt_hw_interrupt_init();
  73. /* initialize the system clock */
  74. //rt_hw_clock_init(); //set each pll etc.
  75. /* initialize uart */
  76. rt_hw_uart_init();
  77. rt_console_set_device(RT_CONSOLE_DEVICE_NAME);
  78. /* initialize timer0 */
  79. rt_hw_timer_init();
  80. }