7 #define MOTOR_SPEED_MAX 0x3FF
8 typedef int16_t motor_speed_t
; //only 11 bits used, 10+sign
9 typedef uint16_t motor_uspeed_t
;
12 volatile uint8_t * const port
;
16 typedef struct motor_s
{
17 volatile uint8_t * const reg_pwm
;
18 volatile uint8_t * const reg_pwmh
;
19 const struct pin_s pin
[2];
22 // Motor structure constructor
23 #define MOTOR_DEF(reg, port1, index1, port2, index2) \
27 .pin[0].port = &port1, \
28 .pin[1].port = &port2, \
29 .pin[0].mask = (uint8_t) ( 1 << (index1) ), \
30 .pin[1].mask = (uint8_t) ( 1 << (index2) ) \
34 void motor_init(void);
36 void motor_set(motor_t
*motor
, motor_speed_t value
);
37 motor_speed_t
motor_get(motor_t
*motor
);