.设置按键中断,按键1按下,LED亮,再按一次,灭
按键2按下,蜂鸣器响。再按一次,不响
按键3按下,风扇转,再按一次,风扇停
头文件key_it.h
#ifndef __KEY_IT_H__
#define __KEY_IT_H__
#include "stm32mp1xx_rcc.h"
#include "stm32mp1xx_gpio.h"
#include "stm32mp1xx_exti.h"
#include "stm32mp1xx_gic.h"
void key_it_config();
void key3_it_config();
void all_led_init();
void buzzer_init();
void fan_init();
#endif
源文件key_it.c
#include"key_it.h"
void key3_it_config()
{
//RCC使能GPIOF时钟
RCC->MP_AHB4ENSETR |= (0x1MODER &= (~(0x3EXTICR3 &=(~(0xFFEXTICR3 |= (0x5FTSR1 |= (0x1C1IMR1 |= (0x1ISENABLER[3] |= (0X1IPRIORITYR[24] &= (~(0X1FITARGETSR[24] &= (~(0X3ITARGETSR[24] |= (0X1MP_AHB4ENSETR |= (0x1MODER &= (~(0x3MODER &= (~(0x3MODER &= (~(0x3EXTICR2 &=(~(0xFFEXTICR2 |= (0x5EXTICR3 &=(~(0xFFEXTICR3 |= (0x5EXTICR3 &=(~(0xFFEXTICR3 |= (0x5FTSR1 |= (0x1FTSR服务器托管网1 |= (0x1FTSR1 |= (0x1C1IMR1 |= (0x1C1IMR1 |= (0x1C1IMR1 |= (0x1ISENABLER[3] |= (0X1ISENABLER[3] |= (0X1ISENABLER[3] |= (0X1IPRIORITYR[24] &= (~(0X1FIPRIORITYR[24] &= (~(0X1FIPRIORITYR[24] &= (~(0X1FITARGETSR[24] &= (~(0X3ITARGETSR[24] |= (0X1ITARGETSR[24] &= (~(0X3ITARGETSR[24] |= (0X1ITARGETSR[24] &= (~(0X3ITARGETSR[24] |= (0X1CTRL |= 0X1;
//设置中断优先级掩码GICC_PMR
GICC->PMR |= (0x1FCTRL |= 0X1;
}
void all_led_init()
{
//RCC使能
RCC->MP_AHB4ENSETR |= (0x3MODER &= (~(0X3MODER |= (0X1OTYPER &= (~(0X1OSPEEDR &= (~(0X3PUPDR &= (~(0X3MP_AHB4ENSETR |= (0x1MODER &= (~(0X3MODER |= (0X1OTYPER &= (~(0X1OSPEEDR &= (~(0X3PUPDR &= (~(0X3MP_AHB4ENSETR |= (0x1MODER &= (~(0X3MODER |= (0X1OTYPER &= (~(0X1OSPEEDR &= (~(0X3PUPDR &= (~(0X3
do_irq.c
#include "key_it.h"
extern void printf(const char *fmt, ...);
unsigned int i = 0;
void do_irq(void)
{
int irqno;//保存中断号
irqno=GICC->IAR & 0X3FF;
switch(irqno)
{
case 99://key1
//按键1中断处理
printf("KEY1 INTn");
G服务器托管网PIOE->ODR ^=(0X1ICPENDR[3] |= (0x1FPR1 |= (0x1ODR ^=(0x1ICPENDR[3] |= (0x1FPR1 |= (0x1ODR ^=(0x1ICPENDR[3] |= (0x1FPR1 |= (0x1EOIR =irqno;
}
main.c
#include "uart.h"
#include "key_it.h"
int main()
{
all_led_init();
uart4_init();//串口初始化
//中断初始化
key_it_config();
key3_it_config();
buzzer_init();
fan_init();
while(1)
{
//保证主程序不结束
}
return 0;
}
现象
服务器托管,北京服务器托管,服务器租用 http://www.fwqtg.net
很容易就能看出半平面交的公式...但是比赛的时候这题看都来不及看... #include using namespace std; typedef long long LL; const int maxn = 1005; const double eps = …