23 #ifndef SERVOS_4017_HW_H
24 #define SERVOS_4017_HW_H
34 #define SERVOS_TICS_OF_USEC(s) cpu_ticks_of_usec(s)
35 #define ClipServo(x,a,b) Clip(x, a, b)
37 #if defined NB_CHANNELS
38 #define _4017_NB_CHANNELS Clip(NB_CHANNELS,0,10)
40 #define _4017_NB_CHANNELS 10
44 #define Actuator4017Set(_i, _v) { servos_values[_i] = SERVOS_TICS_OF_USEC(_v); }
47 #define Actuators4017Commit() {}
48 #define Actuators4017Init() actuators_4017_init()
52 #define ACTUATORS_IT TIR_MR1I
54 #ifndef SERVOS_4017_CLOCK_FALLING
55 #define SERVOS_4017_ISR() { \
56 if (servos_4017_idx >= _4017_NB_CHANNELS) { \
57 SetBit(IO1SET, SERVO_RESET_PIN); \
58 servos_4017_idx = 0; \
59 SetBit(IO1CLR, SERVO_RESET_PIN); \
63 T0MR1 += servos_values[servos_4017_idx]; \
70 #define SERVOS_4017_RESET_WIDTH SERVOS_TICS_OF_USEC(1000)
71 #define SERVOS_4017_FIRST_PULSE_WIDTH SERVOS_TICS_OF_USEC(100)
73 #define SERVOS_4017_ISR() { \
74 if (servos_4017_idx == _4017_NB_CHANNELS) { \
75 SetBit(IO1SET, SERVO_RESET_PIN); \
77 T0MR1 += SERVOS_4017_RESET_WIDTH; \
81 else if (servos_4017_idx > _4017_NB_CHANNELS) { \
83 SetBit(IO1CLR,SERVO_RESET_PIN); \
87 T0MR1 += SERVOS_4017_FIRST_PULSE_WIDTH; \
92 T0MR1 += servos_values[servos_4017_idx]; \
94 if (servos_4017_idx != _4017_NB_CHANNELS-1) { \
void actuators_4017_init(void)
Architecture independent timing functions.
uint16_t servos_values[_4017_NB_CHANNELS]
#define _4017_NB_CHANNELS