4 * This file is part of BeRTOS.
6 * Bertos is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 * As a special exception, you may use this file as part of a free software
21 * library without restriction. Specifically, if other files instantiate
22 * templates or use macros or inline functions from this file, or you compile
23 * this file and link it with other files to produce an executable, this
24 * file does not by itself cause the resulting executable to be covered by
25 * the GNU General Public License. This exception does not however
26 * invalidate any other reasons why the executable file might be covered by
27 * the GNU General Public License.
29 * Copyright 2003, 2004, 2006, 2008, 2010 Develer S.r.l. (http://www.develer.com/)
30 * Copyright 2000 Bernie Innocenti <bernie@codewiz.org>
34 * \author Marco Benelli <marco@develer.com>
35 * \author Bernie Innocenti <bernie@codewiz.org>
36 * \author Daniele Basile <asterix@develer.com>
38 * \brief Triface application.
40 * This application manage some devices, like buzzer, digital in/out or analogic input.
41 * To controll all devices the application provide the interactive shell
42 * that allow the user to send commands to the board. All commands are generate
43 * throuth the macro, that convert its parameters, at compile time, to C function.
44 * In this way is more simple to implement the new command. Other that, the application,
45 * automaticly, parse this new command from the shell and call the our function.
46 * Actually this application runs on custom hardware, that you can see the scheme on bertos
47 * site, this hardware is able to read the tags string that come from rfid reader and
48 * print this on another serial port. The main scope of this function is to create
49 * the automatic opendoor, reading the tag key that will pass on the rfid reader.
54 #include "hw/hw_input.h"
56 #include <cfg/macros.h>
58 #include <drv/timer.h>
59 #include <drv/buzzer.h>
63 #include <mware/parser.h>
64 #include <net/keytag.h>
67 static Serial tag_ser;
69 static void init(void)
84 /* Initialize Tag serial port and data structure */
87 /* Open the main communication port */
88 ser_init(&fd_ser, SER_UART1);
89 ser_setbaudrate(&fd_ser, 115200);
91 /* Tag reader serial port */
92 ser_init(&tag_ser, SER_UART0);
93 ser_setbaudrate(&tag_ser, 9600);
95 /* Init the tag parser */
96 keytag_init(&pkt, &fd_ser.fd, &tag_ser.fd);
98 protocol_init(&fd_ser.fd);
102 protocol_run(&fd_ser.fd);
104 uint8_t buf[CONFIG_TAG_MAX_LEN];
106 /* Read the new tag, if this is avaible */
107 if ((len = keytag_recv(&pkt, buf, sizeof(buf))) != EOF)
108 kfile_write(&fd_ser.fd, buf, len);