summaryrefslogtreecommitdiff
path: root/usb-i2c-sl018/limits.c
diff options
context:
space:
mode:
authorChristian Pointner <equinox@spreadspace.org>2013-02-06 23:55:03 +0000
committerChristian Pointner <equinox@spreadspace.org>2013-02-06 23:55:03 +0000
commit39cdfa41fda19c6b9a5f5f7bb03f78b19fe05e6c (patch)
tree638df46085e7ea6d818a5b396b2a73dd4f53a66b /usb-i2c-sl018/limits.c
parentstatemachine enhanced (diff)
limits work now
added ledmatrix actions to state git-svn-id: https://svn.spreadspace.org/avr/trunk@155 aa12f405-d877-488e-9caf-2d797e2a1cc7
Diffstat (limited to 'usb-i2c-sl018/limits.c')
-rw-r--r--usb-i2c-sl018/limits.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/usb-i2c-sl018/limits.c b/usb-i2c-sl018/limits.c
index 471f894..8b75024 100644
--- a/usb-i2c-sl018/limits.c
+++ b/usb-i2c-sl018/limits.c
@@ -32,17 +32,21 @@
void init_limits(void)
{
- LIMITS_DDR = LIMITS_PORT & ~(1<<LIMITS_OPEN | 1<<LIMITS_CLOSE);
+ LIMITS_DDR = LIMITS_DDR & ~(1<<LIMITS_OPEN | 1<<LIMITS_CLOSE);
LIMITS_PORT |= (1<<LIMITS_OPEN | 1<<LIMITS_CLOSE);
}
limits_t limits_get(void)
{
- limits_t state = moving;
-
- uint8_t tmp = LIMITS_PORT & (1<<LIMITS_OPEN | 1<<LIMITS_CLOSE);
-
+ uint8_t tmp = LIMITS_PIN & (1<<LIMITS_OPEN | 1<<LIMITS_CLOSE);
+ if(!(tmp & 1<<LIMITS_OPEN)) {
+ if(tmp & 1<<LIMITS_CLOSE)
+ return open;
+ else
+ return both;
+ }
+ else if(!(tmp & 1<<LIMITS_CLOSE))
+ return close;
- return state;
+ return moving;
}
-