Subversion Repositories HomeAutomation

Rev

Rev 503 | Blame | Compare with Previous | Last modification | View Log | SVN | RSS feed

  1. #ifndef RC_SERVO_H_
  2. #define RC_SERVO_H_
  3.  
  4. /*-----------------------------------------------
  5.  * Includes
  6.  * ---------------------------------------------*/
  7. #include <stdlib.h>
  8. #include <stdio.h>
  9. #include <inttypes.h>
  10.  
  11. /*-----------------------------------------------
  12.  * Defines
  13.  * --------------------------------------------*/
  14.  
  15. /*
  16.  * For width of the pulse that control the RC servo.
  17.  * Clock pulses.
  18.  * This is adjusted for a 8 MHz clock, to use different speeds recalculate.
  19.  */
  20. #define PWM1_MIN_PULSE   800 // 1000
  21. #define PWM1_MAX_PULSE   2200 // 2000
  22. #define PWM2_MIN_PULSE   20
  23. #define PWM2_MAX_PULSE   50
  24. #define PWM3_MIN_PULSE   20
  25. #define PWM3_MAX_PULSE   50
  26.  
  27. #define STEP1   ((PWM1_MAX_PULSE - PWM1_MIN_PULSE)/256)
  28. #define STEP2   1
  29. #define STEP3   1
  30.  
  31. #define MAX_POSITION 255
  32. #define MIN_POSITION 0
  33.  
  34. /*-----------------------------------------------
  35.  * Functions
  36.  * ---------------------------------------------*/
  37. void rcServoInit(void);
  38. void setPosition(uint8_t abs_pos, uint8_t servo);
  39. void alterPosition(int8_t rel_pos, uint8_t servo);
  40. uint8_t getPosition(uint8_t servo);
  41. void servoDisable(void);
  42. void servoEnable(void);
  43.  
  44. #endif
  45.