/**
|
******************************************************************************
|
* @file : functions.h
|
* @brief : Header for functions.c file.
|
* This file contains the user functions defines of the application.
|
******************************************************************************
|
*/
|
#ifndef __MYFUNCTIONS_H__
|
#define __MYFUNCTIONS_H__
|
|
|
#include "KBus.h"
|
//#include "KLProtocol.h"
|
#include "myqueue.h"
|
#include "GlobalDef.h"
|
extern int TickFreq;//=10000;
|
extern int CoreClkMHz; //=SystemCoreClock/1000000;
|
extern int TickPriodClk; //=SystemCoreClock/TickFreq;
|
extern unsigned int TickPrioduS; //
|
extern volatile unsigned int nCurTick;
|
extern volatile unsigned int CurTickuS;
|
//extern volatile unsigned int ThisRunTime;
|
//extern volatile unsigned int TotalRunTime;
|
//extern volatile unsigned int PwrCount; //开机次数
|
#pragma anon_unions
|
typedef union tagshortbits {
|
unsigned short value;
|
struct {
|
unsigned short bit0:1;
|
unsigned short bit1:1;
|
unsigned short bit2:1;
|
unsigned short bit3:1;
|
unsigned short bit4:1;
|
unsigned short bit5:1;
|
unsigned short bit6:1;
|
unsigned short bit7:1;
|
unsigned short bit8:1;
|
unsigned short bit9:1;
|
unsigned short bit10:1;
|
unsigned short bit11:1;
|
unsigned short bit12:1;
|
unsigned short bit13:1;
|
unsigned short bit14:1;
|
unsigned short bit15:1;
|
};
|
}shortbits;
|
|
#define UART3RXBUFSIZE 256
|
#define UART3TXBUFSIZE 64
|
|
extern stUartStat Uart3Stat;
|
extern unsigned char Uart3RxBuf[UART3RXBUFSIZE];
|
extern unsigned char Uart3TxBuf[UART3TXBUFSIZE];
|
extern unsigned int Uart3RecvBuf1DataLen;
|
extern unsigned int Uart3ToSendLen;
|
extern unsigned int Uart3SentLen;
|
|
#define UART5RXBUFSIZE 256
|
#define UART5TXBUFSIZE 64
|
|
extern stUartStat Uart5Stat;
|
extern unsigned char Uart5RxBuf[UART5RXBUFSIZE];
|
extern unsigned char Uart5TxBuf[UART5TXBUFSIZE];
|
extern unsigned int Uart5RecvBuf1DataLen;
|
extern unsigned int Uart5ToSendLen;
|
extern unsigned int Uart5SentLen;
|
|
|
#define UART6RXBUFSIZE 64
|
#define UART6TXBUFSIZE 64
|
|
extern stUartStat Uart6Stat;
|
extern unsigned char Uart6RxBuf[UART6RXBUFSIZE];
|
extern unsigned char Uart6TxBuf[UART6TXBUFSIZE];
|
extern unsigned int Uart6RecvBuf1DataLen;
|
extern unsigned int Uart6ToSendLen;
|
extern unsigned int Uart6SentLen;
|
|
|
typedef unsigned char uint8_t;
|
typedef unsigned char uchar;
|
typedef unsigned short uint16_t;
|
//typedef unsigned long uint32_t;
|
typedef int int32_t;
|
|
int InituS(int TickFreq1);
|
unsigned int GetuS(void);
|
unsigned int GetTick(void);
|
void logData(unsigned char d);
|
int InitUartstat(stUartStat * pUartstat,void * pBufRx, int nSizeRx, void * pBufTx, int nSizeTx);
|
int Uart1SendDMA(void * pData, int nSize);
|
int Uart1TriggerSendDMA(void );
|
int Uart2SendDMA(void * pData, int nSize);
|
int Uart2RecvDMA(void * pBuf, int nSize);
|
int Uart2TriggerRecvDMA(void );
|
int Uart2TriggerSendDMA(void );
|
int Uart3SendDMA(void * pData, int nSize);
|
int Uart3RecvDMA(void * pBuf, int nSize);
|
int Uart3TriggerRecvDMA(void );
|
int Uart3TriggerSendDMA(void );
|
void TriggerPendSV(void);
|
void PendSvCallBack(void);
|
void SPI1_IRQ_CallBack(void);
|
|
void Uart1SendDone(void);
|
void Uart1RecvDone(void);
|
void Uart2SendDone(void);
|
void Uart2RecvDone(void);
|
|
void Uart3SendDone(void);
|
void Uart3RecvDone(void);
|
void Uart3SendPacket(char * str, int len);
|
|
void Uart5SendDone(void);
|
void Uart5RecvDone(void);
|
void Uart5SendPacket(char * str, int len);
|
|
void Uart6SendDone(void);
|
void Uart6RecvDone(void);
|
void Uart6SendPacket(char * str, int len);
|
|
void SLPSendPacket(char * str, uchar len);
|
|
int PutStr(char * str1, int len1);
|
int SendPacket(int nChn, void * pBuf,int len1);
|
//int SendPacket1(void * pBuf,int len1);
|
//int SendPacket2(pKBPacket p1,int len1);
|
void ToggleRunLed(void );
|
void ToggleErrLed(void );
|
void ToggleErr2Led(void );
|
void ToggleOutStat(void );
|
int ReadJumperSW(void );
|
void SetRunLed(uchar bOn);
|
void SetErrLed(uchar bOn);
|
void SetErr2Led(uchar bOn);
|
void SetOutStat(uchar bOn);
|
void Enable595(uchar bEnable);
|
unsigned int GetInput(void );
|
void PutOutput(unsigned int nOutValue);
|
inline unsigned int GetTick(void);
|
unsigned short crc_check(const unsigned char * data, unsigned int length);
|
unsigned short crc16bitbybit(const unsigned char *ptr, unsigned int len);
|
uint16_t crc16table(const uint8_t *ptr, uint16_t len);
|
//uint16_t crc16tablefast(const uint8_t *ptr, uint16_t len) ;
|
|
void EnableDisIn(uchar bEnable);
|
void displayInput(unsigned int cc);
|
void PutOutputSPI1(unsigned int Y);
|
|
#endif /* __MYFUNCTIONS_H__ */
|