mbed os with nrf51 internal bandgap enabled to read battery level

Dependents:   BLE_file_test BLE_Blink ExternalEncoder

Committer:
elessair
Date:
Sun Oct 23 15:10:02 2016 +0000
Revision:
0:f269e3021894
Initial commit

Who changed what in which revision?

UserRevisionLine numberNew contents of line
elessair 0:f269e3021894 1 /***************************************************************************//**
elessair 0:f269e3021894 2 * @file clocking.h
elessair 0:f269e3021894 3 * @brief Clock selection calculations
elessair 0:f269e3021894 4 *******************************************************************************
elessair 0:f269e3021894 5 * @section License
elessair 0:f269e3021894 6 * <b>(C) Copyright 2015 Silicon Labs, http://www.silabs.com</b>
elessair 0:f269e3021894 7 *******************************************************************************
elessair 0:f269e3021894 8 *
elessair 0:f269e3021894 9 * SPDX-License-Identifier: Apache-2.0
elessair 0:f269e3021894 10 *
elessair 0:f269e3021894 11 * Licensed under the Apache License, Version 2.0 (the "License"); you may
elessair 0:f269e3021894 12 * not use this file except in compliance with the License.
elessair 0:f269e3021894 13 * You may obtain a copy of the License at
elessair 0:f269e3021894 14 *
elessair 0:f269e3021894 15 * http://www.apache.org/licenses/LICENSE-2.0
elessair 0:f269e3021894 16 *
elessair 0:f269e3021894 17 * Unless required by applicable law or agreed to in writing, software
elessair 0:f269e3021894 18 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
elessair 0:f269e3021894 19 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
elessair 0:f269e3021894 20 * See the License for the specific language governing permissions and
elessair 0:f269e3021894 21 * limitations under the License.
elessair 0:f269e3021894 22 *
elessair 0:f269e3021894 23 ******************************************************************************/
elessair 0:f269e3021894 24
elessair 0:f269e3021894 25 #include "device_peripherals.h"
elessair 0:f269e3021894 26
elessair 0:f269e3021894 27 #if( CORE_CLOCK_SOURCE == HFXO)
elessair 0:f269e3021894 28 # define REFERENCE_FREQUENCY HFXO_FREQUENCY
elessair 0:f269e3021894 29 #elif( CORE_CLOCK_SOURCE == HFRCO)
elessair 0:f269e3021894 30
elessair 0:f269e3021894 31 # if defined _CMU_HFRCOCTRL_BAND_MASK
elessair 0:f269e3021894 32 # if( HFRCO_FREQUENCY == _CMU_HFRCOCTRL_BAND_1MHZ)
elessair 0:f269e3021894 33 # define REFERENCE_FREQUENCY 1000000
elessair 0:f269e3021894 34 # elif(HFRCO_FREQUENCY == _CMU_HFRCOCTRL_BAND_7MHZ)
elessair 0:f269e3021894 35 # define REFERENCE_FREQUENCY 7000000
elessair 0:f269e3021894 36 # elif(HFRCO_FREQUENCY == _CMU_HFRCOCTRL_BAND_11MHZ)
elessair 0:f269e3021894 37 # define REFERENCE_FREQUENCY 7000000
elessair 0:f269e3021894 38 # elif(HFRCO_FREQUENCY == _CMU_HFRCOCTRL_BAND_14MHZ)
elessair 0:f269e3021894 39 # define REFERENCE_FREQUENCY 14000000
elessair 0:f269e3021894 40 # elif(HFRCO_FREQUENCY == _CMU_HFRCOCTRL_BAND_21MHZ)
elessair 0:f269e3021894 41 # define REFERENCE_FREQUENCY 21000000
elessair 0:f269e3021894 42 # elif(HFRCO_FREQUENCY == _CMU_HFRCOCTRL_BAND_28MHZ)
elessair 0:f269e3021894 43 # define REFERENCE_FREQUENCY 28000000
elessair 0:f269e3021894 44 # else
elessair 0:f269e3021894 45 # define REFERENCE_FREQUENCY 14000000
elessair 0:f269e3021894 46 # endif
elessair 0:f269e3021894 47 # elif defined _CMU_HFRCOCTRL_FREQRANGE_MASK
elessair 0:f269e3021894 48 # define REFERENCE_FREQUENCY HFRCO_FREQUENCY
elessair 0:f269e3021894 49 # else
elessair 0:f269e3021894 50 # error "HFRCO frequency not defined"
elessair 0:f269e3021894 51 # endif
elessair 0:f269e3021894 52 #endif
elessair 0:f269e3021894 53
elessair 0:f269e3021894 54 #if ( LOW_ENERGY_CLOCK_SOURCE == LFXO )
elessair 0:f269e3021894 55 # define LEUART_USING_LFXO
elessair 0:f269e3021894 56 # if ( (defined(CMU_CTRL_HFLE) || defined(CMU_CTRL_WSHFLE) ) && (REFERENCE_FREQUENCY > 24000000) )
elessair 0:f269e3021894 57 # define LEUART_HF_REF_FREQ (REFERENCE_FREQUENCY / 4)
elessair 0:f269e3021894 58 # else
elessair 0:f269e3021894 59 # define LEUART_HF_REF_FREQ (REFERENCE_FREQUENCY / 2)
elessair 0:f269e3021894 60 # endif
elessair 0:f269e3021894 61 # define LEUART_LF_REF_FREQ LFXO_FREQUENCY
elessair 0:f269e3021894 62 #else
elessair 0:f269e3021894 63 # if ( (defined(CMU_CTRL_HFLE) || defined(CMU_CTRL_WSHFLE) ) && (REFERENCE_FREQUENCY > 24000000) )
elessair 0:f269e3021894 64 # define LEUART_REF_FREQ (REFERENCE_FREQUENCY / 4)
elessair 0:f269e3021894 65 # else
elessair 0:f269e3021894 66 # define LEUART_REF_FREQ (REFERENCE_FREQUENCY / 2)
elessair 0:f269e3021894 67 # endif
elessair 0:f269e3021894 68 #endif
elessair 0:f269e3021894 69