--- /dev/null
+The UprintC component uses the uprintf() function. The MSP430 libc provides
+uprintf(), which can be trivially created for any other platform. The benefits
+of uprintf are:
+
+* No internal buffer; data are written as the format string is parsed.
+* By using a pointer to a putc() function, the function is usable for
+ multiple UARTs, when appropriate.
+
+An example of using UprintC is shown below.
+
+configuration AppC {
+ ...
+ components PlatformUartC as UartC;
+ AppP.UartResource -> UartC;
+ AppP.UartByte -> UartC;
+
+ components new UprintC();
+ AppP.Uprint -> UprintC;
+ UprintC.UartByte -> UartC;
+ ...
+}
+
+module AppP {
+ ...
+ #define cprintf(fmt, args...) uprintf(call Uprint.uptr(), fmt, ## args)
+ ...
+ cprintf("Hello, world!\r\n");
+ ...
+}
--- /dev/null
+/* Copyright (c) 2006-2009 by Sporian Microsystems, Inc.
+ * All Rights Reserved.
+ *
+ * This document is the proprietary and confidential property of Sporian
+ * Microsystems, Inc. All use, distribution, reproduction or re-distribution
+ * is disallowed without the prior express written consent of Sporian
+ * Microsystems, Inc.
+ */
+
+/**
+ * Simple dbgprintf helper
+ *
+ * @author R. Steve McKown <rsmckown@gmail.com>
+ */
+
+#ifndef UPRINT_H
+#define UPRINT_H
+
+typedef int (*uprint_ptr_t)();
+
+#endif /* end of include guard: UPRINT_H */
--- /dev/null
+/* Copyright (c) 2012 by Sporian Microsystems, Inc.
+ * All Rights Reserved.
+ *
+ * This document is the proprietary and confidential property of Sporian
+ * Microsystems, Inc. All use, distribution, reproduction or re-distribution
+ * is disallowed without the prior express written consent of Sporian
+ * Microsystems, Inc.
+ */
+
+/* A shim for putc to enable uprintf.
+ */
+
+#include <stdarg.h>
+#include "Uprint.h"
+
+interface Uprint {
+ async command uprint_ptr_t uptr();
+}
--- /dev/null
+/* Copyright (c) 2006-2009 by Sporian Microsystems, Inc.
+ * All Rights Reserved.
+ *
+ * This document is the proprietary and confidential property of Sporian
+ * Microsystems, Inc. All use, distribution, reproduction or re-distribution
+ * is disallowed without the prior express written consent of Sporian
+ * Microsystems, Inc.
+ */
+
+/* A shim for printf on a uart.
+ */
+
+generic configuration UprintC() {
+ provides interface Uprint;
+ uses interface UartByte;
+}
+implementation {
+ components new UprintP();
+ Uprint = UprintP;
+ UartByte = UprintP;
+}
--- /dev/null
+/* Copyright (c) 2006-2007 by Sporian Microsystems, Inc.
+ * All Rights Reserved.
+ *
+ * This document is the proprietary and confidential property of Sporian
+ * Microsystems, Inc. All use, distribution, reproduction or re-distribution
+ * is disallowed without the prior express written consent of Sporian
+ * Microsystems, Inc.
+ */
+
+/* A shim for printf on a uart.
+ */
+
+#include <stdarg.h>
+#include "Uprint.h"
+
+generic module UprintP() {
+ provides interface Uprint;
+ uses interface UartByte;
+}
+implementation {
+ int uart_putc(int c)
+ {
+ call UartByte.send((uint8_t)c);
+ return c;
+ }
+
+ async command uprint_ptr_t Uprint.uptr()
+ {
+ return uart_putc;
+ }
+}
%T/chips/bq2403x
%T/chips/cp210x
%T/chips/stm25p
- %T/lib/timer
- %T/lib/serial
%T/lib/adc
- %T/lib/power
%T/lib/misc
+ %T/lib/power
+ %T/lib/serial
+ %T/lib/timer
+ %T/lib/uprintf
) );
@opts = qw(