mbed HRM11017を使ってkonashi.jsでナイトライダー

Dependencies:   BLE_API_Native_IRC mbed

Fork of BLE_RCBController by Junichi Katsu

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers nrf_temp.h Source File

nrf_temp.h

00001 /* Copyright (c) 2012 Nordic Semiconductor. All Rights Reserved.
00002  *
00003  * The information contained herein is property of Nordic Semiconductor ASA.
00004  * Terms and conditions of usage are described in detail in NORDIC
00005  * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT.
00006  *
00007  * Licensees are granted free, non-transferable use of the information. NO
00008  * WARRANTY of ANY KIND is provided. This heading must NOT be removed from
00009  * the file.
00010  *
00011  */
00012 
00013 #ifndef NRF_TEMP_H__
00014 #define NRF_TEMP_H__
00015 
00016 #include "nordic_global.h"
00017 #include "nrf51.h"
00018 
00019 /**
00020 * @defgroup nrf_temperature TEMP (temperature) abstraction
00021 * @{
00022 * @ingroup nrf_drivers temperature_example
00023 * @brief Temperature module init and read functions.
00024 *
00025 */
00026 
00027 
00028 
00029 /**
00030  * @brief Function for preparing the temp module for temperature measurement.
00031  *
00032  * This function initializes the TEMP module and writes to the hidden configuration register.
00033  * 
00034  * @param none
00035  */
00036 static __INLINE void nrf_temp_init(void)
00037 {
00038     /**@note Workaround for PAN_028 rev2.0A anomaly 31 - TEMP: Temperature offset value has to be manually loaded to the TEMP module */
00039     *(uint32_t *) 0x4000C504 = 0;
00040 }
00041 
00042 
00043 
00044 #define MASK_SIGN           (0x00000200UL)
00045 #define MASK_SIGN_EXTENSION (0xFFFFFC00UL)
00046 
00047 /**
00048  * @brief Function for reading temperature measurement.
00049  *
00050  * The function reads the 10 bit 2's complement value and transforms it to a 32 bit 2's complement value.
00051  * 
00052  * @param none
00053  */
00054 static __INLINE int32_t nrf_temp_read(void)
00055 {    
00056     /**@note Workaround for PAN_028 rev2.0A anomaly 28 - TEMP: Negative measured values are not represented correctly */
00057     return ((NRF_TEMP->TEMP & MASK_SIGN) != 0) ? (NRF_TEMP->TEMP | MASK_SIGN_EXTENSION) : (NRF_TEMP->TEMP);    
00058 }
00059 
00060 /** @} */
00061 
00062 #endif