inspektors/robot/include/servos.h

25 lines
606 B
C
Raw Normal View History

#ifndef SERVOS_H
#define SERVOS_H
#define SERVO_DDR DDRD
#define SERVO_L_REG OCR0B
#define SERVO_R_REG OCR0A
#define SERVO_L_BIT PD5
#define SERVO_R_BIT PD6
#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-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
void init_servos(void);
void run_servos(void);
#endif /* SERVOS_H */