2020-10-16 11:38:52 +08:00
|
|
|
/*
|
2020-10-20 17:28:59 +08:00
|
|
|
Copyright 2020 Shenzhen Academy of Aerospace Technology
|
|
|
|
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
you may not use this file except in compliance with the License.
|
|
|
|
You may obtain a copy of the License at
|
|
|
|
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
See the License for the specific language governing permissions and
|
|
|
|
limitations under the License.
|
|
|
|
|
|
|
|
Change Logs:
|
|
|
|
Date Author Notes
|
|
|
|
2020-10-16 Dystopia the first version
|
|
|
|
*/
|
2020-10-16 11:38:52 +08:00
|
|
|
|
|
|
|
#include <rthw.h>
|
|
|
|
#include <rtthread.h>
|
|
|
|
#include <finsh.h>
|
|
|
|
|
|
|
|
#include "board.h"
|
|
|
|
#include <interrupt.h>
|
|
|
|
|
|
|
|
extern int __bss_end;
|
|
|
|
|
2020-10-20 17:28:59 +08:00
|
|
|
static void rt_hw_timer_isr(int vector, void *param)
|
2020-10-16 11:38:52 +08:00
|
|
|
{
|
2020-10-20 17:28:59 +08:00
|
|
|
rt_tick_increase();
|
|
|
|
/* timer interrupt cleared by hardware */
|
2020-10-16 11:38:52 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
int rt_hw_timer_init(void)
|
|
|
|
{
|
2020-10-20 17:28:59 +08:00
|
|
|
unsigned int counter = 1000000 / RT_TICK_PER_SECOND;
|
|
|
|
volatile struct lregs *regs = (struct lregs *)PREGS;
|
|
|
|
|
2020-10-16 11:38:52 +08:00
|
|
|
regs->scalercnt = CPU_FREQ / 1000000 - 1;
|
|
|
|
regs->scalerload = CPU_FREQ / 1000000 - 1;
|
|
|
|
regs->timercnt2 = counter - 1;
|
|
|
|
regs->timerload2 = counter - 1;
|
|
|
|
|
2020-10-20 17:28:59 +08:00
|
|
|
rt_hw_interrupt_install(TIMER2_TT, rt_hw_timer_isr, RT_NULL, "tick");
|
|
|
|
rt_hw_interrupt_umask(TIMER2_TT);
|
2020-10-16 11:38:52 +08:00
|
|
|
|
2020-10-20 17:28:59 +08:00
|
|
|
/* start timer */
|
|
|
|
regs->timerctrl2 = 0x7;
|
2020-10-16 11:38:52 +08:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
INIT_BOARD_EXPORT(rt_hw_timer_init);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This function will initialize beaglebone board
|
|
|
|
*/
|
|
|
|
void rt_hw_board_init(void)
|
|
|
|
{
|
2020-10-20 17:28:59 +08:00
|
|
|
rt_system_heap_init((void *)&__bss_end, (void *)&__bss_end + 0x01000000);
|
2020-10-16 11:38:52 +08:00
|
|
|
rt_components_board_init();
|
2020-10-20 17:28:59 +08:00
|
|
|
rt_console_set_device(RT_CONSOLE_DEVICE_NAME);
|
2020-10-16 11:38:52 +08:00
|
|
|
}
|