/*!
 * @file        main.c
 *
 * @brief       Main program body
 *
 * @version     V1.0.0
 *
 * @date        2026-02-25
 *
 * @attention
 *
 *  Copyright (C) 2026 Geehy Semiconductor
 *
 *  You may not use this file except in compliance with the
 *  GEEHY COPYRIGHT NOTICE (Geehy Semiconductor Software License Agreement).
 *
 *  The program is only for reference, which is distributed in the hope
 *  that it will be useful and instructional for customers to develop
 *  their software. Unless required by applicable law or agreed to in
 *  writing, the program is distributed on an "AS IS" BASIS, WITHOUT
 *  ANY WARRANTY OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the Geehy Semiconductor Software License Agreement for the governing permissions
 *  and limitations under the License.
 */

/* Includes */
#include "Board.h"
#include "stdio.h"
#include "g32a10xx_gpio.h"
#include "g32a10xx_misc.h"
#include "g32a10xx_eint.h"
#include "g32a10xx_rcm.h"
#include "g32a10xx_int.h"

/** @addtogroup Examples
  @{
*/

/** @addtogroup SysTick_Examples
  @{
*/

/** @addtogroup SysTick
  @{
  */

/** @defgroup SysTick_Variables Variables
  @{
*/

/* System tick */
volatile uint32_t sysTick = 0;

/**@} end of group SysTick_Variables */

/** @defgroup SysTick_Functions Functions
  @{
  */

/*!
 * @brief       Main program
 *
 * @param       None
 *
 * @retval      None
 *
 * @note
 */
int main(void)
{
    Board_LedInit(LED2);
    Board_LedInit(LED3);

    Board_LedOff(LED2);
    Board_LedOn(LED3);

    /* Configure the SysTick to generate a time base equal to 1 ms */
    if (SysTick_Config(SystemCoreClock / 1000U) != 0U)
    {
        Board_LedOff(LED3);
        while(1)
        {
            /* nothing */
        }
    }
    else
    {
        while (1)
        {
            if (sysTick >= 1000U)
            {
                sysTick = 0;

                Board_LedToggle(LED2);
                Board_LedToggle(LED3);
            }
            else
            {
                /* nothing */
            }
        }
    }
}

/**@} end of group SysTick_Functions */
/**@} end of group SysTick */
/**@} end of group SysTick_Examples */
/**@} end of group Examples */
