📄 init_qtime.c
字号:
/* * $QNXLicenseC: * Copyright 2007,2008, QNX Software Systems. * * Licensed under the Apache License, Version 2.0 (the "License"). You * may not reproduce, modify or distribute this software 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 OF ANY KIND, either express or implied. * * This file may contain contributions from others, either as * contributors under the License or as licensors under other terms. * Please review this entire file for other proprietary rights or license * notices, as well as the QNX Development Suite License Guide at * http://licensing.qnx.com/license-guide/ for other information. * $ *//* * TI OMAP specific timer support */#include "startup.h"#include "atlasii.h"extern struct callout_rtn timer_load_atlasii;extern struct callout_rtn timer_value_atlasii;extern struct callout_rtn timer_reload_atlasii;#define ATLAS_CLOCK_SCALE -15#define OST_TIMER_SIZE 0x40static uintptr_t timer_base;extern unsigned long atlasii_clock(int OP) ; static const struct callout_slot timer_callouts[] = { { CALLOUT_SLOT(timer_load, _atlasii) }, { CALLOUT_SLOT(timer_value, _atlasii) }, { CALLOUT_SLOT(timer_reload, _atlasii) },};static unsignedtimer_start_atlasii(){ out32(timer_base + 0x30, 1 ); //TIMER_LATCH =1; return in32(timer_base + 0x34 );}static unsignedtimer_diff_atlasii(unsigned start){ unsigned now; out32(timer_base + 0x30, 1 ); now= in32(timer_base + 0x34 ); return start - now;}voidinit_qtime(){ unsigned long timer_clock=atlasii_clock(1)>>1; //equal to sys clock/2 struct qtime_entry *qtime = alloc_qtime(); /* * Map the timer 0 registers */ timer_base = startup_io_map(OST_TIMER_SIZE, _OST_MODULE_BASE); /*clear any existing interrupt*/ out32(timer_base +0x20, 0x3f); //We divide the sys clock to half to get os timer clock (DIV=(SYSCLK/TIMERCLK)/2-1) out32(timer_base +0x2C, 0); //Enable TIMER_MATCH_0 timer interrupt out32(timer_base +0x24, 0x1); //TIMER_INT_EN = 0x1; //clear Counter Low & Hi out32(timer_base +0x4, 0x0); out32(timer_base +0x0, 0x0); timer_start = timer_start_atlasii; timer_diff = timer_diff_atlasii; qtime->intr = 28; qtime->timer_rate = ((uint64_t)1000000000000000ULL)/((uint64_t)timer_clock); qtime->timer_scale = ATLAS_CLOCK_SCALE; qtime->cycles_per_sec =timer_clock; add_callout_array(timer_callouts, sizeof(timer_callouts)); }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -