/************************************************************
//  Copyright (c)
//  FileName	 : main.c
//  Module Function	:
//  Instructions : Contains the MCU initialization function and its H file
*******************Includes************************************************************************/
#include "SC_Init.h"
#include "SC_it.h"
#include "HeadFiles\SysFunVarDefine.h"
#include "stdio.h"
#include "Function_Init.h"
#include "sc32_conf.h"

/**************************************Generated by EasyCodeCube*************************************/
//Forbid editing areas between the labels !!!

/*************************************.Generated by EasyCodeCube.************************************/
/*****************************************************************************************************
* Function Name: main
* Description  : This function implements main function.
* Arguments    : None
* Return Value : None
******************************************************************************************************/
struct __FILE
{
    int handle;
};

FILE  __stdout;
//定义_sys_exit()以避免使用半主机模式
void _sys_exit ( int x )
{
    x = x;
}
#if defined(SC32f10xx)||defined(SC32f12xx)
/* UART3作信息打印使用 */
int fputc ( int c, FILE* f )
{
    UART_SendData ( UART3, ( uint8_t ) c );
    while ( !UART_GetFlagStatus ( UART3, UART_Flag_TX ) );
    UART_ClearFlag ( UART3, UART_Flag_TX );
    return c;
}
#endif
int main ( void )
{
    /*<Generated by EasyCodeCube begin>*/
    /*<UserCodeStart>*//*<SinOne-Tag><36>*/
    SC_Init();        //HLCK 分频为1分频
#if defined(SC32f10xx)||defined(SC32f12xx)
    /* 初始化UART3，配置为UART3（TX_PB14，RX_PB13） */
    RCC_APB2Cmd ( ENABLE ); //开启APB0时钟
    RCC_APB2PeriphClockCmd ( RCC_APB2Periph_UART3, ENABLE ); //开启UART3时钟

    {
        UART_InitTypeDef UART_InitStruct;
        UART_InitStruct.UART_BaudRate = 115200;

        UART_InitStruct.UART_ClockFrequency = 32000000;

        UART_InitStruct.UART_Mode = UART_Mode_10B;

        UART_Init ( UART3, &UART_InitStruct );

        UART_TXCmd ( UART3, ENABLE );
        UART_RXCmd ( UART3, ENABLE );
    }
    __enable_irq(); // 开启总中断
#if defined(SC32f12xx)
    printf ( "\r\n This is SC32F12xx Demo!!! \r\n" );
#elif defined(SC32f10xx)
    printf ( "\r\n This is SC32F10xx Demo!!! \r\n" );	
#endif
#endif

    /*<Generated by EasyCodeCube begin>*/
#if (TestNum == 1)
    GPIO_InOut_Function();
#elif (TestNum == 2)
    ADC_SingleConversion_Function();
#elif (TestNum == 3)
    BTM_Base_Function();
#elif (TestNum == 4)
    CMP_Interrupt_Function();
#elif (TestNum == 5)
    CRC_CalculateArrays_Function();
#elif (TestNum == 6)
    DMA_Burst_Function();
#elif (TestNum == 7)
    DMA_Pause_Function();
#elif (TestNum == 8)
    DMA_ScatterGather_Function();
#elif (TestNum == 9)
    INT_Example_Function();
#elif (TestNum == 10)
    IAP_ReadUID_Example();
#elif (TestNum == 11)
    IAP_Program_Function();
#elif (TestNum == 12)
    RCC_SystemClockConfig_Function();
#elif (TestNum == 13)
    SPI_Communication_Function();
#elif (TestNum == 14)
    SPI_FIFOMaster_Function();
#elif (TestNum == 15)
    SPI_FIFOSlave_Function();
#elif (TestNum == 16)
    SPI_Communication_DMA_Function();
#elif (TestNum == 17)
    TIM_TimeBase_Function();
#elif (TestNum == 18)
    TIM_CounterBase_Function();
#elif (TestNum == 19)
    TIM_PWMOutput_Function();
#elif (TestNum == 20)
    TIM_InputCapture_Function();
#elif (TestNum == 21)
    TIM_TI_DMA_Function();
#elif (TestNum == 22)
    TWI_Communication_Function();
#elif (TestNum == 23)
    TWI_Master_DMA_Function();
#elif (TestNum == 24)
    TWI_Slave_DMA_Function();
#elif (TestNum == 25)
    UART_Communication_Function();
#elif (TestNum == 26)
    UART_Communication_DMA_Function();
#elif (TestNum == 27)
    SYSTICK_Example_Function();
#elif (TestNum == 28)
    STOP_IDLE_WakeUp_Function();

#endif
#if defined(SC32f10xx)||defined(SC32f12xx)
#if (TestNum == 29)
    ADC_CycleConversion_DMA_Function();
#elif (TestNum == 30)
    CMP_AnalogWatchdog_Function();
#elif (TestNum == 31)
    LCD_Example_Function();
#elif (TestNum == 32)
    LED_Example_Function();
#elif (TestNum == 33)
    PWM_Independent_Function();
#elif (TestNum == 34)
    PWM_Complementary_Function();
#elif (TestNum == 35)
    LEDPWM_Example_Function();
#endif
#if defined(SC32f12xx)
#if (TestNum == 36)				 
  	UART_LINMaster_Function	();
#elif (TestNum == 37)		
  	UART_LINSlave_Function();
#elif (TestNum == 38)
    OP_AmplifiesVoltage_Function();

#endif
#endif


#endif

    /*****MainLoop*****/
    while ( 1 )
    {
        /*<UserCodeStart>*//*<SinOne-Tag><14>*/
        /***User program***/
        /*<UserCodeEnd>*//*<SinOne-Tag><14>*/
        /*<Begin-Inserted by EasyCodeCube for Condition>*/
    }
    /*<UserCodeEnd>*//*<SinOne-Tag><4>*/

    /*<Generated by EasyCodeCube end>*/

}
