/** * @file system_init.c * @author 1722451300@qq.com * @brief * @version 0.1 * @date 2021-12-13 * * @copyright Copyright (c) 2021 * */ #include "system_init.h" #include "basic_type.h" #include "IO_Config.h" #include "lcd.h" #include "motor.h" extern volatile int32_t lcd_issue_motor_speed;//lcd下发的速度单位dsp extern volatile int32_t speed_dsp_now;//当前电机的速度单位dsp extern volatile int32_t motor_jerk_state; extern volatile char lcd_rxbuff[50]; extern volatile int32_t lcd_count; extern volatile int16_t judge_now_foreward_or_reversal_state; void ram_clear(void) { /** * @brief 初始化内存 * */ for (IAAH = 0; IAAH <= 0x03; IAAH++) { for (IAAL = 0; IAAL < 0xFF; IAAL++) IAD = 0x00; IAD = 0x00; } } void gpio_Init(void) { /** * @brief gpio初始化 * 注意PBT3初始化为输出状态 */ ANSL = 0xFF; //选择对应端口为数字IO功能 ANSH = 0xFF; //选择对应端口为数字IO功能 PAT = 0x00; PBT = 0x00; //控制输入输出模式 1为输入 PCT = 0x00; PA = 0x00; //控制电平状态 0是低电平 PB = 0x00; PC = 0x00; } void clear_global_variable(void) { /** * @brief 对全局变量进行清零操作 * */ lcd_issue_motor_speed = 0;//lcd下发的速度单位dsp speed_dsp_now= 0;//当前电机的速度单位dsp motor_jerk_state= 0; lcd_rxbuff[50]= 0; lcd_count= 0; judge_now_foreward_or_reversal_state=0; } void set_gie(uint8_t state) { /** * @brief 参考:ES7P169C_Datasheet_C%20V1.3.pdf:7.5.1 */ while (GIE != state) { GIE = state; } } void sys_init(void) { ram_clear(); //clear_global_variable(); gpio_Init(); set_gie(1); }