📄 testisr.c
字号:
#include "vxWorks.h"
#include "taskLib.h"
#include "intLib.h"
#include "iv.h"
#include "logLib.h"
#include "S3C2410.h"
#include "irqs.h"
/*复用功能管脚定义宏*/
#define nYPON 0x3
#define YMON 0x3
#define nXPON 0x3
#define XMON 0x3
/*ACDCON宏*/
#define ECFLG_END 1 // End of A/D conversion
#define PRSCEN_Enable 1 //prescaler Enable
#define PRSCVL_49 49 //A/D converter in process
#define SEL_MUX 7 // xp
#define STDBM_NORMAL 0 //normal mode
#define STDBM_STANDBY 1 //Standby mode
#define READ_START 0 //Disable start by read operation
#define ENABLE_START 0 //No operation
/*ADC touch screen control register宏*/
#define YM_SEN_Hi_Z 0 //YM=Hi-Z
#define YM_SEN_GND 1 //YM=GND
#define YP_SEN_External_voltage 0 //YP=External voltage
#define YP_SEN_AIN5 1 //conntected with AIN5
#define XM_SEN_Hi_Z 0
#define XM_SEN_GND 1
#define XP_SEN_External_voltage 0
#define xp_SEN_AIN7 1
#define PULL_UP_ENABLE 0 //ENABLE
#define PULL_UP_DISABLE 1 //DISABLE
#define AUTO_PST_Normal 0 //Normal ADC conversion
#define AUTO_PST_AUTO 1 //Auto(sequential) x/y positioin conversion mode
#define XY_PST 0 //No operation mode
#define XY_PST_INT 0x3 //waiting for interrupt Mode
/*ADC start or interval delay register*/
#define DELAY
/*ADC conversion data0 register*/
#define UPDOWN_DOWN_0 0
#define UPDOWN_UP_0 1
#define AUTO_PST_sequencing_0 1
#define XY_PST_0 0
/*ADC conversion data1 register*/
#define UPDOWN_DOWN_1 0
#define UPDOWN_UP_1 1
#define AUTO_PST_sequencing_1 1
#define XY_PST_1 0
#define LCDWIDTH 320
#define LCDHEIGHT 240
int TchScr_Xmin=145,TchScr_Xmax=902,
TchScr_Ymin=142,TchScr_Ymax=902;
void TchScr_init()
{
/*复用管脚功能定义*/
GPGCON &= ~((0x03 << 30)|(0x03 << 28)|(0x03 << 26)|(0x03 << 24));
GPGCON|=(nYPON<<30)|(YMON<<28)|(nXPON<<26)|(XMON<<24);
/*set ACDCON*/
ADCCON=(PRSCEN_Enable<<14)|(PRSCVL_49<<6)|(SEL_MUX<<3);
/*ADC start or interval delay register*/
ADCDLY=0xffff;
/*set ADC touch screen control register*/
ADCTSC = (0<<8)|(1<<7)|(1<<6)|(0<<5)|(1<<4)|(0<<3)|(0<<2)|(3);
}
void testIsr(void)
{
/* 第一步:设置中断相关寄存器,屏蔽中断 */
INTMSK |= 0x80000000;
INTSUBMSK |= 0x00000200;
/* 第二步:进行中断的相关操作 */
logMsg("testIsr run...\n", 1, 2, 3, 4, 5, 6);
/* 第三步:设置中断相关寄存器,打开中断 */
SRCPND |= 0x80000000;
SUBSRCPND |= 0x00000200;
INTPND |= 0x80000000;
INTSUBMSK &= (~0x00000200);
INTMSK &= (~0x80000000);
}
void intTest(void)
{
TchScr_init();
/* 第一步:初始化中断相关寄存器 */
SRCPND |= 0x80000000;
printf("SRCPND = 0x%x\n", SRCPND);
INTPND |= 0x80000000;
printf("INTPND = 0x%x\n", INTPND);
INTMOD &= (~0x80000000);
printf("INTMOD = 0x%x\n", INTMOD);
INTMSK &= (~0x80000000);
printf("INTMSK = 0x%x\n", INTMSK);
SUBSRCPND |= 0x00000200;
printf("SUBSRCPND = 0x%x\n", SUBSRCPND);
INTSUBMSK &= (~0x00000200);
printf("INTSUBMSK = 0x%x\n", INTSUBMSK);
/* 第二步:连接中断服务程序 */
intConnect((IRQ_TC), (FUNCPTR)testIsr, 0);
/* 第三步:中断使能 */
intEnable(IVEC_TO_INUM(IRQ_TC));
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -