2018-01-02 14:02:42 +02:00
|
|
|
#ifndef SERVOS_H
|
|
|
|
#define SERVOS_H
|
|
|
|
|
2018-01-22 13:01:37 +02:00
|
|
|
#define SERVO_DDR DDRD
|
|
|
|
#define SERVO_L_REG OCR0A
|
|
|
|
#define SERVO_R_REG OCR0B
|
|
|
|
#define SERVO_L_BIT PD6
|
|
|
|
#define SERVO_R_BIT PD5
|
2018-01-02 14:02:42 +02:00
|
|
|
|
2018-01-22 13:01:37 +02:00
|
|
|
// Not just STOP +- 500us because of rounding errors (e.g. 19.9 will become
|
|
|
|
// 19 and not 20 because of integer division)
|
|
|
|
#define SERVO_MID 1381UL
|
|
|
|
#define SERVO_MAX 1883UL
|
|
|
|
#define SERVO_MIN 880UL
|
2018-01-02 14:02:42 +02:00
|
|
|
|
2018-01-22 13:01:37 +02:00
|
|
|
#define SERVO_L_STOP SERVO_MID
|
|
|
|
#define SERVO_L_FORW SERVO_MAX
|
|
|
|
#define SERVO_L_BACKW SERVO_MIN
|
2018-01-19 18:13:16 +02:00
|
|
|
|
2018-01-22 13:01:37 +02:00
|
|
|
#define SERVO_R_STOP SERVO_MID
|
|
|
|
#define SERVO_R_FORW SERVO_MIN
|
|
|
|
#define SERVO_R_BACKW SERVO_MAX
|
2018-01-02 14:02:42 +02:00
|
|
|
|
2018-01-22 13:01:37 +02:00
|
|
|
#define PRESCALER 1024UL
|
|
|
|
#define PWM_PERIOD_MS (uint16_t)((256000UL * PRESCALER) / F_CPU)
|
|
|
|
#define US2TIMER0(us) (uint16_t)((51U * us) / (200U * PWM_PERIOD_MS))
|
2018-01-02 14:02:42 +02:00
|
|
|
|
|
|
|
void init_servos(void);
|
|
|
|
void run_servos(void);
|
|
|
|
|
|
|
|
#endif /* SERVOS_H */
|