// Include necessary header files
#include "LED.H"
#include
#include
#include
#include
#include
#include
// Define longer identifiers as shorter forms
#define SysCtlPeriEnable SysCtlPeripheralEnable
#define SysCtlPeriDisable SysCtlPeripheralDisable
#define GPIOPinTypeIn GPIOPinTypeGPIOInput
#define GPIOPinTypeOut GPIOPinTypeGPIOOutput
#define GPIOPinTypeOD GPIOPinTypeGPIOOutputOD
//Define KEY
#define KEY_PERIPH SYSCTL_PERIPH_GPIOG
#define KEY_PORT GPIO_PORTG_BASE
#define KEY_PIN GPIO_PIN_5
// Prevent JTAG from failing
void JTAG_Wait(void)
{
SysCtlPeriEnable(KEY_PERIPH); // Enable the GPIO port where KEY is located
GPIOPinTypeIn(KEY_PORT, KEY_PIN); // Set the pin where KEY is located to input
if ( GPIOPinRead(KEY_PORT , KEY_PIN) == 0x00 ) // If KEY is pressed during reset, enter
{
for (;;); // Infinite loop to wait for JTAG connection
}
SysCtlPeriDisable(KEY_PERIPH); // Disable the GPIO port where KEY is located
}
// GPIOD interrupt initialization
void GPIOD_IntInit(void)
{
SysCtlPeriEnable(SYSCTL_PERIPH_GPIOD); // Enable GPIOD port
GPIOPinTypeIn(GPIO_PORTD_BASE, GPIO_PIN_1); // Set PD1 pin to input
GPIOIntTypeSet(GPIO_PORTD_BASE, //Set the interrupt type of
PD1GPIO_PIN_1,
GPIO_LOW_LEVEL); //Low level trigger
GPIOPinIntEnable(GPIO_PORTD_BASE , GPIO_PIN_1); // Enable PD1 pin interrupt
IntEnable(INT_GPIOD); // Enable GPIOD port interrupt
}
// GPIOG interrupt initialization
void GPIOG_IntInit(void)
{
SysCtlPeriEnable(SYSCTL_PERIPH_GPIOG); // Enable GPIOG port
GPIOPinTypeIn(GPIO_PORTG_BASE, GPIO_PIN_5); // Set PG5 pin as input
GPIOIntTypeSet(GPIO_PORTG_BASE, //Set PG5 interrupt type
GPIO_PIN_5,
GPIO_LOW_LEVEL); //Low level trigger
GPIOPinIntEnable(GPIO_PORTG_BASE , GPIO_PIN_5); // Enable PG5 pin interrupt
IntEnable(INT_GPIOG); // Enable GPIOG port interrupt
}
// System initialization
void SystemInit(void)
{
SysCtlLDOSet(SYSCTL_LDO_2_50V); // Set LDO output voltage
SysCtlClockSet(SYSCTL_USE_OSC | // System clock setting, using the main oscillator
SYSCTL_OSC_MAIN |
SYSCTL_XTAL_6MHZ |
SYSCTL_SYSDIV_1);
/*
SysCtlLDOSet(SYSCTL_LDO_2_75V); // Before configuring PLL, set the LDO voltage to 2.75V
SysCtlClockSet(SYSCTL_USE_PLL | // System clock setting, using PLL
SYSCTL_OSC_MAIN | // Main oscillator
SYSCTL_XTAL_6MHZ | // External 6MHz crystal oscillator
SYSCTL_SYSDIV_10); // The frequency division result is 20MHz
*/
LED_Init(LED1); // Initialize LED1 and LED2
LED_On(LED1); // Turn on LED1
GPIOD_IntInit(); // GPIOD interrupt initialization
GPIOG_IntInit(); // GPIOG interrupt initialization
IntMasterEnable(); // Enable processor interrupts (turn on global interrupts)
}
// Main function (program entry)
int main(void)
{
JTAG_Wait(); // Prevent JTAG failure, important!
SystemInit(); // System initialization
for (;;)
{
}
}
// GPIOD interrupt service function
void GPIO_Port_D_ISR(void)
{
unsigned long ulStatus;
ulStatus = GPIOPinIntStatus(GPIO_PORTD_BASE , true); // Read interrupt status
GPIOPinIntClear(GPIO_PORTD_BASE , ulStatus); // Clear interrupt status, important (must be cleared by software)
if ( ulStatus & GPIO_PIN_1 ) // If the interrupt status of PD1 is valid
{
LED_On(LED1); // Turn on LED1
}
// If there are interrupts from other pins of the GPIOD port to be processed, please add multiple if statements in parallel
}
//GPIOG interrupt service function
void GPIO_Port_G_ISR(void)
{
unsigned long ulStatus;
ulStatus = GPIOPinIntStatus(GPIO_PORTG_BASE, true); // Read interrupt status
GPIOPinIntClear(GPIO_PORTG_BASE, ulStatus); // Clear interrupt status, important
if ( ulStatus & GPIO_PIN_5 ) // If the interrupt status of PG5 is valid
{
LED_Off(LED1); // Turn off LED1
}
// If there are interrupts from other pins of the GPIOG port to be processed, please parallelize multiple if statements
}
Previous article:LM3S1138 Getting Started 4, Interrupt Priority
Next article:LM3S1138 Getting Started 2, Marquee
- Popular Resources
- Popular amplifiers
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
- Keysight Technologies Helps Samsung Electronics Successfully Validate FiRa® 2.0 Safe Distance Measurement Test Case
- Innovation is not limited to Meizhi, Welling will appear at the 2024 China Home Appliance Technology Conference
- Innovation is not limited to Meizhi, Welling will appear at the 2024 China Home Appliance Technology Conference
- Huawei's Strategic Department Director Gai Gang: The cumulative installed base of open source Euler operating system exceeds 10 million sets
- Download from the Internet--ARM Getting Started Notes
- Learn ARM development(22)
- Learn ARM development(21)
- Learn ARM development(20)
- Learn ARM development(19)
- Learn ARM development(14)
- Flathead RVB2601 creative application development] @fxyc87 RVB2601-Qiqiao technology
- Looking for a DC/DC step-down chip
- Ask for advice from the experts! Design of soft start circuit based on single chip microcomputer
- U disk IAP jump APP abnormal
- Control power-on circuit problem
- [RISC-V MCU CH32V103 Review] - 0: Three unexpected things when meeting for the first time
- ONENET platform DTLS encryption mentioned the boot machine and access machine. What are the boot machine and access machine? What is the difference between them?
- 【phyBOARD-i.MX 8M Plus Development Board】Part 2: Powering on the Development Board and Evaluating the Development Environment
- 22 Ways to Prevent EMI When Designing Power Supplies
- 【NXP Rapid IoT Review】Hello Touch