summaryrefslogtreecommitdiff
path: root/2004/n/asserv/src/serial.h
diff options
context:
space:
mode:
authorschodet2003-09-30 22:17:01 +0000
committerschodet2003-09-30 22:17:01 +0000
commitea695ca13b725b6f2037986ef26fa1fea06b8faf (patch)
tree3dbe01ef7cca286eca1ad9433599699fa8f5ea52 /2004/n/asserv/src/serial.h
parent45e9ad53c377e594e03bf14fa4c6bab5322ada64 (diff)
Initial revision
Diffstat (limited to '2004/n/asserv/src/serial.h')
-rw-r--r--2004/n/asserv/src/serial.h86
1 files changed, 86 insertions, 0 deletions
diff --git a/2004/n/asserv/src/serial.h b/2004/n/asserv/src/serial.h
new file mode 100644
index 0000000..e06c1f0
--- /dev/null
+++ b/2004/n/asserv/src/serial.h
@@ -0,0 +1,86 @@
+#ifndef serial_h
+#define serial_h
+/* serial.h */
+/* APBTasserv - asservissement Robot 2004 {{{
+ *
+ * Copyright (C) 2003 Nicolas Schodet
+ *
+ * Robot APB Team/Efrei 2004.
+ * Web: http://assos.efrei.fr/robot/
+ * Mail: robot AT efrei DOT fr
+ *
+ * This program 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 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * }}} */
+
+/* Tampon de reception. */
+#define SERIAL_RECV_BUF_LEN 20
+extern char serial_recv_buf[SERIAL_RECV_BUF_LEN];
+extern int serial_recv_buf_n;
+
+/* Macros de récupération de la commande recu. */
+#define HEXBIN(a) (((a) >= '0' && (a) <= '9') ? (a) - '0' : (a) - ('a' + 10))
+#define serial_recv_com() \
+ (serial_recv_buf[0])
+#define serial_recv_int(v) \
+ ((v) = HEXBIN (serial_recv_buf[1]) << 4 | HEXBIN (serial_recv_buf[2]))
+#define serial_recv_int1(v) \
+ ((v) = HEXBIN (serial_recv_buf[3]) << 4 | HEXBIN (serial_recv_buf[4]))
+#define serial_recv_long(v) \
+ ((v) = make16 (HEXBIN (serial_recv_buf[0]) << 4 | HEXBIN \
+ (serial_recv_buf[1]), \
+ HEXBIN (serial_recv_buf[2]) << 4 | HEXBIN \
+ (serial_recv_buf[3])))
+#define serial_recv_bool(v) \
+ ((v) = serial_recv_buf[1] == '1')
+
+
+/* +AutoDec */
+
+/* Initialise la reception serie. */
+void
+serial_init (void);
+
+/* Recois des caractères. */
+#int_RDA
+serial_recv ();
+
+/* Traite la commande recue. */
+void
+serial_parse (void);
+
+/* Envoie un code d'erreur. */
+void
+serial_send_error (char c);
+
+/* Envoie un code ok. */
+void
+serial_send_ok (char c);
+
+/* Envoie un rapport d'un moteur. */
+void
+serial_send_motor_stat (char side, unsigned int vacc, unsigned long &e, unsigned long &pwm);
+
+/* Envoie un long. */
+void
+serial_send_long (unsigned long &value);
+
+/* Envoie un int. */
+void
+serial_send_int (unsigned int &value);
+
+/* -AutoDec */
+
+#endif /* serial_h */