/** ************************************************************************** * @file main.c * @brief main program ************************************************************************** * * ************************************************************************** */ #include "at32a423.h" #include "at32a423_clock.h" #include "systick.h" #include "sysconfig.h" #include "string.h" #include "stdio.h" #include "at32a423_tmr.h" // 定时器专用头文件(关键!) #include "at32a423_crm.h" // 时钟管理头文件(关键!) #include "app_get_json.h" #include "app_scan.h" #include "app_soft.h" #include "bsp_led.h" #include "bsp_uart.h" #include "bsp_adc.h" #include "bsp_can.h" #include "bsp_spi.h" #include "bsp_rs2251.h" #include "bsp_74hc595.h" #include "bsp_flash.h" #include "mx_spi.h" #include "resi_math_lib.h" #include "bsp_rs2251.h" #include "cali_process.h" #include "lib_cal_creep_resistance.h" #include "main.h" #define CAL_CREEP_ENABLE 0 #define JSON_ENABLE 0 uint8_t serial_tx_buffer2[AX_NUM][AY_NUM] = {0};//校准数组 uint8_t map_matrix[12*12*3]; crm_clocks_freq_type crm_clocks_freq_struct = {0}; void TMR1_init(void); int line_flag=0; int main(void) { static uint64_t time_ms = 0; system_clock_config();//时钟配置 nvic_priority_group_config(NVIC_PRIORITY_GROUP_4);//中断优先级配置 systick_config();//时基配置 bsp_led_init(LED2); can1_init(); adc_init(); RS2251_Init(); ref_gpio_init(); ic_74hc595_init(); mx_spi_init(); line_flag = line_init(); app_user_map_init(); // uart3_init(921600); uart3_init(2000000); delay_ms(1000); TMR1_init(); // Choose_AX_Channel(5); // REF_OUT(0); // ic_74hc595_io_write_1(7); while(1) { delay_ms(1); scan_deal();//扫描处理 adc_deal(); //数据处理 } } void TMR1_init(void){ crm_clocks_freq_get(&crm_clocks_freq_struct); /* enable tmr1 clock */ crm_periph_clock_enable(CRM_TMR1_PERIPH_CLOCK, TRUE); /* tmr1 configuration */ /* time base configuration */ tmr_base_init(TMR1, 6, 139);//此处119不是对应系统频率 tmr_cnt_dir_set(TMR1, TMR_COUNT_UP); /* overflow interrupt enable */ tmr_interrupt_enable(TMR1, TMR_OVF_INT, TRUE); /* tmr1 hall interrupt nvic init */ nvic_priority_group_config(NVIC_PRIORITY_GROUP_4); nvic_irq_enable(TMR1_OVF_TMR10_IRQn, 1, 0); /* enable tmr1 */ tmr_counter_enable(TMR1, TRUE); }