From a60c072e17cd502a06d9cea5de928b899d5cac16 Mon Sep 17 00:00:00 2001 From: Nicolas Schodet Date: Sun, 9 Mar 2008 17:40:28 +0100 Subject: * digital/asserv/src/asserv: - cleaned up, separated compilation. - prepared auxialliary motor control. --- digital/asserv/src/asserv/postrack.c | 33 ++++++++++++--------------------- 1 file changed, 12 insertions(+), 21 deletions(-) (limited to 'digital/asserv/src/asserv/postrack.c') diff --git a/digital/asserv/src/asserv/postrack.c b/digital/asserv/src/asserv/postrack.c index 6da77592..14de6c09 100644 --- a/digital/asserv/src/asserv/postrack.c +++ b/digital/asserv/src/asserv/postrack.c @@ -1,4 +1,4 @@ -/* postrack.c */ +/* postrack.c - Compute current position from counters. */ /* asserv - Position & speed motor control on AVR. {{{ * * Copyright (C) 2006 Nicolas Schodet @@ -22,6 +22,12 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * * }}} */ +#include "common.h" +#include "postrack.h" + +#include "modules/math/fixed/fixed.h" + +#include "counter.h" /** Current position, f24.8. */ int32_t postrack_x, postrack_y; @@ -39,26 +45,10 @@ uint16_t postrack_footing; * a angle in f8.24 format. * - this factor is in f8.24 format, therefore, 1 is writen (1L << 24). * - there is a two factor because of the sum done in the motor control. */ -uint32_t postrack_footing_factor; - -/* +AutoDec */ +static uint32_t postrack_footing_factor; /** Initialise the position tracker. */ -static inline void -postrack_init (void); - -/** Update the current position. */ -static inline void -postrack_update (void); - -/** Change the footing value. */ -static inline void -postrack_set_footing (uint16_t footing); - -/* -AutoDec */ - -/** Initialise the position tracker. */ -static inline void +void postrack_init (void) { /* Prevent division by 0 by providing a default large value. */ @@ -68,7 +58,7 @@ postrack_init (void) #define M_PI 3.14159265358979323846 /* pi */ /** Update the current position. */ -static inline void +void postrack_update (void) { int32_t d, dd, da, na, dsc; @@ -107,10 +97,11 @@ postrack_update (void) #define M_1_PI 0.31830988618379067154 /* 1/pi */ /** Change the footing value. */ -static inline void +void postrack_set_footing (uint16_t footing) { postrack_footing = footing; postrack_footing_factor = (uint32_t) (M_1_PI * (1L << 8) * (1L << 24)) / footing; } + -- cgit v1.2.3