summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--usb-i2c-sl018/stepper.c7
-rw-r--r--usb-i2c-sl018/stepper.h2
-rw-r--r--usb-i2c-sl018/tuer-rfid.c12
3 files changed, 19 insertions, 2 deletions
diff --git a/usb-i2c-sl018/stepper.c b/usb-i2c-sl018/stepper.c
index f8f2991..4258da7 100644
--- a/usb-i2c-sl018/stepper.c
+++ b/usb-i2c-sl018/stepper.c
@@ -95,8 +95,11 @@ void init_stepper(void)
STEPPER_DDR |= (0xF << STEPPER_FIRST_BIT) | (1<<STEPPER_ENABLE_BIT);
}
-void start_stepper(stepper_direction_t direction)
+uint8_t start_stepper(stepper_direction_t direction)
{
+ if(TCCR1B)
+ return 0;
+
step_cnt = 0;
step_direction = direction;
STEPPER_PORT |= 1<<STEPPER_ENABLE_BIT;
@@ -108,6 +111,8 @@ void start_stepper(stepper_direction_t direction)
//OCR1A = 155; // (1+155)*256 = 40000 -> 2 ms @ 20 MHz
TCNT1 = 0; // reseting timer
TIMSK1 = 1<<OCIE1A; // enable Interrupt
+
+ return 1;
}
diff --git a/usb-i2c-sl018/stepper.h b/usb-i2c-sl018/stepper.h
index 257f81b..8e85dde 100644
--- a/usb-i2c-sl018/stepper.h
+++ b/usb-i2c-sl018/stepper.h
@@ -28,7 +28,7 @@ typedef enum { dir_open = 0, dir_close = 1 } stepper_direction_t;
//uint8_t handle_step(void);
void init_stepper(void);
-void start_stepper(stepper_direction_t direction);
+uint8_t start_stepper(stepper_direction_t direction);
//void stop_stepper(void);
#endif
diff --git a/usb-i2c-sl018/tuer-rfid.c b/usb-i2c-sl018/tuer-rfid.c
index 1817239..7fa7d14 100644
--- a/usb-i2c-sl018/tuer-rfid.c
+++ b/usb-i2c-sl018/tuer-rfid.c
@@ -344,6 +344,18 @@ void handle_stdio(uint8_t cmd)
case 'd': //dump eeprom - this breaks security!
dump_keystore_to_stdio();
break;
+ case 'o':
+ if(start_stepper(dir_open))
+ fprintf(stdio, "ok\n\r");
+ else
+ fprintf(stdio, "error: already in progress\n\r");
+ break;
+ case 'c':
+ if(start_stepper(dir_close))
+ fprintf(stdio, "ok\n\r");
+ else
+ fprintf(stdio, "error: already in progress\n\r");
+ break;
default: fprintf(stdio, "error, unknown command %02X '%c'\n\r",cmd, cmd); return;
}
}