/**
  ******************************************************************************
  * @file    RCM/RCM_ClockConfig/main.c
  * @author  IOT Development Team
  * @version V1.0.0
  * @date    10-January-2020
  * @brief   Main program body.
  ******************************************************************************
  */

/* Includes ------------------------------------------------------------------*/
#include "main.h"

/** @addtogroup APM32F10x_StdPeriph_Examples
  * @{
  */


/** @addtogroup RCM_ClockConfig
  * @{
  */

/* Private typedef -----------------------------------------------------------*/
/* Private define ------------------------------------------------------------*/
#define DELAY_COUNT    0x3FFFF

/* Private macro -------------------------------------------------------------*/
/* Private variables ---------------------------------------------------------*/
//typedef struct
//{
uint32_t SYSCLK_Frequency;  /*!< returns SYSCLK clock frequency expressed in Hz */
uint32_t HCLK_Frequency;    /*!< returns HCLK clock frequency expressed in Hz */
uint32_t PCLK1_Frequency;   /*!< returns PCLK1 clock frequency expressed in Hz */
uint32_t PCLK2_Frequency;   /*!< returns PCLK2 clock frequency expressed in Hz */
uint32_t ADCCLK_Frequency;  /*!< returns ADCCLK clock frequency expressed in Hz */
//}RCC_ClocksTypeDef;

GPIO_ConfigStruct_T GPIO_configStruct;

//RCC_ClocksTypeDef RCM_ClockFreq;

uint8_t HXTStartUpStatus;

/* Private function prototypes -----------------------------------------------*/
void NVIC_Configuration(void);
void Delay(__IO uint32_t nCount);

void SetSysClock(void);
#ifdef SYSCLK_HXT
void SetSysClockToHXT(void);
#elif defined SYSCLK_FREQ_24MHz
void SetSysClockTo24(void);
#elif defined SYSCLK_FREQ_36MHz
void SetSysClockTo36(void);
#elif defined SYSCLK_FREQ_48MHz
void SetSysClockTo48(void);
#elif defined SYSCLK_FREQ_56MHz
void SetSysClockTo56(void);
#elif defined SYSCLK_FREQ_72MHz
void SetSysClockTo72(void);
#endif

/* Private functions ---------------------------------------------------------*/

/**
  * @brief  Main program.
  * @param  None
  * @retval None
  */
int main(void)
{
    /*!< At this stage the microcontroller clock setting is already configured,
         this is done through SystemInit() function which is called from startup
         file (startup_apm32f10x_xx.s) before to branch to application main.
         To reconfigure the default setting of SystemInit() function, refer to
         system_apm32f10x.c file
       */

    /* Configure the System clock frequency, HCLK, PCLK2 and PCLK1 prescalers */
    SetSysClock();

    /* This function fills the ADCCLK_Frequency¡¢HCLK_Frequency¡¢PCLK1_Frequency¡¢
    PCLK2_Frequency¡¢SYSCLK_Frequency with the currentfrequencies of 
    different on chip clocks (for debug purpose) */
    ADCCLK_Frequency=RCM_GetADCCLKFreq();
    HCLK_Frequency=RCM_GetHCLKFreq();
    RCM_GetPCLKFreq(&PCLK1_Frequency, &PCLK2_Frequency);
    SYSCLK_Frequency=RCM_GetSYSCLKFreq();

    /* Enable Clock Security System(CSS): this will generate an NMI exception
       when HXT clock fails */
    RCM_EnableCCS();

    /* NVIC configuration ------------------------------------------------------*/
    NVIC_Configuration();

    /* Initialize Leds mounted on APM3210X-EVAL board --------------------------*/
#if defined(APM32_MINI)
    APM_MINI_LEDInit(LED2);
    APM_MINI_LEDInit(LED3);
#elif defined (APM32_DISCOVERY)
    APM_DISCOVERY_LEDInit(LED2);
    APM_DISCOVERY_LEDInit(LED3);
#elif defined(APM32F103V_EVAL)
    APM_EVAL_LEDInit(LED1);
    APM_EVAL_LEDInit(LED2);
    APM_EVAL_LEDInit(LED3);
    APM_EVAL_LEDInit(LED4);
#endif
    /* Output HXT clock on MCO pin ---------------------------------------------*/
    RCM_EnableAPB2PeriphClock(RCM_APB2_PERIPH_GPIOA);

    GPIO_configStruct.pin = GPIO_PIN_8;
    GPIO_configStruct.mode = GPIO_MODE_AF_PP;
    GPIO_configStruct.speed = GPIO_SPEED_50MHz;
    GPIO_Config(GPIOA, &GPIO_configStruct);
    RCM_ConfigCOC(RCM_COC_HXT);

    while (1)
    {
#if defined(APM32F103V_EVAL)
        /* Toggle LED1 */
        APM_EVAL_LEDToggle(LED1);
        /* Insert delay */
        Delay(DELAY_COUNT);
#endif
#if defined(APM32_MINI)
        /* Toggle LED2 */
        APM_MINI_LEDToggle(LED2);
        /* Insert delay */
        Delay(DELAY_COUNT);

        /* Toggle LED3 */
        APM_MINI_LEDToggle(LED3);
        /* Insert delay */
        Delay(DELAY_COUNT);
#elif defined (APM32_DISCOVERY)
        /* Toggle LED2 */
        APM_DISCOVERY_LEDToggle(LED2);
        /* Insert delay */
        Delay(DELAY_COUNT);

        /* Toggle LED3 */
        APM_DISCOVERY_LEDToggle(LED3);
        /* Insert delay */
        Delay(DELAY_COUNT);
#elif defined(APM32F103V_EVAL)
        /* Toggle LED2 */
        APM_EVAL_LEDToggle(LED2);
        /* Insert delay */
        Delay(DELAY_COUNT);

        /* Toggle LED3 */
        APM_EVAL_LEDToggle(LED3);
        /* Insert delay */
        Delay(DELAY_COUNT);
        /* Toggle LED4 */
        APM_EVAL_LEDToggle(LED4);
        /* Insert a delay */
        Delay(DELAY_COUNT);
#endif
    }
}

/**
  * @brief  Configures the System clock frequency, HCLK, PCLK2 and PCLK1
  *         prescalers.
  * @param  None
  * @retval None
  */
void SetSysClock(void)
{
    /* The System clock configuration functions defined below assume that:
            - For Low, Medium and High density devices an external 8MHz crystal is
              used to drive the System clock.
            - For Connectivity line devices an external 25MHz crystal is used to drive
              the System clock.
         If you are using different crystal you have to adapt those functions accordingly.*/

#if defined SYSCLK_HXT
    SetSysClockToHXT();
#elif defined SYSCLK_FREQ_24MHz
    SetSysClockTo24();
#elif defined SYSCLK_FREQ_36MHz
    SetSysClockTo36();
#elif defined SYSCLK_FREQ_48MHz
    SetSysClockTo48();
#elif defined SYSCLK_FREQ_56MHz
    SetSysClockTo56();
#elif defined SYSCLK_FREQ_72MHz
    SetSysClockTo72();
#endif

    /* If none of the define above is enabled, the HIRC is used as System clock
       source (default after reset) */
}

/**
  * @brief  Selects HXT as System clock source and configure HCLK, PCLK2
  *         and PCLK1 prescalers.
  * @param  None
  * @retval None
  */
void SetSysClockToHXT(void)
{
    /* SYSCLK, HCLK, PCLK2 and PCLK1 configuration -----------------------------*/
    /* RCM system reset(for debug purpose) */
    RCM_Reset();

    /* Enable HXT */
    RCM_ConfigHXT(RCM_HXT_OPEN);

    /* Wait till HXT is ready */
    HXTStartUpStatus = RCM_WaitHXTReady();

    if (HXTStartUpStatus == SUCCESS)
    {
#if !defined APM32F10X_LD_VL && !defined APM32F10X_MD_VL && !defined APM32F10X_HD_VL
        /* Enable Prefetch Buffer */
        FLASH_EnablePrefetchBuffer();

#ifndef APM32F10X_CL
        /* Flash 0 wait state */
        FLASH_SetLatency(FLASH_LATENCY_0);
#else

        if (HXT_Value <= 24000000)
        {
            /* Flash 0 wait state */
            FLASH_SetLatency(FLASH_Latency_0);
        }
        else
        {
            /* Flash 1 wait state */
            FLASH_SetLatency(FLASH_Latency_1);
        }

#endif /* APM32F10X_CL */
#endif /* APM32F10X_LD_VL && APM32F10X_MD_VL */

        /* HCLK = SYSCLK */
        RCM_ConfigAHB(RCM_SYSCLK_DIV_1);

        /* PCLK2 = HCLK */
        RCM_ConfigAPB2(RCM_HCLK_DIV_1);

        /* PCLK1 = HCLK */
        RCM_ConfigAPB1(RCM_HCLK_DIV_1);

        /* Select HXT as system clock source */
        RCM_ConfigSYSCLK(RCM_SYSCLK_SEL_HXT);

        /* Wait till PLL is used as system clock source */
        while (RCM_GetSYSCLKSource() != RCM_SYSCLK_SEL_HXT)
        {
        }
    }
    else
    {
        /* If HXT fails to start-up, the application will have wrong clock configuration.
           User can add here some code to deal with this error */

        /* Go to infinite loop */
        while (1)
        {
        }
    }
}

/**
  * @brief  Sets System clock frequency to 24MHz and configure HCLK, PCLK2
  *         and PCLK1 prescalers.
  * @param  None
  * @retval None
  */
void SetSysClockTo24(void)
{
    /* SYSCLK, HCLK, PCLK2 and PCLK1 configuration -----------------------------*/
    /* RCM system reset(for debug purpose) */
    RCM_Reset();

    /* Enable HXT */
    RCM_ConfigHXT(RCM_HXT_OPEN);

    /* Wait till HXT is ready */
    HXTStartUpStatus = RCM_WaitHXTReady();

    if (HXTStartUpStatus == SUCCESS)
    {
#if !defined APM32F10X_LD_VL && !defined APM32F10X_MD_VL && !defined APM32F10X_HD_VL
        /* Enable Prefetch Buffer */
        FLASH_EnablePrefetchBuffer();

        /* Flash 0 wait state */
        FLASH_SetLatency(FLASH_LATENCY_0);
#endif /* APM32F10X_LD_VL && APM32F10X_MD_VL */

        /* HCLK = SYSCLK */
        RCM_ConfigAHB(RCM_SYSCLK_DIV_1);

        /* PCLK2 = HCLK */
        RCM_ConfigAPB2(RCM_HCLK_DIV_1);

        /* PCLK1 = HCLK */
        RCM_ConfigAPB1(RCM_HCLK_DIV_1);

#ifdef APM32F10X_CL
        /* Configure PLLs *********************************************************/
        /* PLL2 configuration: PLL2CLK = (HXT / 5) * 8 = 40 MHz */
        RCM_PREDIV2Config(RCM_PREDIV2_Div5);
        RCM_PLL2Config(RCM_PLL2Mul_8);

        /* Enable PLL2 */
        RCM_PLL2Cmd(ENABLE);

        /* Wait till PLL2 is ready */
        while (RCM_GetFlagStatus(RCM_FLAG_PLL2RDY) == RESET)
        {}

        /* PLL configuration: PLLCLK = (PLL2 / 10) * 6 = 24 MHz */
        RCM_PREDIV1Config(RCM_PREDIV1_Source_PLL2, RCM_PREDIV1_Div10);
        RCM_PLLConfig(RCM_PLLSource_PREDIV1, RCM_PLLMul_6);
#elif defined APM32F10X_LD_VL || defined APM32F10X_MD_VL || defined APM32F10X_HD_VL
        /* PLLCLK = (8MHz/2) * 6 = 24 MHz */
        RCM_PREDIV1Config(RCM_PREDIV1_Source_HXT, RCM_PREDIV1_Div2);
        RCM_PLLConfig(RCM_PLLSource_PREDIV1, RCM_PLLMul_6);
#else
        /* PLLCLK = 8MHz * 3 = 24 MHz */
        RCM_ConfigPLL(RCM_PLLSEL_HXT, RCM_PLLMF_3);
#endif

        /* Enable PLL */
        RCM_EnablePLL();

        /* Wait till PLL is ready */
        while (RCM_ReadFlag(RCM_FLAG_PLLRDY) == RESET)
        {
        }

        /* Select PLL as system clock source */
        RCM_ConfigSYSCLK(RCM_SYSCLK_SEL_PLL);

        /* Wait till PLL is used as system clock source */
        while (RCM_GetSYSCLKSource() != RCM_SYSCLK_SEL_PLL)
        {
        }
    }
    else
    {
        /* If HXT fails to start-up, the application will have wrong clock configuration.
           User can add here some code to deal with this error */

        /* Go to infinite loop */
        while (1)
        {
        }
    }
}
#if !defined APM32F10X_LD_VL && !defined APM32F10X_MD_VL && !defined APM32F10X_HD_VL
/**
  * @brief  Sets System clock frequency to 36MHz and configure HCLK, PCLK2
  *         and PCLK1 prescalers.
  * @param  None
  * @retval None
  */
void SetSysClockTo36(void)
{
    /* SYSCLK, HCLK, PCLK2 and PCLK1 configuration -----------------------------*/
    /* RCM system reset(for debug purpose) */
    RCM_Reset();

    /* Enable HXT */
    RCM_ConfigHXT(RCM_HXT_OPEN);

    /* Wait till HXT is ready */
    HXTStartUpStatus = RCM_WaitHXTReady();

    if (HXTStartUpStatus == SUCCESS)
    {
        /* Enable Prefetch Buffer */
        FLASH_EnablePrefetchBuffer();

        /* Flash 1 wait state */
        FLASH_SetLatency(FLASH_LATENCY_1);

        /* HCLK = SYSCLK */
        RCM_ConfigAHB(RCM_SYSCLK_DIV_1);

        /* PCLK2 = HCLK */
        RCM_ConfigAPB2(RCM_HCLK_DIV_1);

        /* PCLK1 = HCLK */
        RCM_ConfigAPB1(RCM_HCLK_DIV_1);

#ifdef APM32F10X_CL
        /* Configure PLLs *********************************************************/
        /* PLL2 configuration: PLL2CLK = (HXT / 5) * 8 = 40 MHz */
        RCM_PREDIV2Config(RCM_PREDIV2_Div5);
        RCM_PLL2Config(RCM_PLL2Mul_8);

        /* Enable PLL2 */
        RCM_PLL2Cmd(ENABLE);

        /* Wait till PLL2 is ready */
        while (RCM_GetFlagStatus(RCM_FLAG_PLL2RDY) == RESET)
        {}

        /* PLL configuration: PLLCLK = (PLL2 / 10) * 9 = 36 MHz */
        RCM_PREDIV1Config(RCM_PREDIV1_Source_PLL2, RCM_PREDIV1_Div10);
        RCM_PLLConfig(RCM_PLLSource_PREDIV1, RCM_PLLMul_9);
#else
        /* PLLCLK = (8MHz / 2) * 9 = 36 MHz */
        RCM_ConfigPLL(RCM_PLLSEL_HXT_DIV2, RCM_PLLMF_9);
#endif

        /* Enable PLL */
        RCM_EnablePLL();

        /* Wait till PLL is ready */
        while (RCM_ReadFlag(RCM_FLAG_PLLRDY) == RESET)
        {
        }

        /* Select PLL as system clock source */
        RCM_ConfigSYSCLK(RCM_SYSCLK_SEL_PLL);

        /* Wait till PLL is used as system clock source */
        while (RCM_GetSYSCLKSource() != RCM_SYSCLK_SEL_PLL)
        {
        }
    }
    else
    {
        /* If HXT fails to start-up, the application will have wrong clock configuration.
           User can add here some code to deal with this error */

        /* Go to infinite loop */
        while (1)
        {
        }
    }
}

/**
  * @brief  Sets System clock frequency to 48MHz and configure HCLK, PCLK2
  *         and PCLK1 prescalers.
  * @param  None
  * @retval None
  */
void SetSysClockTo48(void)
{
    /* SYSCLK, HCLK, PCLK2 and PCLK1 configuration -----------------------------*/
    /* RCM system reset(for debug purpose) */
    RCM_Reset();

    /* Enable HXT */
    RCM_ConfigHXT(RCM_HXT_OPEN);

    /* Wait till HXT is ready */
    HXTStartUpStatus = RCM_WaitHXTReady();

    if (HXTStartUpStatus == SUCCESS)
    {
        /* Enable Prefetch Buffer */
        FLASH_EnablePrefetchBuffer();

        /* Flash 1 wait state */
        FLASH_SetLatency(FLASH_LATENCY_1);

        /* HCLK = SYSCLK */
        RCM_ConfigAHB(RCM_SYSCLK_DIV_1);

        /* PCLK2 = HCLK */
        RCM_ConfigAPB2(RCM_HCLK_DIV_1);

        /* PCLK1 = HCLK/2 */
        RCM_ConfigAPB1(RCM_HCLK_DIV_2);

#ifdef APM32F10X_CL
        /* Configure PLLs *********************************************************/
        /* PLL2 configuration: PLL2CLK = (HXT / 5) * 8 = 40 MHz */
        RCM_PREDIV2Config(RCM_PREDIV2_Div5);
        RCM_PLL2Config(RCM_PLL2Mul_8);

        /* Enable PLL2 */
        RCM_PLL2Cmd(ENABLE);

        /* Wait till PLL2 is ready */
        while (RCM_GetFlagStatus(RCM_FLAG_PLL2RDY) == RESET)
        {}

        /* PLL configuration: PLLCLK = (PLL2 / 5) * 6 = 48 MHz */
        RCM_PREDIV1Config(RCM_PREDIV1_Source_PLL2, RCM_PREDIV1_Div5);
        RCM_PLLConfig(RCM_PLLSource_PREDIV1, RCM_PLLMul_6);
#else
        /* PLLCLK = 8MHz * 6 = 48 MHz */
        RCM_ConfigPLL(RCM_PLLSEL_HXT, RCM_PLLMF_6);
#endif

        /* Enable PLL */
        RCM_EnablePLL();

        /* Wait till PLL is ready */
        while (RCM_ReadFlag(RCM_FLAG_PLLRDY) == RESET)
        {
        }

        /* Select PLL as system clock source */
        RCM_ConfigSYSCLK(RCM_SYSCLK_SEL_PLL);

        /* Wait till PLL is used as system clock source */
        while (RCM_GetSYSCLKSource() != RCM_SYSCLK_SEL_PLL)
        {
        }
    }
    else
    {
        /* If HXT fails to start-up, the application will have wrong clock configuration.
           User can add here some code to deal with this error */

        /* Go to infinite loop */
        while (1)
        {
        }
    }
}

/**
  * @brief  Sets System clock frequency to 56MHz and configure HCLK, PCLK2
  *         and PCLK1 prescalers.
  * @param  None
  * @retval None
  */
void SetSysClockTo56(void)
{
    /* SYSCLK, HCLK, PCLK2 and PCLK1 configuration -----------------------------*/
    /* RCM system reset(for debug purpose) */
    RCM_Reset();

    /* Enable HXT */
    RCM_ConfigHXT(RCM_HXT_OPEN);

    /* Wait till HXT is ready */
    HXTStartUpStatus = RCM_WaitHXTReady();

    if (HXTStartUpStatus == SUCCESS)
    {
        /* Enable Prefetch Buffer */
        FLASH_EnablePrefetchBuffer();

        /* Flash 2 wait state */
        FLASH_SetLatency(FLASH_LATENCY_2);

        /* HCLK = SYSCLK */
        RCM_ConfigAHB(RCM_SYSCLK_DIV_1);

        /* PCLK2 = HCLK */
        RCM_ConfigAPB2(RCM_HCLK_DIV_1);

        /* PCLK1 = HCLK/2 */
        RCM_ConfigAPB1(RCM_HCLK_DIV_2);

#ifdef APM32F10X_CL
        /* Configure PLLs *********************************************************/
        /* PLL2 configuration: PLL2CLK = (HXT / 5) * 8 = 40 MHz */
        RCM_PREDIV2Config(RCM_PREDIV2_Div5);
        RCM_PLL2Config(RCM_PLL2Mul_8);

        /* Enable PLL2 */
        RCM_PLL2Cmd(ENABLE);

        /* Wait till PLL2 is ready */
        while (RCM_GetFlagStatus(RCM_FLAG_PLL2RDY) == RESET)
        {}

        /* PLL configuration: PLLCLK = (PLL2 / 5) * 7 = 56 MHz */
        RCM_PREDIV1Config(RCM_PREDIV1_Source_PLL2, RCM_PREDIV1_Div5);
        RCM_PLLConfig(RCM_PLLSource_PREDIV1, RCM_PLLMul_7);
#else
        /* PLLCLK = 8MHz * 7 = 56 MHz */
        RCM_ConfigPLL(RCM_PLLSEL_HXT, RCM_PLLMF_7);
#endif

        /* Enable PLL */
        RCM_EnablePLL();

        /* Wait till PLL is ready */
        while (RCM_ReadFlag(RCM_FLAG_PLLRDY) == RESET)
        {
        }

        /* Select PLL as system clock source */
        RCM_ConfigSYSCLK(RCM_SYSCLK_SEL_PLL);

        /* Wait till PLL is used as system clock source */
        while (RCM_GetSYSCLKSource() != RCM_SYSCLK_SEL_PLL)
        {
        }
    }
    else
    {
        /* If HXT fails to start-up, the application will have wrong clock configuration.
           User can add here some code to deal with this error */

        /* Go to infinite loop */
        while (1)
        {
        }
    }
}

/**
  * @brief  Sets System clock frequency to 72MHz and configure HCLK, PCLK2
  *         and PCLK1 prescalers.
  * @param  None
  * @retval None
  */
void SetSysClockTo72(void)
{
    /* SYSCLK, HCLK, PCLK2 and PCLK1 configuration -----------------------------*/
    /* RCM system reset(for debug purpose) */
    RCM_Reset();

    /* Enable HXT */
    RCM_ConfigHXT(RCM_HXT_OPEN);

    /* Wait till HXT is ready */
    HXTStartUpStatus = RCM_WaitHXTReady();

    if (HXTStartUpStatus == SUCCESS)
    {
        /* Enable Prefetch Buffer */
        FLASH_EnablePrefetchBuffer();

        /* Flash 2 wait state */
        FLASH_SetLatency(FLASH_LATENCY_2);

        /* HCLK = SYSCLK */
        RCM_ConfigAHB(RCM_SYSCLK_DIV_1);

        /* PCLK2 = HCLK */
        RCM_ConfigAPB2(RCM_HCLK_DIV_1);

        /* PCLK1 = HCLK/2 */
        RCM_ConfigAPB1(RCM_HCLK_DIV_2);

#ifdef APM32F10X_CL
        /* Configure PLLs *********************************************************/
        /* PLL2 configuration: PLL2CLK = (HXT / 5) * 8 = 40 MHz */
        RCM_PREDIV2Config(RCM_PREDIV2_Div5);
        RCM_PLL2Config(RCM_PLL2Mul_8);

        /* Enable PLL2 */
        RCM_PLL2Cmd(ENABLE);

        /* Wait till PLL2 is ready */
        while (RCM_GetFlagStatus(RCM_FLAG_PLL2RDY) == RESET)
        {}

        /* PLL configuration: PLLCLK = (PLL2 / 5) * 9 = 72 MHz */
        RCM_PREDIV1Config(RCM_PREDIV1_Source_PLL2, RCM_PREDIV1_Div5);
        RCM_PLLConfig(RCM_PLLSource_PREDIV1, RCM_PLLMul_9);
#else
        /* PLLCLK = 8MHz * 9 = 72 MHz */
        RCM_ConfigPLL(RCM_PLLSEL_HXT, RCM_PLLMF_9);
#endif

        /* Enable PLL */
        RCM_EnablePLL();

        /* Wait till PLL is ready */
        while (RCM_ReadFlag(RCM_FLAG_PLLRDY) == RESET)
        {
        }

        /* Select PLL as system clock source */
        RCM_ConfigSYSCLK(RCM_SYSCLK_SEL_PLL);

        /* Wait till PLL is used as system clock source */
        while (RCM_GetSYSCLKSource() != RCM_SYSCLK_SEL_PLL)
        {
        }
    }
    else
    {
        /* If HXT fails to start-up, the application will have wrong clock configuration.
           User can add here some code to deal with this error */

        /* Go to infinite loop */
        while (1)
        {
        }
    }
}

#endif /* APM32F10X_LD_VL && APM32F10X_MD_VL */

/**
  * @brief  Configures Vector Table base location.
  * @param  None
  * @retval None
  */
void NVIC_Configuration(void)
{
    /* Enable and configure RCM global IRQ channel */
    NVIC_EnableIRQRequest(RCM_IRQn, 0, 0);
}

/**
  * @brief  Inserts a delay time.
  * @param  nCount: specifies the delay time length.
  * @retval None
  */
void Delay(__IO uint32_t nCount)
{
    for (; nCount!= 0; nCount--);
}

#ifdef  USE_FULL_ASSERT

/**
  * @brief  Reports the name of the source file and the source line number
  *         where the assert_param error has occurred.
  * @param  file: pointer to the source file name
  * @param  line: assert_param error line source number
  * @retval None
  */
void assert_failed(uint8_t* file, uint32_t line)
{
    /* User can add his own implementation to report the file name and line number,
       ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */

    /* Infinite loop */
    while (1)
    {
    }
}

#endif

/**
  * @}
  */

/**
  * @}
  */

