这是好东西,请珍惜这等宝贝,绝对是惜世珍宝,ABOV单片机资料太少,如有有缘人,拿去(硬货)//======================================================
// Used ABOV Semiconductor's code generator
// Device name : A31G111/112
//======================================================
#include "A31G11x_pcu.h"
#include "A31G11x_scucg.h"
#include "A31G11x_uartn.h"
#include "A31G11x_int.h"
#include "A31G11x_adc.h"
#include "debug_frmwrk.h"
/**********************************************************************
// Main Clock Selection
**********************************************************************/
//#define USED_HIRC
//#define USED_WDTRC
//#define USED_MOSC
//#define USED_SOSC
//Clock Out Selection ( Monitoring )
#define USED_CLKO
volatile uint32_t msec;
volatile uint32_t test;
void mainloop(void);
//uint32_t bo;
//uint32_t bi;
void delay (void)
{
uint32_t i;
for (i = 0; i < 0x100000; i++) ;
}
// PE0 port interrupt
void EXTINT0_Handler(void)
{
uint32_t j;
uint32_t status;
status = EIntPE_GetIntStatus();
if(status & (_BIT(0)))
{
for (j= 0; j<5; j++)
{
GPIO_SetValue(PE, _BIT(5));
delay();
GPIO_ClearValue(PE, _BIT(5));
delay();
}
}
EIntPE_ClearIntStatus(0xFF);
}
// PE1 port interrupt
void EXTINT1_Handler(void)
{
uint32_t j;
uint32_t status;
status = EIntPE_GetIntStatus();
if(status & (_BIT(1)))
{
for (j= 0; j<5; j++)
{
GPIO_SetValue(PE, _BIT(5));
delay();
GPIO_ClearValue(PE, _BIT(5));
delay();
}
}
EIntPE_ClearIntStatus(0xFF);
}
// PE2 port interrupt
void EXTINT2_Handler(void)
{
uint32_t j;
uint32_t status;
status = EIntPE_GetIntStatus();
if(status & (_BIT(2)))
{
for (j= 0; j<5; j++)
{
GPIO_SetValue(PE, _BIT(6));
delay();
GPIO_ClearValue(PE, _BIT(6));
delay();
}
}
EIntPE_ClearIntStatus(0xFF);
}
// PE3 port interrupt
void EXTINT3_Handler(void)
{
uint32_t j;
uint32_t status;
status = EIntPE_GetIntStatus();
if(status & (_BIT(3)))
{
for (j= 0; j<5; j++)
{
GPIO_SetValue(PE, _BIT(7));
delay();
GPIO_ClearValue(PE, _BIT(7));
delay();
}
}
EIntPE_ClearIntStatus(0xFF);
}
/**********************************************************************
// Main
**********************************************************************/
int main()
{
init(); // 初始化
mainloop();//主程序
return (0);
} //main
///////////////////////////////////////
void mainloop(void)
{
// uint32_t tmp=0x0;
// AD_Init(); //AD管脚初始化
// Test Pin setting PE5
PCU_SetDirection(PE, 5, PUSH_PULL_OUTPUT);
PCU_ConfigurePullupdown(PE, 5, DISPUPD);
GPIO_ClearValue(PE, _BIT(5));
// Test Pin setting PE6
PCU_SetDirection(PE, 6, PUSH_PULL_OUTPUT);
PCU_ConfigurePullupdown(PE, 6, DISPUPD);
GPIO_ClearValue(PE, _BIT(6));
// Test Pin setting PE7
PCU_SetDirection(PE, 7, PUSH_PULL_OUTPUT);
PCU_ConfigurePullupdown(PE, 7, DISPUPD);
GPIO_ClearValue(PE, _BIT(7));
// // external interrupt test pin PE0
PCU_SetDirection(PE, 0, INPUT);
PCU_ConfigurePullupdown(PE, 0, ENPU);
PCU_SetDebounce(PE,0,HCLK_1024);
// external interrupt test pin PE1
PCU_SetDirection(PE, 1, INPUT);
PCU_ConfigurePullupdown(PE, 1, ENPU);
PCU_SetDebounce(PE,1,HCLK_1024);
// // external interrupt test pin PE2
PCU_SetDirection(PE, 2, INPUT);
PCU_ConfigurePullupdown(PE, 2, ENPU);
PCU_SetDebounce(PE,2,HCLK_1024);
// external interrupt test pin PE3
PCU_SetDirection(PE, 3, INPUT);
PCU_ConfigurePullupdown(PE, 3, ENPU);
PCU_SetDebounce(PE,3,HCLK_1024);
EIntPx_SetReg(PORTE, 0, 0, 1); //使能GPIO中断
EIntPx_SetReg(PORTE, 1, 0, 1); //使能GPIO中断
EIntPx_SetReg(PORTE, 2, 0, 1); //使能GPIO中断
EIntPx_SetReg(PORTE, 3, 0, 1); //使能GPIO中断
EIntCfg(EINT0_SEL,PORTE,0); //外部中断配置
EIntCfg(EINT1_SEL,PORTE,1); //外部中断配置
EIntCfg(EINT2_SEL,PORTE,2); //外部中断配置
EIntCfg(EINT3_SEL,PORTE,3); //外部中断配置
EIntPE_ClearIntStatus(0xFF);
NVIC_EnableIRQ(EXINT0_IRQn); //使能外部中断
NVIC_EnableIRQ(EXINT1_IRQn); //使能外部中断
NVIC_EnableIRQ(EXINT2_IRQn); //使能外部中断
NVIC_EnableIRQ(EXINT3_IRQn); //使能外部中断
EInt_MaskDisable(EXINT0_MASK|EXINT1_MASK|EXINT2_MASK|EXINT3_MASK); //中断源掩码配置
while(1){
// AD_scan(); //按键扫描
// AD_Handle(); //按键处理
// for(tmp = 0; tmp < 1000000; tmp++);
delay();
GPIO_SetValue(PB, _BIT(0));
delay();
GPIO_ClearValue(PB, _BIT(0));
} //while
} //mainloop
全部资料51hei下载地址:
abov-四路按键中断-.7z
(219.92 KB, 下载次数: 11)
|