summaryrefslogtreecommitdiff
path: root/n/avr/proto/proto_inline.c
diff options
context:
space:
mode:
authorschodet2005-01-20 23:51:01 +0000
committerschodet2005-01-20 23:51:01 +0000
commit063362de35410ac94c958db519264d86d498d5ca (patch)
treec00bcc252832909025d31f546aff0f407b399559 /n/avr/proto/proto_inline.c
parent1b06d41e837f192a9f94c2c92ffa7a0d92c37118 (diff)
Modification du fonctionnement de proto.
Diffstat (limited to 'n/avr/proto/proto_inline.c')
-rw-r--r--n/avr/proto/proto_inline.c159
1 files changed, 159 insertions, 0 deletions
diff --git a/n/avr/proto/proto_inline.c b/n/avr/proto/proto_inline.c
new file mode 100644
index 0000000..2919c50
--- /dev/null
+++ b/n/avr/proto/proto_inline.c
@@ -0,0 +1,159 @@
+/* proto_inline.c */
+/* {{{
+ *
+ * Copyright (C) 2005 Nicolas Schodet
+ *
+ * Robot APB Team/Efrei 2005.
+ * Web: http://assos.efrei.fr/robot/
+ * Email: 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.
+ *
+ * }}} */
+
+/* Send a command with no argument. */
+extern inline void
+proto_send0 (uint8_t cmd)
+{
+ proto_send (cmd, 0, 0);
+}
+
+/* Send a command with 1 byte argument. */
+extern inline void
+proto_send1b (uint8_t cmd, uint8_t arg0)
+{
+ uint8_t args[1];
+ args[0] = arg0;
+ proto_send (cmd, 1, args);
+}
+
+/* Send a command with 1 word argument. */
+extern inline void
+proto_send1w (uint8_t cmd, uint16_t arg0)
+{
+ uint8_t args[1 * 2];
+ args[0] = (arg0 >> 0) & 0xff;
+ args[0] = (arg0 >> 8) & 0xff;
+ proto_send (cmd, 1 * 2, args);
+}
+
+/* Send a command with 1 double word argument. */
+extern inline void
+proto_send1d (uint8_t cmd, uint32_t arg0)
+{
+ uint8_t args[1 * 4];
+ args[0] = arg0;
+ proto_send (cmd, 1 * 4, args);
+}
+
+/* Send a command with 2 bytes arguments. */
+extern inline void
+proto_send2b (uint8_t cmd, uint8_t arg0, uint8_t arg1)
+{
+ uint8_t args[2];
+ args[0] = arg0;
+ args[1] = arg1;
+ proto_send (cmd, 2, args);
+}
+
+/* Send a command with 2 words arguments. */
+extern inline void
+proto_send2w (uint8_t cmd, uint16_t arg0, uint16_t arg1)
+{
+ uint8_t args[2 * 2];
+ args[0] = arg0;
+ args[1] = arg1;
+ proto_send (cmd, 2 * 2, args);
+}
+
+/* Send a command with 2 double words arguments. */
+extern inline void
+proto_send2d (uint8_t cmd, uint32_t arg0, uint32_t arg1)
+{
+ uint8_t args[2 * 4];
+ args[0] = arg0;
+ args[1] = arg1;
+ proto_send (cmd, 2 * 4, args);
+}
+
+/* Send a command with 3 bytes arguments. */
+extern inline void
+proto_send3b (uint8_t cmd, uint8_t arg0, uint8_t arg1, uint8_t arg2)
+{
+ uint8_t args[3];
+ args[0] = arg0;
+ args[1] = arg1;
+ args[2] = arg2;
+ proto_send (cmd, 3, args);
+}
+
+/* Send a command with 3 words arguments. */
+extern inline void
+proto_send3w (uint8_t cmd, uint16_t arg0, uint16_t arg1, uint16_t arg2)
+{
+ uint8_t args[3 * 2];
+ args[0] = arg0;
+ args[1] = arg1;
+ args[2] = arg2;
+ proto_send (cmd, 3 * 2, args);
+}
+
+/* Send a command with 3 double words arguments. */
+extern inline void
+proto_send3d (uint8_t cmd, uint32_t arg0, uint32_t arg1, uint32_t arg2)
+{
+ uint8_t args[3 * 4];
+ args[0] = arg0;
+ args[1] = arg1;
+ args[2] = arg2;
+ proto_send (cmd, 3 * 4, args);
+}
+
+/* Send a command with 4 bytes arguments. */
+extern inline void
+proto_send4b (uint8_t cmd, uint8_t arg0, uint8_t arg1, uint8_t arg2, uint8_t arg3)
+{
+ uint8_t args[4];
+ args[0] = arg0;
+ args[1] = arg1;
+ args[2] = arg2;
+ args[3] = arg3;
+ proto_send (cmd, 4, args);
+}
+
+/* Send a command with 4 words arguments. */
+extern inline void
+proto_send4w (uint8_t cmd, uint16_t arg0, uint16_t arg1, uint16_t arg2, uint16_t arg3)
+{
+ uint8_t args[4 * 2];
+ args[0] = arg0;
+ args[1] = arg1;
+ args[2] = arg2;
+ args[3] = arg3;
+ proto_send (cmd, 4 * 2, args);
+}
+
+/* Send a command with 4 double words arguments. */
+extern inline void
+proto_send4d (uint8_t cmd, uint32_t arg0, uint32_t arg1, uint32_t arg2, uint32_t arg3)
+{
+ uint8_t args[4 * 4];
+ args[0] = arg0;
+ args[1] = arg1;
+ args[2] = arg2;
+ args[3] = arg3;
+ proto_send (cmd, 4 * 4, args);
+}
+