2018-01-02 14:02:42 +02:00
|
|
|
#ifndef SERVOS_H
|
|
|
|
#define SERVOS_H
|
|
|
|
|
2018-01-09 20:17:50 +02:00
|
|
|
#define SERVO_DDR DDRD
|
|
|
|
#define SERVO_L_REG OCR0B
|
|
|
|
#define SERVO_R_REG OCR0A
|
|
|
|
#define SERVO_L_BIT PD5
|
|
|
|
#define SERVO_R_BIT PD6
|
2018-01-02 14:02:42 +02:00
|
|
|
|
|
|
|
#define SERVO_MIN 930 // (us). Go backwards
|
|
|
|
#define SERVO_MAX 1930 // (us). Go forwards
|
2018-01-19 18:13:16 +02:00
|
|
|
#define SERVO_MID (SERVO_MIN + SERVO_MAX) / 2 // (us). Stop
|
2018-01-02 14:02:42 +02:00
|
|
|
|
2018-01-19 18:13:16 +02:00
|
|
|
#define PRESCALER 1024L
|
|
|
|
#define PWM_CLOCK F_CPU / (256 * PRESCALER)
|
|
|
|
#define PWM_PERIOD_US 1000000 / PWM_CLOCK
|
|
|
|
|
|
|
|
#define US2TIMER0(us) (255 * (uint32_t)us) / PWM_PERIOD_US
|
2018-01-02 14:02:42 +02:00
|
|
|
|
|
|
|
|
|
|
|
void init_servos(void);
|
|
|
|
void run_servos(void);
|
|
|
|
|
|
|
|
#endif /* SERVOS_H */
|