[TM4C1294NCPDT]如果不按开关使led连续闪烁则使led闪烁固定次数

[TM4C1294NCPDT ]make the led blink continuously while pressing a switch if not make the led blink a fixed number of times

正在使用的电路板是 TM4C1294NCPDT,想法是当按下开关 1 时,led 会不断闪烁(我理解那部分),并且在没有按下开关的那一刻开始闪烁一个固定的如果是次数,假设是 5,那是我所在的位置,我不知道如何在未按下开关时说明条件。

我做了流程图和代码。
闪光灯 1 或 2 只是用于打开和关闭说明的标签 led.

#include <stdbool.h>
#include <stdint.h>
#include "inc/tm4c1294ncpdt.h"

uint32_t i; //int 1
int main(void) {
    SYSCTL_RCGCGPIO_R=0X1100; // set clock portn
    i=SYSCTL_RCGCGPIO_R; // delay (more than 3 cycles)
    GPIO_PORTN_DIR_R=0X03;      //enable the GPIO pin for the LED-PN0, set the direction as output, and
    GPIO_PORTN_DEN_R=0X03;  //enable the GPIO pin for digital function
    GPIO_PORTJ_AHB_DIR_R=0;
    GPIO_PORTJ_AHB_DEN_R=0X03;
    GPIO_PORTJ_AHB_PUR_R=0X01;

    while(1){
        GPIO_PORTN_DATA_R &=~0X02; //turn led off
        while (GPIO_PORTJ_AHB_DATA_R & 0X01){
            GPIO_PORTN_DATA_R |=0X01; //turn led on
            SysCtlDelay(2666666);
            GPIO_PORTN_DATA_R &=~0X01; //turn led off again
            SysCtlDelay(2666666);
        }
        GPIO_PORTN_DATA_R |=0X02;
    }

}  
#include <stdbool.h>
#include <stdint.h>
#include "inc/tm4c1294ncpdt.h"

uint32_t i,j; //int 1

int main(void) {
    SYSCTL_RCGCGPIO_R=0X1100; // set clock portn
    i=SYSCTL_RCGCGPIO_R; // delay (more than 3 cycles)
     j=0;
    GPIO_PORTN_DIR_R=0X03;      //enable the GPIO pin for the LED-PN0, set the direction as output, and
    GPIO_PORTN_DEN_R=0X03;  //enable the GPIO pin for digital function
    GPIO_PORTJ_AHB_DIR_R=0;
    GPIO_PORTJ_AHB_DEN_R=0X03;
    GPIO_PORTJ_AHB_PUR_R=0X01;

    while(1){
        GPIO_PORTN_DATA_R &=~0X02; //turn led off
        while (GPIO_PORTJ_AHB_DATA_R & 0X01){
            GPIO_PORTN_DATA_R |=0X01; //turn led on
            SysCtlDelay(2666666);
            GPIO_PORTN_DATA_R &=~0X01; //turn led off again
            SysCtlDelay(2666666);
        }
          for (j=0; i<5; i++)
                {
                    GPIO_PORTN_DATA_R |=0X01; //turn led on
                SysCtlDelay(2666666);
                GPIO_PORTN_DATA_R &=~0X01; //turn led off again
                SysCtlDelay(2666666)
                }                     
        GPIO_PORTN_DATA_R |=0X02;  //clear the interrupt flag before return
    }

}