diff --git a/application.c b/application.c index 452271a..eb8b730 100644 --- a/application.c +++ b/application.c @@ -79,7 +79,7 @@ static bool drv8825_reached = false; /**< set when the goal is reached */ /** maximum speed (in steps/s) before the motor stalls (found empirically) * @note found empirically 300 @ 9V/180mA, 420 @ 12V/150mA */ -#define DRV8825_SPEED_LIMIT 420U +#define DRV8825_SPEED_LIMIT 600U // dials position info #define DIAL_SWITCH_PIN PB4 /**< pin connected to reed switch, connected to ground when the hour dial is nearby */ @@ -115,10 +115,10 @@ static void drv8825_speed(int16_t speed) drv8825_direction = 0; // remember we stopped } else { if (speed > 0) { - gpio_clear(GPIO_PORT(DRV8825_DIRECTION_PIN), GPIO_PIN(DRV8825_DIRECTION_PIN)); // set clockwise + gpio_set(GPIO_PORT(DRV8825_DIRECTION_PIN), GPIO_PIN(DRV8825_DIRECTION_PIN)); // set clockwise drv8825_direction = 1; // remember we go clockwise } else { - gpio_set(GPIO_PORT(DRV8825_DIRECTION_PIN), GPIO_PIN(DRV8825_DIRECTION_PIN)); // set counter-clockwise + gpio_clear(GPIO_PORT(DRV8825_DIRECTION_PIN), GPIO_PIN(DRV8825_DIRECTION_PIN)); // set counter-clockwise drv8825_direction = -1; // remember we go counter-clockwise speed = -speed; // get positive speed } @@ -961,6 +961,7 @@ void main(void) rcc_periph_clock_enable(GPIO_RCC(DRV8825_FAULT_PIN)); // enable clock for GPIO port peripheral gpio_mode_setup(GPIO_PORT(DRV8825_FAULT_PIN), GPIO_MODE_INPUT, GPIO_PUPD_PULLUP, GPIO_PIN(DRV8825_FAULT_PIN)); // set GPIO to input and pull up (a 10 kOhm external pull-up resistor is still required, the internal is too weak) bool drv8825_fault = false; // if driver reported fault + gpio_set(GPIO_PORT(DRV8825_RESET_PIN), GPIO_PIN(DRV8825_RESET_PIN)); // power up driver puts_debug("OK\n"); puts_debug("setup dial position: ");