sched: Use uint_fast8_t for return type of timers

Some architectures are faster passing regular integers than 8bit
integers.  Use uint_fast8_t so that the architecture chooses the
appropriate type.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
Kevin O'Connor 2016-06-08 21:33:50 -04:00
parent fa85094cbb
commit b0524947e5
7 changed files with 14 additions and 14 deletions

View File

@ -156,7 +156,7 @@ DECL_COMMAND(command_finalize_config, "finalize_config crc=%u");
static struct timer group_timer; static struct timer group_timer;
static uint8_t static uint_fast8_t
group_end_event(struct timer *timer) group_end_event(struct timer *timer)
{ {
shutdown("Missed scheduling of next event"); shutdown("Missed scheduling of next event");

View File

@ -23,7 +23,7 @@ struct end_stop {
enum { ESF_HOMING=1, ESF_REPORT=2 }; enum { ESF_HOMING=1, ESF_REPORT=2 };
// Timer callback for an end stop // Timer callback for an end stop
static uint8_t static uint_fast8_t
end_stop_event(struct timer *t) end_stop_event(struct timer *t)
{ {
struct end_stop *e = container_of(t, struct end_stop, time); struct end_stop *e = container_of(t, struct end_stop, time);

View File

@ -22,13 +22,13 @@ struct digital_out_s {
uint8_t value, default_value; uint8_t value, default_value;
}; };
static uint8_t static uint_fast8_t
digital_end_event(struct timer *timer) digital_end_event(struct timer *timer)
{ {
shutdown("Missed scheduling of next pin event"); shutdown("Missed scheduling of next pin event");
} }
static uint8_t static uint_fast8_t
digital_out_event(struct timer *timer) digital_out_event(struct timer *timer)
{ {
struct digital_out_s *d = container_of(timer, struct digital_out_s, timer); struct digital_out_s *d = container_of(timer, struct digital_out_s, timer);
@ -103,10 +103,10 @@ enum {
SPF_NEXT_ON=1<<4, SPF_NEXT_TOGGLING=1<<5, SPF_NEXT_CHECK_END=1<<6, SPF_NEXT_ON=1<<4, SPF_NEXT_TOGGLING=1<<5, SPF_NEXT_CHECK_END=1<<6,
}; };
static uint8_t soft_pwm_load_event(struct timer *timer); static uint_fast8_t soft_pwm_load_event(struct timer *timer);
// Normal pulse change event // Normal pulse change event
static uint8_t static uint_fast8_t
soft_pwm_toggle_event(struct timer *timer) soft_pwm_toggle_event(struct timer *timer)
{ {
struct soft_pwm_s *s = container_of(timer, struct soft_pwm_s, timer); struct soft_pwm_s *s = container_of(timer, struct soft_pwm_s, timer);
@ -127,7 +127,7 @@ soft_pwm_toggle_event(struct timer *timer)
} }
// Load next pwm settings // Load next pwm settings
static uint8_t static uint_fast8_t
soft_pwm_load_event(struct timer *timer) soft_pwm_load_event(struct timer *timer)
{ {
struct soft_pwm_s *s = container_of(timer, struct soft_pwm_s, timer); struct soft_pwm_s *s = container_of(timer, struct soft_pwm_s, timer);

View File

@ -25,7 +25,7 @@ static uint16_t millis;
// also simplifies the timer code by ensuring there is always at least // also simplifies the timer code by ensuring there is always at least
// one timer on the timer list and that there is always a timer not // one timer on the timer list and that there is always a timer not
// more than 1 ms in the future. // more than 1 ms in the future.
static uint8_t static uint_fast8_t
ms_event(struct timer *t) ms_event(struct timer *t)
{ {
millis++; millis++;
@ -154,7 +154,7 @@ sched_timer_kick(void)
struct timer *t = timer_list; struct timer *t = timer_list;
for (;;) { for (;;) {
// Invoke timer callback // Invoke timer callback
uint8_t res; uint_fast8_t res;
if (CONFIG_INLINE_STEPPER_HACK && likely(!t->func)) if (CONFIG_INLINE_STEPPER_HACK && likely(!t->func))
res = stepper_event(t); res = stepper_event(t);
else else

View File

@ -15,7 +15,7 @@
// Timer structure for scheduling timed events (see sched_timer() ) // Timer structure for scheduling timed events (see sched_timer() )
struct timer { struct timer {
struct timer *next; struct timer *next;
uint8_t (*func)(struct timer*); uint_fast8_t (*func)(struct timer*);
uint32_t waketime; uint32_t waketime;
}; };

View File

@ -35,7 +35,7 @@ enum { MF_DIR=1 };
enum { SF_LAST_DIR=1, SF_NEXT_DIR=2, SF_INVERT_STEP=4, SF_HAVE_ADD=8 }; enum { SF_LAST_DIR=1, SF_NEXT_DIR=2, SF_INVERT_STEP=4, SF_HAVE_ADD=8 };
// Setup a stepper for the next move in its queue // Setup a stepper for the next move in its queue
static uint8_t static uint_fast8_t
stepper_load_next(struct stepper *s) stepper_load_next(struct stepper *s)
{ {
struct move *m = s->first; struct move *m = s->first;
@ -64,7 +64,7 @@ stepper_load_next(struct stepper *s)
} }
// Timer callback - step the given stepper. // Timer callback - step the given stepper.
uint8_t uint_fast8_t
stepper_event(struct timer *t) stepper_event(struct timer *t)
{ {
struct stepper *s = container_of(t, struct stepper, time); struct stepper *s = container_of(t, struct stepper, time);
@ -78,7 +78,7 @@ stepper_event(struct timer *t)
s->interval += s->add; s->interval += s->add;
return SF_RESCHEDULE; return SF_RESCHEDULE;
} }
uint8_t ret = stepper_load_next(s); uint_fast8_t ret = stepper_load_next(s);
gpio_out_toggle(s->step_pin); gpio_out_toggle(s->step_pin);
return ret; return ret;
} }

View File

@ -5,7 +5,7 @@
enum { STEPPER_POSITION_BIAS=0x40000000 }; enum { STEPPER_POSITION_BIAS=0x40000000 };
uint8_t stepper_event(struct timer *t); uint_fast8_t stepper_event(struct timer *t);
void command_config_stepper(uint32_t *args); void command_config_stepper(uint32_t *args);
struct stepper; struct stepper;
uint32_t stepper_get_position(struct stepper *s); uint32_t stepper_get_position(struct stepper *s);