PowerCtrl.c 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. /********************************************************************************
  2. * File Name: PowerCtrl.c
  3. * Function Describe:
  4. * Relate Module:
  5. * Explain:
  6. * Writer:
  7. * Date: 2015.12.10
  8. *******************************************************************************/
  9. #define THIS_FILE_ID 17
  10. #include "includes.h"
  11. /*
  12. 电源控制初始化
  13. */
  14. void PowerInit(void)
  15. {
  16. GPIO_InitTypeDef GPIO_InitStructure;
  17. RCC_APB2PeriphClockCmd( RCC_APB2Periph_GPIOA | RCC_APB2Periph_GPIOB| RCC_APB2Periph_GPIOC,ENABLE);
  18. GPIO_InitStructure.GPIO_Pin = SYS_POWER_EN_PIN; //
  19. GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_OD; //GPIO_Mode_Out_PP
  20. GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
  21. SYS_POWER_EN; //默认
  22. GPIO_Init(SYS_POWER_EN_PORT, &GPIO_InitStructure);//初始化GPIO
  23. SYS_POWER_EN; //默认
  24. GPIO_InitStructure.GPIO_Pin = TEST_POWER_EN_PIN; //测试板电源
  25. GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; //推挽输出
  26. GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
  27. GPIO_Init(TEST_POWER_EN_PORT, &GPIO_InitStructure);//初始化GPIO
  28. TEST_POWER_DIS; //默认
  29. GPIO_InitStructure.GPIO_Pin = GPS_POWER_EN_PIN; //
  30. GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; //
  31. GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
  32. GPIO_Init(GPS_POWER_EN_PORT, &GPIO_InitStructure);//初始化GPIO
  33. GPS_POWER_EN; //默认
  34. GPIO_InitStructure.GPIO_Pin = GSM_POWER_EN_PIN; //
  35. GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; //
  36. GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
  37. GPIO_Init(GSM_POWER_EN_PORT, &GPIO_InitStructure);//初始化GPIO
  38. GSM_POWER_DIS; //默认
  39. GPIO_InitStructure.GPIO_Pin = GSM_ONOFF_PIN; //
  40. GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; //
  41. GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
  42. GPIO_Init(GSM_ONOFF_PORT, &GPIO_InitStructure);//初始化GPIO
  43. GSM_POWER_DIS; //默认
  44. }
  45. /*
  46. 测试板电源重启,当发现测试版相关传感器死机或工作不正常时,可以重启电源
  47. */
  48. void TestBoardPowerRestart(void)
  49. {
  50. TEST_POWER_DIS;
  51. os_dly_wait(100);
  52. TEST_POWER_EN;
  53. }
  54. /*
  55. MCU和运动传感器电源重启
  56. */
  57. void SysPowerRestart(void)
  58. {
  59. SYS_POWER_DIS;
  60. os_dly_wait(50);
  61. SYS_POWER_EN;
  62. }
  63. /*
  64. GPS电源重启
  65. */
  66. void GpsPowerRestart(void)
  67. {
  68. GPS_POWER_DIS;
  69. os_dly_wait(100);
  70. GPS_POWER_EN;
  71. }
  72. /*******************************************************************************/