summaryrefslogtreecommitdiff
path: root/n/avr/proto/proto_inline.c
diff options
context:
space:
mode:
Diffstat (limited to 'n/avr/proto/proto_inline.c')
-rw-r--r--n/avr/proto/proto_inline.c165
1 files changed, 109 insertions, 56 deletions
diff --git a/n/avr/proto/proto_inline.c b/n/avr/proto/proto_inline.c
index 2919c50..bbeee20 100644
--- a/n/avr/proto/proto_inline.c
+++ b/n/avr/proto/proto_inline.c
@@ -27,133 +27,186 @@
extern inline void
proto_send0 (uint8_t cmd)
{
- proto_send (cmd, 0, 0);
+ proto_putc ('!');
+ proto_putc (cmd);
+ proto_putc ('\r');
}
/* 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);
+ proto_putc ('!');
+ proto_putc (cmd);
+ proto_arg (arg0);
+ proto_putc ('\r');
}
/* 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);
+ proto_putc ('!');
+ proto_putc (cmd);
+ proto_arg ((arg0 >> 8) & 0xff);
+ proto_arg ((arg0 >> 0) & 0xff);
+ proto_putc ('\r');
}
/* 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);
+ proto_putc ('!');
+ proto_putc (cmd);
+ proto_arg ((arg0 >> 24) & 0xff);
+ proto_arg ((arg0 >> 16) & 0xff);
+ proto_arg ((arg0 >> 8) & 0xff);
+ proto_arg ((arg0 >> 0) & 0xff);
+ proto_putc ('\r');
}
/* 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);
+ proto_putc ('!');
+ proto_putc (cmd);
+ proto_arg (arg0);
+ proto_arg (arg1);
+ proto_putc ('\r');
}
/* 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);
+ proto_putc ('!');
+ proto_putc (cmd);
+ proto_arg ((arg0 >> 8) & 0xff);
+ proto_arg ((arg0 >> 0) & 0xff);
+ proto_arg ((arg1 >> 8) & 0xff);
+ proto_arg ((arg1 >> 0) & 0xff);
+ proto_putc ('\r');
}
/* 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);
+ proto_putc ('!');
+ proto_putc (cmd);
+ proto_arg ((arg0 >> 24) & 0xff);
+ proto_arg ((arg0 >> 16) & 0xff);
+ proto_arg ((arg0 >> 8) & 0xff);
+ proto_arg ((arg0 >> 0) & 0xff);
+ proto_arg ((arg1 >> 24) & 0xff);
+ proto_arg ((arg1 >> 16) & 0xff);
+ proto_arg ((arg1 >> 8) & 0xff);
+ proto_arg ((arg1 >> 0) & 0xff);
+ proto_putc ('\r');
}
/* 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);
+ proto_putc ('!');
+ proto_putc (cmd);
+ proto_arg (arg0);
+ proto_arg (arg1);
+ proto_arg (arg2);
+ proto_putc ('\r');
}
/* 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);
+ proto_putc ('!');
+ proto_putc (cmd);
+ proto_arg ((arg0 >> 8) & 0xff);
+ proto_arg ((arg0 >> 0) & 0xff);
+ proto_arg ((arg1 >> 8) & 0xff);
+ proto_arg ((arg1 >> 0) & 0xff);
+ proto_arg ((arg2 >> 8) & 0xff);
+ proto_arg ((arg2 >> 0) & 0xff);
+ proto_putc ('\r');
}
/* 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);
+ proto_putc ('!');
+ proto_putc (cmd);
+ proto_arg ((arg0 >> 24) & 0xff);
+ proto_arg ((arg0 >> 16) & 0xff);
+ proto_arg ((arg0 >> 8) & 0xff);
+ proto_arg ((arg0 >> 0) & 0xff);
+ proto_arg ((arg1 >> 24) & 0xff);
+ proto_arg ((arg1 >> 16) & 0xff);
+ proto_arg ((arg1 >> 8) & 0xff);
+ proto_arg ((arg1 >> 0) & 0xff);
+ proto_arg ((arg2 >> 24) & 0xff);
+ proto_arg ((arg2 >> 16) & 0xff);
+ proto_arg ((arg2 >> 8) & 0xff);
+ proto_arg ((arg2 >> 0) & 0xff);
+ proto_putc ('\r');
}
/* 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);
+ proto_putc ('!');
+ proto_putc (cmd);
+ proto_arg (arg0);
+ proto_arg (arg1);
+ proto_arg (arg2);
+ proto_arg (arg3);
+ proto_putc ('\r');
}
/* 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);
+ proto_putc ('!');
+ proto_putc (cmd);
+ proto_arg ((arg0 >> 8) & 0xff);
+ proto_arg ((arg0 >> 0) & 0xff);
+ proto_arg ((arg1 >> 8) & 0xff);
+ proto_arg ((arg1 >> 0) & 0xff);
+ proto_arg ((arg2 >> 8) & 0xff);
+ proto_arg ((arg2 >> 0) & 0xff);
+ proto_arg ((arg3 >> 8) & 0xff);
+ proto_arg ((arg3 >> 0) & 0xff);
+ proto_putc ('\r');
}
/* 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);
+ proto_putc ('!');
+ proto_putc (cmd);
+ proto_arg ((arg0 >> 24) & 0xff);
+ proto_arg ((arg0 >> 16) & 0xff);
+ proto_arg ((arg0 >> 8) & 0xff);
+ proto_arg ((arg0 >> 0) & 0xff);
+ proto_arg ((arg1 >> 24) & 0xff);
+ proto_arg ((arg1 >> 16) & 0xff);
+ proto_arg ((arg1 >> 8) & 0xff);
+ proto_arg ((arg1 >> 0) & 0xff);
+ proto_arg ((arg2 >> 24) & 0xff);
+ proto_arg ((arg2 >> 16) & 0xff);
+ proto_arg ((arg2 >> 8) & 0xff);
+ proto_arg ((arg2 >> 0) & 0xff);
+ proto_arg ((arg3 >> 24) & 0xff);
+ proto_arg ((arg3 >> 16) & 0xff);
+ proto_arg ((arg3 >> 8) & 0xff);
+ proto_arg ((arg3 >> 0) & 0xff);
+ proto_putc ('\r');
}