From fa1dc85d0a8ca03e24a8c48d7916f272c3f138e6 Mon Sep 17 00:00:00 2001 From: Nicolas Schodet Date: Tue, 3 Apr 2012 00:49:55 +0200 Subject: digital/avr/modules/proto: add automatic send[bwd] with n arguments --- digital/avr/modules/proto/proto_inline.c | 11 +++++++++++ digital/avr/modules/proto/test/test_proto.c | 2 ++ 2 files changed, 13 insertions(+) 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); -- cgit v1.2.3