1
0

board.c 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /*
  2. * File : board.c
  3. * This file is part of RT-Thread RTOS
  4. * COPYRIGHT (C) 2006-2011, RT-Thread Development Team
  5. *
  6. * The license and distribution terms for this file may be
  7. * found in the file LICENSE in this distribution or at
  8. * http://www.rt-thread.org/license/LICENSE
  9. *
  10. * Change Logs:
  11. * Date Author Notes
  12. * 2011-02-14 aozima first implementation for Nios II.
  13. */
  14. #include <rthw.h>
  15. #include <rtthread.h>
  16. #include <stdio.h>
  17. #include "system.h"
  18. #include "sys/alt_irq.h"
  19. #include "altera_avalon_timer_regs.h"
  20. #include "uart.h"
  21. extern int alt_irq_register (alt_u32 id,
  22. void* context,
  23. void (*alt_isr_func)(void* isr_context, alt_u32 id) );
  24. /**
  25. * @addtogroup NIOS_II
  26. */
  27. /*@{*/
  28. /**
  29. * This is the timer interrupt service routine.
  30. *
  31. */
  32. void rt_hw_timer_handler(void * context,unsigned long id)
  33. {
  34. void* base = (void*)TIMER_BASE;
  35. /* clear the interrupt */
  36. IOWR_ALTERA_AVALON_TIMER_STATUS (base, 0);
  37. /* enter interrupt */
  38. rt_interrupt_enter();
  39. rt_tick_increase();
  40. /* leave interrupt */
  41. rt_interrupt_leave();
  42. }
  43. void sysTick_config(void)
  44. {
  45. void* base = (void*)TIMER_BASE;
  46. IOWR_ALTERA_AVALON_TIMER_CONTROL (base,
  47. ALTERA_AVALON_TIMER_CONTROL_ITO_MSK |
  48. ALTERA_AVALON_TIMER_CONTROL_CONT_MSK |
  49. ALTERA_AVALON_TIMER_CONTROL_START_MSK);
  50. alt_irq_register (TIMER_IRQ, NULL, rt_hw_timer_handler);
  51. }
  52. static void rt_hw_show_info(void)
  53. {
  54. rt_kprintf("\r\n\r\n---------- board info ----------\r\n");
  55. rt_kprintf("ALT_DEVICE_FAMILY: %s\r\n",ALT_DEVICE_FAMILY);
  56. rt_kprintf("ALT_CPU_ARCHITECTURE: %s\r\n",ALT_CPU_ARCHITECTURE);
  57. rt_kprintf("ALT_CPU_CPU_FREQ: %uMHz\r\n",ALT_CPU_CPU_FREQ/1000000UL);
  58. rt_kprintf("memory size: at 0x%08X 0x%08X byte\r\n",SDRAM_BASE,SDRAM_SPAN);
  59. }
  60. void rt_hw_board_init(void)
  61. {
  62. rt_hw_uart_init();
  63. rt_console_set_device("uart");
  64. rt_hw_show_info();
  65. sysTick_config();
  66. }
  67. /*@}*/