sysmgr(897).h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  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 <stdint.h>
  15. #include <stdbool.h>
  16. #include "fds.h"
  17. #include "nrf_fstorage.h"
  18. #define SC16IS750_ADDRESS_AA (0X90)
  19. #define SC16IS750_ADDRESS_AB (0X92)
  20. #define SC16IS750_ADDRESS_AC (0X94)
  21. #define SC16IS750_ADDRESS_AD (0X96)
  22. #define SC16IS750_ADDRESS_BA (0X98)
  23. #define SC16IS750_ADDRESS_BB (0X9A)
  24. #define SC16IS750_ADDRESS_BC (0X9C)
  25. #define SC16IS750_ADDRESS_BD (0X9E)
  26. #define SC16IS750_ADDRESS_CA (0XA0)
  27. #define SC16IS750_ADDRESS_CB (0XA2)
  28. #define SC16IS750_ADDRESS_CC (0XA4)
  29. #define SC16IS750_ADDRESS_CD (0XA6)
  30. #define SC16IS750_ADDRESS_DA (0XA8)
  31. #define SC16IS750_ADDRESS_DB (0XAA)
  32. #define SC16IS750_ADDRESS_DC (0XAC)
  33. #define SC16IS750_ADDRESS_DD (0XAE)
  34. //General Registers
  35. #define SC16IS750_REG_RHR (0x00)
  36. #define SC16IS750_REG_THR (0X00)
  37. #define SC16IS750_REG_IER (0X01)
  38. #define SC16IS750_REG_FCR (0X02)
  39. #define SC16IS750_REG_IIR (0X02)
  40. #define SC16IS750_REG_LCR (0X03)
  41. #define SC16IS750_REG_MCR (0X04)
  42. #define SC16IS750_REG_LSR (0X05)
  43. #define SC16IS750_REG_MSR (0X06)
  44. #define SC16IS750_REG_SPR (0X07)
  45. #define SC16IS750_REG_TCR (0X06)
  46. #define SC16IS750_REG_TLR (0X07)
  47. #define SC16IS750_REG_TXLVL (0X08)
  48. #define SC16IS750_REG_RXLVL (0X09)
  49. #define SC16IS750_REG_IODIR (0X0A)
  50. #define SC16IS750_REG_IOSTATE (0X0B)
  51. #define SC16IS750_REG_IOINTENA (0X0C)
  52. #define SC16IS750_REG_IOCONTROL (0X0E)
  53. #define SC16IS750_REG_EFCR (0X0F)
  54. //Special Registers
  55. #define SC16IS750_REG_DLL (0x00)
  56. #define SC16IS750_REG_DLH (0X01)
  57. //Enhanced Registers
  58. #define SC16IS750_REG_EFR (0X02)
  59. #define SC16IS750_REG_XON1 (0X04)
  60. #define SC16IS750_REG_XON2 (0X05)
  61. #define SC16IS750_REG_XOFF1 (0X06)
  62. #define SC16IS750_REG_XOFF2 (0X07)
  63. //
  64. #define SC16IS750_INT_CTS (0X80)
  65. #define SC16IS750_INT_RTS (0X40)
  66. #define SC16IS750_INT_XOFF (0X20)
  67. #define SC16IS750_INT_SLEEP (0X10)
  68. #define SC16IS750_INT_MODEM (0X08)
  69. #define SC16IS750_INT_LINE (0X04)
  70. #define SC16IS750_INT_THR (0X02)
  71. #define SC16IS750_INT_RHR (0X01)
  72. //Application Related
  73. #define SC16IS750_CRYSTCAL_FREQ (14745600UL)
  74. //#define SC16IS750_CRYSTCAL_FREQ (1843200UL)
  75. //#define SC16IS750_CRYSTCAL_FREQ (16000000UL)
  76. //#define SC16IS750_DEBUG_PRINT (0)
  77. #define SC16IS750_PROTOCOL_I2C (0)
  78. #define SC16IS750_PROTOCOL_SPI (1)
  79. #define AES_ENC_NONE 0
  80. #define AES_ENC_CAR 1
  81. #define AES_ENC_EMG 2
  82. #define AES_ENC_PCA 3
  83. #define AES_ENC_WES 4
  84. #define AES_ENC_WES_EMG 5
  85. #define AES_ENC_WES_ALV 6
  86. #define AES_ENC_WES_TST 7
  87. #define AES_ENC_WES_REG 8
  88. #if 0
  89. void SC16IS750_ResetDevice(void);
  90. void SC16IS750_WriteRegister(unsigned char reg_addr, unsigned char val);
  91. unsigned char SC16IS750_ReadRegister(unsigned char reg_addr);
  92. void SC16IS750_FIFOEnable(unsigned char fifo_enable);
  93. int16_t SC16IS750_SetBaudrate(uint32_t baudrate);
  94. void SC16IS750_SetLine(uint8_t data_length, uint8_t parity_select, uint8_t stop_length );
  95. void SC16IS750_WriteByte(uint8_t val);
  96. int DBGPrint(const char *fmt, ...);
  97. void ParkSysInit();
  98. #endif
  99. void RegMac(char* str);
  100. void LoadRegMac();
  101. void SetMacAddress(uint8_t* addr);
  102. /* A dummy structure to save in flash. */
  103. #define CONFIG_FILE (0x8010)
  104. #define CONFIG_REC_KEY (0x7010)
  105. typedef struct
  106. {
  107. uint32_t boot_count;
  108. char device_name[16];
  109. bool config1_on;
  110. bool config2_on;
  111. } configuration_t;
  112. typedef struct
  113. {
  114. char Mac[10][15];
  115. int Count;
  116. }RegMacPool_t;
  117. void FlashTest();
  118. void RegMacDelteAll();
  119. void delete_all_begin(void);
  120. void DisplayRegMac();
  121. void SaveRegMac(char* mac);
  122. int FindRegMac(char* mac);
  123. void CarEncryptEcb(int mode);
  124. void CarDecryptEcb(char* in, char* out);
  125. void CarEncryptEcbACK(char type);
  126. int AppParkingCheck(char* data);
  127. int AppParkingCheck_IOS(char* data);
  128. extern ble_gap_addr_t old_ble_addr;
  129. extern ble_gap_addr_t new_ble_addr;
  130. extern RegMacPool_t RegMacPool;
  131. #endif