/*!
 * @file        main.c
 *
 * @brief       Main program body
 *
 * @version     V2.4
 *
 * @date        2024-04-26
 *
 * @attention
 *
 *  Copyright (C) 2020-2022 Geehy Semiconductor
 *
 *  You may not use this file except in compliance with the
 *  GEEHY COPYRIGHT NOTICE (GEEHY SOFTWARE PACKAGE LICENSE).
 *
 *  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 SOFTWARE PACKAGE LICENSE for the governing permissions
 *  and limitations under the License.
 */

#include "include.h"
#include "hsuart_transfer.h"        /*Serial port*/

/*!
 * @brief       Main program,UART
 *
 * @param       None
 *
 * @retval      None
 *
 */
int main(void)
{
    printf("Hello GW3323 HSUART!\n");
    bsp_sys_init();                     /*System initialization*/
    set_sys_clk(SYS_160M);              //主频提升至160M

    u8 len =10;
    gpio_init_typedef gpio_init_structure;
    gpio_init_structure.gpio_pin = GPIO_PIN_5;
    gpio_init_structure.gpio_dir = GPIO_DIR_INPUT;
    gpio_init_structure.gpio_fen = GPIO_FEN_GPIO;
    gpio_init_structure.gpio_mode = GPIO_MODE_DIGITAL;
    gpio_init_structure.gpio_pupd = GPIO_PUPD_UP;
    gpio_init(GPIOB_REG, &gpio_init_structure);

    my_hsuart_init(1500000);

    while (1)
    {
        hsuart_transfer_example();

        if (gpio_read_bit(GPIOB_REG, GPIO_PIN_5) == RESET)  //发送函数
        {
            delay_ms(20);
            if (gpio_read_bit(GPIOB_REG, GPIO_PIN_5) == RESET)
            {
                len ++;
                huart_SendString("\r\nNum1=");
                huart_SendNumber(len,3);
            }
        }
    }
    return 0;
}
