modified locally to use with HRM1017

Dependents:   BLE_HTM_HRM1017

Fork of nRF51822 by Nordic Semiconductor

Committer:
bogdanm
Date:
Wed Mar 26 14:38:17 2014 +0000
Revision:
0:eff01767de02
Child:
37:c29c330d942c
Initial import of the nRF51822 code

Who changed what in which revision?

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