• Main Page
  • Modules
  • Index
  • File List
  • Globals

hal/nrf24le1/hal_clk.c

Go to the documentation of this file.
00001 /* Copyright (c) 2009 Nordic Semiconductor. All Rights Reserved.
00002  *
00003  * The information contained herein is confidential property of Nordic
00004  * Semiconductor ASA.Terms and conditions of usage are described in detail
00005  * in NORDIC SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT.
00006  *
00007  * Licensees are granted free, non-transferable use of the information. NO
00008  * WARRENTY of ANY KIND is provided. This heading must NOT be removed from
00009  * the file.
00010  *
00011  * $LastChangedRevision: 2513 $
00012  */
00013 
00018 #include "nrf24le1.h"
00019 #include <stdbool.h>
00020 #include "hal_clk.h"
00021 
00022 void hal_clk_regret_xosc16m_on(bool on)
00023 {
00024   if(on)
00025   {
00026     CLKCTRL = (CLKCTRL | 0x80U) & (uint8_t)~0x08U;   // & ~0x08 to prevent writing 1 to this bit
00027   }
00028   else
00029   {
00030     CLKCTRL = CLKCTRL & (uint8_t)~0x88U;            // & ~0x08 to prevent writing 1 to this bit
00031   }
00032 }
00033 
00034 void hal_clk_set_input(hal_clk_input_t input)
00035 {
00036   CLKCTRL = (CLKCTRL & (uint8_t)~0x48U) | ((input & 0x01U) << 6);
00037 }
00038 
00039 void hal_clk_set_16m_source(hal_clk_source_t source)
00040 {
00041   CLKCTRL = (CLKCTRL & (uint8_t)~0x38U) | ((source & 0x03U) << 4);
00042 }
00043 
00044 hal_clk_source_t hal_clk_get_16m_source(void)
00045 {
00046   hal_clk_source_t clock_source;
00047   if(CLKLFCTRL & (uint8_t)0x08U)
00048   {
00049     clock_source = HAL_CLK_XOSC16M;
00050   }
00051   else
00052   {
00053     clock_source = HAL_CLK_RCOSC16M;
00054   }
00055 
00056   return clock_source;
00057 }
00058 
00059 void hal_clk_set_freq(hal_clk_freq_t freq)
00060 {
00061   CLKCTRL = ((CLKCTRL & (uint8_t)~0x0FU) | ((uint8_t)freq & 0x07U)); // & ~0x08 to prevent writing 1 to this bit
00062 }
00063 
00064 bool hal_clklf_phase(void)
00065 {
00066   return (bool)(CLKLFCTRL & 0x80U);
00067 }
00068 
00069 bool hal_clklf_ready(void)
00070 {
00071   return (bool)(CLKLFCTRL & 0x40U);
00072 }
00073 
00074 void hal_clklf_set_source(hal_clklf_source_t source)
00075 {
00076   CLKLFCTRL = (uint8_t)(CLKLFCTRL & (uint8_t)~0x07U) | (uint8_t)((uint8_t)source & (uint8_t)0x07U);
00077 }

Generated on Fri Apr 20 2012 14:11:44 for nRFGo SDK by  doxygen 1.7.2