|
| 1 | +/* |
| 2 | + * File : board.c |
| 3 | + * This file is part of RT-Thread RTOS |
| 4 | + * COPYRIGHT (C) 2020, Shenzhen Academy of Aerospace Technology |
| 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 | + * 2020-10-16 Dystopia the first version |
| 13 | + */ |
| 14 | + |
| 15 | +#include <rthw.h> |
| 16 | +#include <rtthread.h> |
| 17 | +#include <finsh.h> |
| 18 | + |
| 19 | +#include "board.h" |
| 20 | +#include <interrupt.h> |
| 21 | + |
| 22 | +extern int __bss_end; |
| 23 | + |
| 24 | +static void rt_hw_timer_isr(int vector, void* param) |
| 25 | +{ |
| 26 | + rt_tick_increase(); |
| 27 | + /* timer interrupt cleared by hardware */ |
| 28 | +} |
| 29 | + |
| 30 | +int rt_hw_timer_init(void) |
| 31 | +{ |
| 32 | + unsigned int counter = 1000000 / RT_TICK_PER_SECOND; |
| 33 | + volatile struct lregs *regs = (struct lregs*)PREGS; |
| 34 | + |
| 35 | + regs->scalercnt = CPU_FREQ / 1000000 - 1; |
| 36 | + regs->scalerload = CPU_FREQ / 1000000 - 1; |
| 37 | + regs->timercnt2 = counter - 1; |
| 38 | + regs->timerload2 = counter - 1; |
| 39 | + |
| 40 | + rt_hw_interrupt_install(TIMER2_TT, rt_hw_timer_isr, RT_NULL, "tick"); |
| 41 | + rt_hw_interrupt_umask(TIMER2_TT); |
| 42 | + |
| 43 | + /* start timer */ |
| 44 | + regs->timerctrl2 = 0x7; |
| 45 | + |
| 46 | + return 0; |
| 47 | +} |
| 48 | +INIT_BOARD_EXPORT(rt_hw_timer_init); |
| 49 | + |
| 50 | +/** |
| 51 | + * This function will initialize beaglebone board |
| 52 | + */ |
| 53 | +void rt_hw_board_init(void) |
| 54 | +{ |
| 55 | + rt_system_heap_init((void*)&__bss_end, (void*)&__bss_end + 0x01000000); |
| 56 | + rt_components_board_init(); |
| 57 | + rt_console_set_device(RT_CONSOLE_DEVICE_NAME); |
| 58 | +} |
0 commit comments