You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

80 lines
1.8 KiB

  1. /**
  2. * @file system_init.c
  3. * @author 1722451300@qq.com
  4. * @brief
  5. * @version 0.1
  6. * @date 2021-12-13
  7. *
  8. * @copyright Copyright (c) 2021
  9. *
  10. */
  11. #include "system_init.h"
  12. #include "basic_type.h"
  13. #include "IO_Config.h"
  14. #include "lcd.h"
  15. #include "motor.h"
  16. extern volatile int32_t lcd_issue_motor_speed;//lcd下发的速度单位dsp
  17. extern volatile int32_t speed_dsp_now;//当前电机的速度单位dsp
  18. extern volatile int32_t motor_jerk_state;
  19. extern volatile char lcd_rxbuff[50];
  20. extern volatile int32_t lcd_count;
  21. extern volatile int16_t judge_now_foreward_or_reversal_state;
  22. void ram_clear(void)
  23. {
  24. /**
  25. * @brief
  26. *
  27. */
  28. for (IAAH = 0; IAAH <= 0x03; IAAH++)
  29. {
  30. for (IAAL = 0; IAAL < 0xFF; IAAL++)
  31. IAD = 0x00;
  32. IAD = 0x00;
  33. }
  34. }
  35. void gpio_Init(void)
  36. {
  37. /**
  38. * @brief gpio初始化
  39. * PBT3初始化为输出状态
  40. */
  41. ANSL = 0xFF; //选择对应端口为数字IO功能
  42. ANSH = 0xFF; //选择对应端口为数字IO功能
  43. PAT = 0x00;
  44. PBT = 0x00; //控制输入输出模式 1为输入
  45. PCT = 0x00;
  46. PA = 0x00; //控制电平状态 0是低电平
  47. PB = 0x00;
  48. PC = 0x00;
  49. }
  50. void clear_global_variable(void)
  51. {
  52. /**
  53. * @brief
  54. *
  55. */
  56. lcd_issue_motor_speed = 0;//lcd下发的速度单位dsp
  57. speed_dsp_now= 0;//当前电机的速度单位dsp
  58. motor_jerk_state= 0;
  59. lcd_rxbuff[50]= 0;
  60. lcd_count= 0;
  61. judge_now_foreward_or_reversal_state=0;
  62. }
  63. void set_gie(uint8_t state) {
  64. /**
  65. * @brief :ES7P169C_Datasheet_C%20V1.3.pdf:7.5.1
  66. */
  67. while (GIE != state) {
  68. GIE = state;
  69. }
  70. }
  71. void sys_init(void)
  72. {
  73. ram_clear();
  74. //clear_global_variable();
  75. gpio_Init();
  76. set_gie(1);
  77. }