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

📄 hal_ancmp.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 Rune Brandsegg
 *
 */

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

#include <Nordic\reg24le1.h>
#include "nordic_common.h"
#include "hal_ancmp.h"

void hal_ancmp_set_polarity(hal_ancmp_pol_t polarity)
{ // Update "polarity" bit
  COMPCON = (COMPCON & 0xEF) | (((uint8_t)polarity << 4) & ~0xEF);   
}

void hal_ancmp_set_ref_voltage_scale(hal_ancmp_ref_scale_t scale)
{ // Update "refscale" bits
  COMPCON = (COMPCON & 0xF3) | (((uint8_t)scale << 2) & ~0xF3);   
}

void hal_ancmp_set_reference(hal_ancmp_ref_t ref)
{ // Update "cmpref" bit
  COMPCON = (COMPCON & 0xFD) | (((uint8_t)ref << 1) & ~0xFD);   
}

void hal_ancmp_set_input_channel(hal_ancmp_input_channel_t chsel)
{ 
  hal_adc_input_channel_t channel;
  channel = (hal_adc_input_channel_t)chsel;
  hal_adc_set_input_channel(channel);       
}

void hal_ancmp_enable(bool en)
{
  if(en)
  {
    COMPCON = COMPCON | BIT_0;                // Set "enable" bit
  }
  else
  {
    COMPCON = COMPCON & ~BIT_0;               // Clear "enable" bit
  }
}

⌨️ 快捷键说明

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