summaryrefslogtreecommitdiff
path: root/usb-i2c-sl018/limits.c
diff options
context:
space:
mode:
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;
}
-