138 lines
2.3 KiB
C
138 lines
2.3 KiB
C
|
|
/**
|
|||
|
|
**************************************************************************
|
|||
|
|
* @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" // <20><>ʱ<EFBFBD><CAB1>ר<EFBFBD><D7A8>ͷ<EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD>ؼ<EFBFBD><D8BC><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
#include "at32a423_crm.h" // ʱ<>ӹ<EFBFBD><D3B9><EFBFBD>ͷ<EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD>ؼ<EFBFBD><D8BC><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
|
|||
|
|
|
|||
|
|
#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};//У<D0A3><D7BC><EFBFBD><EFBFBD>
|
|||
|
|
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();//ʱ<><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
nvic_priority_group_config(NVIC_PRIORITY_GROUP_4);//<2F>ж<EFBFBD><D0B6><EFBFBD><EFBFBD>ȼ<EFBFBD><C8BC><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
systick_config();//ʱ<><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
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();//ɨ<>账<EFBFBD><E8B4A6>
|
|||
|
|
adc_deal(); //<2F><><EFBFBD>ݴ<EFBFBD><DDB4><EFBFBD>
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
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);//<2F>˴<EFBFBD>119<31><39><EFBFBD>Ƕ<EFBFBD>ӦϵͳƵ<CDB3><C6B5>
|
|||
|
|
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);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|