00001
00025 #ifndef __CALIB_VALUES_H__
00026 #define __CALIB_VALUES_H__
00027
00039
00040
00041
00044 #define CALIBRATION_FREQUENCY 1000000
00045
00048 #define XTAL_FREQUENCY 32768
00049 #define EXTERNAL_TICKS 100 // ticks on XTAL. Modify to increase/decrease accuracy
00050
00056 #define FALSE 0
00057 #define TRUE 1
00058 #define RUNNING 0
00059 #define FINISHED 1
00060 #define DEFAULT_OSCCAL_MASK 0x00 // Lower half and
00061 #define DEFAULT_OSCCAL_MASK_HIGH 0x80 // upper half for devices with splitted OSCCAL register
00062
00063 #include "device_specific.h"
00064
00065 #define DEFAULT_OSCCAL_HIGH ((1 << (OSCCAL_RESOLUTION - 1)) | DEFAULT_OSCCAL_MASK_HIGH)
00066 #define INITIAL_STEP (1 << (OSCCAL_RESOLUTION - 2))
00067 #define DEFAULT_OSCCAL ((1 << (OSCCAL_RESOLUTION - 1)) | DEFAULT_OSCCAL_MASK)
00068
00069
00070 #define PREPARE_CALIBRATION() \
00071 calStep = INITIAL_STEP; \
00072 calibration = RUNNING;
00073
00074 #define COMPUTE_COUNT_VALUE() \
00075 countVal = ((EXTERNAL_TICKS*CALIBRATION_FREQUENCY)/(XTAL_FREQUENCY*LOOP_CYCLES));
00076
00077
00078 #define SETUP_ASYNC_TIMER() \
00079 ASSR |= (1<<ASYNC_TIMER); \
00080 ASYNC_TIMER_CONTROL_REGISTER = (1<<NO_PRESCALING);
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090 #if defined(__AT90Mega64__) | defined(__ATmega64__) | \
00091 defined(__AT90Mega128__) | defined(__ATmega128__)
00092
00093 #define NOP() \
00094 __no_operation(); \
00095 __no_operation(); \
00096 __no_operation(); \
00097 __no_operation(); \
00098 __no_operation(); \
00099 __no_operation(); \
00100 __no_operation(); \
00101 __no_operation();
00102
00103
00104 #else
00105 #define NOP() __no_operation()
00106 #endif
00107
00108
00109 #define ABS(var) (((var) < 0) ? -(var) : (var));
00110
00111 #endif
00112