summaryrefslogtreecommitdiff
path: root/digital/avr
diff options
context:
space:
mode:
authorNicolas Schodet2012-04-03 00:49:55 +0200
committerNicolas Schodet2012-04-06 23:55:25 +0200
commitfa1dc85d0a8ca03e24a8c48d7916f272c3f138e6 (patch)
tree75592df9c2da334a46cc79cafc0d5596d44bd383 /digital/avr
parent720037c9a21a15910266fad2650fc446faa6ed58 (diff)
digital/avr/modules/proto: add automatic send[bwd] with n arguments
Diffstat (limited to 'digital/avr')
-rw-r--r--digital/avr/modules/proto/proto_inline.c11
-rw-r--r--digital/avr/modules/proto/test/test_proto.c2
2 files changed, 13 insertions, 0 deletions
diff --git a/digital/avr/modules/proto/proto_inline.c b/digital/avr/modules/proto/proto_inline.c
index 43110c8e..58779ec8 100644
--- a/digital/avr/modules/proto/proto_inline.c
+++ b/digital/avr/modules/proto/proto_inline.c
@@ -23,6 +23,17 @@
*
* }}} */
#include "modules/utils/byte.h"
+#include "preproc.h"
+
+/** Send a command with n byte arguments. */
+#define proto_sendb(cmd, args...) \
+ PREPROC_PASTE (proto_send, PREPROC_NARG (args), b) (cmd, args)
+/** Send a command with n word arguments. */
+#define proto_sendw(cmd, args...) \
+ PREPROC_PASTE (proto_send, PREPROC_NARG (args), w) (cmd, args)
+/** Send a command with n double word arguments. */
+#define proto_sendd(cmd, args...) \
+ PREPROC_PASTE (proto_send, PREPROC_NARG (args), d) (cmd, args)
/** Send a command with no argument. */
extern inline void
diff --git a/digital/avr/modules/proto/test/test_proto.c b/digital/avr/modules/proto/test/test_proto.c
index 21edaf59..c3d1fe2e 100644
--- a/digital/avr/modules/proto/test/test_proto.c
+++ b/digital/avr/modules/proto/test/test_proto.c
@@ -52,6 +52,8 @@ proto_callback (uint8_t cmd, uint8_t size, uint8_t *args)
proto_send1b ('e', 0xf0);
proto_send2w ('l', 0x1234, 0x5678);
proto_send1d ('o', 0x12345678);
+ proto_sendb ('p', 1);
+ proto_sendb ('p', 1, 2, 3, 4);
{
volatile uint32_t i = 0x12345678;
proto_send1d ('i', i);