#include "def.h"
#include "option.h"
#include "2440addr.h"
#include "mmu.h"
#include "stdio.h"
/*Interrupt processing function Press different buttons to enter the interrupt processing, and start different functions according to the different buttons pressed to realize the button functions of the function control panel*/
void __irq Eint_Isr(void)
{
switch(rEINTPEND)
{
case 1<<13: //Function 1 starts and function 2 is turned off at the same time
rGPBDAT=0<<6|1<<7;
rEINTPEND=1<<13; //Wait for the next interrupt to enter
break;
case 1<<14: //Function 2 starts and function 1 is turned off at the same time
rGPBDAT=1<<6|0<<7;
rEINTPEND=1<<14; //Wait for the next interrupt to enter
break;
case 1<<8: //Close functions 1 and 2
rGPBDAT=1<<6|1<<7;
rEINTPEND=1<<8; //Wait for the next interrupt to enter
break;
default:
rGPBDAT=1<<6|1<<7;
break;
}
ClearPending(BIT_EINT8_23); //Wait for the next interrupt in this interrupt vector to arrive
}
/*Set the default function after startup*/
void Led_on()
{
//Set up the LED light
rGPBCON=0x155555; //Set GPB to output
rGPBDAT=(0x1<<6)|(0x1<<7); //GPB7 pin is set, LED is off
}
/*Set button trigger mode*/
void Eint_func()
{
//Key interrupt source settings
rGPGCON=(rGPGCON&~((0x3<<0)|(0x3<<10)|(0x3<<12)))|(0x1<<1)|(0x1<<11)|(0x1<<13); //Set GPG0, 5, 6 pins to EINT8, 13, 14
rGPGUP|=(0x1<<0)|(0x1<<5)|(0x1<<6); //Pin uses the second function
rEXTINT1=rEXTINT1&~(0x7<<0);//|(0x1<<2); //Button 1 is set to low level edge trigger
rEXTINT1=rEXTINT1&~(0x7<<20);//|(0x1<<22); //Button 2 is set to low level edge trigger
rEXTINT1=rEXTINT1&~(0x7<<24);//|(0x1<<26); //Button 3 is set to low level edge trigger
}
/*Interrupt initialization*/
void Eint_init()
{
rEINTMASK=rEINTMASK&~((0x1<<8)|(0x1<<13)|(0x1<<14)); // Enable external interrupt mask, do not mask interrupt when it is 0
/*Set up interrupt controller*/
rINTMOD&=~BIT_EINT8_23; //Set the interrupt mode to IRQ
rINTMSK&=~BIT_EINT8_23; //Start interrupt enable
}
/*Interrupt pending, waiting for interrupt*/
void Eint_wait()
{
rSRCPND=rSRCPND; //Interrupt pending register clear
rINTPND=rINTPND; //Interrupt source pending register clear
rEINTPEND|=(0x1<<8)|(0x1<<13)|(0x1<<14); //External interrupt suspend register, Eint13 suspends waiting for interrupt
rSRCPND=BIT_EINT8_23; //Interrupt source pending register corresponding position 1 waiting for interrupt
rINTPND=BIT_EINT8_23; //Interrupt pending register corresponding position 1 waiting for interrupt
}
/*Set interrupt pointer*/
void Eint_p()
{
pISR_EINT8_23 =(U32)Eint_Isr; //Set interrupt to Eint11 response
}
/*Main program starts*/
void Main()
{
// isr_asm(); // Enable the I bit of the CPSR register
Led_on(); //Turn off the LED at startup
Eint_init(); //Interrupt initialization
Eint_func(); //Interrupt trigger status initialization
Eint_wait(); //Wait for interrupt
Eint_p(); //Interrupt pointer
}
Previous article:S3C2440 external interrupt response register setting method
Next article:S3C2440 processor UART dedicated registers
Recommended ReadingLatest update time:2024-11-16 14:45
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- Unboxing the newly purchased PIC Kit4, looking forward to its improved functions
- EEWORLD University Hall----Live playback: AVNET uses on-chip CIP and intelligent analog to build complex embedded control functions
- Urgent! Urgent! Urgent! Can the teacher provide a 50A/1000W mature constant current source circuit. The adjustable constant current source can be controlled by a single chip microcomputer.
- 【K210 Series】2. Download tool and latest firmware for K210
- The Low Noise Ripple Probe Guide tells you how important probes are to your testing!
- 【ST NUCLEO-G071RB Review】+ My review process
- Share a learning material: Comic electronic circuit
- Help: Current-type voltage transformer detects AC voltage circuit
- Share two PPT lectures on MOS tubes, very good
- The application circuit of the operational amplifier as a battery pack indicator light is shown in the figure