Nordic nrf51 sdk sources. Mirrored from https://github.com/ARMmbed/nrf51-sdk.

Dependents:   nRF51822 nRF51822

Committer:
vcoubard
Date:
Thu Apr 07 17:37:40 2016 +0100
Revision:
19:47192cb9def7
Parent:
10:233fefd8162b
Child:
20:a90c48eb1d30
Synchronized with git rev 9251259f
Author: Liyou Zhou
Copy over coresponding files from nordic-sdk 9.0.0

Who changed what in which revision?

UserRevisionLine numberNew contents of line
vcoubard 19:47192cb9def7 1 /* Copyright (c) 2012 Nordic Semiconductor. All Rights Reserved.
vcoubard 19:47192cb9def7 2 *
vcoubard 19:47192cb9def7 3 * The information contained herein is property of Nordic Semiconductor ASA.
vcoubard 19:47192cb9def7 4 * Terms and conditions of usage are described in detail in NORDIC
vcoubard 19:47192cb9def7 5 * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT.
vcoubard 19:47192cb9def7 6 *
vcoubard 19:47192cb9def7 7 * Licensees are granted free, non-transferable use of the information. NO
vcoubard 19:47192cb9def7 8 * WARRANTY of ANY KIND is provided. This heading must NOT be removed from
vcoubard 19:47192cb9def7 9 * the file.
vcoubard 19:47192cb9def7 10 *
Vincent Coubard 0:f2542974c862 11 */
Vincent Coubard 0:f2542974c862 12
Vincent Coubard 0:f2542974c862 13 #ifndef NRF_TEMP_H__
Vincent Coubard 0:f2542974c862 14 #define NRF_TEMP_H__
Vincent Coubard 0:f2542974c862 15
Vincent Coubard 0:f2542974c862 16 #include "nrf51.h"
Vincent Coubard 0:f2542974c862 17
Vincent Coubard 0:f2542974c862 18 /**
Vincent Coubard 0:f2542974c862 19 * @defgroup nrf_temperature TEMP (temperature) abstraction
Vincent Coubard 0:f2542974c862 20 * @{
Vincent Coubard 0:f2542974c862 21 * @ingroup nrf_drivers temperature_example
Vincent Coubard 0:f2542974c862 22 * @brief Temperature module init and read functions.
Vincent Coubard 0:f2542974c862 23 *
Vincent Coubard 0:f2542974c862 24 */
Vincent Coubard 0:f2542974c862 25
vcoubard 1:ebc0e0ef0a11 26 /**@cond NO_DOXYGEN */
vcoubard 1:ebc0e0ef0a11 27 #define MASK_SIGN (0x00000200UL)
vcoubard 1:ebc0e0ef0a11 28 #define MASK_SIGN_EXTENSION (0xFFFFFC00UL)
Vincent Coubard 0:f2542974c862 29
Vincent Coubard 0:f2542974c862 30 /**
Vincent Coubard 0:f2542974c862 31 * @brief Function for preparing the temp module for temperature measurement.
Vincent Coubard 0:f2542974c862 32 *
Vincent Coubard 0:f2542974c862 33 * This function initializes the TEMP module and writes to the hidden configuration register.
Vincent Coubard 0:f2542974c862 34 */
Vincent Coubard 0:f2542974c862 35 static __INLINE void nrf_temp_init(void)
Vincent Coubard 0:f2542974c862 36 {
Vincent Coubard 0:f2542974c862 37 /**@note Workaround for PAN_028 rev2.0A anomaly 31 - TEMP: Temperature offset value has to be manually loaded to the TEMP module */
Vincent Coubard 0:f2542974c862 38 *(uint32_t *) 0x4000C504 = 0;
Vincent Coubard 0:f2542974c862 39 }
Vincent Coubard 0:f2542974c862 40
Vincent Coubard 0:f2542974c862 41 /**
Vincent Coubard 0:f2542974c862 42 * @brief Function for reading temperature measurement.
Vincent Coubard 0:f2542974c862 43 *
Vincent Coubard 0:f2542974c862 44 * The function reads the 10 bit 2's complement value and transforms it to a 32 bit 2's complement value.
Vincent Coubard 0:f2542974c862 45 */
Vincent Coubard 0:f2542974c862 46 static __INLINE int32_t nrf_temp_read(void)
Vincent Coubard 0:f2542974c862 47 {
Vincent Coubard 0:f2542974c862 48 /**@note Workaround for PAN_028 rev2.0A anomaly 28 - TEMP: Negative measured values are not represented correctly */
Vincent Coubard 0:f2542974c862 49 return ((NRF_TEMP->TEMP & MASK_SIGN) != 0) ? (NRF_TEMP->TEMP | MASK_SIGN_EXTENSION) : (NRF_TEMP->TEMP);
Vincent Coubard 0:f2542974c862 50 }
vcoubard 1:ebc0e0ef0a11 51 /**@endcond */
Vincent Coubard 0:f2542974c862 52
Vincent Coubard 0:f2542974c862 53 /** @} */
Vincent Coubard 0:f2542974c862 54
vcoubard 1:ebc0e0ef0a11 55 #endif