Files
QDAC-firmware/app/main.c
2024-07-14 14:34:07 +08:00

95 lines
3.4 KiB
C
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*********************************************************************************************************************
* CH32V307VCT6 Opensourec Library 即CH32V307VCT6 开源库)是一个基于官方 SDK 接口的第三方开源库
* Copyright (c) 2022 SEEKFREE 逐飞科技
*
* 本文件是 CH32V307VCT6 开源库的一部分
*
* CH32V307VCT6 开源库 是免费软件
* 您可以根据自由软件基金会发布的 GPLGNU General Public License即 GNU 通用公共许可证)的条款
* 即 GPL 的第 3 版(即 GPL3.0)或(您选择的)任何后来的版本,重新发布和/或修改它
*
* 本开源库的发布是希望它能发挥作用,但并未对其作任何的保证
* 甚至没有隐含的适销性或适合特定用途的保证
* 更多细节请参见 GPL
*
* 您应该在收到本开源库的同时收到一份 GPL 的副本
* 如果没有,请参阅<https://www.gnu.org/licenses/>
*
* 额外注明:
* 本开源库使用 GPL3.0 开源许可证协议 以上许可申明为译文版本
* 许可申明英文版在 libraries/doc 文件夹下的 GPL3_permission_statement.txt 文件中
* 许可证副本在 libraries 文件夹下 即该文件夹下的 LICENSE 文件
* 欢迎各位使用并传播本程序 但修改内容时必须保留逐飞科技的版权声明(即本声明)
********************************************************************************************************************/
#include "zf_common_headfile.h"
#include "gl_headfile.h"
#include "page.h"
#include "by_frame.h"
#include "by_buzzer.h"
#include "by_led.h"
#include "jj_param.h"
#include "jj_blueteeth.h"
#include "zf_device_config.h"
int main(void)
{
TYPE_UNION recv_data[BY_FRAME_DATA_NUM_RECV];
clock_init(SYSTEM_CLOCK_144M);
system_delay_init();
debug_init();
ips200_init(IPS200_TYPE_SPI);
by_led_init();
by_buzzer_init();
by_button_init();
jj_bt_init();
jj_param_eeprom_init();
mt9v03x_init();
mt9v03x_sccb_set_exposure_time((uint16_t)auto_exp);
Page_Init();
pit_ms_init(TIM1_PIT, 10);
timer_init(TIM_3, TIMER_MS);
timer_init(TIM_2, TIMER_MS);
by_frame_init();
printf("start running\r\n");
while (1) {
memset(recv_data, 0, sizeof(recv_data));
by_frame_parse(&recv_data[0].u32);
if (0x0D == recv_data[0].u32) {
NVIC_SystemReset();
} else if (0x5C == recv_data[0].u32) {
begin_flag = 1;
}
Page_Run();
by_buzzer_run();
tiny_frame_param[0].f32 = pure_angle;
tiny_frame_param[1].f32 = curvature;
tiny_frame_param[2].u8[0] = (uint8_t)state_type; // 0: 无状态 1: 弯道 2: 直行
tiny_frame_param[2].u8[1] = (uint8_t)garage_type; // 0: 无车库 1: 有车库
if (mt9v03x_finish_flag) {
// 该操作消耗大概 1970 个 tick折合约 110us
memcpy(mt9v03x_image_copy[0], mt9v03x_image[0], (sizeof(mt9v03x_image_copy) / sizeof(uint8_t)));
mt9v03x_finish_flag = 0;
by_led_info_blink();
state_type = COMMON_STATE;
img_processing();
get_corners();
tracking();
ElementJudge();
ElementRun();
aim_distance_select();
MidLineTrack();
// if (barrier_type) {
// bt_printf("type= %d", barrier_type);
// }
}
}
}