hello, follow the adccmds
task, I create a 1 second my_printf
task, but it do not run continuously, it only runs several times, before it halted, the timer ticks are as follows:
my_printf_event: 2894236097
my_printf_task: 2894606682
could you help me, thanks
// Commands for controlling GPIO analog-to-digital input pins
//
// Copyright (C) 2016 Kevin O'Connor <kevin@koconnor.net>
//
// This file may be distributed under the terms of the GNU GPLv3 license.
#include "basecmd.h" // oid_alloc
#include "board/irq.h" // irq_disable
#include "sched.h" // DECL_TASK
struct my_printf_s {
struct timer timer;
uint32_t rest_ticks;
};
static struct task_wake my_printf_wake;
static uint_fast8_t
my_printf_event(struct timer *timer)
{
struct my_printf_s *mp = container_of(timer, struct my_printf_s, timer);
my_printf("%s: %lu\n", __FUNCTION__, timer_read_time());
irq_disable();
mp->timer.waketime = timer_read_time() + mp->rest_ticks;
sched_wake_task(&my_printf_wake);
irq_enable();
return SF_RESCHEDULE;
}
void
my_printf_task(void)
{
if (!sched_check_wake(&my_printf_wake))
return;
my_printf("%s: %lu\n", __FUNCTION__, timer_read_time());
}
DECL_TASK(my_printf_task);
static void
my_printf_task_init()
{
struct my_printf_s *mp = alloc_chunk(sizeof(*mp));
mp->timer.func = my_printf_event;
mp->timer.waketime = timer_read_time() + mp->rest_ticks;
mp->rest_ticks = timer_from_us(1000000ul); // 1 second
sched_add_timer(&mp->timer);
}
DECL_INIT(my_printf_task_init);