dsPid33
src/dsPID33_common.h
Go to the documentation of this file.
00001 /* //////////////////////////////////////////////////////////////////////////*/
00002 /*Commons includes and definitions                                           */
00003 /* //////////////////////////////////////////////////////////////////////////*/
00004 
00005 // standard include 
00006 #include "p33Fxxxx.h"
00007 #include <dsp.h>
00008 #include <pwm12.h>
00009 #include <uart.h>
00010 #include <qei.h>
00011 #include <adc.h>
00012 #include <timer.h>
00013 #include <InCap.h>
00014 #include <ports.h>
00015 #include <dma.h>
00016 #include <math.h>
00017 #include <stdlib.h>
00018 #include <libq.h>
00019 
00020 /*---------------------------------------------------------------------------*/
00021 /* include                                                                                                                           */
00022 /*---------------------------------------------------------------------------*/
00023 #include "dsPID33_prototypes.h"
00024 
00025 
00026 // Configuration switches for compilation. Comment the undesired lines [34]****
00027 #define CLOCK_FREQ_10 10        // [34b]
00028 
00029 // [34c] valid only for 28 pin dsPIC. Choose one only
00030 //#define PROTOTYPE 1
00031 #define DROIDS 1
00032 
00033 // [34d] valid only for 44 pin dsPIC. Choose one only
00034 // #define DSNAVCON33 1
00035 //#define ROBOCONTROLLER 1 
00036 
00037 // #define SLOW_ENC // uncomment for low CPR encoders
00038 
00039 // for debugging purposes------------------------------------------------------
00040 #define NO_FLASH 1      //  [34a]
00041 // #define NO_OBSTACLE 1        //  [34e]
00042 // #define debug_SA     // [15]
00043 // #define SIM 1        //      [21]
00044 // #define TIMER_OFF 1
00045 //*****************************************************************************
00046 
00047 
00048 #ifdef CLOCK_FREQ_10
00049 /*
00050 CLOCK_FREQ = 10 MHz
00051 Fosc = CLOCK_FREQ*M/(N1*N2) = 10M*32/(2*2)=80Mhz
00052 Fcy = Fosc / 2 = 40
00053 */
00054 #define FCY 40000000
00055 // TCY = 1 / FCY = 25 ns
00056 
00057 #else
00058 /*
00059 CLOCK_FREQ = 7,3728 MHz
00060 Fosc = CLOCK_FREQ*M/(N1*N2) = 7.3728M*43/(2*2)=79,2576Mhz
00061 Fcy = Fosc / 2 = 39.6288
00062 */
00063 #define FCY 39628800
00064 // TCY = 1 / FCY = 25.2341731266 ns
00065 
00066 #endif
00067 #define TCY 1/((float)(FCY)
00068 
00069 #define _ISR_PSV __attribute__((interrupt, auto_psv))
00070 
00071 #define MAX_TX_BUFF 90 // big enough to store a row of cells grid (X_SIZE)
00072 #define MAX_RX_BUFF 144
00073 #define MAX_TX2_BUFF 32
00074 
00075 // macro to round a float in a int
00076 #define FLOAT2INT(x) ((x)>=0?(int)((x)+0.5):(int)((x)-0.5))
00077 #define max(a,b) ((a) > (b) ? (a) : (b))
00078 
00079 #define geographic      // [22aa]
00080 
00081 #define RX_HEADER_LEN 3                                 // command string header length (byte)
 All Data Structures Files Functions Variables Defines