API for temperature sensor in nrf51822
Dependents: BLE_TemperatureAdvertising BLE_TemperatureObserver TEMP_YM2
TMP_nrf51.cpp@2:189632d43a8f, 2015-07-20 (annotated)
- Committer:
- sunsmile2015
- Date:
- Mon Jul 20 07:56:01 2015 +0000
- Revision:
- 2:189632d43a8f
- Parent:
- 1:27efbf620fc5
add space
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
sunsmile2015 | 0:4a8259030297 | 1 | |
sunsmile2015 | 0:4a8259030297 | 2 | /* mbed Microcontroller Library |
sunsmile2015 | 0:4a8259030297 | 3 | * Copyright (c) 2006-2015 ARM Limited |
sunsmile2015 | 0:4a8259030297 | 4 | * |
sunsmile2015 | 0:4a8259030297 | 5 | * Licensed under the Apache License, Version 2.0 (the "License"); |
sunsmile2015 | 0:4a8259030297 | 6 | * you may not use this file except in compliance with the License. |
sunsmile2015 | 0:4a8259030297 | 7 | * You may obtain a copy of the License at |
sunsmile2015 | 0:4a8259030297 | 8 | * |
sunsmile2015 | 0:4a8259030297 | 9 | * http://www.apache.org/licenses/LICENSE-2.0 |
sunsmile2015 | 0:4a8259030297 | 10 | * |
sunsmile2015 | 0:4a8259030297 | 11 | * Unless required by applicable law or agreed to in writing, software |
sunsmile2015 | 0:4a8259030297 | 12 | * distributed under the License is distributed on an "AS IS" BASIS, |
sunsmile2015 | 0:4a8259030297 | 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
sunsmile2015 | 0:4a8259030297 | 14 | * See the License for the specific language governing permissions and |
sunsmile2015 | 0:4a8259030297 | 15 | * limitations under the License. |
sunsmile2015 | 0:4a8259030297 | 16 | */ |
sunsmile2015 | 0:4a8259030297 | 17 | |
sunsmile2015 | 0:4a8259030297 | 18 | #include "TMP_nrf51.h" |
sunsmile2015 | 0:4a8259030297 | 19 | #include "nrf_soc.h" // for internal Thermo sensoer |
sunsmile2015 | 0:4a8259030297 | 20 | |
sunsmile2015 | 0:4a8259030297 | 21 | /** |
sunsmile2015 | 0:4a8259030297 | 22 | * @brief Get the temperature value. |
sunsmile2015 | 0:4a8259030297 | 23 | * |
sunsmile2015 | 0:4a8259030297 | 24 | * @return Die temperature in °C |
sunsmile2015 | 0:4a8259030297 | 25 | * |
sunsmile2015 | 0:4a8259030297 | 26 | */ |
sunsmile2015 | 1:27efbf620fc5 | 27 | TMP_nrf51::tmpSensorValue_t TMP_nrf51::get() |
sunsmile2015 | 0:4a8259030297 | 28 | { |
sunsmile2015 | 0:4a8259030297 | 29 | int32_t p_temp; |
sunsmile2015 | 0:4a8259030297 | 30 | |
sunsmile2015 | 0:4a8259030297 | 31 | sd_temp_get(&p_temp); |
sunsmile2015 | 0:4a8259030297 | 32 | |
sunsmile2015 | 2:189632d43a8f | 33 | return (TMP_nrf51::tmpSensorValue_t) ((float)p_temp * 0.25); /* 0.25 is temperature sensor resolution */ |
sunsmile2015 | 0:4a8259030297 | 34 | } |