From 0d53478381fe1297d6fd56e05f4a43a2179d2505 Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Wed, 6 Feb 2013 02:47:46 +0000 Subject: added first version for ledmatrix driver git-svn-id: https://svn.spreadspace.org/avr/trunk@125 aa12f405-d877-488e-9caf-2d797e2a1cc7 --- usb-i2c-sl018/Makefile | 2 +- usb-i2c-sl018/ledmatrix.c | 108 ++++++++++++++++++++++++++++++++++++++++++++++ usb-i2c-sl018/ledmatrix.h | 34 +++++++++++++++ usb-i2c-sl018/tuer-rfid.c | 21 +++++---- 4 files changed, 155 insertions(+), 10 deletions(-) create mode 100644 usb-i2c-sl018/ledmatrix.c create mode 100644 usb-i2c-sl018/ledmatrix.h (limited to 'usb-i2c-sl018') 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 + * Othmar Gsenger + * + * 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 . + */ + +#include +#include + +#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< + * Othmar Gsenger + * + * 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 . + */ + +#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(); -- cgit v1.2.3