00001
00009
00010 #include "esos.h"
00011 #include "esos_pic24.h"
00012
00013
00014 ESOS_USER_INTERRUPT(ESOS_IRQ_PIC24_T2);
00015 void initialize_servo_2(void);
00016
00017
00018
00019 #ifdef ESOS_USE_IRQS
00020 #if (SERVO_IRQ_LEVEL_2 == 1)
00021 #define SERVO_IRQ_2 ESOS_USER_IRQ_LEVEL1
00022 #elif (SERVO_IRQ_LEVEL_2 == 2)
00023 #define SERVO_IRQ_2 ESOS_USER_IRQ_LEVEL2
00024 #elif (SERVO_IRQ_LEVEL_2 == 3)
00025 #define SERVO_IRQ_2 ESOS_USER_IRQ_LEVEL3
00026 #elif (SERVO_IRQ_LEVEL_2 == 4)
00027 #define SERVO_IRQ_2 ESOS_USER_IRQ_LEVEL4
00028 #else
00029 #error Incorrect value for SERVO_IRQ_LEVEL_2! Available choices are 1, through 4 (1 being highest).
00030 #endif
00031 #else
00032 #if !(SERVO_IRQ_LEVEL_2 >= 1 && SERVO_IRQ_LEVEL_2 <= 7)
00033 #error Incorrect value for SERVO_IRQ_LEVEL_2! Available choices are 1 through 7 (7 being highest).
00034 #endif
00035 #endif
00036
00037
00038
00039 #if (SERVO_PRESCALER_2 == 1)
00040 #define SERVO_PRESCALER_BITFIELD_2 T2_PS_1_1
00041 #elif (SERVO_PRESCALER_2 == 8)
00042 #define SERVO_PRESCALER_BITFIELD_2 T2_PS_1_8
00043 #elif (SERVO_PRESCALER_2 == 64)
00044 #define SERVO_PRESCALER_BITFIELD_2 T2_PS_1_64
00045 #elif (SERVO_PRESCALER_2 == 256)
00046 #define SERVO_PRESCALER_BITFIELD_2 T2_PS_1_256
00047 #else
00048 #error Incorrect value for SERVO_PRESCALAR_2! Available choices are 1, 8, 64, or 256.
00049 #endif
00050
00052 #define MAX_NUM_SERVOS_2 7
00053
00054
00055 #if ((NUM_SERVOS_USED_2 < 1) || (NUM_SERVOS_USED_2 > MAX_NUM_SERVOS_2))
00056 #error The value selected for NUM_SERVOS_USED_2 must be between 1
00057 #error and MAX_NUM_SERVOS_2.
00058 #endif
00059
00063 #define TIME_PER_SERVO_2 (SERVO_PULSE_PERIOD_2 / MAX_NUM_SERVOS_2)