summaryrefslogtreecommitdiff
path: root/n/avr/proto/proto_inline.c
blob: 2919c509a0d5d94d412ace5b109648ad07c11484 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
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);
}