Files
OpenCellular/core/cortex-m/fpu.c
Vic Yang 93d77ada6c Change TMP006 temperature calculation to use FP.
The temperature calculation currently uses fixed point operations.
Change it to use floating point for better readability and maintenance.
Also changes disable_fpu() to accept parameter which serves as
optimization barrier to prevent floating point operations after
disabling FPU.

BUG=chrome-os-partner:7801
TEST=In console, tempremote "tempremote 29715 -105000 6390" gives 28506.

Change-Id: Ib766904b8feb9a78eac9f7cd53afeca85091c5a5
Signed-off-by: Vic Yang <victoryang@chromium.org>
2012-02-15 16:34:54 -08:00

30 lines
724 B
C

/* Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
/* FPU module for Chrome EC operating system */
#include "task.h"
void enable_fpu(void)
{
interrupt_disable();
asm volatile("mrs r0, control;"
"orr r0, r0, #(1 << 2);"
"msr control, r0;"
"isb;");
}
void disable_fpu(int32_t v)
{
/* Optimization barrier to force compiler generate floating point
* calculation code for 'v' before disabling FPU. */
asm volatile("" : : "r" (v) : "memory");
asm volatile("mrs r0, control;"
"bic r0, r0, #(1 << 2);"
"msr control, r0;"
"isb;");
interrupt_enable();
}