summaryrefslogtreecommitdiff
path: root/n
diff options
context:
space:
mode:
Diffstat (limited to 'n')
-rw-r--r--n/avr/proto/avrconfig.h6
-rw-r--r--n/avr/proto/proto.c16
-rw-r--r--n/avr/proto/proto.h4
-rw-r--r--n/avr/proto/proto_inline.c78
4 files changed, 55 insertions, 49 deletions
diff --git a/n/avr/proto/avrconfig.h b/n/avr/proto/avrconfig.h
index 7935ea3..6ed37bd 100644
--- a/n/avr/proto/avrconfig.h
+++ b/n/avr/proto/avrconfig.h
@@ -28,4 +28,10 @@
/** Maximum argument size. */
#define AC_PROTO_ARGS_MAX_SIZE 8
+/** Callback function name. */
+#define AC_PROTO_CALLBACK proto_callback
+
+/** Putchar function name. */
+#define AC_PROTO_PUTC rs232_putc
+
#endif /* avrconfig_h */
diff --git a/n/avr/proto/proto.c b/n/avr/proto/proto.c
index 2a62381..ddba80b 100644
--- a/n/avr/proto/proto.c
+++ b/n/avr/proto/proto.c
@@ -71,7 +71,7 @@ proto_accept (uint8_t c)
}
else
{
- proto_callback ('?', 0, 0);
+ AC_PROTO_CALLBACK ('?', 0, 0);
step = 0;
}
break;
@@ -79,7 +79,7 @@ proto_accept (uint8_t c)
/* Command received yet. */
if (c == '\r')
{
- proto_callback (cmd, size, args);
+ AC_PROTO_CALLBACK (cmd, size, args);
step = 0;
}
else
@@ -103,7 +103,7 @@ proto_accept_digit (uint8_t c)
/* Test for argument list overflow. */
if (size >= AC_PROTO_ARGS_MAX_SIZE)
{
- proto_callback ('?', 0, 0);
+ AC_PROTO_CALLBACK ('?', 0, 0);
step = 0;
return;
}
@@ -116,7 +116,7 @@ proto_accept_digit (uint8_t c)
c -= 'A' - 10;
else
{
- proto_callback ('?', 0, 0);
+ AC_PROTO_CALLBACK ('?', 0, 0);
return;
}
/* Add digit. */
@@ -130,7 +130,7 @@ proto_accept_digit (uint8_t c)
inline static void
proto_hex (uint8_t h)
{
- proto_putc (h >= 10 ? h - 10 + 'a' : h + '0');
+ AC_PROTO_PUTC (h >= 10 ? h - 10 + 'a' : h + '0');
}
/* Send a argument byte. */
@@ -145,10 +145,10 @@ proto_arg (uint8_t a)
void
proto_send (uint8_t cmd, uint8_t size, uint8_t *args)
{
- proto_putc ('!');
- proto_putc (cmd);
+ AC_PROTO_PUTC ('!');
+ AC_PROTO_PUTC (cmd);
while (size--)
proto_arg (*args++);
- proto_putc ('\r');
+ AC_PROTO_PUTC ('\r');
}
diff --git a/n/avr/proto/proto.h b/n/avr/proto/proto.h
index c52bb35..a9a97a1 100644
--- a/n/avr/proto/proto.h
+++ b/n/avr/proto/proto.h
@@ -29,12 +29,12 @@
/** Protocol callback function. Take the command and the arguments. Must be
* defined by the user. */
void
-proto_callback (uint8_t cmd, uint8_t size, uint8_t *args);
+AC_PROTO_CALLBACK (uint8_t cmd, uint8_t size, uint8_t *args);
/** Protocol putc function. Take a char to send. Must be defined by the
* user. */
void
-proto_putc (uint8_t c);
+AC_PROTO_PUTC (uint8_t c);
/* +AutoDec */
diff --git a/n/avr/proto/proto_inline.c b/n/avr/proto/proto_inline.c
index bbeee20..f17b52b 100644
--- a/n/avr/proto/proto_inline.c
+++ b/n/avr/proto/proto_inline.c
@@ -27,75 +27,75 @@
extern inline void
proto_send0 (uint8_t cmd)
{
- proto_putc ('!');
- proto_putc (cmd);
- proto_putc ('\r');
+ AC_PROTO_PUTC ('!');
+ AC_PROTO_PUTC (cmd);
+ AC_PROTO_PUTC ('\r');
}
/* Send a command with 1 byte argument. */
extern inline void
proto_send1b (uint8_t cmd, uint8_t arg0)
{
- proto_putc ('!');
- proto_putc (cmd);
+ AC_PROTO_PUTC ('!');
+ AC_PROTO_PUTC (cmd);
proto_arg (arg0);
- proto_putc ('\r');
+ AC_PROTO_PUTC ('\r');
}
/* Send a command with 1 word argument. */
extern inline void
proto_send1w (uint8_t cmd, uint16_t arg0)
{
- proto_putc ('!');
- proto_putc (cmd);
+ AC_PROTO_PUTC ('!');
+ AC_PROTO_PUTC (cmd);
proto_arg ((arg0 >> 8) & 0xff);
proto_arg ((arg0 >> 0) & 0xff);
- proto_putc ('\r');
+ AC_PROTO_PUTC ('\r');
}
/* Send a command with 1 double word argument. */
extern inline void
proto_send1d (uint8_t cmd, uint32_t arg0)
{
- proto_putc ('!');
- proto_putc (cmd);
+ AC_PROTO_PUTC ('!');
+ AC_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');
+ AC_PROTO_PUTC ('\r');
}
/* Send a command with 2 bytes arguments. */
extern inline void
proto_send2b (uint8_t cmd, uint8_t arg0, uint8_t arg1)
{
- proto_putc ('!');
- proto_putc (cmd);
+ AC_PROTO_PUTC ('!');
+ AC_PROTO_PUTC (cmd);
proto_arg (arg0);
proto_arg (arg1);
- proto_putc ('\r');
+ AC_PROTO_PUTC ('\r');
}
/* Send a command with 2 words arguments. */
extern inline void
proto_send2w (uint8_t cmd, uint16_t arg0, uint16_t arg1)
{
- proto_putc ('!');
- proto_putc (cmd);
+ AC_PROTO_PUTC ('!');
+ AC_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');
+ AC_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)
{
- proto_putc ('!');
- proto_putc (cmd);
+ AC_PROTO_PUTC ('!');
+ AC_PROTO_PUTC (cmd);
proto_arg ((arg0 >> 24) & 0xff);
proto_arg ((arg0 >> 16) & 0xff);
proto_arg ((arg0 >> 8) & 0xff);
@@ -104,42 +104,42 @@ proto_send2d (uint8_t cmd, uint32_t arg0, uint32_t arg1)
proto_arg ((arg1 >> 16) & 0xff);
proto_arg ((arg1 >> 8) & 0xff);
proto_arg ((arg1 >> 0) & 0xff);
- proto_putc ('\r');
+ AC_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)
{
- proto_putc ('!');
- proto_putc (cmd);
+ AC_PROTO_PUTC ('!');
+ AC_PROTO_PUTC (cmd);
proto_arg (arg0);
proto_arg (arg1);
proto_arg (arg2);
- proto_putc ('\r');
+ AC_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)
{
- proto_putc ('!');
- proto_putc (cmd);
+ AC_PROTO_PUTC ('!');
+ AC_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');
+ AC_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)
{
- proto_putc ('!');
- proto_putc (cmd);
+ AC_PROTO_PUTC ('!');
+ AC_PROTO_PUTC (cmd);
proto_arg ((arg0 >> 24) & 0xff);
proto_arg ((arg0 >> 16) & 0xff);
proto_arg ((arg0 >> 8) & 0xff);
@@ -152,28 +152,28 @@ proto_send3d (uint8_t cmd, uint32_t arg0, uint32_t arg1, uint32_t arg2)
proto_arg ((arg2 >> 16) & 0xff);
proto_arg ((arg2 >> 8) & 0xff);
proto_arg ((arg2 >> 0) & 0xff);
- proto_putc ('\r');
+ AC_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)
{
- proto_putc ('!');
- proto_putc (cmd);
+ AC_PROTO_PUTC ('!');
+ AC_PROTO_PUTC (cmd);
proto_arg (arg0);
proto_arg (arg1);
proto_arg (arg2);
proto_arg (arg3);
- proto_putc ('\r');
+ AC_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)
{
- proto_putc ('!');
- proto_putc (cmd);
+ AC_PROTO_PUTC ('!');
+ AC_PROTO_PUTC (cmd);
proto_arg ((arg0 >> 8) & 0xff);
proto_arg ((arg0 >> 0) & 0xff);
proto_arg ((arg1 >> 8) & 0xff);
@@ -182,15 +182,15 @@ proto_send4w (uint8_t cmd, uint16_t arg0, uint16_t arg1, uint16_t arg2, uint16_t
proto_arg ((arg2 >> 0) & 0xff);
proto_arg ((arg3 >> 8) & 0xff);
proto_arg ((arg3 >> 0) & 0xff);
- proto_putc ('\r');
+ AC_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)
{
- proto_putc ('!');
- proto_putc (cmd);
+ AC_PROTO_PUTC ('!');
+ AC_PROTO_PUTC (cmd);
proto_arg ((arg0 >> 24) & 0xff);
proto_arg ((arg0 >> 16) & 0xff);
proto_arg ((arg0 >> 8) & 0xff);
@@ -207,6 +207,6 @@ proto_send4d (uint8_t cmd, uint32_t arg0, uint32_t arg1, uint32_t arg2, uint32_t
proto_arg ((arg3 >> 16) & 0xff);
proto_arg ((arg3 >> 8) & 0xff);
proto_arg ((arg3 >> 0) & 0xff);
- proto_putc ('\r');
+ AC_PROTO_PUTC ('\r');
}