123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273 |
- #ifndef _SYSMGR_H_
- #define _SYSMGR_H_
- #include "nrf_drv_spi.h"
- #include "app_util_platform.h"
- #include "nrf_gpio.h"
- #include "nrf_delay.h"
- #include "boards.h"
- #include "app_error.h"
- #include <string.h>
- #include "nrf_log.h"
- #include "nrf_log_ctrl.h"
- #include "nrf_log_default_backends.h"
- #include "ble_gap.h"
- #include "fds.h"
- #include "nrf_fstorage.h"
- struct stSystemTimer__ {
- volatile int MS_1;
- volatile int UART_LAST_RECV_TIMER;
- volatile int SEND_TEST_TIMER;
- volatile int LED_TOGGLE_TIMER;
- volatile int TMR_SYS_OFF;
- volatile int SEND_TIMER;
- volatile int BUZZER_TIMER;
- char EMG_SEND_RUN;
- volatile int TIM_KEY;
- volatile int SLEEP_TIMER;
- };
- typedef struct stSystemTimer__ stSystemTimer;
- struct stSystemManager__ {
- char EmgSendButton;
- char TestSendButton;
- char RxEvent;
- char SendRepeat;
- char SendFlag;
- int BleConnectTime;
- int SendRepeatTimerLimit;
- char BuzzerType;
- char BuzzerBusy;
- unsigned char Batt;
- char BleSendReady;
- char BleSendStatus;
- char BleConnected;
- char BleSendRetry;
- char PeerAddr[6];
- char StrPeerAddr[15];
- char RegPeerAddr[6];
- char StrRegPeerAddr[15];
- char SysReady;
- char SleepEnter;
- char FWUpdate;
-
- char GpReg;
- char GoSleep;
- uint32_t ResetReason;
- char AesEncData[16];
- };
- typedef struct stSystemManager__ stSystemManager;
- #define SC16IS750_ADDRESS_AA (0X90)
- #define SC16IS750_ADDRESS_AB (0X92)
- #define SC16IS750_ADDRESS_AC (0X94)
- #define SC16IS750_ADDRESS_AD (0X96)
- #define SC16IS750_ADDRESS_BA (0X98)
- #define SC16IS750_ADDRESS_BB (0X9A)
- #define SC16IS750_ADDRESS_BC (0X9C)
- #define SC16IS750_ADDRESS_BD (0X9E)
- #define SC16IS750_ADDRESS_CA (0XA0)
- #define SC16IS750_ADDRESS_CB (0XA2)
- #define SC16IS750_ADDRESS_CC (0XA4)
- #define SC16IS750_ADDRESS_CD (0XA6)
- #define SC16IS750_ADDRESS_DA (0XA8)
- #define SC16IS750_ADDRESS_DB (0XAA)
- #define SC16IS750_ADDRESS_DC (0XAC)
- #define SC16IS750_ADDRESS_DD (0XAE)
- //General Registers
- #define SC16IS750_REG_RHR (0x00)
- #define SC16IS750_REG_THR (0X00)
- #define SC16IS750_REG_IER (0X01)
- #define SC16IS750_REG_FCR (0X02)
- #define SC16IS750_REG_IIR (0X02)
- #define SC16IS750_REG_LCR (0X03)
- #define SC16IS750_REG_MCR (0X04)
- #define SC16IS750_REG_LSR (0X05)
- #define SC16IS750_REG_MSR (0X06)
- #define SC16IS750_REG_SPR (0X07)
- #define SC16IS750_REG_TCR (0X06)
- #define SC16IS750_REG_TLR (0X07)
- #define SC16IS750_REG_TXLVL (0X08)
- #define SC16IS750_REG_RXLVL (0X09)
- #define SC16IS750_REG_IODIR (0X0A)
- #define SC16IS750_REG_IOSTATE (0X0B)
- #define SC16IS750_REG_IOINTENA (0X0C)
- #define SC16IS750_REG_IOCONTROL (0X0E)
- #define SC16IS750_REG_EFCR (0X0F)
- //Special Registers
- #define SC16IS750_REG_DLL (0x00)
- #define SC16IS750_REG_DLH (0X01)
- //Enhanced Registers
- #define SC16IS750_REG_EFR (0X02)
- #define SC16IS750_REG_XON1 (0X04)
- #define SC16IS750_REG_XON2 (0X05)
- #define SC16IS750_REG_XOFF1 (0X06)
- #define SC16IS750_REG_XOFF2 (0X07)
- //
- #define SC16IS750_INT_CTS (0X80)
- #define SC16IS750_INT_RTS (0X40)
- #define SC16IS750_INT_XOFF (0X20)
- #define SC16IS750_INT_SLEEP (0X10)
- #define SC16IS750_INT_MODEM (0X08)
- #define SC16IS750_INT_LINE (0X04)
- #define SC16IS750_INT_THR (0X02)
- #define SC16IS750_INT_RHR (0X01)
- //Application Related
- #define SC16IS750_CRYSTCAL_FREQ (14745600UL)
- //#define SC16IS750_CRYSTCAL_FREQ (1843200UL)
- //#define SC16IS750_CRYSTCAL_FREQ (16000000UL)
- //#define SC16IS750_DEBUG_PRINT (0)
- #define SC16IS750_PROTOCOL_I2C (0)
- #define SC16IS750_PROTOCOL_SPI (1)
- #define AES_ENC_CAR 1
- #define AES_ENC_EMG 2
- #define AES_ENC_PCA 3
- #define AES_ENC_WES_EMG 4
- #define AES_ENC_WES_ALV 5
- #define AES_ENC_WES_TST 6
- #define AES_ENC_WES_REG 7
- /* A dummy structure to save in flash. */
- #define CONFIG_FILE (0x8010)
- #define CONFIG_REC_KEY (0x7010)
- typedef struct
- {
- uint32_t boot_count;
- char device_name[16];
- bool config1_on;
- bool config2_on;
- } configuration_t;
- typedef struct
- {
- char Mac[10][15];
- int Count;
- }RegMacPool_t;
- void SC16IS750_ResetDevice(void);
- void SC16IS750_WriteRegister(unsigned char reg_addr, unsigned char val);
- unsigned char SC16IS750_ReadRegister(unsigned char reg_addr);
- void SC16IS750_FIFOEnable(unsigned char fifo_enable);
- int16_t SC16IS750_SetBaudrate(uint32_t baudrate);
- void SC16IS750_SetLine(uint8_t data_length, uint8_t parity_select, uint8_t stop_length );
- void SC16IS750_WriteByte(uint8_t val);
- int DBGPrint(const char *fmt, ...);
- void ParkSysInit();
- void ParkPowerOff();
- void SendEmgData(void);
- extern stSystemTimer SystemTimer;
- extern stSystemManager SystemManager;
- #define KEY_SELECT 0
- #define KEY_UP 1
- #define KEY_DOWN 3
- #define KEY_BACK 2
- typedef struct tsHSKey{
- unsigned char onFlag;
- unsigned char softRelease;
- unsigned char pressedSec;
- unsigned int pressTime;
- unsigned int longPressTimeOne;
- unsigned int longPressTimeKeep;
- unsigned int prevTime;
- }HSKey;
- void ReadKEY(void);
- void KeyInit(void);
- void KeySelectLongPressedOne(void);
- void m_standby_counter_clerar();
- void PortInputCfg(void);
- void lfclk_config(void);
- void rtc_config(void);
- void SaveReceiverMac(char* mac);
- void LoadReceiverMac();
- void FlashTest();
- void WesEncryptEcb(uint8_t* in);
- extern ble_gap_addr_t old_ble_addr;
- extern ble_gap_addr_t new_ble_addr;
- extern RegMacPool_t RegMacPool;
- #endif
|