/*********************************************************
*Copyright (C), 2017, Shanghai Eastsoft Microelectronics Co., Ltd.
 * @文件名:  main.c
 * @作  者:  AE Team
 * @版  本:  V1.00
 * @日  期:  2022/07/25
 * @描  述:  UART模块例程
 *          使用XCOM进行交互，MCU会先发送“essemi ！”给上位机，然后LED1开始闪烁等待上位机发送数据，并将接收到的数据再返回给上位机；
 *          测试时，可将RXD接地，LED1始终保持闪烁，恢复RXD时，使用XCOM发送数据给MCU，MCU将会回复相同的数据
 *          RXD - PA22
 *          TXD - PA23
 * @note
 *          Change Logs:
 *          Date            Author          Notes
 *          25 July 2022    AE Team         change license to Apache-2.0
 *
 * Copyright (C) Shanghai Eastsoft Microelectronics Co. Ltd. All rights reserved.
 *
 * SPDX-License-Identifier: Apache-2.0
 *
 * Licensed under the Apache License, Version 2.0 (the License); you may
 * not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an AS IS BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 **********************************************************************************
 */


#include "main.h"
#include "string.h"

uint8_t i;
uint8_t g_buf[16] = {"essemi ! \n\r"};    /* 发送数据缓存 */
uint8_t g_buffer;

int main(void)
{
    HRC_Config(Enable, SCU_HRC_48M, Enable);    /* 配置HRC时钟频率 */
    SystemInit();
    DeviceClockAllEnable();

    User_SysTickInit();
    LightInit(LED1_PIN);
    UARTInit();

    for (i = 0; i < 16; i++)
    {
        UART_SendByte(UART0, g_buf[i]);

        while (UART_GetFlagStatus(UART0, UART_FLAG_TC) == RESET);

        UART_ClearITPendingBit(UART0, UART_FLAG_TC);
    }

    while (1)
    {
        LightOff(LED1_PIN);
        Delay_100us(10000);
        LightOn(LED1_PIN);
        Delay_100us(10000);
    }
}


/*************************END OF FILE**********************/
