dsPid33
src/com.h
Go to the documentation of this file.
00001 /* ////////////////////////////////////////////////////////////////////////////
00002 ** Included in "com.c", it contains definitions and variables initialization
00004 
00005 #define DISABLE_TX U1STAbits.UTXEN = 0
00006 #define ENABLE_TX U1STAbits.UTXEN = 1
00007 #define DISABLE_T2 U2STAbits.UTXEN = 0
00008 #define ENABLE_TX2 U2STAbits.UTXEN = 1
00009 
00010 /*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
00011 /* External defininitions                                                    */
00012 /*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
00013 
00014 extern volatile unsigned int BlinkPeriod ;
00015 extern unsigned int BlinkOn;
00016 extern long Blink;
00017 extern int ErrCode;
00018 
00019 #define ERR_BLINK_PER   200     // Period for ERR condition
00020 #define ERR_BLINK_ON    100     // ON TIME for ERR condition
00021 
00022 // **debug**
00023 unsigned char ErrNo[16];        // store the occurrence of any kind of error 
00024 // **debug**
00025 
00026 struct Bits{
00027         unsigned bit0:1;
00028         unsigned bit1:1;
00029         unsigned bit2:1;
00030         unsigned bit3:1;
00031         unsigned bit4:1;
00032         unsigned bit5:1;
00033         unsigned bit6:1;
00034         unsigned bit7:1;
00035         unsigned bit8:1;
00036         unsigned bit9:1;
00037         unsigned bit10:1;
00038         unsigned bit11:1;
00039         unsigned bit12:1;
00040         unsigned bit13:1;
00041         unsigned bit14:1;
00042         unsigned bit15:1;
00043 };
00044 
00045 struct Bits COMbits1;
00046 
00047 //UART1
00048 //{
00049 unsigned char Id = 0;                   // Motor Controller Id [14]
00050 volatile unsigned char UartRxBuff[MAX_RX_BUFF][2];//serial communication buffer
00051 unsigned char UartTxBuff[MAX_TX_BUFF] __attribute__((space(dma),aligned(128)));
00052 unsigned char UartTmpBuff[MAX_TX_BUFF-4][2];// temp buffer to compose TX buffer 
00053 unsigned char TxFlag = 0;               // transmission status
00054 unsigned char ChkSum=0;                 // checksum
00055 unsigned char UartRxCmd[2];             // command code
00056 // Rx circular queue pointers
00057 volatile unsigned char UartRxPtrIn=0;   // ingoing bytes captured by ISR
00058 unsigned char UartRxPtrOut=0;   // outgoing bytes read by UartRx function
00059 unsigned char UartRxPtrStart=0; // message packet starting pointer in queue
00060 unsigned char UartRxPtrEnd=0;   // message packet ending pointer in queue
00061 unsigned char UartRxPtrData=0;  // pointer to first data in queue
00062 unsigned char TmpPtr;                   // temporary pointer
00063 unsigned int UartTxCntr=0;
00064 volatile int UartRxStatus =0;                   // index for command decoding status
00065 #define OVERRUN_ERROR U1STAbits.OERR    // RX overrun error flag
00066 #define TX_REG_EMPTY  U1STAbits.TRMT    // TX shift register empty
00067 #define FRAME_ERROR U1STAbits.FERR              // RX frame error flag
00068 #define HEADER '@'                                              // command string header
00069 #define RX_ID_FLAG COMbits1.bit1                // command decode flag
00070 
00071 const unsigned char Test[]="-mary had a little lamb-";
00072 //}
00073 
00074 //UART2
00075 //{ 
00076 unsigned char Id2 = 0;                  // Motor Controller Id [14]
00077 extern unsigned char 
00078                 Uart2TxBuff[MAX_TX2_BUFF] __attribute__((space(dma),aligned(128)));
00079 unsigned char Tx2Flag = 0;              // transmission status
00080 unsigned char ChkSum2=0;                // checksum
00081 // Rx circular queue pointers
00082 volatile unsigned char Uart2RxPtrIn=0;  // ingoing bytes captured by ISR
00083 unsigned char Uart2RxPtrOut=0;  // outgoing bytes read by UartRx function
00084 unsigned char Uart2RxPtrStart=0;// message packet starting pointer in queue
00085 unsigned char Uart2RxPtrEnd=0;  // message packet ending pointer in queue
00086 unsigned char Uart2RxPtrData=0; // pointer to first data in queue
00087 unsigned char TmpPtr2;                  // temporary pointer
00088 unsigned int Uart2TxCntr=0;
00089 #define UART2_CONT_TIMEOUT 100                  // continuos parameters TX in ms(debug) 
00090 int Uart2ContTxTimer=UART2_CONT_TIMEOUT;// timer for continuos parameters TX 
00091 volatile int Uart2RxStatus =0;                  // index for command decoding status
00092 #define OVERRUN_ERROR2 U2STAbits.OERR   // RX overrun error flag
00093 #define TX2_REG_EMPTY  U2STAbits.TRMT   // TX shift register empty
00094 #define FRAME_ERROR2 U2STAbits.FERR             // RX frame error flag
00095 #define RX2_ID_FLAG COMbits1.bit2               // command decode flag
00096 unsigned int Tx2ContFlag=0;                             // continuos parameters TX flag (debug)
00097 //}
00098 
 All Data Structures Files Functions Variables Defines