📄 tamper.c
字号:
/*
\\\|///
\\ - - //
( @ @ )
+---------------------oOOo-(_)-oOOo-------------------------+
| 智林STM32开发板试验程序 |
| Timer1 定时器中断实验 |
| 刘笑然 by Xiaoran Liu |
| 2008.4.16 |
| |
| 智林测控技术研究所 ZERO research group |
| www.the0.net |
| Oooo |
+-----------------------oooO--( )-------------------------+
( ) ) /
\ ( (_/
\_)
*/
/*----------------------------------------------------------*\
| 引入相关芯片的头文件 |
\*----------------------------------------------------------*/
#include <stdio.h>
#include <stm32f10x_lib.h> // STM32F10x Library Definitions
#include "STM32_Init.h" // STM32 Initialization
#include "TFT018.h"
int ledLight = 0;
/*----------------------------------------------------------*\
| HARDWARE DEFINE |
\*----------------------------------------------------------*/
#define LED ( 1 << 5 ) // PB5: LED D2
/*----------------------------------------------------------*\
| TAMPER Interrupt Handler |
\*----------------------------------------------------------*/
void TAMPER_IRQHandler(void)
{
if (BKP->CSR & (1<<9) ) { // Tamper interrupt flag
PWR->CR |= (1<<8); // enable access to RTC, BDC registers
BKP->CSR |= (1<<1); // clear Tamper Interrupt
BKP->CSR |= (1<<0); // clear tamper Event
PWR->CR &= ~(1<<8); // disable access to RTC, BDC registers
if ((BKP->DR1 == 0) &&
(BKP->DR2 == 0) )
GPIOB->ODR |= LED; // switch off LED
else
GPIOB->ODR &= ~LED; // switch on LED
}
}
/*----------------------------------------------------------*\
| MIAN ENTRY |
\*----------------------------------------------------------*/
int main (void) {
stm32_Init (); // STM32 setup
PWR->CR |= (1<<8); // enable access to RTC, BDC registers
BKP->DR1 = 0x55AA; // fill BKP_DR1 register
BKP->DR2 = 0x33CC; // fill BKP_DR2 register
PWR->CR &= ~(1<<8); // disable access to RTC, BDC registers
LCD_Init();
LCD_Clear_Screen(Blue);
Font = 0;
LCD_PutString(30,0,"STM32F 开发板",Cyan,Blue);
LCD_PutString(35,16,"侵入检测实验",Red,Yellow);
Font = 1;
LCD_PutString(38,32,"Version 1.0",Green,Blue);
Font = 0;
LCD_PutString(10,94,"智林测控技术研究所",Yellow,Blue);
LCD_PutString(36,111,"www.the0.net",Magenta,Blue);
for(;;) {
}
}
/*----------------------------------------------------------*\
| END OF FILE |
\*----------------------------------------------------------*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -