diff options
-rw-r--r-- | usb-i2c-sl018/Makefile | 2 | ||||
-rw-r--r-- | usb-i2c-sl018/ledmatrix.c | 108 | ||||
-rw-r--r-- | usb-i2c-sl018/ledmatrix.h | 34 | ||||
-rw-r--r-- | usb-i2c-sl018/tuer-rfid.c | 21 |
4 files changed, 155 insertions, 10 deletions
diff --git a/usb-i2c-sl018/Makefile b/usb-i2c-sl018/Makefile index cb6e98b..989b741 100644 --- a/usb-i2c-sl018/Makefile +++ b/usb-i2c-sl018/Makefile @@ -23,7 +23,7 @@ NAME := tuer-rfid
BOARD_TYPE := teensy2
-OBJ := $(NAME).o heartbeat.o stepper.o
+OBJ := $(NAME).o heartbeat.o stepper.o ledmatrix.o
LIBS := util led lufa-descriptor-usbserial
EXTERNAL_LIBS := lufa
diff --git a/usb-i2c-sl018/ledmatrix.c b/usb-i2c-sl018/ledmatrix.c new file mode 100644 index 0000000..f0b4ba8 --- /dev/null +++ b/usb-i2c-sl018/ledmatrix.c @@ -0,0 +1,108 @@ +/* + * spreadspace avr utils + * + * + * Copyright (C) 2013 Christian Pointner <equinox@spreadspace.org> + * Othmar Gsenger <otti@wirdorange.org> + * + * This file is part of spreadspace avr utils. + * + * spreadspace avr utils is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * spreadspace avr utils is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with spreadspace avr utils. If not, see <http://www.gnu.org/licenses/>. + */ + +#include <avr/sfr_defs.h> +#include <avr/interrupt.h> + +#include "ledmatrix.h" + +#define LEDMATRIX_PORT PORTB +#define LEDMATRIX_DDR DDRB +#define LEDMATRIX_RED 6 +#define LEDMATRIX_GREEN 7 +#define LEDMATRIX_MASK 0x3F + +ledmatrix_mode_t mode = off; + +void ledmatrix_off(void) +{ + LEDMATRIX_PORT = LEDMATRIX_MASK; + LEDMATRIX_PORT |= 1<<LEDMATRIX_RED | 1<<LEDMATRIX_GREEN; +} + +void ledmatrix_red(void) +{ + LEDMATRIX_PORT = LEDMATRIX_MASK | 1<<LEDMATRIX_GREEN; + LEDMATRIX_PORT &= ~(1<<LEDMATRIX_RED); +} + +void ledmatrix_red_moving(void) +{ + +} + +void ledmatrix_red_blink(void) +{ + +} + +void ledmatrix_green(void) +{ + LEDMATRIX_PORT = LEDMATRIX_MASK | 1<<LEDMATRIX_RED; + LEDMATRIX_PORT &= ~(1<<LEDMATRIX_GREEN); +} + +void ledmatrix_green_moving(void) +{ + +} + +void ledmatrix_green_blink(void) +{ + +} + +void ledmatrix_rg_moving(void) +{ + +} + +void ledmatrix_rg_blink(void) +{ + +} + + +void init_ledmatrix(void) +{ + LEDMATRIX_DDR = 0xFF; + LEDMATRIX_PORT = 0xFF; +} + +void ledmatrix(ledmatrix_mode_t m) +{ + mode = m; + + switch(mode) + { + case off: ledmatrix_off(); break; + case red: ledmatrix_red(); break; + case red_moving: ledmatrix_red_moving(); break; + case red_blink: ledmatrix_red_blink(); break; + case green: ledmatrix_green(); break; + case green_moving: ledmatrix_green_moving(); break; + case green_blink: ledmatrix_green_blink(); break; + case rg_moving: ledmatrix_rg_moving(); break; + case rg_blink: ledmatrix_rg_blink(); break; + } +} diff --git a/usb-i2c-sl018/ledmatrix.h b/usb-i2c-sl018/ledmatrix.h new file mode 100644 index 0000000..e7ad817 --- /dev/null +++ b/usb-i2c-sl018/ledmatrix.h @@ -0,0 +1,34 @@ +/* + * spreadspace avr utils + * + * + * Copyright (C) 2013 Christian Pointner <equinox@spreadspace.org> + * Othmar Gsenger <otti@wirdorange.org> + * + * This file is part of spreadspace avr utils. + * + * spreadspace avr utils is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * spreadspace avr utils is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with spreadspace avr utils. If not, see <http://www.gnu.org/licenses/>. + */ + +#ifndef R3TUER_ledmatrix_h_INCLUDED +#define R3TUER_ledmatrix_h_INCLUDED + +typedef enum { off, red, red_moving, red_blink, + green, green_moving, green_blink, + rg_moving, rg_blink } ledmatrix_mode_t; + +void init_ledmatrix(void); +void ledmatrix(ledmatrix_mode_t mode); + +#endif diff --git a/usb-i2c-sl018/tuer-rfid.c b/usb-i2c-sl018/tuer-rfid.c index 5182aa1..3b6b0da 100644 --- a/usb-i2c-sl018/tuer-rfid.c +++ b/usb-i2c-sl018/tuer-rfid.c @@ -34,6 +34,7 @@ #include "heartbeat.h"
#include "stepper.h"
+#include "ledmatrix.h"
#include "LUFA/Drivers/Peripheral/TWI.h"
#include "LUFA/Drivers/Peripheral/Serial.h"
@@ -320,7 +321,7 @@ void handle_stdio(uint8_t cmd) case 'r':
reset2bootloader();
break;
- case '0':
+ case 'R':
if(!sl018_reset())
fprintf(stdio, "ok\n\r");
break;
@@ -330,14 +331,6 @@ void handle_stdio(uint8_t cmd) fprintf(stdio, "%s\n\r",twi_recv_msg->data);
}
break;
- case '4': //turn cardreader led off
- if(!sl018_cmd(SL018_CMD_ComRedLedOff))
- fprintf(stdio, "ok\n\r");
- break;
- case '5': //turn cardreader led on
- if(!sl018_cmd(SL018_CMD_ComRedLedOn))
- fprintf(stdio, "ok\n\r");
- break;
case 'e': //flash eeprom
flash_keystore_from_stdio();
break;
@@ -356,6 +349,15 @@ void handle_stdio(uint8_t cmd) else
fprintf(stdio, "error: already in progress\n\r");
break;
+ case '0': ledmatrix(off); break;
+ case '1': ledmatrix(red); break;
+ case '2': ledmatrix(red_moving); break;
+ case '3': ledmatrix(red_blink); break;
+ case '4': ledmatrix(green); break;
+ case '5': ledmatrix(green_moving); break;
+ case '6': ledmatrix(green_blink); break;
+ case '7': ledmatrix(rg_moving); break;
+ case '8': ledmatrix(rg_blink); break;
default: fprintf(stdio, "error, unknown command %02X '%c'\n\r",cmd, cmd); return;
}
}
@@ -453,6 +455,7 @@ int main(void) init_heartbeat();
init_stepper();
+ init_ledmatrix();
sl018_reset();
|