/*!
 * @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"

/** @addtogroup Examples
  @{
  */

/** @addtogroup GPIO_Examples
  @{
  */

/** @addtogroup GPIO_Toggle
  @{
  */

/** @defgroup GPIO_Toggle_Functions Functions
  @{
  */

/* Gpio_TestDelay */
void Gpio_TestDelay(void);

/*!
 * @brief       Main program
 *
 * @param       None
 *
 * @retval      None
 *
 * @note
 */
int main(void)
{
    Gpio_ConfigType gpioConfig;

    Rcm_EnableAhbPeriphClock(LED2_GPIO_CLK);
    Rcm_EnableAhbPeriphClock(LED3_GPIO_CLK);
    /* LED2 GPIO configuration */
    gpioConfig.pin = (uint16_t)LED2_PIN;
    gpioConfig.mode = GPIO_MODE_OUT;
    gpioConfig.outtype = GPIO_OUT_TYPE_PP;
    gpioConfig.speed = GPIO_SPEED_50MHz;
    gpioConfig.pupd = GPIO_PUPD_NO;
    Gpio_Config(LED2_GPIO_PORT, &gpioConfig);

    /* LED3 GPIO configuration */
    gpioConfig.pin = (uint16_t)LED3_PIN;
    Gpio_Config(LED3_GPIO_PORT, &gpioConfig);

    /* Turn LED2 on */
    Gpio_ClearBit(LED2_GPIO_PORT, (uint16_t)LED2_PIN);
    /* Turn LED3 off */
    Gpio_SetBit(LED3_GPIO_PORT, (uint16_t)LED3_PIN);

    for (;;)
    {
        Gpio_TestDelay();
        /* LED Toggle*/
        Board_LedToggle(LED2);
        Board_LedToggle(LED3);
    }
}

/*!
 * @brief       Gpio_TestDelay
 *
 * @param       None
 *
 * @retval      None
 *
 * @note
 */
void Gpio_TestDelay(void)
{
    volatile uint32_t delay = 0xffff5;

    while (delay != 0U)
    {
        delay = delay - 1U;
    }
}

/**@} end of group GPIO_Toggle_Functions */
/**@} end of group GPIO_Toggle */
/**@} end of group GPIO_Examples */
/**@} end of group Examples */
