summaryrefslogtreecommitdiffstats
path: root/drivers/haptic/solenoid.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/haptic/solenoid.c')
-rw-r--r--drivers/haptic/solenoid.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/drivers/haptic/solenoid.c b/drivers/haptic/solenoid.c
index 25cf344655..7a09940f78 100644
--- a/drivers/haptic/solenoid.c
+++ b/drivers/haptic/solenoid.c
@@ -19,6 +19,7 @@
#include "solenoid.h"
#include "haptic.h"
#include "gpio.h"
+#include "usb_device_state.h"
bool solenoid_on = false;
bool solenoid_buzzing = false;
@@ -36,7 +37,7 @@ void solenoid_set_buzz(int buzz) { haptic_set_buzz(buzz); }
void solenoid_set_dwell(uint8_t dwell) { solenoid_dwell = dwell; }
void solenoid_stop(void) {
- writePinLow(SOLENOID_PIN);
+ SOLENOID_PIN_WRITE_INACTIVE();
solenoid_on = false;
solenoid_buzzing = false;
}
@@ -48,7 +49,7 @@ void solenoid_fire(void) {
solenoid_on = true;
solenoid_buzzing = true;
solenoid_start = timer_read();
- writePinHigh(SOLENOID_PIN);
+ SOLENOID_PIN_WRITE_ACTIVE();
}
void solenoid_check(void) {
@@ -69,20 +70,23 @@ void solenoid_check(void) {
if ((elapsed % (SOLENOID_BUZZ_ACTUATED + SOLENOID_BUZZ_NONACTUATED)) < SOLENOID_BUZZ_ACTUATED) {
if (!solenoid_buzzing) {
solenoid_buzzing = true;
- writePinHigh(SOLENOID_PIN);
+ SOLENOID_PIN_WRITE_ACTIVE();
}
} else {
if (solenoid_buzzing) {
solenoid_buzzing = false;
- writePinLow(SOLENOID_PIN);
+ SOLENOID_PIN_WRITE_INACTIVE();
}
}
}
}
void solenoid_setup(void) {
+ SOLENOID_PIN_WRITE_INACTIVE();
setPinOutput(SOLENOID_PIN);
- solenoid_fire();
+ if ((!HAPTIC_OFF_IN_LOW_POWER) || (usb_device_state == USB_DEVICE_STATE_CONFIGURED)) {
+ solenoid_fire();
+ }
}
-void solenoid_shutdown(void) { writePinLow(SOLENOID_PIN); }
+void solenoid_shutdown(void) { SOLENOID_PIN_WRITE_INACTIVE(); }