提交 | 用户 | age
|
8b51c7
|
1 |
/** |
Q |
2 |
****************************************************************************** |
|
3 |
* @file : functions.h |
|
4 |
* @brief : Header for functions.c file. |
|
5 |
* This file contains the user functions defines of the application. |
|
6 |
****************************************************************************** |
|
7 |
*/ |
|
8 |
#ifndef __MYFUNCTIONS_H__ |
|
9 |
#define __MYFUNCTIONS_H__ |
|
10 |
|
|
11 |
|
|
12 |
#include "KBus.h" |
|
13 |
//#include "KLProtocol.h" |
|
14 |
#include "myqueue.h" |
|
15 |
#include "GlobalDef.h" |
|
16 |
extern int TickFreq;//=10000; |
|
17 |
extern int CoreClkMHz; //=SystemCoreClock/1000000; |
|
18 |
extern int TickPriodClk; //=SystemCoreClock/TickFreq; |
|
19 |
extern unsigned int TickPrioduS; // |
|
20 |
extern volatile unsigned int nCurTick; |
|
21 |
extern volatile unsigned int CurTickuS; |
|
22 |
//extern volatile unsigned int ThisRunTime; |
|
23 |
//extern volatile unsigned int TotalRunTime; |
|
24 |
//extern volatile unsigned int PwrCount; //开机次数 |
|
25 |
#pragma anon_unions |
|
26 |
typedef union tagshortbits { |
|
27 |
unsigned short value; |
|
28 |
struct { |
|
29 |
unsigned short bit0:1; |
|
30 |
unsigned short bit1:1; |
|
31 |
unsigned short bit2:1; |
|
32 |
unsigned short bit3:1; |
|
33 |
unsigned short bit4:1; |
|
34 |
unsigned short bit5:1; |
|
35 |
unsigned short bit6:1; |
|
36 |
unsigned short bit7:1; |
|
37 |
unsigned short bit8:1; |
|
38 |
unsigned short bit9:1; |
|
39 |
unsigned short bit10:1; |
|
40 |
unsigned short bit11:1; |
|
41 |
unsigned short bit12:1; |
|
42 |
unsigned short bit13:1; |
|
43 |
unsigned short bit14:1; |
|
44 |
unsigned short bit15:1; |
|
45 |
}; |
|
46 |
}shortbits; |
|
47 |
|
842bb6
|
48 |
#define RX1BUFSIZE 160 |
Q |
49 |
#define TX1BUFSIZE 260 |
|
50 |
|
|
51 |
#define UART3RXBUFSIZE 256 |
|
52 |
#define UART3TXBUFSIZE 64 |
|
53 |
|
|
54 |
extern stUartStat Uart3Stat; |
|
55 |
extern unsigned char Uart3RxBuf[UART3RXBUFSIZE]; |
|
56 |
extern unsigned char Uart3TxBuf[UART3TXBUFSIZE]; |
|
57 |
extern unsigned int Uart3RecvBuf1DataLen; |
|
58 |
extern unsigned int Uart3ToSendLen; |
|
59 |
extern unsigned int Uart3SentLen; |
|
60 |
|
|
61 |
#define UART5RXBUFSIZE 256 |
|
62 |
#define UART5TXBUFSIZE 64 |
8b51c7
|
63 |
|
Q |
64 |
extern stUartStat Uart5Stat; |
842bb6
|
65 |
extern unsigned char Uart5RxBuf[UART5RXBUFSIZE]; |
Q |
66 |
extern unsigned char Uart5TxBuf[UART5TXBUFSIZE]; |
8b51c7
|
67 |
extern unsigned int Uart5RecvBuf1DataLen; |
Q |
68 |
extern unsigned int Uart5ToSendLen; |
|
69 |
extern unsigned int Uart5SentLen; |
|
70 |
|
|
71 |
|
842bb6
|
72 |
#define UART6RXBUFSIZE 64 |
Q |
73 |
#define UART6TXBUFSIZE 64 |
8b51c7
|
74 |
|
Q |
75 |
extern stUartStat Uart6Stat; |
842bb6
|
76 |
extern unsigned char Uart6RxBuf[UART6RXBUFSIZE]; |
Q |
77 |
extern unsigned char Uart6TxBuf[UART6TXBUFSIZE]; |
8b51c7
|
78 |
extern unsigned int Uart6RecvBuf1DataLen; |
Q |
79 |
extern unsigned int Uart6ToSendLen; |
|
80 |
extern unsigned int Uart6SentLen; |
|
81 |
|
|
82 |
|
|
83 |
typedef unsigned char uint8_t; |
|
84 |
typedef unsigned char uchar; |
|
85 |
typedef unsigned short uint16_t; |
|
86 |
//typedef unsigned long uint32_t; |
|
87 |
typedef int int32_t; |
|
88 |
|
|
89 |
int InituS(int TickFreq1); |
|
90 |
unsigned int GetuS(void); |
|
91 |
unsigned int GetTick(void); |
|
92 |
void logData(unsigned char d); |
|
93 |
int InitUartstat(stUartStat * pUartstat,void * pBufRx, int nSizeRx, void * pBufTx, int nSizeTx); |
|
94 |
int Uart1SendDMA(void * pData, int nSize); |
|
95 |
int Uart1TriggerSendDMA(void ); |
|
96 |
int Uart2SendDMA(void * pData, int nSize); |
|
97 |
int Uart2RecvDMA(void * pBuf, int nSize); |
|
98 |
int Uart2TriggerRecvDMA(void ); |
|
99 |
int Uart2TriggerSendDMA(void ); |
|
100 |
int Uart3SendDMA(void * pData, int nSize); |
|
101 |
int Uart3RecvDMA(void * pBuf, int nSize); |
|
102 |
int Uart3TriggerRecvDMA(void ); |
|
103 |
int Uart3TriggerSendDMA(void ); |
|
104 |
void TriggerPendSV(void); |
|
105 |
void PendSvCallBack(void); |
|
106 |
void SPI1_IRQ_CallBack(void); |
|
107 |
|
|
108 |
void Uart1SendDone(void); |
|
109 |
void Uart1RecvDone(void); |
|
110 |
void Uart2SendDone(void); |
|
111 |
void Uart2RecvDone(void); |
842bb6
|
112 |
|
Q |
113 |
void Uart3SendDone(void); |
|
114 |
void Uart3RecvDone(void); |
|
115 |
void Uart3SendPacket(char * str, int len); |
|
116 |
|
8b51c7
|
117 |
void Uart5SendDone(void); |
Q |
118 |
void Uart5RecvDone(void); |
|
119 |
void Uart5SendPacket(char * str, int len); |
|
120 |
|
|
121 |
void Uart6SendDone(void); |
|
122 |
void Uart6RecvDone(void); |
842bb6
|
123 |
void Uart6SendPacket(unsigned char * str, int len); |
8b51c7
|
124 |
|
842bb6
|
125 |
void SLPSendPacket(void * str, uchar len); |
8b51c7
|
126 |
|
Q |
127 |
int PutStr(char * str1, int len1); |
842bb6
|
128 |
int PutStr2(char * str1, int len1); |
8b51c7
|
129 |
int SendPacket(int nChn, void * pBuf,int len1); |
Q |
130 |
//int SendPacket1(void * pBuf,int len1); |
|
131 |
//int SendPacket2(pKBPacket p1,int len1); |
|
132 |
void ToggleRunLed(void ); |
|
133 |
void ToggleErrLed(void ); |
|
134 |
void ToggleErr2Led(void ); |
|
135 |
void ToggleOutStat(void ); |
|
136 |
int ReadJumperSW(void ); |
|
137 |
void SetRunLed(uchar bOn); |
|
138 |
void SetErrLed(uchar bOn); |
|
139 |
void SetErr2Led(uchar bOn); |
|
140 |
void SetOutStat(uchar bOn); |
|
141 |
void Enable595(uchar bEnable); |
|
142 |
unsigned int GetInput(void ); |
|
143 |
void PutOutput(unsigned int nOutValue); |
|
144 |
inline unsigned int GetTick(void); |
|
145 |
unsigned short crc_check(const unsigned char * data, unsigned int length); |
|
146 |
unsigned short crc16bitbybit(const unsigned char *ptr, unsigned int len); |
|
147 |
uint16_t crc16table(const uint8_t *ptr, uint16_t len); |
|
148 |
//uint16_t crc16tablefast(const uint8_t *ptr, uint16_t len) ; |
|
149 |
|
|
150 |
void EnableDisIn(uchar bEnable); |
|
151 |
void displayInput(unsigned int cc); |
|
152 |
void PutOutputSPI1(unsigned int Y); |
|
153 |
|
|
154 |
#endif /* __MYFUNCTIONS_H__ */ |