#include <stdint.h>
#include <aversive/queue.h>
#include <inttypes.h>
+#include <aversive.h>
+#include <aversive/pgmspace.h>
#include "callout.h"
#endif
#ifdef CALLOUT_DEBUG
-#define callout_dprintf(fmt, ...) printf("%s(): " fmt, __FUNCTION__, \
+#define callout_dprintf_P(fmt, ...) printf_P(PSTR("%s(): " fmt), __FUNCTION__, \
__VA_ARGS__)
#else
-#define callout_dprintf(...) do { } while (0)
+#define callout_dprintf_P(...) do { } while (0)
#endif
/* Initialize a callout manager */
{
struct callout *t;
- callout_dprintf("cm=%p tim=%p\n", cm, tim);
+ callout_dprintf_P(PSTR("cm=%p tim=%p\r\n"), cm, tim);
/* list is empty */
if (TAILQ_EMPTY(&cm->pending_list)) {
static void
callout_del(struct callout_manager *cm, struct callout *tim)
{
- callout_dprintf("cm=%p tim=%p\n", cm, tim);
+ callout_dprintf_P(PSTR("cm=%p tim=%p\r\n"), cm, tim);
TAILQ_REMOVE(&cm->pending_list, tim, next);
}
__callout_reset(struct callout_manager *cm, struct callout *tim, uint16_t expire,
uint16_t period, callout_cb_t fct, void *arg)
{
- callout_dprintf("cm=%p tim=%p expire=%d period=%d\n",
- cm, tim, expire, period);
+ callout_dprintf_P(PSTR("cm=%p tim=%p expire=%d period=%d\r\n"),
+ cm, tim, expire, period);
__TIMER_STAT_ADD(cm, reset, 1);
cm->updated = 1;
void
callout_stop(struct callout_manager *cm, struct callout *tim)
{
- callout_dprintf("cm=%p tim=%p\n", cm, tim);
+ callout_dprintf_P(PSTR("cm=%p tim=%p\r\n"), cm, tim);
__TIMER_STAT_ADD(cm, stop, 1);
cm->updated = 1;
struct callout *tim;
uint16_t cur_time = cm->get_time();
- callout_dprintf("cm=%p\n", cm);
+ callout_dprintf_P(PSTR("cm=%p\r\n"), cm);
TAILQ_INIT(&expired_list);
__TIMER_STAT_ADD(cm, manage, 1);
void callout_dump_stats(struct callout_manager *cm)
{
#ifdef CALLOUT_STATS
- printf("Timer statistics:\n");
- printf(" reset = %d\n", cm->stats.reset);
- printf(" stop = %d\n", cm->stats.stop);
- printf(" manage = %d\n", cm->stats.manage);
- printf(" pending = %d\n", cm->stats.pending);
- printf(" running = %d\n", cm->stats.running);
+ printf_P(PSTR("Timer statistics:\r\n"));
+ printf_P(PSTR(" reset = %d\r\n"), cm->stats.reset);
+ printf_P(PSTR(" stop = %d\r\n"), cm->stats.stop);
+ printf_P(PSTR(" manage = %d\r\n"), cm->stats.manage);
+ printf_P(PSTR(" pending = %d\r\n"), cm->stats.pending);
+ printf_P(PSTR(" running = %d\r\n"), cm->stats.running);
#else
- printf("No timer statistics, CALLOUT_STATS is disabled\n");
+ printf_P(PSTR("No timer statistics, CALLOUT_STATS is disabled\r\n"));
#endif
}
static int cnt;
arg = arg; /* silent compiler */
- printf("cb1\n");
+ printf_P(PSTR("cb1\r\n"));
callout_dump_stats(cm);
if (++cnt >= 4)
callout_stop(cm, tim);
static int cnt;
struct callout *t3 = arg;
- printf("cb2\n");
+ printf_P(PSTR("cb2\r\n"));
if (++cnt < 3)
callout_reset(cm, tim, 5, SINGLE, cb2, arg);
else
tim = tim; /* silent compiler */
arg = arg; /* silent compiler */
- printf("cb3\n");
+ printf_P(PSTR("cb3\r\n"));
}
int main(void)