?? main.c
字號:
/*****************************************************************************************
ST7LITE39 ITC 應用程序(以下程序參考或采用ST公司MCD Application Team提供的相關子程序)
*****************************************************************************************/
#include "ST7lib_config.h"
//函數原型聲明
void EI3_IT_Routine(void);
void EI2_IT_Routine(void);
void main(void);
volatile unsigned int count;
void main (void)
{
unsigned char Pin = 0;
ITC_Init (); /* 初始化ITC */
/* PA4和PA2是推挽(push-pull)輸出 */
IO_Output(IO_PUSH_PULL,IO_PORT_A,((unsigned char)IO_PIN_4 |
(unsigned char)IO_PIN_2 ));
ITC_ConfigureInterrupt(IT_PortB,Pin, IT_EDGE_F);
/*設置port B(PB0~PB7,不包括PB4)的 EI2/EI3下降沿觸發*/
EnableInterrupts; /*使能中斷*/
}
/*******************************************************************************
EI3中斷服務程序( 用于點亮 D2 LED)
REV2.0板上開關和端口的對應關系:
SW4--PB3
SW3--PB2
SW2--PB1
SW1--PB0
*******************************************************************************/
#ifdef _COSMIC_ /* Cosmic編譯器*/
@interrupt /* Cosmic中斷處理 */
#else
#error "Unsupported Compiler!" /* 編譯器未知 */
#endif
void EI3_IT_Routine (void)
{
unsigned int i;
IO_Write (IO_PORT_A,IO_PIN_2,IO_DATA_LOW); /* 在PA2打開LED*/
for ( i=0;i<=1000;i++) /* 延時 */
{
Nop
}
IO_Write (IO_PORT_A,IO_PIN_2,IO_DATA_HIGH); /* 在PA2關閉LED */
ClearInterrupts
}
/*******************************************************************************
EI2中斷服務程序( 用于點亮 D4 LED)
REV2.0板上開關和端口的對應關系:
SW4--PB3
SW3--PB2
SW2--PB1
SW1--PB0
*******************************************************************************/
#ifdef _COSMIC_ /* Cosmic編譯器*/
@interrupt /* Cosmic中斷處理 */
#else
#error "Unsupported Compiler!" /* 編譯器未知 */
#endif
void EI2_IT_Routine (void)
{
unsigned char Temp;
count++;
if(count == 5000)
{
Temp = IO_Read (IO_PORT_A ); /* 切換PA4 */
if (Temp & 0x08)
{
IO_Write (IO_PORT_A,IO_PIN_4,IO_DATA_LOW); /* 在PA4打開LED */
}
else
{
IO_Write (IO_PORT_A,IO_PIN_4,IO_DATA_HIGH); /* 在PA4關閉LED */
}
count = 0;
}
ClearInterrupts
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -