⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 hal_clk.c

📁 非常全的nrf2401设计资料
💻 C
字号:
/* Copyright (c) 2008 Nordic Semiconductor. All Rights Reserved.
 *
 * The information contained herein is property of Nordic Semiconductor ASA.
 * Terms and conditions of usage are described in detail in NORDIC
 * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. 
 *
 * Licensees are granted free, non-transferable use of the information. NO
 * WARRENTY of ANY KIND is provided. This heading must NOT be removed from
 * the file.
 *
 * $LastChangedRevision$
 */ 

/** @file
 *
 * @author Lasse Olsen
 *
 */

#include <stdint.h>
#include <stdbool.h>

#include <Nordic\reg24le1.h>
#include "hal_clk.h"

void hal_clk_regret_xosc16m_on(bool on)
{
  if(on)
  {
    CLKCTRL = (CLKCTRL | 0x80) & ~0x08;   // & ~0x08 to prevent writing 1 to this bit 
  }
  else
  {
    CLKCTRL = CLKCTRL & ~0x88;            // & ~0x08 to prevent writing 1 to this bit
  }
}

void hal_clk_set_input(hal_clk_input_t input)
{
  CLKCTRL = (CLKCTRL & ~0x48) | ((input & 0x01) << 6); 
}

void hal_clk_set_16m_source(hal_clk_source_t source)
{
  CLKCTRL = ((CLKCTRL & ~0x38) | ((source & 0x03) << 4));
}

hal_clk_source_t hal_clk_get_16m_source()
{
  if(CLKCTRL & 0x08)
  {
    return HAL_CLK_XOSC16M;
  }
  else
  {
    return HAL_CLK_RCOSC16M;
  }
}

void hal_clk_set_freq(hal_clk_freq_t freq)
{
  CLKCTRL = ((CLKCTRL & ~0x0F) | (freq & 0x07)); // & ~0x08 to prevent writing 1 to this bit
}

bool hal_clklf_phase()
{
  return((CLKLFCTRL & 0x80) > 0);
}

bool hal_clklf_ready()
{
  return((CLKLFCTRL & 0x40) > 0);
}

void hal_clklf_set_source(hal_clklf_source_t source)
{
  CLKLFCTRL = (CLKLFCTRL & ~0x07) | (source & 0x07);
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -