📄 timer.h
字号:
/* timer.h -- Timer related definitions * * This code is taken from example code in the Xtensa Microprocessor * Programmer's Guide. * * WARNING: It is highly unlikely that this code works as is on your * particular Xtensa processor configuration. It is hardcoded * for the specific processor configuration used for the * examples in the Xtensa Microprocessor Programmer's Guide. * (The example code did not use the Xtensa HAL to address this * portability issue, for clarity's sake.) Getting it to work * on another processor configuration requires some modifications. *//* * Copyright (c) 2003-2005 by Tensilica Inc. ALL RIGHTS RESERVED. * These coded instructions, statements, and computer programs are the * copyrighted works and confidential proprietary information of Tensilica Inc. * They may not be modified, copied, reproduced, distributed, or disclosed to * third parties in any manner, medium, or form, in whole or in part, without * the prior written consent of Tensilica Inc. */#include <xtensa/config/core.h>#define TIMER0_INTERVAL 0x00008000#define TIMER1_INTERVAL 0x00008000#define TIMER2_INTERVAL 0x000186A0#define TIMER0_INT_MASK (1 << XCHAL_TIMER0_INTERRUPT)#define TIMER1_INT_MASK (1 << XCHAL_TIMER1_INTERRUPT)#define TIMER2_INT_MASK (1 << XCHAL_TIMER2_INTERRUPT)#define _XTSTR(x) # x#define XTSTR(x) _XTSTR(x)static __inline__ int read_ccount(){ unsigned int ccount; __asm__ __volatile__ ( "rsr %0, "XTSTR(CCOUNT) : "=a" (ccount) ); return ccount;}static __inline__ int read_ccompare0(){ unsigned int ccompare0; __asm__ __volatile__ ( "rsr %0, "XTSTR(CCOMPARE_0) : "=a" (ccompare0) ); return ccompare0;}static __inline__ int read_ccompare1(){ unsigned int ccompare1; __asm__ __volatile__ ( "rsr %0, "XTSTR(CCOMPARE_1) : "=a" (ccompare1) ); return ccompare1;}static __inline__ unsigned int read_intenable(){ unsigned int intenable; __asm__ __volatile__ ( "rsr %0, "XTSTR(INTENABLE) : "=a" (intenable) ); return intenable;}static __inline__ void set_ccompare1(int val){ __asm__ __volatile__ ( "wsr %0, "XTSTR(CCOMPARE_1)"\n\t" "isync\n\t" : : "a" (val) );}static __inline__ void set_ccompare0(int val){ __asm__ __volatile__ ( "wsr %0, "XTSTR(CCOMPARE_0)"\n\t" "isync\n\t" : : "a" (val) );}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -