GPIO_SYS.c 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. #include "GPIO_SYS.h"
  2. #include "app_def.h"
  3. extern unsigned int LocalTime;
  4. int GPIO_SYS_init(void)
  5. {
  6. GPIO_InitTypeDef GPIO_InitStructure;
  7. //ANDROID_POWER_RccOpen();
  8. // ANDROID_RESET_RccOpen();
  9. RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC |RCC_APB2Periph_GPIOD,ENABLE); //时钟
  10. //ANDROID_V0L_RccOpen();
  11. //================================================
  12. // GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
  13. // GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
  14. // GPIO_InitStructure.GPIO_Pin = ANDROID_POWER_LINE;
  15. // GPIO_Init(ANDROID_POWER_Port,&GPIO_InitStructure);
  16. // GPIO_SetBits(ANDROID_POWER_Port,ANDROID_POWER_LINE);
  17. //================================================
  18. GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
  19. GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
  20. GPIO_InitStructure.GPIO_Pin = ANDROID_RESET_LINE;
  21. GPIO_Init(ANDROID_RESET_Port,&GPIO_InitStructure);
  22. GPIO_SetBits(ANDROID_RESET_Port,ANDROID_RESET_LINE);
  23. SYS_Reset();
  24. //================================================
  25. // GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
  26. // GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
  27. // GPIO_InitStructure.GPIO_Pin = ANDROID_V0L_LINE;
  28. // GPIO_Init(ANDROID_V0L_Port,&GPIO_InitStructure);
  29. // GPIO_SetBits(ANDROID_V0L_Port,ANDROID_V0L_LINE);
  30. // //================================================
  31. GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
  32. GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
  33. GPIO_InitStructure.GPIO_Pin = GPIO_Pin_1;
  34. GPIO_Init(GPIOC,&GPIO_InitStructure);
  35. // Mcu_Reset(RESET) ;
  36. return 1;
  37. }
  38. int SYS_Reset(void) //复位高电平有效
  39. {
  40. unsigned int i=0;
  41. GPIO_ResetBits(ANDROID_RESET_Port,ANDROID_RESET_LINE);
  42. for(i=0;i<500000;i++)
  43. {
  44. WDG_Feed();
  45. }
  46. GPIO_SetBits(ANDROID_RESET_Port,ANDROID_RESET_LINE);
  47. return 1;
  48. }
  49. void Mcu_Reset(U08 flag)
  50. {
  51. if (flag) {
  52. GPIO_SetBits(GPIOC,GPIO_Pin_1);
  53. } else {
  54. GPIO_ResetBits(GPIOC,GPIO_Pin_1);
  55. }
  56. }
  57. //int SYS_SetUpdate(void)
  58. //{
  59. // unsigned int i=0;
  60. // unsigned int TempTimes=0;
  61. // //===========================================
  62. // GPIO_ResetBits(ANDROID_V0L_Port,ANDROID_V0L_LINE); //按下“音量+”键
  63. //
  64. // GPIO_ResetBits(ANDROID_POWER_Port,ANDROID_POWER_LINE); //长按“Power”键
  65. // TempTimes=LocalTime+12000;
  66. // while(TempTimes>LocalTime)
  67. // {
  68. // WDG_Feed();
  69. // }
  70. // GPIO_SetBits(ANDROID_POWER_Port,ANDROID_POWER_LINE); //松开“Power”键
  71. // //===========================================
  72. // TempTimes=LocalTime+500;
  73. // while(TempTimes>LocalTime)
  74. // {
  75. // WDG_Feed();
  76. // }
  77. // GPIO_ResetBits(ANDROID_POWER_Port,ANDROID_POWER_LINE);
  78. // //=============================
  79. // TempTimes=LocalTime+500;
  80. // while(TempTimes>LocalTime)
  81. // {
  82. // WDG_Feed();
  83. // }
  84. // GPIO_SetBits(ANDROID_POWER_Port,ANDROID_POWER_LINE);
  85. // //=============================
  86. // TempTimes=LocalTime+500;
  87. // while(TempTimes>LocalTime)
  88. // {
  89. // WDG_Feed();
  90. // }
  91. // GPIO_ResetBits(ANDROID_POWER_Port,ANDROID_POWER_LINE);
  92. // //=============================
  93. // TempTimes=LocalTime+500;
  94. // while(TempTimes>LocalTime)
  95. // {
  96. // WDG_Feed();
  97. // }
  98. // GPIO_SetBits(ANDROID_POWER_Port,ANDROID_POWER_LINE);
  99. // //=============================
  100. // TempTimes=LocalTime+500;
  101. // while(TempTimes>LocalTime)
  102. // {
  103. // WDG_Feed();
  104. // }
  105. // GPIO_ResetBits(ANDROID_POWER_Port,ANDROID_POWER_LINE);
  106. // //=============================
  107. // TempTimes=LocalTime+500;
  108. // while(TempTimes>LocalTime)
  109. // {
  110. // WDG_Feed();
  111. // }
  112. // GPIO_SetBits(ANDROID_POWER_Port,ANDROID_POWER_LINE);
  113. // //=============================
  114. // TempTimes=LocalTime+500;
  115. // while(TempTimes>LocalTime)
  116. // {
  117. // WDG_Feed();
  118. // }
  119. // GPIO_ResetBits(ANDROID_POWER_Port,ANDROID_POWER_LINE);
  120. // //=============================
  121. // TempTimes=LocalTime+500;
  122. // while(TempTimes>LocalTime)
  123. // {
  124. // WDG_Feed();
  125. // }
  126. // GPIO_SetBits(ANDROID_POWER_Port,ANDROID_POWER_LINE);
  127. // //=============================
  128. // TempTimes=LocalTime+500;
  129. // while(TempTimes>LocalTime)
  130. // {
  131. // WDG_Feed();
  132. // }
  133. //
  134. // GPIO_SetBits(ANDROID_V0L_Port,ANDROID_V0L_LINE);
  135. // return 1;
  136. //}