summaryrefslogtreecommitdiff
path: root/usb-i2c-sl018
diff options
context:
space:
mode:
authorChristian Pointner <equinox@spreadspace.org>2013-02-06 00:54:15 +0000
committerChristian Pointner <equinox@spreadspace.org>2013-02-06 00:54:15 +0000
commit64d7ae4747041352edeb9cbf5418b0ab274da5e1 (patch)
tree3b14302cf6473d8c848bf370076257310792835a /usb-i2c-sl018
parentstepper works now (diff)
added open and close command
git-svn-id: https://svn.spreadspace.org/avr/trunk@123 aa12f405-d877-488e-9caf-2d797e2a1cc7
Diffstat (limited to 'usb-i2c-sl018')
-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;
}
}