86 lines
2.0 KiB
C
86 lines
2.0 KiB
C
/*
|
|
* Copyright 2019 NXP
|
|
* All rights reserved.
|
|
*
|
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
*/
|
|
|
|
#include "pin_mux.h"
|
|
#include "clock_config.h"
|
|
#include "board.h"
|
|
|
|
#include "system_MIMXRT1052.h"
|
|
/*******************************************************************************
|
|
* Definitions
|
|
******************************************************************************/
|
|
#define EXAMPLE_LED_GPIO BOARD_USER_LED_GPIO
|
|
#define EXAMPLE_LED_GPIO_PIN BOARD_USER_LED_PIN
|
|
|
|
|
|
/*******************************************************************************
|
|
* Prototypes
|
|
******************************************************************************/
|
|
|
|
/*******************************************************************************
|
|
* Variables
|
|
******************************************************************************/
|
|
volatile uint32_t g_systickCounter;
|
|
/* The PIN status */
|
|
volatile bool g_pinSet = false;
|
|
|
|
/*******************************************************************************
|
|
* Code
|
|
******************************************************************************/
|
|
void SysTick_Handler(void)
|
|
{
|
|
if (g_systickCounter != 0U)
|
|
{
|
|
g_systickCounter--;
|
|
}
|
|
}
|
|
|
|
void SysTick_DelayTicks(uint32_t n)
|
|
{
|
|
g_systickCounter = n;
|
|
while (g_systickCounter != 0U)
|
|
{
|
|
}
|
|
}
|
|
|
|
/*!
|
|
* @brief Main function
|
|
*/
|
|
int main(void)
|
|
{
|
|
/* Board pin init */
|
|
BOARD_ConfigMPU();
|
|
BOARD_InitBootPins();
|
|
BOARD_InitBootClocks();
|
|
/* Update the core clock */
|
|
SystemCoreClockUpdate();
|
|
|
|
/* Set systick reload value to generate 1ms interrupt */
|
|
if (SysTick_Config(SystemCoreClock / 1000U))
|
|
{
|
|
while (1)
|
|
{
|
|
}
|
|
}
|
|
|
|
while (1)
|
|
{
|
|
/* Delay 1000 ms */
|
|
SysTick_DelayTicks(1000U);
|
|
if (g_pinSet)
|
|
{
|
|
GPIO_PinWrite(EXAMPLE_LED_GPIO, EXAMPLE_LED_GPIO_PIN, 0U);
|
|
g_pinSet = false;
|
|
}
|
|
else
|
|
{
|
|
GPIO_PinWrite(EXAMPLE_LED_GPIO, EXAMPLE_LED_GPIO_PIN, 1U);
|
|
g_pinSet = true;
|
|
}
|
|
}
|
|
}
|