sysmgr(7951).h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. #ifndef _SYSMGR_H_
  2. #define _SYSMGR_H_
  3. #include "nrf_drv_spi.h"
  4. #include "app_util_platform.h"
  5. #include "nrf_gpio.h"
  6. #include "nrf_delay.h"
  7. #include "boards.h"
  8. #include "app_error.h"
  9. #include <string.h>
  10. #include "nrf_log.h"
  11. #include "nrf_log_ctrl.h"
  12. #include "nrf_log_default_backends.h"
  13. #include "ble_gap.h"
  14. #include "fds.h"
  15. #include "nrf_fstorage.h"
  16. struct stSystemTimer__ {
  17. volatile int MS_1;
  18. volatile int UART_LAST_RECV_TIMER;
  19. volatile int SEND_TEST_TIMER;
  20. volatile int LED_TOGGLE_TIMER;
  21. volatile int TMR_SYS_OFF;
  22. volatile int SEND_TIMER;
  23. volatile int BUZZER_TIMER;
  24. char EMG_SEND_RUN;
  25. volatile int TIM_KEY;
  26. volatile int SLEEP_TIMER;
  27. };
  28. typedef struct stSystemTimer__ stSystemTimer;
  29. struct stSystemManager__ {
  30. char EmgSendButton;
  31. char TestSendButton;
  32. char RxEvent;
  33. char SendRepeat;
  34. char SendFlag;
  35. int BleConnectTime;
  36. int SendRepeatTimerLimit;
  37. char BuzzerType;
  38. char BuzzerBusy;
  39. unsigned char Batt;
  40. char BleSendReady;
  41. char BleSendStatus;
  42. char BleConnected;
  43. char BleSendRetry;
  44. char PeerAddr[6];
  45. char StrPeerAddr[15];
  46. char RegPeerAddr[6];
  47. char StrRegPeerAddr[15];
  48. char SysReady;
  49. char SleepEnter;
  50. char FWUpdate;
  51. char GpReg;
  52. char GoSleep;
  53. uint32_t ResetReason;
  54. char AesEncData[16];
  55. };
  56. typedef struct stSystemManager__ stSystemManager;
  57. #define AES_ENC_CAR 1
  58. #define AES_ENC_EMG 2
  59. #define AES_ENC_PCA 3
  60. #define AES_ENC_WES_EMG 4
  61. #define AES_ENC_WES_ALV 5
  62. #define AES_ENC_WES_TST 6
  63. #define AES_ENC_WES_REG 7
  64. /* A dummy structure to save in flash. */
  65. #define CONFIG_FILE (0x8010)
  66. #define CONFIG_REC_KEY (0x7010)
  67. typedef struct
  68. {
  69. uint32_t boot_count;
  70. char device_name[16];
  71. bool config1_on;
  72. bool config2_on;
  73. } configuration_t;
  74. typedef struct
  75. {
  76. char Mac[10][15];
  77. int Count;
  78. }RegMacPool_t;
  79. void ParkSysInit();
  80. void ParkPowerOff();
  81. void SendEmgData(void);
  82. extern stSystemTimer SystemTimer;
  83. extern stSystemManager SystemManager;
  84. #define KEY_SELECT 0
  85. #define KEY_UP 1
  86. #define KEY_DOWN 3
  87. #define KEY_BACK 2
  88. typedef struct tsHSKey{
  89. unsigned char onFlag;
  90. unsigned char softRelease;
  91. unsigned char pressedSec;
  92. unsigned int pressTime;
  93. unsigned int longPressTimeOne;
  94. unsigned int longPressTimeKeep;
  95. unsigned int prevTime;
  96. }HSKey;
  97. void ReadKEY(void);
  98. void KeyInit(void);
  99. void KeySelectLongPressedOne(void);
  100. void m_standby_counter_clerar();
  101. void PortInputCfg(void);
  102. void lfclk_config(void);
  103. void rtc_config(void);
  104. void SaveReceiverMac(char* mac);
  105. void LoadReceiverMac();
  106. void FlashTest();
  107. uint8_t Load_Flash();
  108. void Save_Flash(uint8_t data);
  109. void WesEncryptEcb(uint8_t* in);
  110. void WesDecryptEcb(char* in, char* out);
  111. extern ble_gap_addr_t old_ble_addr;
  112. extern ble_gap_addr_t new_ble_addr;
  113. extern RegMacPool_t RegMacPool;
  114. #endif