2025-08-13 03:12:48 +00:00
|
|
|
/*!
|
|
|
|
\file main.c
|
|
|
|
\brief GPIO running led demo
|
|
|
|
|
|
|
|
\version 2024-12-20, V3.3.1, demo for GD32F4xx
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
Copyright (c) 2024, GigaDevice Semiconductor Inc.
|
|
|
|
|
|
|
|
Redistribution and use in source and binary forms, with or without modification,
|
|
|
|
are permitted provided that the following conditions are met:
|
|
|
|
|
|
|
|
1. Redistributions of source code must retain the above copyright notice, this
|
|
|
|
list of conditions and the following disclaimer.
|
|
|
|
2. Redistributions in binary form must reproduce the above copyright notice,
|
|
|
|
this list of conditions and the following disclaimer in the documentation
|
|
|
|
and/or other materials provided with the distribution.
|
|
|
|
3. Neither the name of the copyright holder nor the names of its contributors
|
|
|
|
may be used to endorse or promote products derived from this software without
|
|
|
|
specific prior written permission.
|
|
|
|
|
|
|
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
|
|
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
|
|
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
|
|
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
|
|
|
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
|
|
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
|
|
|
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
|
|
|
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
|
|
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
|
|
|
OF SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "gd32f4xx.h"
|
|
|
|
#include <stdio.h>
|
2025-08-13 09:38:09 +00:00
|
|
|
#include "rtthread.h"
|
2025-09-12 09:53:32 +00:00
|
|
|
#include "rtservice.h"
|
|
|
|
#include <stdio.h> // FILE 类是一个结构体,在 stdio.h 头文件中
|
2025-09-13 09:22:00 +00:00
|
|
|
#include "drv_adc.h"
|
2025-09-12 09:53:32 +00:00
|
|
|
|
2025-09-13 09:22:00 +00:00
|
|
|
float voltage;
|
|
|
|
float current;
|
|
|
|
float current_origin;
|
2025-09-13 10:04:22 +00:00
|
|
|
float adc_value;
|
2025-08-13 09:38:09 +00:00
|
|
|
|
2025-08-13 03:12:48 +00:00
|
|
|
/*!
|
|
|
|
\brief main function
|
|
|
|
\param[in] none
|
|
|
|
\param[out] none
|
|
|
|
\retval none
|
|
|
|
*/
|
|
|
|
int main(void)
|
|
|
|
{
|
2025-09-12 09:53:32 +00:00
|
|
|
// RT-Thread 内核初始化等操作...
|
|
|
|
|
|
|
|
// 其他应用程序初始化代码...
|
|
|
|
init_data_collect_module();
|
|
|
|
// 进入主循环或启动其他任务
|
|
|
|
while (1)
|
|
|
|
{
|
2025-09-13 09:22:00 +00:00
|
|
|
// voltage = ptz_Voltage_collect_adc1_task();
|
|
|
|
// current = ptz_Current_collect_adc1_task();
|
2025-09-13 10:04:22 +00:00
|
|
|
adc_value = ptz_adc1_collect_task();
|
|
|
|
|
|
|
|
// current_origin = current*0.132 + 3.3/2;
|
2025-09-13 09:22:00 +00:00
|
|
|
rt_thread_mdelay(500);
|
2025-09-12 09:53:32 +00:00
|
|
|
// 主循环代码...
|
2025-08-13 03:12:48 +00:00
|
|
|
}
|
2025-09-12 09:53:32 +00:00
|
|
|
}
|