3 volatile int32_t left_ticks;
4 volatile int32_t right_ticks;
9 static void ext_cb(EXTDriver* driver, expchannel_t channel);
11 const EXTConfig ext_config = {
13 {EXT_CH_MODE_DISABLED, NULL},
14 {EXT_CH_MODE_DISABLED, NULL},
15 {EXT_CH_MODE_DISABLED, NULL},
16 {EXT_CH_MODE_DISABLED, NULL},
17 {EXT_CH_MODE_DISABLED, NULL},
18 {EXT_CH_MODE_DISABLED, NULL},
19 {EXT_CH_MODE_DISABLED, NULL},
20 {EXT_CH_MODE_DISABLED, NULL},
21 {EXT_CH_MODE_DISABLED, NULL},
22 {EXT_CH_MODE_DISABLED, NULL},
23 {EXT_CH_MODE_RISING_EDGE | EXT_CH_MODE_AUTOSTART | EXT_MODE_GPIOB, ext_cb},
24 {EXT_CH_MODE_RISING_EDGE | EXT_CH_MODE_AUTOSTART | EXT_MODE_GPIOB, ext_cb},
25 {EXT_CH_MODE_DISABLED, NULL},
26 {EXT_CH_MODE_DISABLED, NULL},
27 {EXT_CH_MODE_DISABLED, NULL},
28 {EXT_CH_MODE_DISABLED, NULL}
35 static void ext_cb(EXTDriver* driver, expchannel_t channel)
38 if (channel == GPIOB_RCODA) {
39 if (palReadPad(GPIOB, GPIOB_RCODB) == PAL_LOW) {
40 right_wheel_orientation ? right_ticks-- : right_ticks++;
42 right_wheel_orientation ? right_ticks++ : right_ticks--;
44 }
else if (channel == GPIOB_LCODA) {
45 if (palReadPad(GPIOB, GPIOB_LCODB) == PAL_LOW) {
46 left_wheel_orientation ? left_ticks-- : left_ticks++;
48 left_wheel_orientation ? left_ticks++ : left_ticks--;
63 extStart(&EXTD1, &ext_config);
Configuration structure for coding wheels.
wheel_orientation_t right_wheel_orientation
void init_coding_wheels(coding_wheels_config_t config)
Perform all the initializations required by the coding wheels.
wheel_orientation_t
Possible values for coding wheels orientation.
int32_t initial_left_ticks
wheel_orientation_t left_wheel_orientation
int32_t initial_right_ticks