Files
QDAC-firmware/app/main.c

91 lines
3.3 KiB
C
Raw Normal View History

2023-12-11 21:45:06 +08:00
/*********************************************************************************************************************
* 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
* 使
********************************************************************************************************************/
2024-02-15 22:50:20 +08:00
#include "zf_common_headfile.h"
#include "gl_headfile.h"
2024-02-15 22:50:20 +08:00
#include "page.h"
#include "by_frame.h"
2024-01-08 22:08:43 +08:00
#include "by_buzzer.h"
2024-01-31 17:43:48 +08:00
#include "by_led.h"
2024-01-31 17:55:16 +08:00
#include "jj_param.h"
#include "jj_blueteeth.h"
int main(void)
2023-12-11 21:45:06 +08:00
{
2024-07-05 14:50:53 +08:00
TYPE_UNION recv_data[BY_FRAME_DATA_NUM_RECV];
clock_init(SYSTEM_CLOCK_144M);
system_delay_init();
debug_init();
2024-01-16 20:03:21 +08:00
mt9v03x_init();
ips200_init(IPS200_TYPE_SPI);
2024-01-31 17:43:48 +08:00
by_led_init();
by_buzzer_init();
by_button_init();
2024-01-31 17:43:48 +08:00
2024-01-07 16:58:53 +08:00
jj_bt_init();
jj_param_eeprom_init();
2024-01-31 17:55:16 +08:00
Page_Init();
2024-03-02 18:17:30 +08:00
2024-03-05 21:30:27 +08:00
pit_ms_init(TIM1_PIT, 10);
2024-03-24 18:26:36 +08:00
timer_init(TIM_3, TIMER_MS);
2024-07-05 21:29:03 +08:00
timer_init(TIM_2, TIMER_MS);
by_frame_init();
2024-01-31 17:55:16 +08:00
2024-02-15 22:50:20 +08:00
printf("start running\r\n");
while (1) {
2024-07-05 14:50:53 +08:00
memset(recv_data, 0, sizeof(recv_data));
by_frame_parse(&recv_data[0].u32);
2024-07-05 21:29:03 +08:00
if (0x0D == recv_data[0].u32) {
2024-07-05 14:50:53 +08:00
NVIC_SystemReset();
2024-07-05 21:29:03 +08:00
} else if (0x5C == recv_data[0].u32) {
2024-07-05 14:50:53 +08:00
begin_flag = 1;
}
Page_Run();
by_buzzer_run();
2024-07-03 16:30:37 +08:00
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) {
2024-01-06 16:22:49 +08:00
// 该操作消耗大概 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();
2024-03-03 17:55:49 +08:00
state_type = COMMON_STATE;
img_processing();
get_corners();
tracking();
ElementJudge();
ElementRun();
2024-06-26 17:27:38 +08:00
aim_distance_select();
2024-03-03 17:55:49 +08:00
MidLineTrack();
2024-07-03 16:30:37 +08:00
// if (barrier_type) {
// bt_printf("type= %d", barrier_type);
// }
2023-12-11 21:45:06 +08:00
}
}
2024-01-16 20:03:21 +08:00
}