math: use CONFIG_FPU when using float.

ifdef code than needs CONFIG_FPU (acos and friends)
BRANCH=ToT
BUG=chrome-os-partner:32050
TEST=define CONFIG_FPU on host board and use it.

Change-Id: I1c4ed16c23450bb4059d26044f4c1fe45b33674e
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/226414
Reviewed-by: Alec Berg <alecaberg@chromium.org>
Reviewed-by: Sheng-liang Song <ssl@chromium.org>
This commit is contained in:
Gwendal Grignou
2014-10-28 17:52:52 -07:00
committed by chrome-internal-fetch
parent bbe9a877ec
commit 96a39e7ee7
4 changed files with 17 additions and 1 deletions

View File

@@ -21,6 +21,8 @@ extern char __host_flash[CONFIG_FLASH_PHYSICAL_SIZE];
#define CONFIG_RAM_BASE 0x0 /* Not supported */
#define CONFIG_RAM_SIZE 0x0 /* Not supported */
#define CONFIG_FPU
/* Size of one firmware image in flash */
#define CONFIG_FW_IMAGE_SIZE (64 * 1024)

View File

@@ -14,6 +14,7 @@
#define COSINE_LUT_INCR_DEG 5
#define COSINE_LUT_SIZE ((180 / COSINE_LUT_INCR_DEG) + 1)
#ifdef CONFIG_FPU
/* Lookup table for the value of cosine from 0 degrees to 180 degrees. */
static const float cos_lut[] = {
1.00000, 0.99619, 0.98481, 0.96593, 0.93969,
@@ -83,6 +84,7 @@ float cosine_of_angle_diff(const vector_3_t v1, const vector_3_t v2)
return (float)dotproduct / (denominator);
}
#endif
/*
* rotate a vector v

View File

@@ -8,7 +8,12 @@
#ifndef __CROS_MATH_UTIL_H
#define __CROS_MATH_UTIL_H
#ifdef CONFIG_FPU
typedef float matrix_3x3_t[3][3];
#else
typedef int matrix_3x3_t[3][3];
#endif
typedef int vector_3_t[3];
@@ -16,6 +21,7 @@ typedef int vector_3_t[3];
#define SQ(x) ((x) * (x))
#define ABS(x) ((x) >= 0 ? (x) : -(x))
#ifdef CONFIG_FPU
/**
* Find acos(x) in degrees. Argument is clipped to [-1.0, 1.0].
@@ -36,6 +42,8 @@ float arc_cos(float x);
*/
float cosine_of_angle_diff(const vector_3_t v1, const vector_3_t v2);
#endif
/**
* Rotate vector v by rotation matrix R.
*

View File

@@ -7,13 +7,17 @@
#include <math.h>
#include <stdio.h>
#include "common.h"
#include "math_util.h"
#include "motion_sense.h"
#include "test_util.h"
#include "util.h"
/*****************************************************************************/
/* Need to define motion sensor globals just to compile. */
/*
* Need to define motion sensor globals just to compile.
* We include motion task to force the inclusion of math_util.c
*/
struct motion_sensor_t motion_sensors[] = {};
const unsigned int motion_sensor_count = ARRAY_SIZE(motion_sensors);