/* This file has been prepared for Doxygen automatic documentation generation.*/
/*! \file *********************************************************************
*
* \brief
* CC-ADC module.
*
* \par Application note:
* AVR352: Using the CC-ADC
*
* \par Documentation
* For comprehensive code documentation, supported compilers, compiler
* settings and supported devices see readme.html
*
* \author
* Atmel Corporation: http://www.atmel.com \n
* Support email: avr@atmel.com
*
* $Revision: 4810 $
* $Date: 2008-11-04 12:22:27 +0100 (ti, 04 nov 2008) $ \n
*
* Copyright (c) 2008, Atmel Corporation All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* 3. The name of ATMEL may not be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY AND
* SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
******************************************************************************/
#include <ioavr.h>
#include "config.h"
#include "ccadc.h"
/******************************************************************************
Global (file scope) status variables.
******************************************************************************/
//volatile uint8_t ccAdcInputPolarity;
volatile int32_t CCADC_accResult;
volatile int16_t CCADC_iccResult;
union CCADC_conversionFlag_union{
uint8_t allFlags;
struct{
uint8_t accResultReady : 1 ;
uint8_t iccResultReady : 1 ;
uint8_t regularCurrentDetected : 1 ;
};
} volatile CCADC_statusFlags = {0x00};
/******************************************************************************
Proto type for private functions.
******************************************************************************/
static void CCADC_PolarityManager( void );
/*! \brief Configuration of the CC-ADC and Regular Current Level.
*
* Note that the CC-ADC is not started, only configured. The CC-ADC is started
* by the CCADC_Mode_Select() function.\n
*
* \note The Bandgap voltage refence must be enabled and calibrated to used
* the CC-ADC.
*
* \param accConversionTime [ACCT_128, ACCT_256, ACCT_512, ACCT_1024]
* \param rccSamplingInterval [RSI_256, RSI_512, RSI_1024, RSI_2048]
* \param regularCurrentLevel Given in milliAmps
*/
void CCADC_Init( CCADC_AccConvPeriod_t accConversionTime, CCADC_RccConvPeriod_t rccSamplingInterval, uint16_t regularCurrentLevel )
{
// Set Regular current detection level.
CADRC = ((regularCurrentLevel<<RCC_SCALE) / RCC_STEP_SIZE_mA_SCALED);
/* Wait until CC-ADC is ready for configuration change. (wait for
* synchronization between clock domains to be completed since previous change).
*/
while( CADCSRA & (1<<CADUB) ){
}
/* Write CC-ADC settings:
* - Clear CC-ADC Conversion Time and Regular Current Sampling Interval.\n
* - select new CC-ADC Conversion Time and Current Sampling Interval.\n
* - and set the polarity bit accoring the initial state.
*/
CADCSRA = (CADCSRA & ~( (1<<CADAS1)|(1<<CADAS0)|(1<<CADSI1)|(1<<CADSI0)|(1<<CADPOL) )) |
((uint8_t)accConversionTime | (uint8_t)rccSamplingInterval) |
CCADC_POLARITY_POS;
}
/*! \brief Selects mode of operation for the CC-ADC
*
* Select between
* - CCADC_DISABLE (To disable the CC-ADC, and disable and clear interrupts).
* - CCADC_IAC (CC_ADC is enabled and both Instantaneous and Accumulated Conversions generate interrupts).
* - CCADC_IC (CC_ADC is enabled and Instantaneous Conversions generate interrupts).
* - CCADC_ACC (CC_ADC is enabled and Instantaneous Conversions generate interrupts).
* - CCADC_RCC (Regular Current Condition is enabled - Note that accumulator is cleared)\n
*
* \note The enabling and disabling does _not_ modify the configuration of CC-ADC. It
* only enable and disable the mode and interrupts.\n
*
* \note The Bandgap voltage refence must be enabled and calibrated to used
* the CC-ADC
*
* \param mode Mode of operation.
*/
void CCADC_SetMode( CCADC_modes_t mode )
{
//!< Wait for synchronization between clock domains before initiating write
while( CADCSRA & (1<<CADUB) ){
};
switch( mode ){
case CCADC_DISABLE:
// Disable CC-ADC and disable interrupts (and clear pending interrupts).
CADCSRA = CADCSRA & ~( (1<<CADEN) | (1<<CADSE) );
CADCSRB = (0<<CADACIE) | (0<<CADRCIE) | (0<<CADICIE) | (1<<CADACIF) | (1<<CADRCIF) | (1<<CADICIF);
break;
case CCADC_IAC:
// Enable CC-ADC with both ICC and ACC interrupts running (and clear pending interrupts).
CADCSRA = ( CADCSRA & ~(1<<CADSE) ) | (1<<CADEN);
CADCSRB = (1<<CADACIE) | (0<<CADRCIE) | (1<<CADICIE) | (1<<CADACIF) | (1<<CADRCIF) | (1<<CADICIF);
break;
case CCADC_ICC:
// Enable CC-ADC with ICC interrupt running (and clear pending interrupts).
CADCSRA = ( CADCSRA & ~(1<<CADSE) ) | (1<<CADEN);
CADCSRB = (0<<CADACIE) | (0<<CADRCIE) | (1<<CADICIE) | (1<<CADACIF) | (1<<CADRCIF) | (1<<CADICIF);
break;
case CCADC_ACC:
// Enable CC-ADC with ACC interrupt running (and clear pending interrupts).
CADCSRA = ( CADCSRA & ~(1<<CADSE) ) | (1<<CADEN);
CADCSRB = (1<<CADACIE) | (0<<CADRCIE) | (0<<CADICIE) | (1<<CADACIF) | (1<<CADRCIF) | (1<<CADICIF);
break;
case CCADC_RCC:
// Enable CC-ADC with RCC and ICC interrupts running (ICC due to RCC unable to wake up device from power save).
CADCSRA = CADCSRA | (1<<CADSE) | (1<<CADEN);
CADCSRB = (0<<CADACIE) | (1<<CADRCIE) | (1<<CADICIE) | (1<<CADACIF) | (1<<CADRCIF) | (1<<CADICIF);
break;
default:
break;
}
}
/*! \brief Provide information whether CC-ADC is in RCC mode of IC/ACC mode.
*
* \note The Bandgap voltage refence must be enabled and calibrated to used
* the CC-ADC.
*
* \retval mode [CCADC_RCC, CCADC_IAC (for ICC, ACC or IAC) ]
*/
uint8_t CCADC_GetMode( void )
{
//!< Wait for synchronization between clock domains before reading state
while( CADCSRA & (1<<CADUB) ){
}
if( CADCSRA & (1<<CADSE) ){
return CCADC_RCC;
}else{
return CCADC_IAC;
}
}
/*! \brief Returns result of an CC-ADC Accumulated Conversion.
*
* Returns the 18 bit signed result of an Accumulated Conversion as signed
* 32-bit. The result is scaled so to use a 24.8 signed fixed point format
* before it is returned.
*
* \note The Bandgap voltage refence must be enabled and calibrated to used
* the CC-ADC.
*
* \retval result which is returned in a 24.8 signed fixed point format
*/
int32_t CCADC_GetAccResult( void )
{
int32_t result;
uint8_t interruptState = __save_interrupt();
__disable_interrupt();
result = CCADC_acc
没有合适的资源?快使用搜索试试~ 我知道了~
BMS code.rar_ATMEGA16HVB_BMS方案代码_BMS的HVB_HVB BMS_HVB芯片
共84个文件
html:30个
png:21个
md5:7个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
1 下载量 28 浏览量
2022-07-15
06:31:49
上传
评论
收藏 153KB RAR 举报
温馨提示
ATMEGA16HVB芯片---BMS方案代码
资源详情
资源评论
资源推荐
收起资源包目录
BMS code.rar (84个子文件)
BMS code
ccadc.c 11KB
avr352.ewp 51KB
conf
config.h 3KB
common.h 3KB
error.h 2KB
main.c 6KB
doxygen
globals_func.html 4KB
ftv2vertline.png 229B
files.html 2KB
ftv2folderclosed.png 259B
main.html 1KB
ccadc_8h__dep__incl.map 201B
ccadc_8h__dep__incl.png 3KB
ftv2doc.png 255B
globals_type.html 2KB
pages.html 1KB
documentation_8h.html 2KB
main_8h.html 6KB
comp_info.html 2KB
ccadc_8c-source.html 23KB
main_8c_6288eba0f8e8ad3ab1544ad731eb7667_cgraph.map 820B
ccadc_8h__incl.png 3KB
ftv2blank.png 174B
functions.html 2KB
main_8c-source.html 12KB
main_8c_6288eba0f8e8ad3ab1544ad731eb7667_cgraph.md5 32B
main_8c__incl.png 11KB
globals_eval.html 3KB
main_8c__incl.map 251B
annotated.html 1KB
ftv2folderopen.png 261B
tree.html 5KB
main_8h__dep__incl.map 101B
ccadc_8h__incl.map 0B
ftv2link.png 358B
index.html 424B
main_8c.html 24KB
doxygen.png 1KB
ftv2lastnode.png 233B
ccadc_8c.html 43KB
globals.html 10KB
documentation_8h-source.html 1KB
ftv2node.png 235B
functions_vars.html 2KB
doxygen.css 9KB
ccadc_8c__incl.map 112B
ccadc_8c__incl.png 7KB
tab_r.gif 3KB
ftv2plastnode.png 165B
graph_legend.html 4KB
ccadc_8c_c0b494d5f2bd505e6a5b19b3a68cba91_cgraph.map 167B
globals_enum.html 2KB
graph_legend.png 15KB
globals_vars.html 2KB
main_8c_6288eba0f8e8ad3ab1544ad731eb7667_cgraph.png 9KB
ccadc_8c_c0b494d5f2bd505e6a5b19b3a68cba91_cgraph.png 1KB
ccadc_8c_c0b494d5f2bd505e6a5b19b3a68cba91_cgraph.md5 32B
tab_b.gif 35B
ftv2mnode.png 194B
main_8h__dep__incl.png 1KB
ftv2pnode.png 200B
ccadc_8h__incl.md5 32B
tabs.css 2KB
ftv2mlastnode.png 160B
ccadc_8c__incl.md5 32B
License.html 2KB
main_8h-source.html 3KB
ccadc_8h__dep__incl.md5 32B
tab_l.gif 706B
graph_legend.dot 2KB
main_8h__dep__incl.md5 32B
globals_defs.html 4KB
ccadc_8h.html 66KB
ccadc_8h-source.html 15KB
main_8c__incl.md5 32B
unionCCADC__conversionFlag__union.html 6KB
blue.GIF 43B
avr352.eww 160B
atmel.jpg 31KB
config.doxygen 9KB
main.h 1KB
readme.html 345B
documentation.h 3KB
ccadc.h 7KB
共 84 条
- 1
weixin_42653672
- 粉丝: 93
- 资源: 1万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- unity开发教程.docx
- 代码使用Pygame库实现了一个简单的烟花模拟 核心逻辑包括烟花和粒子类的定义,处理位置、爆炸、尾迹和绘制等操作
- Matlab Simulink 电力电子仿真-Flyback(反激电路)电路分析
- tudou-android-release.apk
- 数据分析教程.docx
- 基于matlab实现用有限元法计算电磁场的Matlab工具 .rar
- 基于matlab实现有限元算法 计算电磁场问题 边界条件包括第一类边界和第二类边界.rar
- 基于matlab实现用于计算不同车重下的电动汽车动力性和经济性.rar
- 基于matlab实现遗传算法求解多车场车辆路径问题 有多组算例可以用.rar
- 浏览器.apk
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0